binutils Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gas/elf

Assembler now restricts visibility changes for ELF symbols.

ELF visibility attributes now follow the "most restrictive wins" rule during assembly, aligning with linker behavior.

The assembler now enforces the “most restrictive visibility wins” rule when applying visibility attributes to ELF symbols. This change aligns the assembler’s behavior with the linker, ensuring consistency in visibility propagation. If a symbol already has a visibility attribute, the assembler will only allow it to be changed to a more restrictive one; otherwise, a warning is issued.

In Details

In ELF, symbol visibility attributes (STV_DEFAULT, STV_INTERNAL, STV_HIDDEN, STV_PROTECTED) control how symbols are exposed during linking. The assembler's obj_elf_visibility function in gas/config/obj-elf.c now respects the "most restrictive wins" rule, consistent with the linker. This prevents accidental weakening of visibility during assembly. The interaction with the linker is critical because the linker combines multiple object files, and visibility attributes affect the final symbol table.

For Context

Symbol visibility attributes control how symbols are exposed during linking. These attributes determine whether a symbol can be accessed from outside the current compilation unit (e.g., library or executable). The ELF format defines several visibility levels, such as default, internal, hidden and protected. This commit ensures that the assembler enforces a consistent "most restrictive wins" rule. If a symbol already has a visibility attribute, the assembler will only allow it to be changed to a more restrictive one, preventing accidental exposure of internal symbols.

Filed Under: assemblerelfvisibilitylinking