[compiler-rt] r231174 - [asan] more fixes for x32, patches by H.J. Lu
Kostya Serebryany
kcc at google.com
Tue Mar 3 15:46:40 PST 2015
Author: kcc
Date: Tue Mar 3 17:46:40 2015
New Revision: 231174
URL: http://llvm.org/viewvc/llvm-project?rev=231174&view=rev
Log:
[asan] more fixes for x32, patches by H.J. Lu
Modified:
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_stacktrace_test.cc
compiler-rt/trunk/test/asan/TestCases/Linux/ptrace.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_stacktrace_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_stacktrace_test.cc?rev=231174&r1=231173&r2=231174&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_stacktrace_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_stacktrace_test.cc Tue Mar 3 17:46:40 2015
@@ -30,11 +30,11 @@ class FastUnwindTest : public ::testing:
}
void *mapping;
- uptr *fake_stack;
+ uhwptr *fake_stack;
const uptr fake_stack_size = 10;
- uptr start_pc;
- uptr fake_top;
- uptr fake_bottom;
+ uhwptr start_pc;
+ uhwptr fake_top;
+ uhwptr fake_bottom;
BufferedStackTrace trace;
};
@@ -48,7 +48,7 @@ void FastUnwindTest::SetUp() {
Mprotect((uptr)mapping, ps);
// Unwinder may peek 1 word down from the starting FP.
- fake_stack = (uptr *)((uptr)mapping + ps + sizeof(uptr));
+ fake_stack = (uhwptr *)((uptr)mapping + ps + sizeof(uhwptr));
// Fill an array of pointers with fake fp+retaddr pairs. Frame pointers have
// even indices.
@@ -57,12 +57,12 @@ void FastUnwindTest::SetUp() {
fake_stack[i+1] = PC(i + 1); // retaddr
}
// Mark the last fp point back up to terminate the stack trace.
- fake_stack[RoundDownTo(fake_stack_size - 1, 2)] = (uptr)&fake_stack[0];
+ fake_stack[RoundDownTo(fake_stack_size - 1, 2)] = (uhwptr)&fake_stack[0];
// Top is two slots past the end because FastUnwindStack subtracts two.
- fake_top = (uptr)&fake_stack[fake_stack_size + 2];
+ fake_top = (uhwptr)&fake_stack[fake_stack_size + 2];
// Bottom is one slot before the start because FastUnwindStack uses >.
- fake_bottom = (uptr)mapping;
+ fake_bottom = (uhwptr)mapping;
start_pc = PC(0);
}
@@ -85,7 +85,7 @@ TEST_F(FastUnwindTest, Basic) {
// From: http://code.google.com/p/address-sanitizer/issues/detail?id=162
TEST_F(FastUnwindTest, FramePointerLoop) {
// Make one fp point to itself.
- fake_stack[4] = (uptr)&fake_stack[4];
+ fake_stack[4] = (uhwptr)&fake_stack[4];
if (!TryFastUnwind(kStackTraceMax))
return;
// Should get all on-stack retaddrs up to the 4th slot and start_pc.
@@ -114,7 +114,7 @@ TEST_F(FastUnwindTest, OneFrameStackTrac
return;
EXPECT_EQ(1U, trace.size);
EXPECT_EQ(start_pc, trace.trace[0]);
- EXPECT_EQ((uptr)&fake_stack[0], trace.top_frame_bp);
+ EXPECT_EQ((uhwptr)&fake_stack[0], trace.top_frame_bp);
}
TEST_F(FastUnwindTest, ZeroFramesStackTrace) {
@@ -127,7 +127,7 @@ TEST_F(FastUnwindTest, ZeroFramesStackTr
TEST_F(FastUnwindTest, FPBelowPrevFP) {
// The next FP points to unreadable memory inside the stack limits, but below
// current FP.
- fake_stack[0] = (uptr)&fake_stack[-50];
+ fake_stack[0] = (uhwptr)&fake_stack[-50];
fake_stack[1] = PC(1);
if (!TryFastUnwind(3))
return;
Modified: compiler-rt/trunk/test/asan/TestCases/Linux/ptrace.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/ptrace.cc?rev=231174&r1=231173&r2=231174&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/ptrace.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/ptrace.cc Tue Mar 3 17:46:40 2015
@@ -31,8 +31,8 @@ int main(void) {
// CHECK: AddressSanitizer: stack-buffer-overflow
// CHECK: {{.*ptrace.cc:}}[[@LINE-2]]
assert(!res);
-#if __WORDSIZE == 64
- printf("%zx\n", regs.rip);
+#ifdef __x86_64__
+ printf("%lx\n", (unsigned long)regs.rip);
#else
printf("%lx\n", regs.eip);
#endif
@@ -42,7 +42,7 @@ int main(void) {
assert(!res);
printf("%lx\n", (unsigned long)fpregs.cwd);
-#if __WORDSIZE == 32
+#ifndef __x86_64__
user_fpxregs_struct fpxregs;
res = ptrace(PTRACE_GETFPXREGS, pid, NULL, &fpxregs);
assert(!res);
More information about the llvm-commits
mailing list