Skip to content

ARM: clean up PC-relative arithmetic

Russell King - ARM Linux linux-arm-kernel 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest1 of 8 patches 0 repliesNew

1 of 8 patches is in this archive. The cover letter announces 8.

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8ARM: assembler: introduce adr_l, ldr_l and str_l macros+0 -02 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/8] ARM: clean up PC-relative arithmetic
Quoted 50 lines · Ard Biesheuvel
Quoted 48 lines · Russell King - ARM Linux
Quoted 47 lines · Ard Biesheuvel
Quoted 44 lines · Russell King - ARM Linux
Quoted 13 lines · Ard Biesheuvel
Quoted 11 lines · Russell King - ARM Linux

I don't buy that argument, sorry, and the argument is actually wrong. No, we're _not_ letting the linker do the calculations for us, we're letting the linker do _some_ of the calculation, but not all.

What you're replacing the above with is stuff like (I guess, because I've no idea what this :pc_g0: notation is):

        add     rX, pc, #(sym - . - 8) & 0xff
        add     rX, rX, #(sym - . - 4) & 0xff00
        add     rX, rX, #(sym - .) & 0xff0000
Quoted 8 lines
Quoted 4 lines

which I think is a more complex (and less obvious) way to calculate it. It's also buggy when we end up with a relative offset greater than 16MB, which we have in multi-zImage kernels.

Even if you think this is a more complex way to calculate it, at least it is encapsulated in a single macro instead of having similar but not identical open coded instances all over the place.

... and, it may come as a shocker, but I don't have a problem with that.

Quoted 6 lines

As for the range: the ldr/str variants have 28 bits of range (2x scaled 8 bit immediate for the adds and a single unscaled 12 bit immediate for the ldr/str). The adr variant has 26 bits (3x scaled immediate counting from bit 2) range for word aligned symbols, which gives us +/- 64 MB, which should be plenty. The only pathological outlier is allyesconfig, but that uses Thumb2 anyway.

Our existing code allows for a range of the full address space - the only thing it relies upon is that the literal data is placed within reach of the code - which it will be, because it's always placed near the code which is using it.

Quoted 2 lines

The relocations documented here
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044f/IHI0044F_aaelf.pdf

Right, so it's an EABI thing, and I guess you haven't tested OABI builds, where I suspect these relocations aren't supported.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I suppose that's a fair point. But then, I'm only 40 so I am too young to remember this OABI stuff anyway. Does it require GCC 2.95 from your toolchain museum?

I'm sorry, but that's really no excuse, we're of similar ages, so... <expletive deleted>.

Just countering the unnecessary sarcasm ... :-)

There was nothing sarcastic about my reply to you - everything I said was deadly serious.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.