ld: linking to GNU_UNIQUE symbol does not set ELFOSABI_GNU

Florian Weimer fweimer@redhat.com
Thu Jan 24 11:31:00 GMT 2013


This code in bfd/elf64-x86-64.c seems to be wrong:

   if ((abfd->flags & DYNAMIC) == 0
       && (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
	  || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE))
     elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;

The DYNAMIC requirement should only apply to the STT_GNU_IFUNC case. 
For STB_GNU_UNIQUE, the binding type is propagated to the resulting 
object (at least for DSOs).

I think this might be the appropriate fix:

   if (((abfd->flags & DYNAMIC) == 0
         && (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)
       || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE))
     elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;

But the has_gnu_symbols flag should probably be set in a different 
location because this code is replicated in many places.

-- 
Florian Weimer / Red Hat Product Security Team



More information about the Binutils mailing list