This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: PATCH: Sign extend relocation result to 64bit forR_X86_64_DTPOFF64/R_X86_64_TPOFF64
- From: Roland McGrath <roland at hack dot frob dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Tue, 8 May 2012 10:07:33 -0700 (PDT)
- Subject: Re: PATCH: Sign extend relocation result to 64bit forR_X86_64_DTPOFF64/R_X86_64_TPOFF64
- References: <20120508164809.GA31918@intel.com>
Actually, shouldn't reloc_addr actually be Elf64_Addr regardless?
All the reloc types indicate 64-bit quantities except for those that
already use *(unsigned int *) reloc_addr.
The high bits will be zero because the st_value and r_addend types are
smaller, but that's no reason not to write the full 64 bits for all the
64-bit reloc types.
> +# ifdef __ILP32__
> + *(Elf64_Sxword *) reloc_addr
> + = (Elf64_Sxword)
> + ((Elf32_Sword) (sym->st_value + reloc->r_addend));
> +# else
> *reloc_addr = sym->st_value + reloc->r_addend;
> +# endif
Put the calculation in a temporary rather than repeating it.
(Same below.)
Then it can be just:
*reloc_addr = (Elf64_Sxword) (Elf32_Sword) value;
But it needs a comment saying why this particular reloc type gets sign
extension when all the others get zero extension.
Thanks,
Roland