| Index: runtime/bin/file_linux.cc
|
| diff --git a/runtime/bin/file_linux.cc b/runtime/bin/file_linux.cc
|
| index 4f61db1d306b3415c629dea7a2f3f10b6564b015..e6b27f8ace515a8b1d2a4073c01be6e9005ada64 100644
|
| --- a/runtime/bin/file_linux.cc
|
| +++ b/runtime/bin/file_linux.cc
|
| @@ -77,16 +77,23 @@ bool File::IsClosed() {
|
| }
|
|
|
|
|
| -void* File::MapExecutable(intptr_t* len) {
|
| +void* File::Map(MapType type, int64_t position, int64_t length) {
|
| ASSERT(handle_->fd() >= 0);
|
| - intptr_t length = Length();
|
| - void* addr = mmap(0, length,
|
| - PROT_READ | PROT_EXEC, MAP_PRIVATE,
|
| - handle_->fd(), 0);
|
| + int prot = PROT_NONE;
|
| + switch (type) {
|
| + case kReadOnly:
|
| + prot = PROT_READ;
|
| + break;
|
| + case kReadExecute:
|
| + prot = PROT_READ | PROT_EXEC;
|
| + break;
|
| + default:
|
| + return NULL;
|
| + }
|
| + void* addr = mmap(NULL, length, prot, MAP_PRIVATE,
|
| + handle_->fd(), position);
|
| if (addr == MAP_FAILED) {
|
| - *len = -1;
|
| - } else {
|
| - *len = length;
|
| + return NULL;
|
| }
|
| return addr;
|
| }
|
|
|