Create .rela.got/.rel.got later in _bfd_elf_create_got_section.
Fixes a rare linker issue where the .rela.got or .rel.got section is created before .got, leading to incorrect section mapping when using linker scripts.
The function _bfd_elf_create_got_section in BFD previously created the .rela.got or .rel.got section before the .got section. While this is normally not a problem, it can lead to issues when using linker scripts that map uninteresting sections to a .junk section, especially when using a linker-created dynamic object. This commit reorders the section creation to avoid this issue, ensuring that the .got section is always created first.
In Details
In BFD, _bfd_elf_create_got_section manages the creation of GOT-related sections. Linker scripts can remap output sections, and the order of section creation matters when the script's wildcards match the first created section. This change avoids unexpected section types due to early .rela.got/.rel.got creation. The interaction with linker scripts makes this subtle, and specific to certain test setups.
For Context
The Binary File Descriptor (BFD) library provides a generic interface to manipulate object files. During linking, BFD creates various sections in the output file, such as the Global Offset Table (GOT), which is used for position-independent code (PIC). Linker scripts control how these sections are mapped in the final executable. This change addresses a corner case where the order in which the GOT-related sections are created can lead to unexpected behavior when using specific linker scripts.