diff options
author | Julian Lettner <jlettner@apple.com> | 2019-07-15 20:22:27 +0000 |
---|---|---|
committer | Julian Lettner <jlettner@apple.com> | 2019-07-15 20:22:27 +0000 |
commit | 39d888c1e42a62e02adfb5fe8da54cafe7e62b0b (patch) | |
tree | bb2f314889e1a6092d20dedce1ac60995ecd83d1 /compiler-rt/lib/tsan | |
parent | 66ee934440c21dc2bd6ff938c79dad4ce032990a (diff) | |
download | bcm5719-llvm-39d888c1e42a62e02adfb5fe8da54cafe7e62b0b.tar.gz bcm5719-llvm-39d888c1e42a62e02adfb5fe8da54cafe7e62b0b.zip |
[TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.9
Switch over to computing the xor key in C, instead of assembly for
Linux/AArch64.
llvm-svn: 366126
Diffstat (limited to 'compiler-rt/lib/tsan')
-rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc index 0f23da0e877..db85d547b05 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc @@ -302,26 +302,8 @@ void InitializePlatform() { CHECK_NE(personality(old_personality | ADDR_NO_RANDOMIZE), -1); reexec = true; } - // Initialize the guard pointer used in {sig}{set,long}jump. - longjmp_xor_key = InitializeGuardPtr(); - // uptr old_value = longjmp_xor_key; - // InitializeLongjmpXorKey(); - // CHECK_EQ(longjmp_xor_key, old_value); - // If the above check fails for you, please contact me (jlettner@apple.com) - // and let me know the values of the two differing keys. Please also set a - // breakpoint on `InitializeGuardPtr` and `InitializeLongjmpXorKey` and tell - // me the stack pointer (SP) values that go into the XOR operation (where we - // derive the key): - // - // InitializeLongjmpXorKey: - // uptr sp = (uptr)__builtin_frame_address(0); - // - // InitializeGuardPtr (in tsan_rtl_aarch64.S): - // mov x0, sp - // ... - // eor x0, x0, x1 - // - // Then feel free to comment out the call to `InitializeLongjmpXorKey`. + // Initialize the xor key used in {sig}{set,long}jump. + InitializeLongjmpXorKey(); #endif if (reexec) ReExec(); @@ -437,9 +419,10 @@ static void InitializeLongjmpXorKey() { jmp_buf env; REAL(_setjmp)(env); - // 2. Retrieve mangled/vanilla SP. + // 2. Retrieve vanilla/mangled SP. + uptr sp; + asm("mov %0, %%sp" : "=r" (sp)); uptr mangled_sp = ((uptr *)&env)[LONG_JMP_SP_ENV_SLOT]; - uptr sp = (uptr)__builtin_frame_address(0); // 3. xor SPs to obtain key. longjmp_xor_key = mangled_sp ^ sp; |