[PATCH 10/46] static_call, lto: Mark func_a() as __visible_on_lto

Jiri Slaby (SUSE)
2022-11-14T11:44:57Z

From: Andi Kleen <andi@firstfloor.org>

Symbols referenced from assembler (either directly or e.f. from
DEFINE_STATIC_KEY()) need to be global and visible in gcc LTO because
they could end up in a different object file than the assembler. This
can lead to linker errors without this patch.

So mark func_a() as __visible_on_lto as it was static.

[js] use __visible_on_lto

Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Jason Baron <jbaron@akamai.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Martin Liska <mliska@suse.cz>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
kernel/static_call_inline.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/static_call_inline.c b/kernel/static_call_inline.c
index dc5665b62814..6933b4437597 100644
--- a/kernel/static_call_inline.c
+++ b/kernel/static_call_inline.c
@@ -501,7 +501,7 @@ early_initcall(static_call_init);

#ifdef CONFIG_STATIC_CALL_SELFTEST

-static int func_a(int x)
+__visible_on_lto int sc_func_a(int x)
{
return x+1;
}
@@ -511,7 +511,7 @@ static int func_b(int x)
return x+2;
}

-DEFINE_STATIC_CALL(sc_selftest, func_a);
+DEFINE_STATIC_CALL(sc_selftest, sc_func_a);

static struct static_call_data {
int (*func)(int);
@@ -520,7 +520,7 @@ static struct static_call_data {
} static_call_data [] __initdata = {
{ NULL, 2, 3 },
{ func_b, 2, 4 },
- { func_a, 2, 3 }
+ { sc_func_a, 2, 3 }
};

static int __init test_static_call_init(void)
--
2.38.1