Visibility of ELF symbols not taken into account by certain GDB commands?

Tom Tromey tromey@redhat.com
Fri Mar 15 15:32:00 GMT 2013


Alfonso> During that selection, visibility is not taken into account (e.g. the
Alfonso> ld.so malloc symbol is used although the globally visible one, from
Alfonso> the dynamic loaders point of view, is the one in libc.so)

Alfonso> Should this be considered a bug?

Doug> 1) ELF symbol visibility doesn't really enter the picture.
Doug> Sometimes you don't want it to.  Though I can see a usefulness in
Doug> having knobs to control this, I'm not aware of any (could just be my
Doug> bad memory :-)) or any plans to add them.

Yeah, I don't know about plans to deal with visibility, but there are
some open bugs about how gdb doesn't respect ELF semantics, and so you
can sometimes write expressions that don't give the same result as the
same expression in the source.

E.g., there's a couple of bugs related to copy relocations.

Doug> What happens, in a nutshell, is gdb looks up the symbol in the current
Doug> context (whatever that is), and then does a search over all contexts.
Doug> This involves doing a linear search over the binary and all shared
Doug> libraries and using the first one found.  In this case it's the one in
Doug> ld.so.

... there's also a tweak here to try to reproduce ELF semantics.  I
found elf_lookup_lib_symbol and the corresponding target_so_ops method,
but I thought there was some other hook too... can't find it right now.

Tom



More information about the Gdb mailing list