[PATCH][Binutils][2_44] Prevent an abort in the bfd linker when attempting to generate dynamic relocs for a corrupt input file.
Deepesh.Varatharajan@windriver.com
Deepesh.Varatharajan@windriver.com
Wed May 7 08:15:38 GMT 2025
From: Nick Clifton <nickc@redhat.com>
PR 32638
(cherry picked from commit 75086e9de1707281172cc77f178e7949a4414ed0)
Signed-off-by: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
---
bfd/elf64-x86-64.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index cb32732eba6..03592f090e2 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -5031,6 +5031,15 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
if (generate_dynamic_reloc)
{
+ /* If the relgot section has not been created, then
+ generate an error instead of a reloc. cf PR 32638. */
+ if (relgot == NULL || relgot->size == 0)
+ {
+ info->callbacks->einfo (_("%F%pB: Unable to generate dynamic relocs because a suitable section does not exist\n"),
+ output_bfd);
+ return false;
+ }
+
if (relative_reloc_name != NULL
&& htab->params->report_relative_reloc)
_bfd_x86_elf_link_report_relative_reloc
--
2.43.0
More information about the Binutils
mailing list