| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 * | 5 * |
| 6 * This is a standalone program that loads and runs the dynamic linker. | 6 * This is a standalone program that loads and runs the dynamic linker. |
| 7 * This program itself must be linked statically. To keep it small, it's | 7 * This program itself must be linked statically. To keep it small, it's |
| 8 * written to avoid all dependencies on libc and standard startup code. | 8 * written to avoid all dependencies on libc and standard startup code. |
| 9 * Hence, this should be linked using -nostartfiles. It must be compiled | 9 * Hence, this should be linked using -nostartfiles. It must be compiled |
| 10 * with -fno-stack-protector to ensure the compiler won't emit code that | 10 * with -fno-stack-protector to ensure the compiler won't emit code that |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 int fd, void *buf, size_t bufsz, uintptr_t pos) { | 171 int fd, void *buf, size_t bufsz, uintptr_t pos) { |
| 172 ssize_t result = sys_pread64(fd, buf, bufsz, pos); | 172 ssize_t result = sys_pread64(fd, buf, bufsz, pos); |
| 173 if (result < 0) | 173 if (result < 0) |
| 174 fail(file, fail_message, "errno", my_errno, NULL, 0); | 174 fail(file, fail_message, "errno", my_errno, NULL, 0); |
| 175 if ((size_t) result != bufsz) | 175 if ((size_t) result != bufsz) |
| 176 fail(file, fail_message, "read count", result, NULL, 0); | 176 fail(file, fail_message, "read count", result, NULL, 0); |
| 177 } | 177 } |
| 178 | 178 |
| 179 static uintptr_t my_mmap_simple(uintptr_t address, size_t size, | 179 static uintptr_t my_mmap_simple(uintptr_t address, size_t size, |
| 180 int prot, int flags, int fd, uintptr_t pos) { | 180 int prot, int flags, int fd, uintptr_t pos) { |
| 181 #if defined(__NR_mmap2) | |
| 182 void *result = sys_mmap2((void *) address, size, prot, flags, fd, pos >> 12); | |
| 183 #else | |
| 184 void *result = sys_mmap((void *) address, size, prot, flags, fd, pos); | 181 void *result = sys_mmap((void *) address, size, prot, flags, fd, pos); |
| 185 #endif | |
| 186 return (uintptr_t) result; | 182 return (uintptr_t) result; |
| 187 } | 183 } |
| 188 | 184 |
| 189 static uintptr_t my_mmap(const char *file, | 185 static uintptr_t my_mmap(const char *file, |
| 190 const char *segment_type, unsigned int segnum, | 186 const char *segment_type, unsigned int segnum, |
| 191 uintptr_t address, size_t size, | 187 uintptr_t address, size_t size, |
| 192 int prot, int flags, int fd, uintptr_t pos) { | 188 int prot, int flags, int fd, uintptr_t pos) { |
| 193 uintptr_t result = my_mmap_simple(address, size, prot, flags, fd, pos); | 189 uintptr_t result = my_mmap_simple(address, size, prot, flags, fd, pos); |
| 194 if ((void *) result == MAP_FAILED) | 190 if ((void *) result == MAP_FAILED) |
| 195 fail(file, "Failed to map segment! ", | 191 fail(file, "Failed to map segment! ", |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 | 717 |
| 722 #if defined(__arm__) | 718 #if defined(__arm__) |
| 723 /* | 719 /* |
| 724 * We may bring in __aeabi_* functions from libgcc that in turn | 720 * We may bring in __aeabi_* functions from libgcc that in turn |
| 725 * want to call raise. | 721 * want to call raise. |
| 726 */ | 722 */ |
| 727 int raise(int sig) { | 723 int raise(int sig) { |
| 728 return sys_kill(sys_getpid(), sig); | 724 return sys_kill(sys_getpid(), sig); |
| 729 } | 725 } |
| 730 #endif | 726 #endif |
| OLD | NEW |