[compiler-rt] r318369 - [asan] Fallback to non-ifunc dynamic shadow on android<22.
Evgeniy Stepanov via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 15 18:52:19 PST 2017
Author: eugenis
Date: Wed Nov 15 18:52:19 2017
New Revision: 318369
URL: http://llvm.org/viewvc/llvm-project?rev=318369&view=rev
Log:
[asan] Fallback to non-ifunc dynamic shadow on android<22.
Summary: Android < 22 does not support ifunc.
Reviewers: pcc
Subscribers: srhines, kubamracek, hiraditya, llvm-commits
Differential Revision: https://reviews.llvm.org/D40116
Modified:
compiler-rt/trunk/lib/asan/asan_linux.cc
compiler-rt/trunk/lib/asan/asan_premap_shadow.cc
compiler-rt/trunk/lib/asan/asan_premap_shadow.h
Modified: compiler-rt/trunk/lib/asan/asan_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_linux.cc?rev=318369&r1=318368&r2=318369&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_linux.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_linux.cc Wed Nov 15 18:52:19 2017
@@ -83,7 +83,7 @@ void *AsanDoesNotSupportStaticLinkage()
}
#if ASAN_PREMAP_SHADOW
-uptr FindDynamicShadowStart() {
+uptr FindPremappedShadowStart() {
uptr granularity = GetMmapGranularity();
uptr shadow_start = reinterpret_cast<uptr>(&__asan_shadow);
uptr shadow_size = PremapShadowSize();
@@ -93,8 +93,14 @@ uptr FindDynamicShadowStart() {
IncreaseTotalMmap(shadow_size + granularity);
return shadow_start;
}
-#else
+#endif
+
uptr FindDynamicShadowStart() {
+#if ASAN_PREMAP_SHADOW
+ if (!PremapShadowFailed())
+ return FindPremappedShadowStart();
+#endif
+
uptr granularity = GetMmapGranularity();
uptr alignment = granularity * 8;
uptr left_padding = granularity;
@@ -112,7 +118,6 @@ uptr FindDynamicShadowStart() {
return shadow_start;
}
-#endif
void AsanApplyToGlobals(globals_op_fptr op, const void *needle) {
UNIMPLEMENTED();
Modified: compiler-rt/trunk/lib/asan/asan_premap_shadow.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_premap_shadow.cc?rev=318369&r1=318368&r2=318369&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_premap_shadow.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_premap_shadow.cc Wed Nov 15 18:52:19 2017
@@ -50,6 +50,15 @@ uptr PremapShadow() {
return shadow_start;
}
+bool PremapShadowFailed() {
+ uptr shadow = reinterpret_cast<uptr>(&__asan_shadow);
+ uptr resolver = reinterpret_cast<uptr>(&__asan_premap_shadow);
+ // shadow == resolver is how Android KitKat and older handles ifunc.
+ // shadow == 0 just in case.
+ if (shadow == 0 || shadow == resolver)
+ return true;
+ return false;
+}
} // namespace __asan
extern "C" {
Modified: compiler-rt/trunk/lib/asan/asan_premap_shadow.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_premap_shadow.h?rev=318369&r1=318368&r2=318369&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_premap_shadow.h (original)
+++ compiler-rt/trunk/lib/asan/asan_premap_shadow.h Wed Nov 15 18:52:19 2017
@@ -20,9 +20,11 @@
namespace __asan {
// Conservative upper limit.
uptr PremapShadowSize();
+bool PremapShadowFailed();
}
#endif
extern "C" INTERFACE_ATTRIBUTE void __asan_shadow();
+extern "C" decltype(__asan_shadow)* __asan_premap_shadow();
#endif // ASAN_PREMAP_SHADOW_H
More information about the llvm-commits
mailing list