[PATCH/AARCH64] Fix 32bit reloc for ILP32
Yufeng Zhang
Yufeng.Zhang@arm.com
Wed Jul 24 16:38:00 GMT 2013
Hi Andrew,
Thanks for the patch.
On 07/23/13 23:31, Andrew Pinski wrote:
> Index: bfd/elfnn-aarch64.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/elfnn-aarch64.c,v
> retrieving revision 1.7
> diff -u -p -r1.7 elfnn-aarch64.c
> --- bfd/elfnn-aarch64.c 3 Jul 2013 17:23:24 -0000 1.7
> +++ bfd/elfnn-aarch64.c 23 Jul 2013 22:18:07 -0000
> @@ -344,7 +344,11 @@ static reloc_howto_type elfNN_aarch64_ho
> 32, /* bitsize */
> FALSE, /* pc_relative */
> 0, /* bitpos */
> +#if ARCH_SIZE == 64
> complain_overflow_unsigned, /* complain_on_overflow */
> +#else
> + complain_overflow_signed, /* complain_on_overflow */
> +#endif
complain_overflow_unsigned is wrong to use regardless of ELF64 or ELF32,
but complain_overflow_signed is not the right choice either. According
to AAELF64 4.6.5, the 32-bit relocs shall have the overflow check of
[-2^31, 2^32), and a following note explains that "these overflow ranges
permit either signed or unsigned narrow values to be created from the
intermediate result viewed as a 64-bit signed integer. ...". In other
words, the 32-bit relocs are only overflowed when the check fails in
both cases of complain_overflow_unsigned complain_overflow_signed. FYI,
there is another checking type - complain_overflow_bitfield, but it is
not suitable either as it allows some extra negative values.
I suggest to introduce a new check type which checks the range of
[-2^(N-1), 2^N) for 32-bit and 16-bit relocs (including ABS and PREL).
For 64-bit relocs, their howto entries should really have
complain_overflow_dont instead.
The issue doesn't seem to be ILP32-specific.
Regards,
Yufeng
More information about the Binutils
mailing list