Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(743)

Side by Side Diff: chrome/nacl/nacl_helper_bootstrap_linux.x

Issue 8800034: Use nacl_helper_bootstrap from native_client repository (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 * We need to use a standalone loader program rather than just using a
11 * dynamically-linked program here because its entire address space will be
12 * taken over for the NaCl untrusted address space. A normal program would
13 * cause dynamic linker data structures to point to its .dynamic section,
14 * which is no longer available after startup.
15 *
16 * We need this special layout (and the nacl_helper_bootstrap_munge_phdr
17 * step) because simply having bss space large enough to reserve the
18 * address space would cause the kernel loader to think we're using that
19 * much anonymous memory and refuse to execute the program on a machine
20 * with not much memory available.
21 */
22
23 /*
24 * Set the entry point to the symbol called _start, which we define in assembly.
25 */
26 ENTRY(_start)
27
28 /*
29 * This is the address where the program text starts.
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.
32 */
33 TEXT_START = 0x10000;
34
35 /*
36 * The symbol RESERVE_TOP is the top of the range we are trying to reserve.
37 * This is set via --defsym on the linker command line, because the correct
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.
40 */
41
42 /*
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
45 * that it gets mapped as PROT_NONE.
46 */
47 PHDRS {
48 text PT_LOAD FILEHDR PHDRS;
49 data PT_LOAD;
50 reserve PT_LOAD FLAGS(0);
51 r_debug PT_LOAD;
52 note PT_NOTE;
53 stack PT_GNU_STACK FLAGS(6); /* RW, no E */
54 }
55
56 /*
57 * Now we lay out the sections across those segments.
58 */
59 SECTIONS {
60 . = TEXT_START + SIZEOF_HEADERS;
61
62 /*
63 * The build ID note usually comes first.
64 * It's both part of the text PT_LOAD segment (like other rodata) and
65 * it's what the PT_NOTE header points to.
66 */
67 .note.gnu.build-id : {
68 *(.note.gnu.build-id)
69 } :text :note
70
71 /*
72 * Here is the program itself.
73 */
74 .text : {
75 *(.text*)
76 } :text
77 .rodata : {
78 *(.rodata*)
79 *(.eh_frame*)
80 }
81
82 etext = .;
83
84 /*
85 * Adjust the address for the data segment. We want to adjust up to
86 * the same address within the page on the next page up.
87 */
88 . = (ALIGN(CONSTANT(MAXPAGESIZE)) -
89 ((CONSTANT(MAXPAGESIZE) - .) & (CONSTANT(MAXPAGESIZE) - 1)));
90 . = DATA_SEGMENT_ALIGN(CONSTANT(MAXPAGESIZE), CONSTANT(COMMONPAGESIZE));
91
92 .data : {
93 *(.data*)
94 } :data
95 .bss : {
96 *(.bss*)
97 }
98
99 /*
100 * Now we move up to the next p_align increment, and place the dummy
101 * segment there. The linker emits this segment with the p_vaddr and
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
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.
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.
108 */
109 . = ALIGN(CONSTANT(COMMONPAGESIZE));
110 RESERVE_START = .;
111 .reserve : {
112 . += DEFINED(RESERVE_TOP) ? (RESERVE_TOP - RESERVE_START) : 0;
113 } :reserve
114
115 /*
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
118 * in the memory image so the debugger can make sense of things.
119 */
120 .r_debug : {
121 *(.r_debug)
122 } :r_debug
123
124 /*
125 * These are empty input sections the linker generates.
126 * If we don't discard them, they pollute the flags in the output segment.
127 */
128 /DISCARD/ : {
129 *(.iplt)
130 *(.rel*)
131 *(.igot.plt)
132 }
133 }
OLDNEW
« no previous file with comments | « chrome/nacl/nacl_helper_bootstrap_linux.c ('k') | chrome/nacl/nacl_helper_bootstrap_munge_phdr.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698