BFD: Make `bfd_finalize_section_relocs' return status

Update `bfd_finalize_section_relocs' to return status so that backends
can fail in this interface and propagate that to the respective callers.
Add suitable error reporting there.  No failure cases in the existing
handlers though.
This commit is contained in:
Maciej W. Rozycki
2026-01-14 22:28:43 +00:00
parent e9499dfeb3
commit ca2186f9ca
16 changed files with 54 additions and 26 deletions

View File

@@ -1517,13 +1517,14 @@ coff_frob_file_after_relocs (void)
/* Set relocations for the section and then store the number of relocations
in its aux entry. */
void
bool
obj_coff_finalize_section_relocs (asection *sec, arelent **relocs,
unsigned int n)
{
symbolS *sect_sym;
bfd_finalize_section_relocs (stdoutput, sec, n ? relocs : NULL, n);
if (!bfd_finalize_section_relocs (stdoutput, sec, n ? relocs : NULL, n))
return false;
sect_sym = section_symbol (sec);
#ifdef OBJ_XCOFF
if (S_GET_STORAGE_CLASS (sect_sym) == C_DWARF)
@@ -1531,6 +1532,7 @@ obj_coff_finalize_section_relocs (asection *sec, arelent **relocs,
else
#endif
SA_SET_SCN_NRELOC (sect_sym, n);
return true;
}
/* Implement the .section pseudo op:

View File

@@ -296,7 +296,7 @@ extern void coff_pop_insert (void);
/* We need to store the number of relocations in the section aux entry. */
#define FINALIZE_SECTION_RELOCS(sec, relocs, n) \
obj_coff_finalize_section_relocs (sec, relocs, n)
extern void obj_coff_finalize_section_relocs (asection *, arelent **,
extern bool obj_coff_finalize_section_relocs (asection *, arelent **,
unsigned int);
extern int S_SET_DATA_TYPE (symbolS *, int);

View File

@@ -1879,7 +1879,7 @@ obj_mach_o_frob_file_after_relocs (void)
/* Reverse relocations order to make ld happy. */
void
bool
obj_mach_o_reorder_section_relocs (asection *sec, arelent **rels, unsigned int n)
{
unsigned int i;
@@ -1891,7 +1891,7 @@ obj_mach_o_reorder_section_relocs (asection *sec, arelent **rels, unsigned int n
rels[i] = rels[n - i - 1];
rels[n - i - 1] = r;
}
bfd_finalize_section_relocs (stdoutput, sec, rels, n);
return bfd_finalize_section_relocs (stdoutput, sec, rels, n);
}
/* Relocation rules are different in frame sections. */

View File

@@ -101,7 +101,7 @@ extern void obj_mach_o_frob_file_after_relocs (void);
#define FINALIZE_SECTION_RELOCS(sec, relocs, n) \
obj_mach_o_reorder_section_relocs (sec, relocs, n)
extern void obj_mach_o_reorder_section_relocs (asection *, arelent **,
extern bool obj_mach_o_reorder_section_relocs (asection *, arelent **,
unsigned int);
/* Emit relocs for local subtracts, to cater for subsections-via-symbols. */

View File

@@ -1419,7 +1419,8 @@ write_relocs (bfd *abfd ATTRIBUTE_UNUSED, asection *sec,
}
#endif
FINALIZE_SECTION_RELOCS (sec, relocs, n);
if (!FINALIZE_SECTION_RELOCS (sec, relocs, n))
as_bad (_("%s: unable to finalize relocations"), sec->name);
#ifdef DEBUG3
{