Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: third_party/mach_override/mach_override.c

Issue 22798004: Randomize mach_override_ptr trampoline addresses on 32-bit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use VM_FLAGS_ANYWHERE rather than 1 Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/mach_override/README.chromium ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/mach_override/mach_override.c
diff --git a/third_party/mach_override/mach_override.c b/third_party/mach_override/mach_override.c
index ea41569518009e04c3c8f9056049438dc368d9af..21afa28bd5811533f94c41a95da9c869023dfdff 100644
--- a/third_party/mach_override/mach_override.c
+++ b/third_party/mach_override/mach_override.c
@@ -11,6 +11,7 @@
#include <mach/mach_host.h>
#include <mach/mach_init.h>
#include <mach/vm_map.h>
+#include <mach/vm_statistics.h>
#include <sys/mman.h>
#include <CoreServices/CoreServices.h>
@@ -379,15 +380,22 @@ allocateBranchIsland(
assert( island );
assert( sizeof( BranchIsland ) <= kPageSize );
+#if defined(__i386__)
+ vm_address_t page = 0;
+ mach_error_t err = vm_allocate( mach_task_self(), &page, kPageSize, VM_FLAGS_ANYWHERE );
+ if( err == err_none ) {
+ *island = (BranchIsland*) page;
+ return err_none;
+ }
+ return err;
+#else
+
#if defined(__ppc__) || defined(__POWERPC__)
vm_address_t first = 0xfeffffff;
vm_address_t last = 0xfe000000 + kPageSize;
#elif defined(__x86_64__)
vm_address_t first = ((uint64_t)originalFunctionAddress & ~(uint64_t)(((uint64_t)1 << 31) - 1)) | ((uint64_t)1 << 31); // start in the middle of the page?
vm_address_t last = 0x0;
-#else
- vm_address_t first = 0xffc00000;
- vm_address_t last = 0xfffe0000;
#endif
vm_address_t page = first;
@@ -410,6 +418,7 @@ allocateBranchIsland(
}
return KERN_NO_SPACE;
+#endif
}
/***************************************************************************//**
« no previous file with comments | « third_party/mach_override/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698