| OLD | NEW |
| 1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 * | 4 * |
| 5 * This is a custom linker script used to build nacl_helper_bootstrap. | 5 * This is a custom linker script used to build nacl_helper_bootstrap. |
| 6 * It has a very special layout. This script will only work with input | 6 * It has a very special layout. This script will only work with input |
| 7 * that is kept extremely minimal. If there are unexpected input sections | 7 * that is kept extremely minimal. If there are unexpected input sections |
| 8 * not named here, the result will not be correct. | 8 * not named here, the result will not be correct. |
| 9 * | 9 * |
| 10 * We need to use a standalone loader program rather than just using a | 10 * We need to use a standalone loader program rather than just using a |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 ENTRY(_start) | 26 ENTRY(_start) |
| 27 | 27 |
| 28 /* | 28 /* |
| 29 * This is the address where the program text starts. | 29 * This is the address where the program text starts. |
| 30 * We set this as low as we think we can get away with. | 30 * We set this as low as we think we can get away with. |
| 31 * The common settings for sysctl vm.mmap_min_addr range from 4k to 64k. | 31 * The common settings for sysctl vm.mmap_min_addr range from 4k to 64k. |
| 32 */ | 32 */ |
| 33 TEXT_START = 0x10000; | 33 TEXT_START = 0x10000; |
| 34 | 34 |
| 35 /* | 35 /* |
| 36 * This is the top of the range we are trying to reserve, which is 1G | 36 * The symbol RESERVE_TOP is the top of the range we are trying to reserve. |
| 37 * for x86-32 and ARM. For an x86-64 zero-based sandbox, this really | 37 * This is set via --defsym on the linker command line, because the correct |
| 38 * needs to be 36G. | 38 * value differs for each machine. It's not defined at all if we do not |
| 39 * actually need any space reserved for this configuration. |
| 39 */ | 40 */ |
| 40 RESERVE_TOP = 1 << 30; | |
| 41 | 41 |
| 42 /* | 42 /* |
| 43 * We specify the program headers we want explicitly, to get the layout | 43 * We specify the program headers we want explicitly, to get the layout |
| 44 * exactly right and to give the "reserve" segment p_flags of zero, so | 44 * exactly right and to give the "reserve" segment p_flags of zero, so |
| 45 * that it gets mapped as PROT_NONE. | 45 * that it gets mapped as PROT_NONE. |
| 46 */ | 46 */ |
| 47 PHDRS { | 47 PHDRS { |
| 48 text PT_LOAD FILEHDR PHDRS; | 48 text PT_LOAD FILEHDR PHDRS; |
| 49 data PT_LOAD; | 49 data PT_LOAD; |
| 50 reserve PT_LOAD FLAGS(0); | 50 reserve PT_LOAD FLAGS(0); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 * p_memsz we want, which reserves the address space. But the linker | 102 * p_memsz we want, which reserves the address space. But the linker |
| 103 * gives it a p_filesz of zero. We have to edit the phdr after link | 103 * gives it a p_filesz of zero. We have to edit the phdr after link |
| 104 * time to give it a p_filesz matching its p_memsz. That way, the | 104 * time to give it a p_filesz matching its p_memsz. That way, the |
| 105 * kernel doesn't think we are preallocating a huge amount of memory. | 105 * kernel doesn't think we are preallocating a huge amount of memory. |
| 106 * It just maps it from the file, i.e. way off the end of the file, | 106 * It just maps it from the file, i.e. way off the end of the file, |
| 107 * which is perfect for reserving the address space. | 107 * which is perfect for reserving the address space. |
| 108 */ | 108 */ |
| 109 . = ALIGN(CONSTANT(COMMONPAGESIZE)); | 109 . = ALIGN(CONSTANT(COMMONPAGESIZE)); |
| 110 RESERVE_START = .; | 110 RESERVE_START = .; |
| 111 .reserve : { | 111 .reserve : { |
| 112 . = RESERVE_TOP - RESERVE_START; | 112 . += DEFINED(RESERVE_TOP) ? (RESERVE_TOP - RESERVE_START) : 0; |
| 113 } :reserve | 113 } :reserve |
| 114 | 114 |
| 115 /* | 115 /* |
| 116 * This must be placed above the reserved address space, so it won't | 116 * This must be placed above the reserved address space, so it won't |
| 117 * be clobbered by NaCl. We want this to be visible at its fixed address | 117 * be clobbered by NaCl. We want this to be visible at its fixed address |
| 118 * in the memory image so the debugger can make sense of things. | 118 * in the memory image so the debugger can make sense of things. |
| 119 */ | 119 */ |
| 120 .r_debug : { | 120 .r_debug : { |
| 121 *(.r_debug) | 121 *(.r_debug) |
| 122 } :r_debug | 122 } :r_debug |
| 123 | 123 |
| 124 /* | 124 /* |
| 125 * These are empty input sections the linker generates. | 125 * These are empty input sections the linker generates. |
| 126 * If we don't discard them, they pollute the flags in the output segment. | 126 * If we don't discard them, they pollute the flags in the output segment. |
| 127 */ | 127 */ |
| 128 /DISCARD/ : { | 128 /DISCARD/ : { |
| 129 *(.iplt) | 129 *(.iplt) |
| 130 *(.rel*) | 130 *(.rel*) |
| 131 *(.igot.plt) | 131 *(.igot.plt) |
| 132 } | 132 } |
| 133 } | 133 } |
| OLD | NEW |