From b4e6c30d1182f7d47db1b1cb249461a989190cb2 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 26 Oct 2026 23:00:24 -0700 Subject: [PATCH] Remove NO_LEGACY_INITFINI NO_LEGACY_INITFINI was added in 1da53dad ("disable legacy init/fini processing on ARM") because crt/arm/crti.s was running the init/fini arrays from _init/_fini, which caused the init/fini arrays to be run twice after e69ae844 ("add support for init_array/fini_array ctors/dtors to dynamic linker"). NO_LEGACY_INITFINII is no longer necessary after 976c0fdc ("remove init/fini array asm from arm crti/crtn files"). Keeping it enabled on arm and aarch64 results in _init/_fini symbols that are noops but never called. This conflicts with tools that rewrite the DT_INIT entry if it exists. The problem was seen with LLVM BOLT, which in some cases inserts its initializers in DT_INIT [1]. [1] https://github.com/llvm/llvm-project/blob/llvmorg-23.1.4/bolt/lib/Rewrite/RewriteInstance.cpp#L1478 --- arch/aarch64/reloc.h | 2 -- arch/arm/reloc.h | 2 -- ldso/dynlink.c | 5 +---- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/arch/aarch64/reloc.h b/arch/aarch64/reloc.h index b1b68c72..b3fec9d1 100644 --- a/arch/aarch64/reloc.h +++ b/arch/aarch64/reloc.h @@ -6,8 +6,6 @@ #define LDSO_ARCH "aarch64" ENDIAN_SUFFIX -#define NO_LEGACY_INITFINI - #define TPOFF_K 0 #define REL_SYMBOLIC R_AARCH64_ABS64 diff --git a/arch/arm/reloc.h b/arch/arm/reloc.h index d98eb8af..4810e73e 100644 --- a/arch/arm/reloc.h +++ b/arch/arm/reloc.h @@ -12,8 +12,6 @@ #define LDSO_ARCH "arm" ENDIAN_SUFFIX FP_SUFFIX -#define NO_LEGACY_INITFINI - #define TPOFF_K 0 #define REL_SYMBOLIC R_ARM_ABS32 diff --git a/ldso/dynlink.c b/ldso/dynlink.c index 1cc11276..815bb4f8 100644 --- a/ldso/dynlink.c +++ b/ldso/dynlink.c @@ -1534,10 +1534,8 @@ void __libc_exit_fini() size_t *fn = (size_t *)laddr(p, dyn[DT_FINI_ARRAY])+n; while (n--) ((void (*)(void))*--fn)(); } -#ifndef NO_LEGACY_INITFINI if ((dyn[0] & (1<