diff options
| author | Zachary Turner <zturner@google.com> | 2017-02-22 21:24:06 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2017-02-22 21:24:06 +0000 |
| commit | 842972b7407b6c94660cce9ded1dca65a4479d12 (patch) | |
| tree | 03705002001d2a7f35c9e61a0ad95dfad80614f4 /llvm/lib | |
| parent | 65971d97b0d5182d36cfec472535dabe841ac3b7 (diff) | |
| download | bcm5719-llvm-842972b7407b6c94660cce9ded1dca65a4479d12.tar.gz bcm5719-llvm-842972b7407b6c94660cce9ded1dca65a4479d12.zip | |
[Support] Re-add the special OSX flags on mmap.
The problem appears to be that these flags can only be used
when mapping a file for read-only, not for readwrite. So
we do that here.
llvm-svn: 295880
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Support/Unix/Path.inc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc index 56fa01ab512..629a04b6c5b 100644 --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -551,6 +551,25 @@ std::error_code mapped_file_region::init(int FD, uint64_t Offset, int flags = (Mode == readwrite) ? MAP_SHARED : MAP_PRIVATE; int prot = (Mode == readonly) ? PROT_READ : (PROT_READ | PROT_WRITE); +#if defined(__APPLE__) + //---------------------------------------------------------------------- + // Newer versions of MacOSX have a flag that will allow us to read from + // binaries whose code signature is invalid without crashing by using + // the MAP_RESILIENT_CODESIGN flag. Also if a file from removable media + // is mapped we can avoid crashing and return zeroes to any pages we try + // to read if the media becomes unavailable by using the + // MAP_RESILIENT_MEDIA flag. These flags are only usable when mapping + // with PROT_READ, so take care not to specify them otherwise. + //---------------------------------------------------------------------- + if (Mode == readonly) { +#if defined(MAP_RESILIENT_CODESIGN) + flags |= MAP_RESILIENT_CODESIGN; +#endif +#if defined(MAP_RESILIENT_MEDIA) + flags |= MAP_RESILIENT_MEDIA; +#endif + } +#endif // #if defined (__APPLE__) Mapping = ::mmap(nullptr, Size, prot, flags, FD, Offset); if (Mapping == MAP_FAILED) |

