Questions tagged [symbol-table]

A `symbol table` is a data structure that maps each identifier in a program's source code to information relating to its declaration or appearance in the source.

A symbol table is used by a language translator (compiler, interpreter...) for associating each identifier in a program's source code with information relating to its declaration or appearance in the source (type, scope level, sometimes location...).

A common implementation technique is to use a hash table implementation. A compiler may use one large symbol table for all symbols or use separated, hierarchical symbol tables for different scopes.

202 questions
3
votes
1 answer

How to properly reuse symbol table in a multi-pass compiler

I'm currently building a multi-pass compiler for a block-structured language language. I have built a scope stack in semantic analysis phase. When entering a new scope, create a new table, push it to the stack and make it current scope table, then…
3
votes
1 answer

Why can't I iterate over locals() and within the iteration use returned item as a key?

I have a module named Promotions with some functions, and I have a variable that stores a list of all the functions containing "_promo" in the name. promos = [ locals()[name] for name in locals() # Iterate over each name in the dictionary…
3
votes
1 answer

Where symbol table gets stored?

I'm studying about compilers, and I suddenly got curious that if I compile a program (let's say test.c) with -g option, does an actual file with a symbol table gets created and stored somewhere or it just gets combined with the executable? I am…
3
votes
1 answer

Computing stack demand for C++; How to get readable symbol table?

Assume that you have not only executable file, but also source code files. My problem is to calculate correct stack size of running process only for local variables, return address, passing argument. I was trying to use VMMap developed by MS.…
Hexoul
  • 161
  • 2
  • 13
3
votes
2 answers

Reference a variable by name in C++ by using Symbol Table

Basically what the title asks. Being a bit unfamiliar with C++, and the more advanced concepts such as symbol tables, I've looked into it online but am struggling to find any direction towards what my end goal is. Most of the tutorials I've seen…
MrMattL92
  • 33
  • 7
3
votes
1 answer

i am failing to set intel as disassembly flavour in gdb

i want to set disassembly flavour to intel ........ i tried the following............................... $ gdb -q /root/.gdbinit:1: Error in sourced command file: No symbol table is loaded. Use the "file" command. (gdb) set disassembly-flavour…
user3312448
  • 31
  • 1
  • 2
3
votes
2 answers

Why a stripped binary file can still have library call information in the disassembled file?

test platform is 32 bit Linux. I compile a c program without strip the symbol information, and use objdump to disassembly the elf executable file. Here is part of the results. 804831c: e8 8c fe ff ff call 8048360 If I…
lllllllllllll
  • 8,519
  • 9
  • 45
  • 80
3
votes
1 answer

How to get user defined function range (begin and end address) in elf file?

I know we can get the user defined function's begin address in elf by reading symbol table, just like below, function main and foo: 08048330 T _start 0804a014 b completed.6159 0804a00c W data_start 0804a018 b dtor_idx.6161 080483e4 T foo 080483c0 t…
lllllllllllll
  • 8,519
  • 9
  • 45
  • 80
3
votes
1 answer

Compiler: what is the best way to fill the symbol table?

I'd like to build my own compiler for tiny C language: I've already make my grammar, build an AST (abstract syntax tree) using ANTLR, and implement my symbol table (following GRosemberg code) I have to fill my symbol table with my symbols, but I…
3
votes
2 answers

Should unnamed namespace functions be avoided to reduce symbol table sizes?

I've heard it asserted that the use of unnamed namespaces in C++ to define functions and ensure that they cannot be called from outside the compilation unit in which they are defined is not good in very large code environments because they cause the…
WilliamKF
  • 41,123
  • 68
  • 193
  • 295
3
votes
1 answer

Can an interpreter be implemented with a symbol table?

Often I hear that using a symbol table optimizes look ups of symbols in a programming language. Currently, my language is implemented only as an interpreter, not as a compiler. I do not yet want to allocate the time to build a compiler, so I'm…
Bryan Edds
  • 1,696
  • 12
  • 28
2
votes
3 answers

Symbol Table Design and Implementation in Ruby

I am building a lexical analyzer in Ruby and am about to start gathering and storing symbols in the symbol table. My main question about the design of the symbol and as to whether it should be static table (meaning that all of the data will be held…
Hunter McMillen
  • 59,865
  • 24
  • 119
  • 170
2
votes
2 answers

Why are some relocations .text + addend instead of symbol's name + addend?

Why are some relocation entries in an ELF file symbol name + addend while others are section + addend? I am looking to clear up some confusion and gain a deeper understanding of ELFs. Below is my investigation. I have a very simple C file,…
peachykeen
  • 4,143
  • 4
  • 30
  • 49
2
votes
1 answer

Record ownership in symbol tables

I am implementing a symbol table as described in the dragon book: class SymbolTable { std::unordered_map table; SymbolTable* parent; public: SymbolTable(SymbolTable* p) : parent{p} {} const Record* lookUp(const…
Touloudou
  • 2,079
  • 1
  • 17
  • 28
2
votes
1 answer

Why do symbol tables still exist after compilation

I understand that symbol tables are created by the compiler to help with its process. They exist per object file for when they are being linked together. Assume: void test(void){ // } void main(){ return 0; } compiling above with gcc and running…
user13085934