当前位置: 首页 > news >正文

Symbol Table

Symbol Table(符号表)

Wikipedia

In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier (or symbols), constants, procedures and functions in a program’s source code is associated with information relating to its declaration or appearance in the source. In other words, the entries of a symbol table store the information related to the entry’s corresponding symbol.

在计算机科学中,符号表是语言转换器(如:编译器或解释器)使用的一种数据结构,其中程序源码中的每个标识符(或符号)、常数、过程和函数都与其在源码中的声明或appearance相关的信息相关联。换句话说,符号表的条目存储了与该条目对应的符号相关的信息。

A compiler may use one large symbol table for all symbols or use separated, hierarchical symbol tables for different scopes.

编译器可以对所有符号使用一个大的符号表,也可以对不同的作用域使用分离的、分层的符号表。

A common data structure used to implement symbol tables is the hash table.

用于实现符号表的常见数据结构是哈希表。

As the lexical analyser spends a great proportion of its time looking up the symbol table, this activity has a crucial effect on the overall speed of the compiler. A symbol table must be organised in such a way that entries can be found as quickly as possible.

由于词法分析器要花费大量的时间查找符号表,因此这个活动对编译器的总体速度有至关重要的影响。符号表必须以这样一种方式组织,条目可以尽快找到。

Applications
An object file will contain a symbol table of the identifiers it contains that are externally visible. During the linking of different object files, a linker will identify and resolve these symbol references. Usually all undefined external symbols will be searched for in one or more object libraries. If a module is found that defines that symbol it is linked with together with the first object file, and any undefined external identifiers are added to the list of identifiers to be looked up. This process continues until all external references have been resolved. It is an error if one or more remains unresolved at the end of the process.

一个目标文件将包含一个符号表,它所包含的标识符是对外可见的。在链接不同的目标文件期间,链接器将识别和解析这些符号引用。通常,所有未定义的外部符号会在一个或者多个目标库中搜索。如果找到定义该符号的模块,则将其与第一个目标文件链接在一起,并且将所有未定义的外部标识符添加到要查找的标识符列表中。此过程将继续进行,直到所有外部引用都已解析完毕。如果在该过程结束时,有一个或者多个仍未找到,则被认为出错。

While reverse engineering an executable, many tools refer to the symbol table to check what addresses have been assigned to global variables and known functions. If the symbol table has been stripped or cleaned out before being converted into an executable, tools will find it harder to determine addresses or understand anything about the program.

在对可执行文件进行逆向工程时,许多工具会参考符号表来检查给全局变量和已知函数分配了哪些地址。如果符号表在转换为可执行文件之前已经被剥离或清除,那么工具将很难确定地址或理解有关程序的任何内容。

Example

// Declare an external function
extern double bar(double x);

// Define a public function
double foo(int count)
{
    double sum = 0.0;

    // Sum all the values bar(1) to bar(count)
    for (int i = 1; i <= count; i++)
        sum += bar((double) i);
    return sum;
}

A C compiler that parses this code will contain at least the following symbol table entries:

解析此代码的C编译器将至少包含以下符号表项:

Symbol nameTypeScope
barfunction, doubleextern
xdoublefunction parameter
foofunction, doubleglobal
countintfunction parameter
sumdoubleblock local
iintfor-loop statement

In addition, the symbol table will also contain entries generated by the compiler for intermediate expression values (e.g., the expression that casts the i loop variable into a double, and the return value of the call to function bar()), statement labels, and so forth.

此外,符号表还将包含由编译器为中间表达式值(例如,将i循环变量转换为double类型的表达式,以及调用函数bar()的返回值)、语句标签等生成的条目。

相关文章:

  • LeetCode所有大于等于节点的值之和
  • 基站天线交叉极化比测量的不确定度评定
  • RTL8367/N/RB/S/SC系列千兆交换机方案选型参考
  • GO 调用 python3 (基于ubuntu) 实现人脸识别
  • 澳利率攀升,加息步伐将在某个时候放缓
  • AOP实现系统告警
  • Spring Boot集成第三方登录之微博登录
  • 那么我们应该如何优化Youtube的视频呢?
  • 带你秒懂 SSR-服务端渲染
  • MindRecord-Windows下中文路径问题Unexpected error. Failed to open file
  • 基于随机森林实现特征选择降维及回归预测(Matlab代码实现)
  • 链表的奇偶重排
  • 华为ENSP网络设备配置实战2(较为复杂的ospf)
  • 干货 | 精准化测试原理简介与实践探索
  • 本周面试经验总结
  • hexo+github搭建个人博客
  • [js高手之路]搞清楚面向对象,必须要理解对象在创建过程中的内存表示
  • 30秒的PHP代码片段(1)数组 - Array
  • httpie使用详解
  • Intervention/image 图片处理扩展包的安装和使用
  • JS创建对象模式及其对象原型链探究(一):Object模式
  • js算法-归并排序(merge_sort)
  • Linux链接文件
  • miaov-React 最佳入门
  • Python3爬取英雄联盟英雄皮肤大图
  • UEditor初始化失败(实例已存在,但视图未渲染出来,单页化)
  • vue和cordova项目整合打包,并实现vue调用android的相机的demo
  • 容器服务kubernetes弹性伸缩高级用法
  • 使用 Node.js 的 nodemailer 模块发送邮件(支持 QQ、163 等、支持附件)
  • 微信如何实现自动跳转到用其他浏览器打开指定页面下载APP
  • 云大使推广中的常见热门问题
  • 正则学习笔记
  • 最简单的无缝轮播
  • 宾利慕尚创始人典藏版国内首秀,2025年前实现全系车型电动化 | 2019上海车展 ...
  • 昨天1024程序员节,我故意写了个死循环~
  • (8)STL算法之替换
  • (C#)获取字符编码的类
  • (echarts)echarts使用时重新加载数据之前的数据存留在图上的问题
  • (pytorch进阶之路)扩散概率模型
  • (理论篇)httpmoudle和httphandler一览
  • (每日持续更新)jdk api之FileReader基础、应用、实战
  • (原創) X61用戶,小心你的上蓋!! (NB) (ThinkPad) (X61)
  • (转)socket Aio demo
  • .“空心村”成因分析及解决对策122344
  • .bat文件调用java类的main方法
  • .Net 垃圾回收机制原理(二)
  • .net 流——流的类型体系简单介绍
  • .NET/C# 在 64 位进程中读取 32 位进程重定向后的注册表
  • .NET国产化改造探索(一)、VMware安装银河麒麟
  • .NET精简框架的“无法找到资源程序集”异常释疑
  • .NET开发者必备的11款免费工具
  • .net流程开发平台的一些难点(1)
  • /etc/skel 目录作用
  • /usr/local/nginx/logs/nginx.pid failed (2: No such file or directory)
  • @private @protected @public