[all-commits] [llvm/llvm-project] e8054f: [PPC32] Emit R_PPC_PLTREL24 for calls to dso_local...

Fangrui Song via All-commits all-commits at lists.llvm.org
Fri Dec 20 11:32:08 PST 2019


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

  Changed paths:
    M llvm/lib/Target/PowerPC/PPCISelLowering.cpp
    A llvm/test/CodeGen/PowerPC/ifunc.ll

  Log Message:
  -----------
  [PPC32] Emit R_PPC_PLTREL24 for calls to dso_local ifunc

  static void *ifunc(void) __attribute__((ifunc("resolver")));
  void foo() { ifunc(); }

The relocation produced by the ifunc() call:

1. gcc -msecure-plt -fPIC => R_PPC_PLTREL24 r_addend=0x8000
2. gcc -msecure-plt -PIE => R_PPC_PLTREL24 r_addend=0x8000
3. clang -msecure-plt -fPIC => R_PPC_PLTREL24 r_addend=0x8000
4. clang -msecure-plt -fPIE => R_PPC_REL24

4 is incorrect. The R_PPC_REL24 needs a call stub due to ifunc. If this
relocation is mixed with other R_PPC_PLTREL24(r_addend=0x8000) in a
function, both GNU ld and lld (after D71621 fix) may produce a wrong
result.

This patch fixes 4 to use R_PPC_PLTREL24, which matches GCC.
Both GNU ld and lld (after D71621) will be happy.

Reviewed By: sfertile

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




More information about the All-commits mailing list