This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH/AARCH64] Fix 32bit reloc for ILP32
- From: Yufeng Zhang <Yufeng dot Zhang at arm dot com>
- To: Andrew Pinski <andrew dot pinski at caviumnetworks dot com>
- Cc: binutils <binutils at sourceware dot org>, Marcus Shawcroft <Marcus dot Shawcroft at arm dot com>
- Date: Wed, 24 Jul 2013 17:38:27 +0100
- Subject: Re: [PATCH/AARCH64] Fix 32bit reloc for ILP32
- References: <CA+=Sn1=NekhRQ+pO8o0oqV1h0UMysd5fNAfedOWfVt4Rf+Mj_Q at mail dot gmail dot com>
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