This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH, binutils, ARM, 0/16] Add support for Armv8.1-M Mainline
- From: Alan Modra <amodra at gmail dot com>
- To: "Andre Vieira (lists)" <andre dot simoesdiasvieira at arm dot com>
- Cc: "nickc at redhat dot com" <nickc at redhat dot com>, "binutils at sourceware dot org" <binutils at sourceware dot org>, sudi dot das at arm dot com
- Date: Thu, 2 May 2019 10:51:00 +0930
- Subject: Re: [PATCH, binutils, ARM, 0/16] Add support for Armv8.1-M Mainline
- References: <cfedf9a3-8a0e-d9cd-3b65-683d00e83621@arm.com> <bd31fdec-4529-8aa7-f7df-144c6f93fcce@redhat.com> <9d62b2e9-80fb-1b31-2271-79ad052f8a25@arm.com> <5798f7d9-3059-98d7-8d02-9dd39adce0f6@redhat.com> <AM6PR08MB32541A0791E9ABB2DCF9E9C7882B0@AM6PR08MB3254.eurprd08.prod.outlook.com> <20190416015753.GQ14424@bubble.grove.modra.org> <AM6PR08MB3254BC6A212F7E613F78BA1188240@AM6PR08MB3254.eurprd08.prod.outlook.com> <20190416123631.GX14424@bubble.grove.modra.org> <69f33a7a-97ee-6343-fdb3-c087dbd98748@arm.com>
On Wed, May 01, 2019 at 10:32:17AM +0100, Andre Vieira (lists) wrote:
> As for the vxworks failures Alan spotted, I believe this is due to the
> relocations being treated differently, as you pointed out one uses REL and
> the other RELA. This leads to different relocation encodings. So for
> instance when a REL target encodes a relocation for 'target' it seems to do
> so with:
> A = 0
> S = target
>
> whereas for RELA it uses:
> A = 4
> S = target-4
No, this is confused. The "A" you are showing here is the value
displayed by objdump after decoding. This is completely irrelevant.
In actual fact the value of "A", the addend as per the ABI, is -4 for
both REL and RELA. "S" is the symbol, ie. "target" (there is no such
thing as S = target-4).
For your first testcase, armv8_1-m-bf-rel.d, you expect
f0df e7ff bf 2, 00000000 <.target>
0: R_ARM_THM_BF16 .target
If you squint at that instruction long enough, you'll see that the
instruction (split) field is indeed -4, and since addends are taken
from the instruction for REL relocations, "A" is -4.
armv8_1-m-bf-rela.d expects
f0c0 e001 bf 2, 00000004 <.target\+0x4>
0: R_ARM_THM_BF16 .target-0x4
Here the instruction field is left as 0 (the value of the field
doesn't matter), and "A" of -4 is taken from the RELA relocation
addend.
I believe the reason for the -4 addend is that ARM processors
calculate branch targets relative to the insn PC plus 4 for 4-byte
insns. So I don't have any problem with the patch itself, but wanted
to clear up any confusion in your patch explanation. Approval of the
patch will be handled by one of the ARM maintainers.
--
Alan Modra
Australia Development Lab, IBM