1 /* Default linker script, for normal executables */
2 OUTPUT_FORMAT("elf32-nacl", "elf32-nacl",
4 /* OUTPUT_FORMAT("elf32-i386", "elf32-i386", */
8 /* SEARCH_DIR("/usr/i486-linux-gnu/lib32"); SEARCH_DIR("/usr/local/lib32"); SEARCH_DIR("/lib32"); SEARCH_DIR("/usr/lib32"); SEARCH_DIR("/usr/i486-linux-gnu/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib"); */
11 headers PT_PHDR FILEHDR PHDRS ; /* put the headers in a non-loadable seg */
12 segtext PT_LOAD FLAGS(5) ; /* read + execute */
13 segrodata PT_LOAD FLAGS(4) ; /* read */
14 segdata PT_LOAD FLAGS(6) ; /* read + write */
15 /* TODO: do we need a stack? */
19 /* Read-only sections, merged into text segment: */
20 PROVIDE (__executable_start = 0x10000); . = 0x10000;
21 .interp : { *(.interp) }
22 .note.gnu.build-id : { *(.note.gnu.build-id) }
24 .gnu.hash : { *(.gnu.hash) }
25 .dynsym : { *(.dynsym) }
26 .dynstr : { *(.dynstr) }
27 .gnu.version : { *(.gnu.version) }
28 .gnu.version_d : { *(.gnu.version_d) }
29 .gnu.version_r : { *(.gnu.version_r) }
30 .rel.init : { *(.rel.init) }
31 .rela.init : { *(.rela.init) }
32 .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
33 .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
34 .rel.fini : { *(.rel.fini) }
35 .rela.fini : { *(.rela.fini) }
36 .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
37 .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
38 .rel.data.rel.ro : { *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) }
39 .rela.data.rel.ro : { *(.rela.data.rel.ro* .rela.gnu.linkonce.d.rel.ro.*) }
40 .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
41 .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
42 .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
43 .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
44 .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
45 .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
46 .rel.ctors : { *(.rel.ctors) }
47 .rela.ctors : { *(.rela.ctors) }
48 .rel.dtors : { *(.rel.dtors) }
49 .rela.dtors : { *(.rela.dtors) }
50 .rel.got : { *(.rel.got) }
51 .rela.got : { *(.rela.got) }
52 .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
53 .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
54 .rel.plt : { *(.rel.plt) }
55 .rela.plt : { *(.rela.plt) }
57 /* I couldn't get ld to add NOP-padding between output sections
58 (only between input sections within an output section),
59 so I have simply combined .init and .text */
63 *(.text .stub .text.* .gnu.linkonce.t.*)
64 KEEP (*(.text.*personality*))
65 /* .gnu.warning sections are handled specially by elf32.em. */
67 } :segtext =0x90909090
71 KEEP (*(__libc_freeres_fn))
73 PROVIDE (__etext = .);
76 . = ALIGN(CONSTANT (MAXPAGESIZE)); /* nacl wants page alignment */
77 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } :segrodata
78 .rodata1 : { *(.rodata1) }
79 .eh_frame_hdr : { *(.eh_frame_hdr) }
80 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
81 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
82 /* Adjust the address for the data segment. We want to adjust up to
83 the same address within the page on the next page up. */
84 . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
85 /* Exception handling */
86 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
87 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
88 /* Thread Local Storage sections */
90 PROVIDE (__tls_template_start = .);
91 *(.tdata .tdata.* .gnu.linkonce.td.*)
92 PROVIDE (__tls_template_tdata_end = .);
94 .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
95 PROVIDE (__tls_template_end = .);
98 PROVIDE_HIDDEN (__preinit_array_start = .);
99 KEEP (*(.preinit_array))
100 PROVIDE_HIDDEN (__preinit_array_end = .);
104 PROVIDE_HIDDEN (__init_array_start = .);
105 KEEP (*(SORT(.init_array.*)))
106 KEEP (*(.init_array))
107 PROVIDE_HIDDEN (__init_array_end = .);
111 PROVIDE_HIDDEN (__fini_array_start = .);
112 KEEP (*(.fini_array))
113 KEEP (*(SORT(.fini_array.*)))
114 PROVIDE_HIDDEN (__fini_array_end = .);
118 /* gcc uses crtbegin.o to find the start of
119 the constructors, so we make sure it is
120 first. Because this is a wildcard, it
121 doesn't matter if the user does not
122 actually link against crtbegin.o; the
123 linker won't look for a file to match a
124 wildcard. The wildcard also means that it
125 doesn't matter which directory crtbegin.o
127 KEEP (*crtbegin.o(.ctors))
128 KEEP (*crtbegin?.o(.ctors))
129 /* We don't want to include the .ctor section from
130 the crtend.o file until after the sorted ctors.
131 The .ctor section from the crtend file contains the
132 end of ctors marker and it must be last */
133 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
134 KEEP (*(SORT(.ctors.*)))
139 KEEP (*crtbegin.o(.dtors))
140 KEEP (*crtbegin?.o(.dtors))
141 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
142 KEEP (*(SORT(.dtors.*)))
145 .jcr : { KEEP (*(.jcr)) }
146 .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
147 .dynamic : { *(.dynamic) }
149 . = DATA_SEGMENT_RELRO_END (12, .);
150 .got.plt : { *(.got.plt) }
151 . = ALIGN(CONSTANT (MAXPAGESIZE)); /* nacl wants page alignment */
154 *(.data .data.* .gnu.linkonce.d.*)
155 KEEP (*(.gnu.linkonce.d.*personality*))
158 .data1 : { *(.data1) }
159 _edata = .; PROVIDE (edata = .);
164 *(.bss .bss.* .gnu.linkonce.b.*)
166 /* Align here to ensure that the .bss section occupies space up to
167 _end. Align after .bss to ensure correct alignment even if the
168 .bss section disappears because there are no input sections.
169 FIXME: Why do we need it? When there is no .bss section, we don't
170 pad the .data section. */
171 . = ALIGN(. != 0 ? 32 / 8 : 1);
175 _end = .; PROVIDE (end = .);
176 . = DATA_SEGMENT_END (.);
177 /* Stabs debugging sections. */
178 .stab 0 : { *(.stab) }
179 .stabstr 0 : { *(.stabstr) }
180 .stab.excl 0 : { *(.stab.excl) }
181 .stab.exclstr 0 : { *(.stab.exclstr) }
182 .stab.index 0 : { *(.stab.index) }
183 .stab.indexstr 0 : { *(.stab.indexstr) }
184 .comment 0 : { *(.comment) }
185 /* DWARF debug sections.
186 Symbols in the DWARF debugging sections are relative to the beginning
187 of the section so we begin them at 0. */
189 .debug 0 : { *(.debug) }
190 .line 0 : { *(.line) }
191 /* GNU DWARF 1 extensions */
192 .debug_srcinfo 0 : { *(.debug_srcinfo) }
193 .debug_sfnames 0 : { *(.debug_sfnames) }
194 /* DWARF 1.1 and DWARF 2 */
195 .debug_aranges 0 : { *(.debug_aranges) }
196 .debug_pubnames 0 : { *(.debug_pubnames) }
198 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
199 .debug_abbrev 0 : { *(.debug_abbrev) }
200 .debug_line 0 : { *(.debug_line) }
201 .debug_frame 0 : { *(.debug_frame) }
202 .debug_str 0 : { *(.debug_str) }
203 .debug_loc 0 : { *(.debug_loc) }
204 .debug_macinfo 0 : { *(.debug_macinfo) }
205 /* SGI/MIPS DWARF 2 extensions */
206 .debug_weaknames 0 : { *(.debug_weaknames) }
207 .debug_funcnames 0 : { *(.debug_funcnames) }
208 .debug_typenames 0 : { *(.debug_typenames) }
209 .debug_varnames 0 : { *(.debug_varnames) }
211 .debug_pubtypes 0 : { *(.debug_pubtypes) }
212 .debug_ranges 0 : { *(.debug_ranges) }
213 .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
214 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }
215 /DISCARD/ : { *(.note.ABI-tag) }