Re: [PATCH] Replace __toc_start + 0x8000 with .TOC.

From: Segher Boessenkool
Date: Sun Mar 07 2021 - 01:31:00 EST


Hi!

On Sat, Mar 06, 2021 at 09:14:33PM -0800, Fangrui Song wrote:
> TOC relocations are like GOT relocations on other architectures.
> However, unlike other architectures, GNU ld's ppc64 port defines .TOC.
> relative to the .got output section instead of the linker synthesized
> .got input section. LLD defines .TOC. as the .got input section plus
> 0x8000. When CONFIG_PPC_OF_BOOT_TRAMPOLINE=y,
> arch/powerpc/kernel/prom_init.o is built, and LLD computed .TOC. can be
> different from __toc_start defined by the linker script.
>
> Simplify kernel_toc_addr with asm label .TOC. so that we can get rid of
> __toc_start.
>
> With this change, powernv_defconfig with CONFIG_PPC_OF_BOOT_TRAMPOLINE=y
> is bootable with LLD. There is still an untriaged issue with Alexey's
> configuration.

Do you have any explanation why this *does* work, while the original
doesn't? Some explanation that says *what* is wrong. To me it doesn't
look like the kernel script is.


Segher