| Index: runtime/bin/file_linux.cc
|
| diff --git a/runtime/bin/file_linux.cc b/runtime/bin/file_linux.cc
|
| index 2bf2c2edaa9847089d3deb45758c0522e41fe3a1..2e47d74978a486a0fd1a202b9f365526459ac946 100644
|
| --- a/runtime/bin/file_linux.cc
|
| +++ b/runtime/bin/file_linux.cc
|
| @@ -10,6 +10,7 @@
|
| #include <errno.h> // NOLINT
|
| #include <fcntl.h> // NOLINT
|
| #include <libgen.h> // NOLINT
|
| +#include <sys/mman.h> // NOLINT
|
| #include <sys/sendfile.h> // NOLINT
|
| #include <sys/stat.h> // NOLINT
|
| #include <sys/types.h> // NOLINT
|
| @@ -75,6 +76,21 @@ bool File::IsClosed() {
|
| }
|
|
|
|
|
| +void* File::MapExecutable(intptr_t* len) {
|
| + ASSERT(handle_->fd() >= 0);
|
| + intptr_t length = Length();
|
| + void* addr = mmap(0, length,
|
| + PROT_READ | PROT_EXEC, MAP_PRIVATE,
|
| + handle_->fd(), 0);
|
| + if (addr == MAP_FAILED) {
|
| + *len = -1;
|
| + } else {
|
| + *len = length;
|
| + }
|
| + return addr;
|
| +}
|
| +
|
| +
|
| int64_t File::Read(void* buffer, int64_t num_bytes) {
|
| ASSERT(handle_->fd() >= 0);
|
| return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes));
|
|
|