[PPC32] Emit R_PPC_PLTREL24 for calls to dso_local ifunc

Authored by MaskRay on Dec 17 2019, 9:35 PM.


[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

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