mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
19fb620829
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
26 lines
808 B
LLVM
26 lines
808 B
LLVM
; RUN: llc %s -o - -mtriple=powerpc | FileCheck --check-prefix=REL %s
|
|
; RUN: llc %s -o - -mtriple=powerpc -relocation-model=pic | FileCheck --check-prefix=PLTREL %s
|
|
; RUN: llc %s -o - -mtriple=powerpc64 | FileCheck --check-prefix=REL %s
|
|
; RUN: llc %s -o - -mtriple=powerpc64 -relocation-model=pic | FileCheck --check-prefix=REL %s
|
|
|
|
@ifunc1 = dso_local ifunc void(), i8*()* @resolver
|
|
@ifunc2 = ifunc void(), i8*()* @resolver
|
|
|
|
define i8* @resolver() { ret i8* null }
|
|
|
|
define void @foo() #0 {
|
|
; REL: bl ifunc1{{$}}
|
|
; REL: bl ifunc2{{$}}
|
|
; PLTREL: bl ifunc1@PLT+32768
|
|
; PLTREL: bl ifunc2@PLT+32768
|
|
call void @ifunc1()
|
|
call void @ifunc2()
|
|
ret void
|
|
}
|
|
|
|
;; Use Secure PLT ABI for PPC32.
|
|
attributes #0 = { "target-features"="+secure-plt" }
|
|
|
|
!llvm.module.flags = !{!0}
|
|
!0 = !{i32 1, !"PIC Level", i32 2}
|