static void *ifunc(void) __attribute__((ifunc("resolver"))); void foo() { ifunc(); }
The relocation produced by the ifunc() call:
- gcc -msecure-plt -fPIC => R_PPC_PLTREL24 r_addend=0x8000
- gcc -msecure-plt -PIE => R_PPC_PLTREL24 r_addend=0x8000
- clang -msecure-plt -fPIC => R_PPC_PLTREL24 r_addend=0x8000
- 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.