PATCH: Check SHN_UNDEF for STT_GNU_IFUNC symbol
H.J. Lu
hongjiu.lu@intel.com
Sat May 23 03:47:00 GMT 2009
Hi,
I am working on multiarch string functions. I have
393: 00000000004029b0 0 IFUNC GLOBAL DEFAULT UND strcmp@@GLIBC_2.2.5
We need to check SHN_UNDEF for STT_GNU_IFUNC. Tested on Linux/Intel64.
H.J.
---
2009-05-22 H.J. Lu <hongjiu.lu@intel.com>
* sysdeps/i386/dl-machine.h (elf_machine_rel): Check SHN_UNDEF
for STT_GNU_IFUNC symbol.
* sysdeps/x86_64/dl-machine.h (elf_machine_rela): Likewise.
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 0e15878..36603df 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -342,9 +342,10 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
{
const Elf32_Sym *const refsym = sym;
struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
- Elf32_Addr value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
+ Elf32_Addr value = ((sym_map == NULL || sym->st_shndx == SHN_UNDEF)
+ ? 0 : sym_map->l_addr + sym->st_value);
- if (sym != NULL
+ if (value != 0
&& __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC,
0))
value = ((Elf32_Addr (*) (void)) value) ();
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
index 4444ae0..58cee67 100644
--- a/sysdeps/x86_64/dl-machine.h
+++ b/sysdeps/x86_64/dl-machine.h
@@ -293,10 +293,10 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
const Elf64_Sym *const refsym = sym;
# endif
struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
- Elf64_Addr value = (sym == NULL ? 0
+ Elf64_Addr value = ((sym == NULL || sym->st_shndx == SHN_UNDEF) ? 0
: (Elf64_Addr) sym_map->l_addr + sym->st_value);
- if (sym != NULL
+ if (value != 0
&& __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC,
0))
value = ((Elf64_Addr (*) (void)) value) ();
More information about the Libc-alpha
mailing list