From a21e2f0c20565216fbc560225ba15d8c5c1e1aa8 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 11 Dec 2024 17:02:00 +1030 Subject: xcoff reading dynamic relocs This adds a sanity check to relocation symbol indices, and tidies code a little. The patch does result in a couple of testsuite failures rs6000-aix7.2 +FAIL: TLS relocations (32-bit) rs6000-aix7.2 +FAIL: TLS relocations (64-bit) That seems reasonable to me, because prior to this patch l_symndx was being set to -1 and -2 for .tdata and .tbss symbols resulting in a buffer overflow when accessing the syms array. bfd/ * xcofflink.c (_bfd_xcoff_canonicalize_dynamic_reloc): Prevent symbol array overflow on invalid relocation symbol index. Tidy code for relocs against standard sections. (xcoff_create_ldrel): Remove cast. include/ * coff/xcoff.h (struct internal_ldrel): Make l_symndx uint32_t. Make l_rtype and l_rsecnm int16_t. --- include/coff/xcoff.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/coff') diff --git a/include/coff/xcoff.h b/include/coff/xcoff.h index 104660f..82d82eb 100644 --- a/include/coff/xcoff.h +++ b/include/coff/xcoff.h @@ -298,13 +298,13 @@ struct internal_ldrel bfd_vma l_vaddr; /* The symbol table index in the .loader section symbol table. */ - bfd_size_type l_symndx; + uint32_t l_symndx; /* The relocation type and size. */ - short l_rtype; + int16_t l_rtype; /* The section number this relocation applies to. */ - short l_rsecnm; + int16_t l_rsecnm; }; /* An entry in the XCOFF linker hash table. */ -- cgit v1.1