]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
GAS: Unify code for SET_SECTION_RELOCS call
authorMaciej W. Rozycki <macro@orcam.me.uk>
Wed, 14 Jan 2026 22:28:43 +0000 (22:28 +0000)
committerMaciej W. Rozycki <macro@orcam.me.uk>
Wed, 14 Jan 2026 22:28:43 +0000 (22:28 +0000)
commitb45e8563ca01f874706fba05688fd683720b7003
treef2b08dae8f0fb2e88e1d1fedd138a14fc21590b2
parente6b2a7b23db0eb381a87369f2f593c113c3beb42
GAS: Unify code for SET_SECTION_RELOCS call

Fold a separate call to `bfd_set_reloc' into SET_SECTION_RELOCS itself,
so that the GAS interface to this facility is contained in a single
invocation.

Currently both `write_relocs' and `obj_mach_o_reorder_section_relocs'
call `bfd_set_reloc', causing the function to be called twice by Mach-O
targets, such as `i386-darwin', once before target-specific processing
and again afterwards, which is at the very least fragile in terms of
assuming that any actions made by the function on the first invocation
won't interfere with the final intended result.

Set the macro by default to a plain call to `bfd_set_reloc', letting
backends override the macro, with the requirement now to factor in a
call to said function at the appropriate time.  Backends can choose
whether to call `bfd_set_reloc' first (such as COFF), or last (such as
Mach-O), or at any other point in relation to their own additional
actions.

Update the COFF variant accordingly, moving it to a new function for a
better code structure, retaining functionality.

This is in preparation for `bfd_set_reloc' to return an error status.
gas/config/obj-coff.c
gas/config/obj-coff.h
gas/doc/internals.texi
gas/write.c