OLD | NEW |
---|---|
(Empty) | |
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 | |
3 * found in the LICENSE file. | |
4 * | |
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 | |
7 * that is kept extremely minimal. If there are unexpected input sections | |
8 * not named here, the result will not be correct. | |
9 */ | |
10 | |
11 /* | |
12 * Set the entry point to the symbol called _start, which we define in assembly. | |
13 */ | |
14 ENTRY(_start) | |
15 | |
16 /* | |
17 * This is the address where the program text starts. | |
18 * We set this as low as we think we can get away with. | |
19 * The common settings for sysctl vm.mmap_min_addr range from 4k to 64k. | |
20 */ | |
21 TEXT_START = 0x10000; | |
22 | |
23 /* | |
24 * This is the top of the range we are trying to reserve, which is 1G | |
25 * for x86-32 and ARM. For an x86-64 zero-based sandbox, this really | |
26 * needs to be 36G. | |
27 */ | |
28 RESERVE_TOP = 1 << 30; | |
29 | |
30 /* | |
31 * We specify the program headers we want explicitly, to get the layout | |
32 * exactly right and to give the "reserve" segment p_flags of zero, so | |
33 * that it gets mapped as PROT_NONE. | |
34 */ | |
35 PHDRS { | |
36 text PT_LOAD FILEHDR PHDRS; | |
37 reserve PT_LOAD FLAGS(0); | |
38 stack PT_GNU_STACK FLAGS(6); /* RW, no E */ | |
39 } | |
40 | |
41 /* | |
42 * Now we lay out the sections across those segments. | |
43 */ | |
44 SECTIONS { | |
45 /* | |
46 * Here is the program itself. | |
47 */ | |
48 .text TEXT_START + SIZEOF_HEADERS : { | |
49 *(.note.gnu.build-id) | |
50 *(.text*) | |
51 *(.rodata*) | |
52 *(.eh_frame*) | |
53 } :text | |
54 etext = .; | |
55 | |
56 /* | |
57 * Now we move up to the next p_align increment, and place the dummy | |
58 * segment there. The linker emits this segment with the p_vaddr and | |
59 * p_memsz we want, which reserves the address space. But the linker | |
60 * gives it a p_filesz of zero. We have to edit the phdr after link | |
61 * time to give it a p_filesz matching its p_memsz. That way, the | |
62 * kernel doesn't think we are preallocating a huge amount of memory. | |
63 * It just maps it from the file, i.e. way off the end of the file, | |
64 * which is perfect for reserving the address space. | |
65 */ | |
66 . = ALIGN(CONSTANT(COMMONPAGESIZE)); | |
67 RESERVE_START = .; | |
68 .reserve : { | |
Mark Seaborn
2011/08/30 20:12:25
Nit: just use one space - ".reserve : {"
| |
69 . = RESERVE_TOP - RESERVE_START; | |
70 } :reserve | |
71 | |
72 /* | |
73 * These are empty input sections the linker generates. | |
74 * If we don't discard them, they pollute the flags in the output segment. | |
75 */ | |
76 /DISCARD/ : { | |
77 *(.iplt) | |
78 *(.rel*) | |
79 *(.igot.plt) | |
80 } | |
81 } | |
OLD | NEW |