Domanda

I have 25 object files which are combined to form one shared library. I have generated the shared library with gcc and while I was looking for exposed symbols with nm -D libmylib.so, I found two undesirable exposed symbols with the name of i and y which are in .bss section. I have tried to find them in my source files but i cant find them so if anyone can tell me whether there is some way to find that which .o file exactly has these undesired exposed symbols? Can I do it with nm or do I need another tool?

Any help would be appreciated.

È stato utile?

Soluzione

Once the shared library is linked, you can no longer tell which parts of it came from which object file.

You can search the individual objects from which you build the library:

find . -name '*.o' -print0 | xargs -0 nm -A | egrep ' (i|y)$'

You can ask the linker to tell you when they are defined:

$(CC) -fPIC -shared -o libmy.so $(OBJS) -Wl,-y,i,-y,y

If you built the library from objects compiled with -g, you may ask GDB where i and y came from:

gdb -q libmy.so
(gdb) info var ^i$
(gdb) info var ^y$

Altri suggerimenti

In the directory with your object files you can run:

find . -name '*.o' -exec nm -D {} \; -print

This should print symbols and then file name

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top