Debian Codegraph @

tests/inputs/linker.ld

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