views:

54

answers:

1

Can ELF file contain more than one symbol table? Is it standardized somehow?

+1  A: 

Yes - there may be SHT_SYMTAB and SHT_DYNSYM section types - local and dynamic symbols, in different sections, each with a symbol table.

Yes, there is an ELF standard.

See: http://www.skyfree.org/linux/references/ELF_Format.pdf

What are you trying to do?

jim mcnamara
Okay, but it is possible for some compiler/linker to generate ELF with multiple SYMTAB sections?I'm writing utility to process ELF files.
Dennis Yurichev
The standard says one of each. There are already lots of utilities to work with ELF files, what exactly do you need?
jim mcnamara
Just writing my own very primitive so far static analysis tool.
Dennis Yurichev
I assume it is possible to do that. I don't know if the image activation code will "like" that or not. In other words, I do not know if the code created that way will run. SYMTAB is derived from all of the entrypoints defined in the code and any .a (archive) files linked in. So ld has know all of the local symbols at link time. If it does not you get an error during linking.The only exception to this is dl_open(), which can open any library, on some platforms an executable, then dlsym() creates a pointer to the function, These symbols are completely unkown at runtime.
jim mcnamara
Before I get jumped on - dlopen() also opens the runtime libraries to define the symbols in the DYNSYM section. LD_LIBRARY_PATH can influence the actual source file for the symbol.
jim mcnamara