user2277550
user2277550

Reputation: 621

Requirement of symbol table in the final executable?

I read that the windows portable executable format contains a symbol table. I understand why a symbol table would be required during the semantic analysis phase of the compilation and also during code generation. But I don't understand why the final executable itself should contain a symbol table since the addresses are mapped into the assembly code by this stage. What am I missing??

Upvotes: 0

Views: 194

Answers (1)

Dolda2000
Dolda2000

Reputation: 25855

I can't really speak specifically for PE, but I'd imagine it's similar to the situation for ELF, where there are two different symbol tables to speak of:

  • The "ordinary" symbol table (the one one would normally refer to as "the symbol table"), is optional in the final executable. If it's present, it's used by debuggers and other programs that inspect a program with symbolic information. It is normally generated by the linker, but can, and often is, stripped away afterwards to reduce the file size.
  • The dynamic symbol table is used for linking against DSOs at runtime, and as such needs to be present for executables that use dynamic linking. It only lists the external symbols that the executable needs (or wants to publicize, which is also possible), however; not every symbol that was present inside it during linking.

Upvotes: 3

Related Questions