[U-Boot] [PATCH] mpc83xx: Add -fpic relocation support
Joakim Tjernlund
joakim.tjernlund at transmode.se
Tue Oct 12 16:10:33 CEST 2010
Wolfgang Denk <wd at denx.de> wrote on 2010/10/12 15:47:19:
>
> Dear Joakim Tjernlund,
>
> In message <OF4DCFBD28.58E81A84-ONC12577BA.0047150B-C12577BA.
> 0047D319 at transmode.se> you wrote:
> >
> > > What happens when one uses this patch in combination with a
"standard"
> > > (i. e. older, unpatched) GCC?
> >
> > Nothing, gcc will produce -fPIC relocs and the code will/should just
work.
>
> OK, so your change means effectively a no-op (except for the moderate
> size increase in start.S) to most of us?
Yes.
>
> You mentioned -fpic was smaller and faster; do you have any numbers
> for that (especailly for the faster part) ?
No, but I can show a code fragment,
char *f()
{
return "string";
}
-fPIC -mplt-bss:
.LC1:
.long .LC0
.section ".text"
.align 2
.globl f
.LCL0:
.long .LCTOC1-.LCF0
.type f, @function
f:
stwu 1,-16(1)
mflr 0
bcl 20,31,.LCF0
.LCF0:
stw 30,8(1)
mflr 30
stw 0,20(1)
lwz 0,.LCL0-.LCF0(30)
add 30,0,30
lwz 0,20(1)
lwz 3,.LC1-.LCTOC1(30)
mtlr 0
lwz 30,8(1)
addi 1,1,16
blr
.LC0:
.string "string"
.ident "GCC: (Gentoo 4.4.4-r2 p1.2, pie-0.4.5) 4.4.4"
.section .note.GNU-stack,"", at progbits
-fpic -mbss-plt:
f:
stwu 1,-16(1)
mflr 12
bl _GLOBAL_OFFSET_TABLE_ at local-4
stw 30,8(1)
mflr 30
mtlr 12
lwz 3,.LC0 at got(30)
lwz 30,8(1)
addi 1,1,16
blr
.LC0:
.string "string"
.ident "GCC: (Gentoo 4.4.4-r2 p1.2, pie-0.4.5) 4.4.4"
.section .note.GNU-stack,"", at progbits
>
> > _GLOBAL_OFFSET_TABLE_ is a predefined symbol that the linker defines
to
> > be in the middle of the -fpic GOT table. It marks the end of the GOT
table
> > as far as we are concerned(u-boot does not generate so many relocs
that
> > the
> > linker needs to use the space above _GLOBAL_OFFSET_TABLE_)
> >
> > There is no predefined symbol that marks the start of fpic relocs so
> > one is added(_GOT_TABLE_) by me to the linker script.
>
> OK - can you please include these explanations into the commit
> message? Thanks.
Will do.
Jocke
More information about the U-Boot
mailing list