binutils Newspaper
OCTOBER 6, 2026
elf — Ready to Land

elf: Hide DT_INIT and DT_FINI functions

Reviewer OK'd patch to hide DT_INIT/DT_FINI functions, agreeing they are special and should be hidden by GNU ld.

This discussion concerns a patch to hide _init and _fini functions by default in GNU ld, which are associated with DT_INIT and DT_FINI dynamic section entries. While the ELF specification is silent on this exact behavior, the reviewer agrees that these functions are special and that GNU ld correctly handles them by hiding them from the dynamic symbol table (.dynsym).

In the Thread 1 participant
  1. Alan Modra <amodra@gmail.com> reviewer

    Approved the patch, stating that `_init` and `_fini` are special and it's correct for GNU ld to hide them from .dynsym.

    “I OK'd the patch on the grounds that _init and _fini are sufficiently special given the magic connection to DT_INIT and DT_FINI. I completely agree with Jan that the ELF spec is silent in this area, and that a user supplied _init or _fini ought to be hidden by making them so in the source. However, I don't think it is wrong for GNU ld to force them hidden and remove them from .dynsym.”

In Details

This patch modifies GNU ld's handling of _init and _fini symbols, which are traditionally associated with the DT_INIT and DT_FINI entries in the ELF dynamic section. The change aims to automatically hide these symbols from the dynamic symbol table (.dynsym), even though they are user-supplied and not linker-created symbols. The rationale hinges on their special nature and established linkage conventions.

For Context
_init
A convention for a function that is executed automatically by the dynamic linker before any other code in a shared object or executable is run. It is typically associated with DT_INIT.
_fini
A convention for a function that is executed automatically by the dynamic linker when a shared object or executable is unloaded. It is typically associated with DT_FINI.
DT_INIT
A dynamic tag in an ELF object that specifies the address of the initialization function (_init) for a shared library or executable.
DT_FINI
A dynamic tag in an ELF object that specifies the address of the termination function (_fini) for a shared library or executable.
ELF dynamic symbol table (.dynsym)
A section in an ELF file containing symbols that are needed for dynamic linking, such as exported functions and global variables in shared libraries.
GNU ld
The GNU linker, a standard component of the GNU Binutils package responsible for combining object files into executables or shared libraries.
Filed Under: elflinkersymbol