2 problems with ELF visibility

H . J . Lu hjl@lucon.org
Mon Apr 22 12:07:00 GMT 2002


There are 2 problems with ELF visibility:

1. We don't turn hidden/internal into local unless it is a dynamic symbol.

# cat c.c
extern void *foo __attribute__ ((__visibility__ ("hidden")));
void *foo = 0;
main ()
{
}
# gcc c.c
# readelf -a a.out | grep foo
    72: 0804945c     4 OBJECT  GLOBAL HIDDEN   15 foo

That is not a big problem since it won't be used by ld.so. But it will be
nice to have it local instead of global.

2. _bfd_elf_link_record_dynamic_symbol in elflink.c doesn't call
elf_backend_hide_symbol. Instead, it sets ELF_LINK_FORCED_LOCAL directly.
It doesn't work with MIPS. I got

mips-linux-gcc -O2 -pipe -D_GNU_SOURCE -D_REENTRANT -Wall -Wpointer-arith
-Wstrict-prototypes -Wmissing-prototypes -Wno-char-subscripts -o test1 -static
test1.o  ./.libs/libpopt.a
/export/tools/lib/gcc-lib/mips-linux/2.96/../../../../mips-linux/bin/ld: not enough
GOT space for local GOT entries
/export/tools/lib/gcc-lib/mips-linux/2.96/../../../../mips-linux/bin/ld: BFD
2.12.90.0.5 20020421 internal error, aborting at
/home/hjl/work/gnu/src/tools/tools/bfd/elfxx-mips.c line 5276 in
_bfd_mips_elf_relocate_section

You have to use elf_backend_hide_symbol to turn a global symbol into local
on MIPS. How should we fix it?


H.J.



More information about the Binutils mailing list