elf: Hide DT_INIT and DT_FINI functions
Discussion continues regarding hiding DT_INIT/DT_FINI functions in ELF binaries.
This thread is a continuation of a discussion about hiding DT_INIT and DT_FINI functions in ELF binaries. The participants are actively debating the implications and correct implementation of such a change, with multiple nested replies indicating a thorough review process. The core issue appears to revolve around ensuring that these initialization and finalization functions are properly managed and possibly hidden from certain visibility contexts without breaking dynamic linking or program startup.
- proposer
Engaged in the ongoing discussion about hiding DT_INIT and DT_FINI functions.
“On Sun, Sep 13, 2026 at 5:03 PM Fangrui Song <i@maskray.me> wrote: > > On Fri, Sep 11, 2026 at 9:34 PM Matt Rice <ratmice@gmail.com> wrote: > > > > On Fri, Sep 11, 2026 at 7:47 PM H.J. Lu <hjl.tools@gmail.com> wrote: > > > > > > On Sat, Sep 12, 2026 at 10:12 AM Matt Rice <ratmice@gmail.com> wrote: > > > >”
In Details
This discussion concerns the ELF dynamic linking mechanism, specifically the handling of DT_INIT and DT_FINI entries in the dynamic section (.dynamic). These entries point to functions that are executed upon dynamic library loading (DT_INIT) and unloading (DT_FINI). The patch aims to hide these functions, likely by marking them as local or otherwise reducing their visibility, to prevent unintended calls or symbol resolution issues. The complex threading of replies suggests active debate over the correct approach and potential side effects on dynamic linking behavior.
- ELF
- Executable and Linkable Format. A standard file format for executables, object code, shared libraries, and core dumps on Unix-like systems.
- DT_INIT
- A tag in the ELF dynamic section (
.dynamic) that specifies the address of the initialization function for a shared library. This function is executed when the library is loaded. - DT_FINI
- A tag in the ELF dynamic section (
.dynamic) that specifies the address of the finalization function for a shared library. This function is executed when the library is unloaded. - dynamic linking
- A process where executable files are linked against shared libraries at runtime, rather than at compile time. This allows multiple programs to share code and data from a single library.
- shared library
- A library whose code can be shared by multiple executable programs simultaneously. Also known as a dynamic library.