[RFC PATCH] arm: decompressor: initialize PIC offset base register for uClinux tools

Russell King - ARM Linux linux at arm.linux.org.uk
Mon Feb 4 07:07:08 EST 2013


On Mon, Feb 04, 2013 at 12:00:00PM +0000, Jonathan Austin wrote:
> You seem to have understood! Specifying -mno-single-pic-base
> means the compiler *won't* expect r9 to point to the GOT, but also
> means r9 is free as a general purpose register, the effect that I
> believe gives the performance improvement in the decompresser.
> 
> Perhaps the context missing is that these are two independent patch
> suggestions that achieve the same thing in different ways (that is,
> they stop the decompresser running off to some incorrect memory location
> because r9 isn't set-up). The -mno-single-pic base patch does it by not
> using r9 as a PIC offset, and the 'initialise r9' patch does what it says
> on the tin.
> 
> As you see, I benchmarked them and got the opposite result to what I
> expected (IE -mno-songle-pic-base is quicker), so, based also on
> Nicolas's Ack, would now champion a different patch to the original one
> that I posted...
> 
> This is probably overkill, but here's a simple C example for comparison:
> $cat pic.c
> ----------------
> int foo;
> int ret_foo()
> {
> 	return foo;
> }
> ----------------
> $arm-none-uclinux-uclibceabi-gcc -O2 -fPIC -S pic.c -o pic.s
> $cat pic.s
> -------------
> [...]
> ret_foo:
> 	ldr	r3, .L2
> 	ldr	r3, [r9, r3]
> 	ldr	r0, [r3, #0]
> 	bx	lr
> .L3:
> 	.align	2
> .L2:
> 	.word	foo(GOT)
> 	.size	ret_foo, .-ret_foo

Ah, so the problem is that the default for single-pic-base is different
with uclinux compilers from other compilers.  Other compilers will
default to -mno-single-pic-base, but what your build above shows is that
for your compiler, your default is -msingle-pic-base.

So, passing -mno-single-pic-base means that you're actually _restoring_
the compiler behaviour that we're expecting for the decompressor.



More information about the linux-arm-kernel mailing list