[binutils-gdb] _bfd_elf_create_got_section .rela.got
Alan Modra via Binutils-cvs <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ef105489af06595c66d13d3a15d0f160856f36e8 commit ef105489af06595c66d13d3a15d0f160856f36e8 Author: Alan Modra <[email protected]> Date: Mon May 11 09:21:27 2026 +0930 _bfd_elf_create_got_section .rela.got _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. Diff: --- bfd/elflink.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bfd/elflink.c b/bfd/elflink.c index 6540184ed23..100f13227c8 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -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; }