[PATCH] ld: Check ELF relocs before allocation
H.J. Lu
hjl.tools@gmail.com
Wed Dec 29 16:18:27 GMT 2021
More information about the Binutils mailing list
Wed Dec 29 16:18:27 GMT 2021
- Previous message (by thread): [PATCH] ld: Check ELF relocs before allocation
- Next message (by thread): [PATCH] ld: Check ELF relocs before allocation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Dec 28, 2021 at 11:46 PM Alan Modra <amodra@gmail.com> wrote: > > On Mon, Dec 27, 2021 at 06:48:33PM -0800, H.J. Lu via Binutils wrote: > > To prepare for DT_RELR implemenation, delay checking ELF relocations > > before allocation so that all input sections have been mapped to output > > sections when relocations are checked. This is only enabled for x86 > > targets. > > Please expand on why this is necessary. "Prepare for DT_RELR > implementation" doesn't tell me much. DT_RELR encodes consecutive R_*_RELATIVE relocations in GOT (the global offset table) in a compact format: https://groups.google.com/g/generic-abi/c/bX460iggiKg On some targets, R_*_RELATIVE relocations are counted and the GOT offsets are allocated when setting the dynamic section sizes after seeing all relocations. R_*_RELATIVE relocations are generated while relocating sections after section layout has been finalized. To prepare for DT_RELR implementation on these targets, we need to delay checking ELF relocations before allocation so that when relocations are checked, all input sections have been mapped to output sections, dynamic symbols are known and R_*_RELATIVE relocations can be counted. DT_RELR encoding may be generated in the relax pass when R_*_RELATIVE relocations and their GOT offsets are known. A later fix up is needed if the final GOT vma is different from when DT_RELR encoding was generated. > Also, it seems to me that you could have made the functional changes > in this patch by implementing an x86 before_allocation routine rather > than introducing a new BFD_JUMP_TABLE_LINK entry. Doing it that way > would result in a much smaller patch with few if any changes to > generic ELF linker code. A new linker function, bfd_link_make_reloc_sections, is added to create dynamic relocation sections after all input files have been opened if relocation check is delayed. Otherwise, the dynamic relocation sections are missing when input sections are being mapped to output sections. It is much cleaner than checking relocations in a before_allocation routine. -- H.J.
- Previous message (by thread): [PATCH] ld: Check ELF relocs before allocation
- Next message (by thread): [PATCH] ld: Check ELF relocs before allocation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list