I am trying to process the output of a nm or readelf -s on an executable. However, I am having trouble differentiating static functions from each other in the output.
Here is what I am working with:
test.c
static int foo() {
int x = 6;
}
main() {}
other.c
static int foo() {
int x = 5;
}
I compile these like so:
gcc -o test test.c other.c
And then run a nm command to get all the symbols:
nm test
Among which the following two symbols (for my static functions) appear:
00000000004004ed t foo
0000000000400500 t foo
Is there a method to be able to distinguish which file the specific foo function appeared from? Or will I need to do some magic before compiling to get this to work?
I should add that for my use case, I have access to the final binary and the object files used by it, but I cannot actually build it myself to ensure that it has a symbol table.
Thanks!