6

Why have two symbol tables if .symtab already contains everything that's in .dynsym ?

1
  • 2
    AFAIR one is for debug symbols the other for the dynamic linker, but I'd have to read up on it. Perhaps someone else will be faster to answer, though.
    – 0xC0000022L
    Commented Jul 5, 2019 at 20:24

1 Answer 1

7

The short answer is that the .dynsym table is used by the dynamic linker (also referred to as the runtime loader or RTLD) at program load time to determine which DLLs to map into the address space of the program being loaded into memory. As a result, the .dynsym section is mapped to a loadable segment (specifically, the text segment) and therefore included in the runtime process image in virtual memory when the kernel loads the program segments. As a reflection of this, the Sys V ABI actually requires the dynamic linking array to contain a dynamic symbol hash table, a string table for symbols and library names, and the dynamic symbol table.

On the other hand, the .symtab section is not needed for process creation, is not mapped to a loadable segment and therefore is not loaded into memory when the program is executed, and so can be removed, along with section information.

Dynamic linking and its requirements are discussed in much greater detail in the following articles:

For more information, see chapter 5 of the Sys V ABI - "Program Loading and Dynamic Linking", as well as the LWN article How programs get run: ELF binaries .

Not the answer you're looking for? Browse other questions tagged or ask your own question.