[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 15:17:55 PDT 2017


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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.diff
Type: text/x-patch
Size: 510 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170920/e553d677/attachment.bin>
-------------- next part --------------

Cheers,
Rafael


More information about the llvm-commits mailing list