[all-commits] [llvm/llvm-project] bf535a: [ELF][AArch64] Support R_AARCH64_{CALL26, JUMP26} r...

Fangrui Song via All-commits all-commits at lists.llvm.org
Mon Dec 2 10:07:32 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: bf535ac4a28268e6a481acee5a794ef5deed5018
      https://github.com/llvm/llvm-project/commit/bf535ac4a28268e6a481acee5a794ef5deed5018
  Author: Fangrui Song <maskray at google.com>
  Date:   2019-12-02 (Mon, 02 Dec 2019)

  Changed paths:
    M lld/ELF/Arch/AArch64.cpp
    M lld/ELF/Arch/ARM.cpp
    M lld/ELF/Arch/Mips.cpp
    M lld/ELF/Arch/PPC.cpp
    M lld/ELF/Arch/PPC64.cpp
    M lld/ELF/Relocations.cpp
    M lld/ELF/Relocations.h
    M lld/ELF/Target.cpp
    M lld/ELF/Target.h
    M lld/ELF/Thunks.cpp
    M lld/ELF/Thunks.h
    M lld/test/ELF/aarch64-thunk-pi.s
    M lld/test/ELF/aarch64-thunk-script.s

  Log Message:
  -----------
  [ELF][AArch64] Support R_AARCH64_{CALL26,JUMP26} range extension thunks with addends

Fixes AArch64 part of PR40438

The current range extension thunk framework does not handle a relocation
relative to a STT_SECTION symbol with a non-zero addend, which may be
used by jumps/calls to local functions on some RELA targets (AArch64,
powerpc ELFv1, powerpc64 ELFv2, etc).  See PR40438 and the following
code for examples:

  // clang -target $target a.cc
  // .text.cold may be placed in a separate output section.
  // The distance between bar in .text.cold and foo in .text may be larger than 128MiB.
  static void foo() {}
  __attribute__((section(".text.cold"))) static int bar() { foo(); return
  0; }
  __attribute__((used)) static int dummy = bar();

This patch makes such thunks with addends work for AArch64. The target
independent part can be reused by PPC in the future.

On REL targets (ARM, MIPS), jumps/calls are not represented as
STT_SECTION + non-zero addend (see
MCELFObjectTargetWriter::needsRelocateWithSymbol), so they don't need
this feature, but we need to make sure this patch does not affect them.

Reviewed By: peter.smith

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




More information about the All-commits mailing list