[llvm-branch-commits] [compiler-rt] fde3ae8 - [asan][memprof] Declare _DYNAMIC and fix -Wparentheses

Fangrui Song via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Dec 27 20:33:48 PST 2020


Author: Fangrui Song
Date: 2020-12-27T20:28:59-08:00
New Revision: fde3ae88ee4236d6ecb8178c6c893df5a5a04437

URL: https://github.com/llvm/llvm-project/commit/fde3ae88ee4236d6ecb8178c6c893df5a5a04437
DIFF: https://github.com/llvm/llvm-project/commit/fde3ae88ee4236d6ecb8178c6c893df5a5a04437.diff

LOG: [asan][memprof] Declare _DYNAMIC and fix -Wparentheses

Declare `extern ElfW(Dyn) _DYNAMIC[];` so that it will trivially work on musl.

Added: 
    

Modified: 
    compiler-rt/lib/asan/asan_linux.cpp
    compiler-rt/lib/memprof/memprof_linux.cpp
    compiler-rt/lib/memprof/memprof_mapping.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/asan/asan_linux.cpp b/compiler-rt/lib/asan/asan_linux.cpp
index fb1a442b3d43..4bcbe5d02e33 100644
--- a/compiler-rt/lib/asan/asan_linux.cpp
+++ b/compiler-rt/lib/asan/asan_linux.cpp
@@ -55,6 +55,7 @@ extern Elf_Dyn _DYNAMIC;
 #else
 #include <sys/ucontext.h>
 #include <link.h>
+extern ElfW(Dyn) _DYNAMIC[];
 #endif
 
 // x86-64 FreeBSD 9.2 and older define 'ucontext_t' incorrectly in
@@ -84,7 +85,7 @@ bool IsSystemHeapAddress (uptr addr) { return false; }
 
 void *AsanDoesNotSupportStaticLinkage() {
   // This will fail to link with -static.
-  return &_DYNAMIC;  // defined in link.h
+  return &_DYNAMIC;
 }
 
 #if ASAN_PREMAP_SHADOW

diff  --git a/compiler-rt/lib/memprof/memprof_linux.cpp b/compiler-rt/lib/memprof/memprof_linux.cpp
index 4846e988f58e..61c833bfdf64 100644
--- a/compiler-rt/lib/memprof/memprof_linux.cpp
+++ b/compiler-rt/lib/memprof/memprof_linux.cpp
@@ -39,6 +39,8 @@
 #include <unistd.h>
 #include <unwind.h>
 
+extern ElfW(Dyn) _DYNAMIC[];
+
 typedef enum {
   MEMPROF_RT_VERSION_UNDEFINED = 0,
   MEMPROF_RT_VERSION_DYNAMIC,
@@ -58,7 +60,7 @@ void InitializePlatformExceptionHandlers() {}
 
 void *MemprofDoesNotSupportStaticLinkage() {
   // This will fail to link with -static.
-  return &_DYNAMIC; // defined in link.h
+  return &_DYNAMIC;
 }
 
 uptr FindDynamicShadowStart() {

diff  --git a/compiler-rt/lib/memprof/memprof_mapping.h b/compiler-rt/lib/memprof/memprof_mapping.h
index f48018b1a8f2..ba05b88db307 100644
--- a/compiler-rt/lib/memprof/memprof_mapping.h
+++ b/compiler-rt/lib/memprof/memprof_mapping.h
@@ -37,7 +37,7 @@ extern uptr kHighMemEnd; // Initialized in __memprof_init.
 #define SHADOW_MASK ~(MEM_GRANULARITY - 1)
 
 #define MEM_TO_SHADOW(mem)                                                     \
-  (((mem & SHADOW_MASK) >> SHADOW_SCALE) + (SHADOW_OFFSET))
+  ((((mem) & SHADOW_MASK) >> SHADOW_SCALE) + (SHADOW_OFFSET))
 
 #define kLowMemBeg 0
 #define kLowMemEnd (SHADOW_OFFSET ? SHADOW_OFFSET - 1 : 0)


        


More information about the llvm-branch-commits mailing list