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