[U-Boot] [PATCH] PowerPC: Change -fpic flag to -fPIC flag in the config.mk

Joakim Tjernlund
2012-04-18T10:07:44Z

>
>
>
> Wolfgang Denk wrote:
> > Dear Chunhe Lan,
> >
> > In message <1334719161-3500-1-git-send-email-Chunhe.Lan@freescale.com>
> > you wrote:
> >> The -fPIC/-fpic flag belongs with -mrelocatable. The -fpic flag can
> >> limit the size of the GOT and produce smaller binaries, so it causes
> >> some GOT entries to be lost in the gcc 4.6 version. But -fPIC flag
> >> allows the maximum possible size of the GOT entries.
> >>
> >> However, currently -mrelocatable promotes -fpic flag to -fPIC flag.

Not in newer gcc's. I added this to gcc some time ago and I think
it got into gcc 4.6.

> >>
> >> This reverts that portion of the
> >> commit 33ee4c92339ee386662c0ee2d221098c5cc8b07e.
> >
> > As you state yourself, your modification has the negative impact of
> > increasing the image size. What would be the benefits of it?
> >
> > Are you trying to fix any specific problem? Which one? I am not aware
> > of any related isses for any of the mainline PowerPC systems...
> Yes, I have fixed the booting issue of nand u-boot of
> P1010/P1022/P1023/P2020 with this patch.
>
> When use gcc 4.5 version, produce the size of u-boot-nand.bin to be
> same with -fpic or -fPIC.
> The u-boot-nand.bin is OK.
>
> But when use gcc 4.6 version, produce the size of u-boot-nand.bin to
> be different with -fpic or -fPIC.
> The some GOT entries of u-boot-nand.bin are lost with -fpic(because
> limit the size), so
> u-boot-nand.bin hangs when booting. But use -fPIC, the
> u-boot-nand.bin is OK.

Your linker file is buggy I think. I found u-boot-nand_spl.lds, is that the one?
Check out that files reloc part:
.reloc : {
_GOT2_TABLE_ = .;
KEEP(*(.got2))
_FIXUP_TABLE_ = .;
KEEP(*(.fixup))
}
__got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >> 2;
__fixup_entries = (. - _FIXUP_TABLE_) >> 2;

Compare that with(from u-boot.lds):
.reloc :
{
_GOT2_TABLE_ = .;
KEEP(*(.got2))
KEEP(*(.got))
PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
_FIXUP_TABLE_ = .;
KEEP(*(.fixup))
}
__got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
__fixup_entries = (. - _FIXUP_TABLE_) >> 2;

You may have to look at start.S for nand too