[PATCH] D37517: [ELF] - Report orphan sections if -verbose given.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 17:21:35 PDT 2017


I updated the benchmark set in

https://s3-us-west-2.amazonaws.com/linker-tests/lld-speed-test.tar.xz

To include the linux kernel.

Turns out we are very slow linking it. I will report a bug about it.

George, can you benchmark your patch against the kernel? LGTM if there
is no noticeable regression.

Cheers,
Rafael

Rafael Avila de Espindola <rafael.espindola at gmail.com> writes:

> Rafael Avila de Espindola <rafael.espindola at gmail.com> writes:
>
>>>>error: ./arch/x86/kernel/vmlinux.lds:871: at least one side of the expression must be absolute
>>>>
>>>
>>> That should be about something like
>>> "init_per_cpu__gdt_page = gdt_page + __per_cpu_load";
>>>
>>> I fixed it as:
>>> init_per_cpu__gdt_page = gdt_page + ABSOLUTE(__per_cpu_load);
>>
>> I am taking a look at this one.
>
> This is fascinating.
>
> The kernel has many variables that it wants to have a copy for each
> cpu. It is similar to how each thread wants a copy of a thread local
> variable.
>
> To access such variable, the code has to find the offset of that
> variable in the per cpu block and add it to the address of the current
> brock for that cpu.
>
> Finding the offset is a problem. There are no relocations (at least on
> X86_64) that compute the offset of a symbol in a section. To solve this
> problem, the kernel linker script puts the .data..percpu section at
> address 0. By doing this, the fake address is actually the offset.
>
> This means that symbols defined in that section are effectively
> absolute. There is no way for the linker to guess that, so I think what
> is needed is the attached patch to the kernel build.
>
> I will try upstreaming it once everything works.
>
> At some point we should also try proposing relocations for computing the
> offset directly.
>
> diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
> index f05f00acac89..7fe2ee55c713 100644
> --- a/arch/x86/kernel/vmlinux.lds.S
> +++ b/arch/x86/kernel/vmlinux.lds.S
> @@ -364,7 +364,7 @@ SECTIONS
>   * Per-cpu symbols which need to be offset from __per_cpu_load
>   * for the boot processor.
>   */
> -#define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
> +#define INIT_PER_CPU(x) init_per_cpu__##x = ABSOLUTE(x) + __per_cpu_load
>  INIT_PER_CPU(gdt_page);
>  INIT_PER_CPU(irq_stack_union);
>  
>
> Cheers,
> Rafael


More information about the llvm-commits mailing list