[all-commits] [llvm/llvm-project] fc3386: [ELF] Split scanRelocations into scanRelocations/p...

Fangrui Song via All-commits all-commits at lists.llvm.org
Mon Dec 13 09:57:05 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fc33861d48a95aa4682ce3b6e44732e5c8bbd092
      https://github.com/llvm/llvm-project/commit/fc33861d48a95aa4682ce3b6e44732e5c8bbd092
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-12-13 (Mon, 13 Dec 2021)

  Changed paths:
    M lld/ELF/Relocations.cpp
    M lld/ELF/Relocations.h
    M lld/ELF/Symbols.h
    M lld/ELF/Writer.cpp
    M lld/test/ELF/aarch64-ifunc-bti.s
    M lld/test/ELF/aarch64-thunk-pi.s
    M lld/test/ELF/arm-branch-undef-weak-plt-thunk.s
    M lld/test/ELF/arm-gnu-ifunc.s
    M lld/test/ELF/arm-thumb-interwork-thunk.s
    M lld/test/ELF/bsymbolic.s
    M lld/test/ELF/gnu-ifunc-i386.s
    M lld/test/ELF/ppc32-canonical-plt.s
    M lld/test/ELF/ppc32-ifunc-nonpreemptible-pic.s
    M lld/test/ELF/ppc32-reloc-got.s
    M lld/test/ELF/ppc64-ifunc.s
    M lld/test/ELF/relocation-nocopy.s
    M lld/test/ELF/riscv-reloc-got.s
    M lld/test/ELF/symver.s
    M lld/test/ELF/version-script-symver.s
    M lld/test/ELF/wrap-no-real.s
    M lld/test/ELF/wrap-plt.s
    M lld/test/ELF/x86-64-gotpc-relax-und-dso.s
    M lld/test/ELF/x86-64-plt.s
    M lld/test/ELF/x86-x32-plt.s

  Log Message:
  -----------
  [ELF] Split scanRelocations into scanRelocations/postScanRelocations

The idea is to make scanRelocations mark some actions are needed (GOT/PLT/etc)
and postpone the real work to postScanRelocations. It gives some flexibility:

* Make it feasible to support .plt.got (PR32938): we need to know whether GLOB_DAT and JUMP_SLOT are both needed.
* Make non-preemptible IFUNC handling slightly cleaner: avoid setting/clearing sym.gotInIgot
* -z nocopyrel: report all copy relocation places for one symbol
* Make parallel relocation scanning possible (if we can avoid all stateful operations and make Symbol attributes atomic), but parallelism may not be the appealing choice
* Make GOT deduplication feasible

Since this patch moves a large chunk of code out of ELFT templates. My x86-64
executable is actually a few hundred bytes smaller.

For ppc32-ifunc-nonpreemptible-pic.s: I remove absolute relocation references to non-preemptible ifunc
because absolute relocation references are incorrect in -fpie mode.

Reviewed By: peter.smith, ikudrin

Differential Revision: https://reviews.llvm.org/D114783




More information about the All-commits mailing list