elf: _dl_fixup*: make @reloc_arg 64-bit safe
PATCH 1/1 elf: _dl_fixup*: make @reloc_arg 64-bit safe
This came up during arc64 glibc bringup on qemu usermode.
On ARC, lazy rezolver calls _dl_fixup() with 2nd argument as PC of the PLT entry beiing fixed up. Thus this needs to be full 64-bit value for arc64, however _dl_fixup() defines @reloc_arg as ElfW(Word) which maps to Elf64_Word -> uint32_t causing gcc to truncate the value to 32-bits.
This problem show on 64-bit ARC and not other arches likely due to the semantics of @reloc_arg. On ARC it is the runtime PC of PLT entry whereas for others it might be the index or something similar which doesn't need more than 32-bits.
--- elf/dl-runtime.c | 6 +++--- sysdeps/hppa/dl-fptr.c | 2 +- sysdeps/i386/dl-machine.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
elf/dl-runtime.c +3 -3
@@ -56,7 +56,7 @@ _dl_fixup (# ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS ELF_MACHINE_RUNTIME_FIXUP_ARGS,# endif - struct link_map *l, ElfW(Word) reloc_arg) + struct link_map *l, uintptr_t reloc_arg) {const ElfW (Sym) *const symtab = (const void *)D_PTR (l, l_info[DT_SYMTAB ]);
@@ -152,7 +152,7 @@ _dl_profile_fixup (#ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS ELF_MACHINE_RUNTIME_FIXUP_ARGS,#endif - struct link_map *l, ElfW(Word) reloc_arg, + struct link_map *l, uintptr_t reloc_arg, ElfW(Addr) retaddr, void *regs, long int *framesizep) { void (*mcount_fct) (ElfW(Addr), ElfW(Addr)) = _dl_mcount;
@@ -484,7 +484,7 @@ _dl_profile_fixup (#include <stdio.h> void ARCH_FIXUP_ATTRIBUTE -_dl_call_pltexit (struct link_map *l, ElfW(Word) reloc_arg, +_dl_call_pltexit (struct link_map *l, uintptr_t reloc_arg,const void *inregs,void *outregs) {#ifdef SHARED
sysdeps/hppa/dl-fptr.c +1 -1
@@ -321,7 +321,7 @@ _dl_unmap (struct link_map *map) map->l_mach.fptr_table =NULL ; } -extern ElfW(Addr) _dl_fixup (struct link_map *, ElfW(Word)) attribute_hidden; +extern ElfW(Addr) _dl_fixup (struct link_map *, uintptr_t) attribute_hidden;static inline Elf32_Addr elf_machine_resolve (void )
sysdeps/i386/dl-machine.h +2 -2
@@ -130,10 +130,10 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)#define ARCH_FIXUP_ATTRIBUTE __attribute__ ((regparm (3), stdcall, unused)) extern ElfW(Addr) _dl_fixup (struct link_map *l, - ElfW(Word) reloc_offset) + uintptr_t reloc_offset) ARCH_FIXUP_ATTRIBUTE; extern ElfW(Addr) _dl_profile_fixup (struct link_map *l, - ElfW(Word) reloc_offset, + uintptr_t reloc_offset, ElfW(Addr) retaddr, void *regs, long int *framesizep) ARCH_FIXUP_ATTRIBUTE;
Signature · 7 lines
2.32.0 _______________________________________________ linux-snps-arc mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-snps-arc
elf/dl-runtime.c _dl_fixup ( · line 59
Quoted 10 lines · Vladimir Isaev via Libc-alpha
elf/dl-runtime.c +1
-1@@ -56,7 +56,7 @@ _dl_fixup (# ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS ELF_MACHINE_RUNTIME_FIXUP_ARGS,# endif - struct link_map *l, ElfW(Word) reloc_arg) + struct link_map *l, uintptr_t reloc_arg)
ElfW(Addr)?
Andreas.
Signature · 8 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." _______________________________________________ linux-snps-arc mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Quoted 16 lines · Andreas Schwab
elf/dl-runtime.c _dl_fixup ( · line 59
Quoted 10 lines · Vladimir Isaev via Libc-alpha
elf/dl-runtime.c +1
-1@@ -56,7 +56,7 @@ _dl_fixup (# ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS ELF_MACHINE_RUNTIME_FIXUP_ARGS,# endif - struct link_map *l, ElfW(Word) reloc_arg) + struct link_map *l, uintptr_t reloc_arg)ElfW(Addr)?
We can use it, but I think that uintptr_t is more natural here because it is used in reloc_offset and reloc_index.
Thank you,
Vladimir Isaev
_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Hi Joseph, Adhemerval, Florian
Quoted 18 lines · Vladimir Isaev via Libc-alpha
Quoted 16 lines · Andreas Schwab
elf/dl-runtime.c _dl_fixup ( · line 59
Quoted 10 lines · Vladimir Isaev via Libc-alpha
elf/dl-runtime.c +1
-1@@ -56,7 +56,7 @@ _dl_fixup (# ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS ELF_MACHINE_RUNTIME_FIXUP_ARGS,# endif - struct link_map *l, ElfW(Word) reloc_arg) + struct link_map *l, uintptr_t reloc_arg)ElfW(Addr)?
Quoted 2 lines
We can use it, but I think that
uintptr_tis more natural here because it is used inreloc_offsetandreloc_index.
Any objections to this change - OK to commit ?
-Vineet
_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc