From: Richard Sandiford <richard.sandiford@linaro.org>
To: Richard Earnshaw <rearnsha@arm.com>
Cc: binutils@sourceware.org, patches@linaro.org
Subject: Re: Fix assembly of Thumb pcrel LDRs against global symbols
Date: Wed, 02 Mar 2011 16:36:00 -0000 [thread overview]
Message-ID: <g4wrkhwkcy.fsf@linaro.org> (raw)
In-Reply-To: <1299079089.24968.14.camel@e102346-lin.cambridge.arm.com> (Richard Earnshaw's message of "Wed, 02 Mar 2011 15:18:09 +0000")
Richard Earnshaw <rearnsha@arm.com> writes:
> On Mon, 2011-02-28 at 12:59 +0000, Richard Sandiford wrote:
>> The PC-relative LDR instructions have no associated relocation,
>> so even LDRs for global symbols should be resolved by the assembler.
>> We currently handle this correctly for single-register ARM loads,
>> but we're missing the associated relocation types for LDRD and Thumb.
>> This leads to errors like:
>
> I'm not sure I agree with this. If I write
>
> .global foo
>
> ...
> ldr r0, foo
>
> ...
>
> foo:
> ...
>
> but then at link/load time pre-empt foo with some other definition, that
> will silently leave me with the wrong answer.
Yeah, I realise we normally try to do that. The point was that we
already resolve these references at assembly time for ARM LDRs --
.syntax unified
ldr r3,foo
nop
.globl foo
foo:
.word 0x1234
-- just not for Thumb LDRs or for (any) LDRDs. I think I'd wrongly assumed
that the current ARM LDR behaviour was by design, and that we should make
the other cases match. However, looking at the ABI again, I see there is
a reloc (R_ARM_THM_PC12) that we can use here, but that we aren't using.
So if the current ARM behaviour is wrong, then I suppose there are
three bugs:
- We're using a generic ARM_OFFSET_IMM fixup for ARM LDRs, which is
always getting resolved by the assembler. We should generate a
reloc instead for this case (but not for some other ARM_OFFSET_IMM cases).
- We're using a generic T32_OFFSET_IMM fixup for Thumb LDRs, which is
always triggering an error (one of the two in my message). We should
generate a reloc instead (but not for some other T32_OFFSET_IMM cases).
- We generate the internal error for things like:
.syntax unified
.thumb_func
ldr r3,[r12,#foo-.]
nop
.globl foo
foo:
.word 0x1234
which AFAICS couldn't be handled by relocations. (The patch fixes
this too.)
That's a bit more work than I'd anticipated, and the first change might
annoy some people, so I think I'd better put it to one side for now. :-)
Richard
next prev parent reply other threads:[~2011-03-02 16:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-28 12:59 Richard Sandiford
2011-03-01 11:26 ` Dave Martin
2011-03-01 13:50 ` Richard Sandiford
2011-03-02 15:18 ` Richard Earnshaw
2011-03-02 16:36 ` Richard Sandiford [this message]
2011-03-02 16:37 ` Dave Martin
2011-03-02 16:45 ` Richard Earnshaw
2011-03-02 17:04 ` Dave Martin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=g4wrkhwkcy.fsf@linaro.org \
--to=richard.sandiford@linaro.org \
--cc=binutils@sourceware.org \
--cc=patches@linaro.org \
--cc=rearnsha@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).