From ca2186f9ca89e4d0602e67d2ecca997c8a097aa6 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Wed, 14 Jan 2026 22:28:43 +0000 Subject: 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. --- binutils/objcopy.c | 11 ++++++++--- binutils/rescoff.c | 8 +++++++- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'binutils') diff --git a/binutils/objcopy.c b/binutils/objcopy.c index aea69ba886a..5f44c6295f2 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -4555,7 +4555,10 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, bfd *obfd) } if (relsize == 0) - bfd_finalize_section_relocs (obfd, osection, NULL, 0); + { + if (!bfd_finalize_section_relocs (obfd, osection, NULL, 0)) + return false; + } else { if (isection->orelocation != NULL) @@ -4596,8 +4599,10 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, bfd *obfd) *w_relpp = 0; } - bfd_finalize_section_relocs (obfd, osection, - relcount == 0 ? NULL : relpp, relcount); + if (!bfd_finalize_section_relocs (obfd, osection, + relcount == 0 ? NULL : relpp, + relcount)) + return false; } return true; } diff --git a/binutils/rescoff.c b/binutils/rescoff.c index afeadf161c1..6b07ddd2bcb 100644 --- a/binutils/rescoff.c +++ b/binutils/rescoff.c @@ -685,7 +685,13 @@ write_coff_file (const char *filename, const char *target, return false; } - bfd_finalize_section_relocs (abfd, sec, cwi.relocs, cwi.reloc_count); + if (!bfd_finalize_section_relocs (abfd, sec, cwi.relocs, cwi.reloc_count)) + { + bfd_nonfatal ("bfd_finalize_section_relocs"); + bfd_close_all_done (abfd); + free (cwi.relocs); + return false; + } offset = 0; for (d = cwi.dirs.d; d != NULL; d = d->next) -- cgit v1.2.3