binutils Newspaper
OCTOBER 6, 2026
elf — Under Review — Sentiment 4 / 10

elf: Only use function size from regular object

Ensures linker uses function size from regular objects, not shared libraries, for relevance.

This patch modifies the ELF linker to exclusively use function sizes defined in regular object files. It argues that function sizes specified in shared libraries at link-time are irrelevant for the linking process. The change is intended to fix PR ld/34585 and includes updates to test cases for various ELF targets.

In the Thread 4 participants
  1. H.J. Lu proposer

    Submits a patch to ensure function sizes are taken only from regular objects, deeming shared library sizes irrelevant at link-time.

    “Only use function size defined in regular object since function size defined in shared library at link-time is irrelevant.”
  2. Alan Modra reviewer

    Expresses doubt about the patch's premise, citing test suite failures on MIPS targets as evidence that the assumption might be incorrect.

    “I'm not completely convinced this is true. If you had run the testsuite over a good set of targets, you would have discovered: mipsisa32r2el-elf +FAIL: Build pr34585b.so”
  3. H.J. Lu proposer

    Acknowledges the test failures but reiterates the point about irrelevant function sizes from shared libraries.

  4. Jan Beulich reviewer

    Agrees with Alan Modra's concern about the patch's assertion and the observed test failures.

Technical Tradeoffs

  • Simplifies linker logic by removing consideration of shared library function sizes, potentially improving performance.
  • Risk of breaking compilation or runtime behavior on architectures where shared library function sizes are relevant for linking.

In Details

This patch targets the ELF linker's handling of function sizes, particularly when linking objects that might involve shared libraries. The core issue is whether the size of a function defined in a shared library (which is determined at runtime or during its own build) should influence how the linker calculates or represents that function's size when linking against it from another object file. The proposer believes it's irrelevant and potentially problematic, while reviewers point to test failures on specific architectures like MIPS, suggesting the assumption may not hold universally.

For Context
ELF
Executable and Linkable Format, a common standard file format for object files, executables, and shared libraries on Unix-like systems.
linker
A program that combines object files and libraries into an executable program, resolving external references between them.
shared library
A library whose code can be shared by multiple programs at runtime, loaded dynamically by the operating system.
object file
A file produced by a compiler or assembler containing machine code and data, typically intended to be linked with other object files to form an executable or library.
Filed Under: ELFlinkerfunction sizeshared librariesMIPS