Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include static symbols in GNU ld map file?

Tags:

c

static

map

linker

ld

It's good programming practice to define module-local symbols as static (assuming C). Unfortunately, that interferes with analysis of the resulting object/binary files. For example, GNU ld map file (-Map=...) doesn't include static symbols, so important information is missed (like, how many symbols there're really in a module, size of each function defined, etc.).

Is there way to ask GNU ld to include static symbols in a map file, without modifying original source code? (It's obvious that one can make static modifier conditional, but that's quite a chore when analyzing bunch of 3rd-party projects.)

like image 653
pfalcon Avatar asked Oct 20 '22 14:10

pfalcon


1 Answers

Although the linker map file and nm don't include symbols without extern linkage, objdump does (as long as debug information is available). You'll want the -t option.

See this related answer

like image 64
Ben Voigt Avatar answered Nov 01 '22 17:11

Ben Voigt