summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/interception/interception_win.cc
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-11-15 18:29:17 +0000
committerReid Kleckner <rnk@google.com>2016-11-15 18:29:17 +0000
commit0d7c42c7abb3a822ce5b3c5960923dee07cc496f (patch)
treee0bf3ef2df0e321cf65e8b3d7c905f4bdcef3026 /compiler-rt/lib/interception/interception_win.cc
parentb17efcbcc560859636c8e28c0388f750a73f1918 (diff)
downloadbcm5719-llvm-0d7c42c7abb3a822ce5b3c5960923dee07cc496f.tar.gz
bcm5719-llvm-0d7c42c7abb3a822ce5b3c5960923dee07cc496f.zip
[asan] Don't assert that a target is within 2GB on 32-bit Windows
Summary: In a 32-bit address space, PC-relative jump targets are wrapped, so a direct branch at 0x90000001 can reach address 0x10000000 with a displacement of 0x7FFFFFFFF. This can happen in applications, such as Chrome, that are linked with /LARGEADDRESSAWARE. Reviewers: etienneb Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D26650 llvm-svn: 286997
Diffstat (limited to 'compiler-rt/lib/interception/interception_win.cc')
-rw-r--r--compiler-rt/lib/interception/interception_win.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler-rt/lib/interception/interception_win.cc b/compiler-rt/lib/interception/interception_win.cc
index 8ffc5ae8f83..91abecf6de5 100644
--- a/compiler-rt/lib/interception/interception_win.cc
+++ b/compiler-rt/lib/interception/interception_win.cc
@@ -148,10 +148,16 @@ static void InterceptionFailed() {
}
static bool DistanceIsWithin2Gig(uptr from, uptr target) {
+#if SANITIZER_WINDOWS64
if (from < target)
return target - from <= (uptr)0x7FFFFFFFU;
else
return from - target <= (uptr)0x80000000U;
+#else
+ // In a 32-bit address space, the address calculation will wrap, so this check
+ // is unnecessary.
+ return true;
+#endif
}
static uptr GetMmapGranularity() {
OpenPOWER on IntegriCloud