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