[PATCH 05/46] compiler.h: introduce __global_on_lto

From: Jiri Slaby (SUSE)
Date: Mon Nov 14 2022 - 06:44:27 EST


From: Jiri Slaby <jslaby@xxxxxxx>

__global_on_lto is defined as "globl" when gcc LTO is turned on (see
later patches), and "local" otherwise. It is needed for top-level
symbols which are referenced in assembly. It is because the assembly and
the symbol can each end up in a different file with gcc LTO. And that
leads to linker errors.

So the symbols have to be global when gcc LTO is in charge. On the
contrary, they can remain local on non-gcc-LTO builds.

Cc: Martin Liska <mliska@xxxxxxx>
Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
---
include/linux/compiler.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 2305a3cbe99c..16e4c1de14c4 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -135,8 +135,10 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,

#ifdef CONFIG_LTO_GCC
# define __visible_on_lto __visible
+# define __global_on_lto "globl"
#else
# define __visible_on_lto static
+# define __global_on_lto "local"
#endif

#ifndef unreachable
--
2.38.1