<div dir="ltr">The patch looks good, thanks! <div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 14, 2014 at 8:06 AM, Peter Bergner <span dir="ltr"><<a href="mailto:bergner@vnet.ibm.com" target="_blank">bergner@vnet.ibm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">The following patch gets ASAN somewhat working on powerpc64le-linux.<br>
It currently assumes the LE kernel uses 46-bit addressing, which is<br>
true, but it doesn't solve the case for BE where it may be 44 or<br>
46 bits. That can be fixed with a follow on patch.<br></blockquote><div>Let's do it on demand. </div><div><br></div><div>Please use <a href="http://llvm.org/docs/Phabricator.html">http://llvm.org/docs/Phabricator.html</a> for any changes that are even slightly less trivial than this one</div><div>(preferably for all changes).</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
There are some test suite fails even with this patch that I haven't had<br>
time to solve yet, but this is better than the state it is in now.<br>
The limited debugging of those test suite fails seems to show that the<br>
address map for 46-bit addressing has changed and so we'll need to<br>
modify the shadow memory location slightly. Again, that can be fixed<br>
with a follow on patch.<br>
<br>
Is this ok to commit?<br>
<br>
Peter<br>
<br>
<br>
Index: lib/asan/asan_mapping.h<br>
===================================================================<br>
--- lib/asan/asan_mapping.h (revision 219685)<br>
+++ lib/asan/asan_mapping.h (working copy)<br>
@@ -87,7 +87,11 @@<br>
static const u64 kDefaultShort64bitShadowOffset = 0x7FFF8000; // < 2G.<br>
static const u64 kAArch64_ShadowOffset64 = 1ULL << 36;<br>
static const u64 kMIPS32_ShadowOffset32 = 0x0aaa8000;<br>
+#if defined(__powerpc64__) && defined (__BIG_ENDIAN__)<br>
static const u64 kPPC64_ShadowOffset64 = 1ULL << 41;<br>
+#elif defined(__powerpc64__) && defined (__LITTLE_ENDIAN__)<br>
+static const u64 kPPC64_ShadowOffset64 = 1ULL << 43;<br>
+#endif<br>
static const u64 kFreeBSD_ShadowOffset32 = 1ULL << 30; // 0x40000000<br>
static const u64 kFreeBSD_ShadowOffset64 = 1ULL << 46; // 0x400000000000<br>
<br>
Index: lib/asan/asan_report.cc<br>
===================================================================<br>
--- lib/asan/asan_report.cc (revision 219685)<br>
+++ lib/asan/asan_report.cc (working copy)<br>
@@ -437,8 +437,8 @@<br>
// especially given that the alloca may be from entirely different place<br>
// (e.g. use-after-scope, or different thread's stack).<br>
StackTrace alloca_stack;<br>
-#ifdef __powerpc64__<br>
- // On PowerPC64, the address of a function actually points to a<br>
+#if defined(__powerpc64__) and defined(__BIG_ENDIAN__)<br>
+ // On PowerPC64 ELFv1, the address of a function actually points to a<br>
// three-doubleword data structure with the first field containing<br>
// the address of the function's code.<br>
access.frame_pc = *reinterpret_cast<uptr *>(access.frame_pc);<br>
Index: lib/sanitizer_common/sanitizer_posix.cc<br>
===================================================================<br>
--- lib/sanitizer_common/sanitizer_posix.cc (revision 219685)<br>
+++ lib/sanitizer_common/sanitizer_posix.cc (working copy)<br>
@@ -78,7 +78,7 @@<br>
<br>
uptr GetMaxVirtualAddress() {<br>
#if SANITIZER_WORDSIZE == 64<br>
-# if defined(__powerpc64__)<br>
+# if defined(__powerpc64__) && defined(__BIG_ENDIAN__)<br>
// On PowerPC64 we have two different address space layouts: 44- and 46-bit.<br>
// We somehow need to figure out which one we are using now and choose<br>
// one of 0x00000fffffffffffUL and 0x00003fffffffffffUL.<br>
@@ -85,6 +85,8 @@<br>
// Note that with 'ulimit -s unlimited' the stack is moved away from the top<br>
// of the address space, so simply checking the stack address is not enough.<br>
return (1ULL << 44) - 1; // 0x00000fffffffffffUL<br>
+# elif defined(__powerpc64__) && defined(__LITTLE_ENDIAN__)<br>
+ return (1ULL << 46) - 1; // 0x00003fffffffffffUL<br>
# elif defined(__aarch64__)<br>
return (1ULL << 39) - 1;<br>
# else<br>
Index: lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc<br>
===================================================================<br>
--- lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc (revision 219685)<br>
+++ lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc (working copy)<br>
@@ -341,8 +341,10 @@<br>
const char* const kSymbolizerArch = "--default-arch=x86_64";<br>
#elif defined(__i386__)<br>
const char* const kSymbolizerArch = "--default-arch=i386";<br>
-#elif defined(__powerpc64__)<br>
+#elif defined(__powerpc64__) && defined(__BIG_ENDIAN__)<br>
const char* const kSymbolizerArch = "--default-arch=powerpc64";<br>
+#elif defined(__powerpc64__) && defined(__LITTLE_ENDIAN__)<br>
+ const char* const kSymbolizerArch = "--default-arch=powerpc64le";<br>
#else<br>
const char* const kSymbolizerArch = "--default-arch=unknown";<br>
#endif<br>
<br>
<br>
</blockquote></div><br></div></div>