blob: 1b7cfd5252a651069330c45e1df5010d398a03a5 [file] [log] [blame]
Ben Murdoch097c5b22016-05-18 11:27:45 +01001/* Script for -z combreloc: combine and sort reloc sections */
2OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
3 "elf64-x86-64")
4OUTPUT_ARCH(i386:x86-64)
5ENTRY(_start)
6SEARCH_DIR("/build/output/x86_64-unknown-linux-gnu/lib64"); SEARCH_DIR("/build/output/lib64"); SEARCH_DIR("/usr/local/lib64"); SEARCH_DIR("/lib64"); SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/build/output/x86_64-unknown-linux-gnu/lib"); SEARCH_DIR("/build/output/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
7SECTIONS
8{
9 /* Read-only sections, merged into text segment: */
10 PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x400000)); . = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS;
11 .interp : { *(.interp) }
12 .note.gnu.build-id : { *(.note.gnu.build-id) }
13 .hash : { *(.hash) }
14 .gnu.hash : { *(.gnu.hash) }
15 .dynsym : { *(.dynsym) }
16 .dynstr : { *(.dynstr) }
17 .gnu.version : { *(.gnu.version) }
18 .gnu.version_d : { *(.gnu.version_d) }
19 .gnu.version_r : { *(.gnu.version_r) }
20 .rela.dyn :
21 {
22 *(.rela.init)
23 *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
24 *(.rela.fini)
25 *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
26 *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
27 *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
28 *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
29 *(.rela.ctors)
30 *(.rela.dtors)
31 *(.rela.got)
32 *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
33 *(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*)
34 *(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*)
35 *(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*)
36 *(.rela.ifunc)
37 }
38 .rela.plt :
39 {
40 *(.rela.plt)
41 PROVIDE_HIDDEN (__rela_iplt_start = .);
42 *(.rela.iplt)
43 PROVIDE_HIDDEN (__rela_iplt_end = .);
44 }
45 .init :
46 {
47 KEEP (*(SORT_NONE(.init)))
48 }
49 .plt : { *(.plt) *(.iplt) }
50 .text :
51 {
52 *(.text.unlikely .text.*_unlikely .text.unlikely.*)
53 *(.text.exit .text.exit.*)
54 *(.text.startup .text.startup.*)
55 *(.text.hot .text.hot.*)
56 *(.text .stub .text.* .gnu.linkonce.t.*)
57 /* .gnu.warning sections are handled specially by elf32.em. */
58 *(.gnu.warning)
59 }
60 .fini :
61 {
62 KEEP (*(SORT_NONE(.fini)))
63 }
64 PROVIDE (__etext = .);
65 PROVIDE (_etext = .);
66 PROVIDE (etext = .);
67 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
68 .rodata1 : { *(.rodata1) }
69 .eh_frame_hdr : { *(.eh_frame_hdr) }
70 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
71 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table
72 .gcc_except_table.*) }
73 /* These sections are generated by the Sun/Oracle C++ compiler. */
74 .exception_ranges : ONLY_IF_RO { *(.exception_ranges
75 .exception_ranges*) }
76 /* Adjust the address for the data segment. We want to adjust up to
77 the same address within the page on the next page up. */
78 . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
79 /* Exception handling */
80 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
81 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
82 .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
83 /* Thread Local Storage sections */
84 .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
85 .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
86 .preinit_array :
87 {
88 PROVIDE_HIDDEN (__preinit_array_start = .);
89 KEEP (*(.preinit_array))
90 PROVIDE_HIDDEN (__preinit_array_end = .);
91 }
92 .init_array :
93 {
94 PROVIDE_HIDDEN (__init_array_start = .);
95 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
96 KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
97 PROVIDE_HIDDEN (__init_array_end = .);
98 }
99 .fini_array :
100 {
101 PROVIDE_HIDDEN (__fini_array_start = .);
102 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
103 KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
104 PROVIDE_HIDDEN (__fini_array_end = .);
105 }
106 .ctors :
107 {
108 /* gcc uses crtbegin.o to find the start of
109 the constructors, so we make sure it is
110 first. Because this is a wildcard, it
111 doesn't matter if the user does not
112 actually link against crtbegin.o; the
113 linker won't look for a file to match a
114 wildcard. The wildcard also means that it
115 doesn't matter which directory crtbegin.o
116 is in. */
117 KEEP (*crtbegin.o(.ctors))
118 KEEP (*crtbegin?.o(.ctors))
119 /* We don't want to include the .ctor section from
120 the crtend.o file until after the sorted ctors.
121 The .ctor section from the crtend file contains the
122 end of ctors marker and it must be last */
123 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
124 KEEP (*(SORT(.ctors.*)))
125 KEEP (*(.ctors))
126 }
127 .dtors :
128 {
129 KEEP (*crtbegin.o(.dtors))
130 KEEP (*crtbegin?.o(.dtors))
131 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
132 KEEP (*(SORT(.dtors.*)))
133 KEEP (*(.dtors))
134 }
135 .jcr : { KEEP (*(.jcr)) }
136 .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
137 .dynamic : { *(.dynamic) }
138 .got : { *(.got) *(.igot) }
139 . = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 24 ? 24 : 0, .);
140 .got.plt : { *(.got.plt) *(.igot.plt) }
141 .data :
142 {
143 *(.data .data.* .gnu.linkonce.d.*)
144 SORT(CONSTRUCTORS)
145 }
146 .data1 : { *(.data1) }
147 _edata = .; PROVIDE (edata = .);
148 . = .;
149 __bss_start = .;
150 .bss :
151 {
152 *(.dynbss)
153 *(.bss .bss.* .gnu.linkonce.b.*)
154 *(COMMON)
155 /* Align here to ensure that the .bss section occupies space up to
156 _end. Align after .bss to ensure correct alignment even if the
157 .bss section disappears because there are no input sections.
158 FIXME: Why do we need it? When there is no .bss section, we don't
159 pad the .data section. */
160 . = ALIGN(. != 0 ? 64 / 8 : 1);
161 }
162 .lbss :
163 {
164 *(.dynlbss)
165 *(.lbss .lbss.* .gnu.linkonce.lb.*)
166 *(LARGE_COMMON)
167 }
168 . = ALIGN(64 / 8);
169 . = SEGMENT_START("ldata-segment", .);
170 .lrodata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
171 {
172 *(.lrodata .lrodata.* .gnu.linkonce.lr.*)
173 }
174 .ldata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
175 {
176 *(.ldata .ldata.* .gnu.linkonce.l.*)
177 . = ALIGN(. != 0 ? 64 / 8 : 1);
178 }
179 . = ALIGN(64 / 8);
180 _end = .; PROVIDE (end = .);
181 . = DATA_SEGMENT_END (.);
182 /* Stabs debugging sections. */
183 .stab 0 : { *(.stab) }
184 .stabstr 0 : { *(.stabstr) }
185 .stab.excl 0 : { *(.stab.excl) }
186 .stab.exclstr 0 : { *(.stab.exclstr) }
187 .stab.index 0 : { *(.stab.index) }
188 .stab.indexstr 0 : { *(.stab.indexstr) }
189 .comment 0 : { *(.comment) }
190 /* DWARF debug sections.
191 Symbols in the DWARF debugging sections are relative to the beginning
192 of the section so we begin them at 0. */
193 /* DWARF 1 */
194 .debug 0 : { *(.debug) }
195 .line 0 : { *(.line) }
196 /* GNU DWARF 1 extensions */
197 .debug_srcinfo 0 : { *(.debug_srcinfo) }
198 .debug_sfnames 0 : { *(.debug_sfnames) }
199 /* DWARF 1.1 and DWARF 2 */
200 .debug_aranges 0 : { *(.debug_aranges) }
201 .debug_pubnames 0 : { *(.debug_pubnames) }
202 /* DWARF 2 */
203 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
204 .debug_abbrev 0 : { *(.debug_abbrev) }
205 .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
206 .debug_frame 0 : { *(.debug_frame) }
207 .debug_str 0 : { *(.debug_str) }
208 .debug_loc 0 : { *(.debug_loc) }
209 .debug_macinfo 0 : { *(.debug_macinfo) }
210 /* SGI/MIPS DWARF 2 extensions */
211 .debug_weaknames 0 : { *(.debug_weaknames) }
212 .debug_funcnames 0 : { *(.debug_funcnames) }
213 .debug_typenames 0 : { *(.debug_typenames) }
214 .debug_varnames 0 : { *(.debug_varnames) }
215 /* DWARF 3 */
216 .debug_pubtypes 0 : { *(.debug_pubtypes) }
217 .debug_ranges 0 : { *(.debug_ranges) }
218 /* DWARF Extension. */
219 .debug_macro 0 : { *(.debug_macro) }
220 .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
221 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
222}