[lkml]   [2019]   [Apr]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 3.18 039/104] x86/build: Mark per-CPU symbols as absolute explicitly for LLD
[ Upstream commit d071ae09a4a1414c1433d5ae9908959a7325b0ad ]

Accessing per-CPU variables is done by finding the offset of the
variable in the per-CPU block and adding it to the address of the
respective CPU's block.

Section 3.10.8 of ld.bfd's documentation states:

For expressions involving numbers, relative addresses and absolute
addresses, ld follows these rules to evaluate terms:

Other binary operations, that is, between two relative addresses
not in the same section, or between a relative address and an
absolute address, first convert any non-absolute term to an
absolute address before applying the operator."

Note that LLVM's linker does not adhere to the GNU ld's implementation
and as such requires implicitly-absolute terms to be explicitly marked
as absolute in the linker script. If not, it fails currently with:

ld.lld: error: ./arch/x86/kernel/ at least one side of the expression must be absolute
ld.lld: error: ./arch/x86/kernel/ at least one side of the expression must be absolute
Makefile:1040: recipe for target 'vmlinux' failed

This is not a functional change for ld.bfd which converts the term to an
absolute symbol anyways as specified above.

Based on a previous submission by Tri Vo <>.

Reported-by: Dmitry Golovin <>
Signed-off-by: Rafael Ávila de Espíndola <>
[ Update commit message per Boris' and Michael's suggestions. ]
Signed-off-by: Nick Desaulniers <>
[ Massage commit message more, fix typos. ]
Signed-off-by: Borislav Petkov <>
Tested-by: Dmitry Golovin <>
Cc: "H. Peter Anvin" <>
Cc: Andy Lutomirski <>
Cc: Brijesh Singh <>
Cc: Cao Jin <>
Cc: Ingo Molnar <>
Cc: Joerg Roedel <>
Cc: Masahiro Yamada <>
Cc: Masami Hiramatsu <>
Cc: Thomas Gleixner <>
Cc: Tri Vo <>
Cc: x86-ml <>
Signed-off-by: Sasha Levin <>
arch/x86/kernel/ | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/ b/arch/x86/kernel/
index 49edf2dd3613..1bd47a144db1 100644
--- a/arch/x86/kernel/
+++ b/arch/x86/kernel/
@@ -345,7 +345,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


 \ /
  Last update: 2019-04-24 20:14    [W:0.288 / U:23.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site