Sample Header Ad - 728x90

How do `nm` choose the character to print for each symbol type?

2 votes
1 answer
935 views
I'm currently doing a nm like program, to print the symbols of an ELF file with their addresses and their type. The typical output is something like :
$ nm ./my_exec      
0000000000003d28 d _DYNAMIC
0000000000003f28 d _GLOBAL_OFFSET_TABLE_
0000000000002000 R _IO_stdin_used
                 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
The first column is the symbol address, the second is the symbol type and the third, the symbol name. The man indicates the meaning for each character, upper-case is a global symbol, lower-case is local symbol etc... But I don't understand *how* it choose which character to use. I'm using the Gelf library and I didn't see a field from where I could determine the character.
Asked by hollow (31 rep)
Mar 10, 2022, 08:06 PM
Last activity: Mar 10, 2022, 09:42 PM