From: Luca Bonissi Date: Wed, 10 May 2023 11:08:28 +0000 (+0100) Subject: or1k relocation truncated to fit: R_OR1K_GOT16 even when using -mcmodel=large X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8b7b3b2bf4357781439e5434c4a5942ea29e983d;p=binutils-gdb.git or1k relocation truncated to fit: R_OR1K_GOT16 even when using -mcmodel=large PR 30422 * elf32-or1k.c (or1k_elf_relocate_section): Prescan for R_OR1K_GOT_AHI16 relocs as they may occur after R_OR1K_GOT16 relocs. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index b8150d4d0c8..5cb20e1c278 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2023-05-10 Luca Bonissi + + PR 30422 + * elf32-or1k.c (or1k_elf_relocate_section): Prescan for + R_OR1K_GOT_AHI16 relocs as they may occur after R_OR1K_GOT16 + relocs. + 2023-05-05 Nick Clifton PR 30354 diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c index 48b8f765747..6b20e27cf09 100644 --- a/bfd/elf32-or1k.c +++ b/bfd/elf32-or1k.c @@ -1341,6 +1341,17 @@ or1k_elf_relocate_section (bfd *output_bfd, sym_hashes = elf_sym_hashes (input_bfd); relend = relocs + input_section->reloc_count; + /* Make a full scan for R_OR1K_GOT_AHI16, since it could be AFTER R_OR1K_GOT16. */ + for (rel = relocs; rel < relend; rel++) + { + int r_type = ELF32_R_TYPE (rel->r_info); + if (r_type==R_OR1K_GOT_AHI16) + { + saw_gotha = true; + break; + } + } + for (rel = relocs; rel < relend; rel++) { reloc_howto_type *howto; @@ -1520,9 +1531,6 @@ or1k_elf_relocate_section (bfd *output_bfd, || r_type == R_OR1K_GOT_AHI16) relocation -= got_sym_value; - if (r_type == R_OR1K_GOT_AHI16) - saw_gotha = true; - /* If we have a R_OR1K_GOT16 following a R_OR1K_GOT_AHI16 relocation we assume the code is doing the right thing to avoid overflows. */