This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Sign extend relocation result to 64bit forR_X86_64_DTPOFF64/R_X86_64_TPOFF64


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]