binutils Newspaper
OCTOBER 6, 2026
binutils — Proposed

bfin, frv, m68k, vax: got creation in check_relocs

Call to create GOT section within `check_relocs` is acceptable due to idempotency.

Alan Modra questioned the correctness of calling GOT section creation functions within a !dynobj check in check_relocs, as it was not obvious if the GOT section would always be created. Maciej W. Rozycki confirms that while the original intent might have been to call it only once, the functions are idempotent, making the current calls acceptable.

In the Thread 1 participant
  1. Maciej W. Rozycki contributor

    States that calls to create GOT section functions are idempotent, thus the current placement within `check_relocs` is acceptable.

    “I think the original intent was to call `_bfd_elf_create_got_section' only once, at least from here. However calls to this function are idempotent, so this change seems fine to me.”

In Details

This discussion resolves a minor point of confusion regarding the placement of Global Offset Table (GOT) section creation calls within the check_relocs function in Binutils' BFD library. The concern was that the GOT might not be created under certain conditions (!dynobj). The consensus is that since the GOT creation functions are idempotent, their repeated or conditional calls do not cause issues, even if the original author's intent was different.

For Context
GOT
Global Offset Table. A table used by position-independent code (PIC) to store addresses of global variables and functions. It allows code to access data and functions regardless of its final load address.
check_relocs
A function within the Binutils BFD library responsible for checking relocation entries in an object file.
dynobj
Dynamic object. Refers to an executable or shared library that is linked and loaded at runtime.
idempotent
An operation is idempotent if applying it multiple times has the same effect as applying it once.
BFD
Binary File Descriptor library. A library provided by GNU binutils that provides a generic interface to a wide variety of object file formats.
Filed Under: binutilsbfdrelocationgotcode