forked from OSchip/llvm-project
[xray] Avoid text relocations in trampolines for ARM/AArch64
Summary: Switch to pc-relative lookup of the xray handler function to avoid text relocations. Reviewers: MaskRay, dberris, johnislarry Subscribers: kristof.beyls, danielkiss, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D78595
This commit is contained in:
parent
eeaabe64e3
commit
5081468a66
|
@ -27,10 +27,10 @@ __xray_FunctionEntry:
|
|||
STP Q2, Q3, [SP, #-32]!
|
||||
STP Q4, Q5, [SP, #-32]!
|
||||
STP Q6, Q7, [SP, #-32]!
|
||||
/* Load the address of _ZN6__xray19XRayPatchedFunctionE into X1 */
|
||||
LDR X1, =_ZN6__xray19XRayPatchedFunctionE
|
||||
/* Load the page address of _ZN6__xray19XRayPatchedFunctionE into X1 */
|
||||
ADRP X1, _ZN6__xray19XRayPatchedFunctionE
|
||||
/* Load the handler function pointer into X2 */
|
||||
LDR X2, [X1]
|
||||
LDR X2, [X1, #:lo12:_ZN6__xray19XRayPatchedFunctionE]
|
||||
/* Handler address is nullptr if handler is not set */
|
||||
CMP X2, #0
|
||||
BEQ FunctionEntry_restore
|
||||
|
@ -72,10 +72,10 @@ __xray_FunctionExit:
|
|||
STP X5, X6, [SP, #-16]!
|
||||
STP X7, X30, [SP, #-16]!
|
||||
STR Q0, [SP, #-16]!
|
||||
/* Load the address of _ZN6__xray19XRayPatchedFunctionE into X1 */
|
||||
LDR X1, =_ZN6__xray19XRayPatchedFunctionE
|
||||
/* Load the page address of _ZN6__xray19XRayPatchedFunctionE into X1 */
|
||||
ADRP X1, _ZN6__xray19XRayPatchedFunctionE
|
||||
/* Load the handler function pointer into X2 */
|
||||
LDR X2, [X1]
|
||||
LDR X2, [X1, #:lo12:_ZN6__xray19XRayPatchedFunctionE]
|
||||
/* Handler address is nullptr if handler is not set */
|
||||
CMP X2, #0
|
||||
BEQ FunctionExit_restore
|
||||
|
@ -117,10 +117,10 @@ __xray_FunctionTailExit:
|
|||
STP Q2, Q3, [SP, #-32]!
|
||||
STP Q4, Q5, [SP, #-32]!
|
||||
STP Q6, Q7, [SP, #-32]!
|
||||
/* Load the address of _ZN6__xray19XRayPatchedFunctionE into X1 */
|
||||
LDR X1, =_ZN6__xray19XRayPatchedFunctionE
|
||||
/* Load the page address of _ZN6__xray19XRayPatchedFunctionE into X1 */
|
||||
ADRP X1, _ZN6__xray19XRayPatchedFunctionE
|
||||
/* Load the handler function pointer into X2 */
|
||||
LDR X2, [X1]
|
||||
LDR X2, [X1, #:lo12:_ZN6__xray19XRayPatchedFunctionE]
|
||||
/* Handler address is nullptr if handler is not set */
|
||||
CMP X2, #0
|
||||
BEQ FunctionTailExit_restore
|
||||
|
|
|
@ -21,9 +21,9 @@ __xray_FunctionEntry:
|
|||
PUSH {r1-r3,lr}
|
||||
@ Save floating-point parameters of the instrumented function
|
||||
VPUSH {d0-d7}
|
||||
MOVW r1,#:lower16:_ZN6__xray19XRayPatchedFunctionE
|
||||
MOVT r1,#:upper16:_ZN6__xray19XRayPatchedFunctionE
|
||||
LDR r2, [r1]
|
||||
MOVW r1, #:lower16:_ZN6__xray19XRayPatchedFunctionE - (. + 16)
|
||||
MOVT r1, #:upper16:_ZN6__xray19XRayPatchedFunctionE - (. + 12)
|
||||
LDR r2, [pc, r1]
|
||||
@ Handler address is nullptr if handler is not set
|
||||
CMP r2, #0
|
||||
BEQ FunctionEntry_restore
|
||||
|
@ -53,9 +53,9 @@ __xray_FunctionExit:
|
|||
@ Save the floating-point return value of the instrumented function
|
||||
VPUSH {d0}
|
||||
@ Load the handler address
|
||||
MOVW r1,#:lower16:_ZN6__xray19XRayPatchedFunctionE
|
||||
MOVT r1,#:upper16:_ZN6__xray19XRayPatchedFunctionE
|
||||
LDR r2, [r1]
|
||||
MOVW r1, #:lower16:_ZN6__xray19XRayPatchedFunctionE - (. + 16)
|
||||
MOVT r1, #:upper16:_ZN6__xray19XRayPatchedFunctionE - (. + 12)
|
||||
LDR r2, [pc, r1]
|
||||
@ Handler address is nullptr if handler is not set
|
||||
CMP r2, #0
|
||||
BEQ FunctionExit_restore
|
||||
|
@ -84,9 +84,9 @@ __xray_FunctionTailExit:
|
|||
PUSH {r1-r3,lr}
|
||||
@ Save floating-point parameters of the instrumented function
|
||||
VPUSH {d0-d7}
|
||||
MOVW r1,#:lower16:_ZN6__xray19XRayPatchedFunctionE
|
||||
MOVT r1,#:upper16:_ZN6__xray19XRayPatchedFunctionE
|
||||
LDR r2, [r1]
|
||||
MOVW r1, #:lower16:_ZN6__xray19XRayPatchedFunctionE - (. + 16)
|
||||
MOVT r1, #:upper16:_ZN6__xray19XRayPatchedFunctionE - (. + 12)
|
||||
LDR r2, [pc, r1]
|
||||
@ Handler address is nullptr if handler is not set
|
||||
CMP r2, #0
|
||||
BEQ FunctionTailExit_restore
|
||||
|
|
Loading…
Reference in New Issue