From 31c3b5397b91ea058dbd9e773e2a2c397f17558e Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 6 Nov 2023 13:25:27 +0900 Subject: [PATCH] [POWER10] Emit dynamic relocation for ifunc Previously, we didn't emit a dynamic relocation for a statically- initialized function pointer pointing to an ifunc on POWER10, e.g. int fn() __attribute__((ifunc("resolve_fn"))); void *ptr = fn; Fixes https://github.com/rui314/mold/issues/1142 --- elf/input-sections.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elf/input-sections.cc b/elf/input-sections.cc index 864e72bb1..70187ef39 100644 --- a/elf/input-sections.cc +++ b/elf/input-sections.cc @@ -274,7 +274,7 @@ static Action get_absrel_action(Context &ctx, Symbol &sym) { template static Action get_dyn_absrel_action(Context &ctx, Symbol &sym) { if (sym.is_ifunc()) - return ctx.arg.pic ? IFUNC_DYNREL : NONE; + return sym.is_pde_ifunc(ctx) ? NONE : IFUNC_DYNREL; // This is a decision table for absolute relocations for the pointer // size data (e.g. R_X86_64_64). Unlike the absrel_table, we can emit