]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
_bfd_elf_create_got_section .rela.got
authorAlan Modra <amodra@gmail.com>
Sun, 10 May 2026 23:51:27 +0000 (09:21 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 14 May 2026 06:38:52 +0000 (16:08 +0930)
_bfd_elf_create_got_section creates .rela.got or .rel.got before it
creates .got.  This normally isn't a problem, but in some tests that
use a script to map uninteresting sections to a .junk section, if it
happens to be the first section so mapped then .junk becomes RELA
rather than the usual PROGBITS.  Using a linker created dynobj makes
this more likely as the linker created bfd is put first on
link_info.input_bfds.

* elflink.c (_bfd_elf_create_got_section): Create .rela.got/
.rel.got later.

bfd/elflink.c

index 6540184ed23f2b4316f814555973510f9da23a48..100f13227c8f1ab682512fbe4dc34ccbf7c9cd27 100644 (file)
@@ -240,15 +240,6 @@ _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
 
   flags = bed->dynamic_sec_flags;
 
-  s = bfd_make_section_anyway_with_flags (abfd,
-                                         (bed->rela_plts_and_copies_p
-                                          ? ".rela.got" : ".rel.got"),
-                                         flags | SEC_READONLY);
-  if (s == NULL
-      || !bfd_set_section_alignment (s, bed->s->log_file_align))
-    return false;
-  htab->srelgot = s;
-
   s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
   if (s == NULL
       || !bfd_set_section_alignment (s, bed->s->log_file_align))
@@ -280,6 +271,15 @@ _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
        return false;
     }
 
+  s = bfd_make_section_anyway_with_flags (abfd,
+                                         (bed->rela_plts_and_copies_p
+                                          ? ".rela.got" : ".rel.got"),
+                                         flags | SEC_READONLY);
+  if (s == NULL
+      || !bfd_set_section_alignment (s, bed->s->log_file_align))
+    return false;
+  htab->srelgot = s;
+
   return true;
 }
 \f