Make React Profiler asm position independent

Reviewed By: compnerd

Differential Revision: D4297098

fbshipit-source-id: 567f640f2d1ed4187e53356e7ca2d066f1412f9d
This commit is contained in:
Stepan Hruda 2016-12-08 14:54:53 -08:00 committed by Facebook Github Bot
parent 4a6f2ec44a
commit 1642b38abe
2 changed files with 11 additions and 6 deletions

View File

@ -10,4 +10,9 @@
#define _CONCAT(A, B) A##B
#define CONCAT(A, B) _CONCAT(A, B)
#define SYMBOL_NAME(S) CONCAT(__USER_LABEL_PREFIX__, S)
#if !defined(PIC_MODIFIER)
#define PIC_MODIFIER
#endif
#define SYMBOL_NAME(name) CONCAT(__USER_LABEL_PREFIX__, name)
#define SYMBOL_NAME_PIC(name) CONCAT(SYMBOL_NAME(name), PIC_MODIFIER)

View File

@ -59,7 +59,7 @@ SYMBOL_NAME(RCTProfileTrampoline):
* This is a C function defined in `RCTProfile.m`, the object and the selector
* already have to be on %rdi and %rsi respectively, as in any ObjC call.
*/
callq SYMBOL_NAME(RCTProfileGetImplementation)
callq SYMBOL_NAME_PIC(RCTProfileGetImplementation)
// Restore/unalign the stack pointer, so we can access the registers we stored
movq %r12, %rsp
@ -90,7 +90,7 @@ SYMBOL_NAME(RCTProfileTrampoline):
// allocate 16 bytes
movq $0x10, %rdi
callq SYMBOL_NAME(malloc)
callq SYMBOL_NAME_PIC(malloc)
// store the initial value of calle saved registers %r13 and %r14
movq %r13, 0x0(%rax)
@ -108,7 +108,7 @@ SYMBOL_NAME(RCTProfileTrampoline):
movq 0x38(%r12), %rsi // selector
// void RCTProfileTrampolineStart(id, SEL) in RCTProfile.m
callq SYMBOL_NAME(RCTProfileTrampolineStart)
callq SYMBOL_NAME_PIC(RCTProfileTrampolineStart)
// unalign the stack and restore %r12
movq %r12, %rsp
@ -148,7 +148,7 @@ SYMBOL_NAME(RCTProfileTrampoline):
movdqa %xmm1, 0x10(%rsp)
// void RCTProfileTrampolineEnd(void) in RCTProfile.m - just ends this profile
callq SYMBOL_NAME(RCTProfileTrampolineEnd)
callq SYMBOL_NAME_PIC(RCTProfileTrampolineEnd)
/**
* Restore the initial value of the callee saved registers, saved in the
@ -169,7 +169,7 @@ SYMBOL_NAME(RCTProfileTrampoline):
andq $-0x10, %rsp
// Free the memory allocated to stash callee saved registers
callq SYMBOL_NAME(free)
callq SYMBOL_NAME_PIC(free)
// unalign stack and restore %r12
movq %r12, %rsp