* [PATCH] elf: _dl_fixup*: make @reloc_arg 64-bit safe
@ 2021-07-22 13:22 Vladimir Isaev via Libc-alpha
2021-07-22 13:39 ` Andreas Schwab
0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Isaev via Libc-alpha @ 2021-07-22 13:22 UTC (permalink / raw)
To: libc-alpha
Cc: Cupertino Miranda, Vineet Gupta, linux-snps-arc, Vladimir Isaev
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.
Reported-by: Cupertino Miranda <cmiranda@synopsys.com>
Signed-off-by: Vladimir Isaev <isaev@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
elf/dl-runtime.c | 6 +++---
sysdeps/hppa/dl-fptr.c | 2 +-
sysdeps/i386/dl-machine.h | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
index 9d0d941000..6099a44ffb 100644
--- a/elf/dl-runtime.c
+++ b/elf/dl-runtime.c
@@ -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
diff --git a/sysdeps/hppa/dl-fptr.c b/sysdeps/hppa/dl-fptr.c
index 62ef68b62b..bcab1bf100 100644
--- a/sysdeps/hppa/dl-fptr.c
+++ b/sysdeps/hppa/dl-fptr.c
@@ -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)
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 590b41d8d7..8f73e0efda 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -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;
--
2.32.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] elf: _dl_fixup*: make @reloc_arg 64-bit safe
2021-07-22 13:22 [PATCH] elf: _dl_fixup*: make @reloc_arg 64-bit safe Vladimir Isaev via Libc-alpha
@ 2021-07-22 13:39 ` Andreas Schwab
2021-07-22 13:58 ` Vladimir Isaev via Libc-alpha
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2021-07-22 13:39 UTC (permalink / raw)
To: Vladimir Isaev via Libc-alpha
Cc: Cupertino Miranda, Vineet Gupta, linux-snps-arc, Vladimir Isaev
On Jul 22 2021, Vladimir Isaev via Libc-alpha wrote:
> diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
> index 9d0d941000..6099a44ffb 100644
> --- a/elf/dl-runtime.c
> +++ b/elf/dl-runtime.c
> @@ -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.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] elf: _dl_fixup*: make @reloc_arg 64-bit safe
2021-07-22 13:39 ` Andreas Schwab
@ 2021-07-22 13:58 ` Vladimir Isaev via Libc-alpha
2021-08-02 23:18 ` Vineet Gupta via Libc-alpha
0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Isaev via Libc-alpha @ 2021-07-22 13:58 UTC (permalink / raw)
To: Andreas Schwab, Vladimir Isaev via Libc-alpha
Cc: Cupertino Miranda, Vineet Gupta,
linux-snps-arc@lists.infradead.org
On Jul 22 2021, Andreas Schwab wrote:
>
> On Jul 22 2021, Vladimir Isaev via Libc-alpha wrote:
>
> > diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
> > index 9d0d941000..6099a44ffb 100644
> > --- a/elf/dl-runtime.c
> > +++ b/elf/dl-runtime.c
> > @@ -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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] elf: _dl_fixup*: make @reloc_arg 64-bit safe
2021-07-22 13:58 ` Vladimir Isaev via Libc-alpha
@ 2021-08-02 23:18 ` Vineet Gupta via Libc-alpha
0 siblings, 0 replies; 4+ messages in thread
From: Vineet Gupta via Libc-alpha @ 2021-08-02 23:18 UTC (permalink / raw)
To: Vladimir Isaev, Andreas Schwab, Vladimir Isaev via Libc-alpha
Cc: Cupertino Miranda, Florian Weimer,
linux-snps-arc@lists.infradead.org, Joseph Myers
Hi Joseph, Adhemerval, Florian
On 7/22/21 6:58 AM, Vladimir Isaev via Libc-alpha wrote:
> On Jul 22 2021, Andreas Schwab wrote:
>>
>> On Jul 22 2021, Vladimir Isaev via Libc-alpha wrote:
>>
>>> diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
>>> index 9d0d941000..6099a44ffb 100644
>>> --- a/elf/dl-runtime.c
>>> +++ b/elf/dl-runtime.c
>>> @@ -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.
Any objections to this change - OK to commit ?
-Vineet
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-08-02 23:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-22 13:22 [PATCH] elf: _dl_fixup*: make @reloc_arg 64-bit safe Vladimir Isaev via Libc-alpha
2021-07-22 13:39 ` Andreas Schwab
2021-07-22 13:58 ` Vladimir Isaev via Libc-alpha
2021-08-02 23:18 ` Vineet Gupta via Libc-alpha
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).