PATCH: Sign extend relocation result to 64bit for R_X86_64_DTPOFF64/R_X86_64_TPOFF64

Roland McGrath roland@hack.frob.com
Tue May 8 17:07:00 GMT 2012


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



More information about the Libc-alpha mailing list