xref: /freebsd/sys/conf/ldscript.amd64 (revision c4698dec73a4a95ae8649be552485e874758346c)
1/* $FreeBSD$ */
2OUTPUT_FORMAT("elf64-x86-64-freebsd", "elf64-x86-64-freebsd", "elf64-x86-64-freebsd")
3OUTPUT_ARCH(i386:x86-64)
4ENTRY(btext)
5SEARCH_DIR("/usr/lib");
6SECTIONS
7{
8  /* Read-only sections, merged into text segment: */
9  kernphys = 0x200000; /* 2MB superpage size */
10  . = kernbase + kernphys + SIZEOF_HEADERS;
11  /*
12   * Use the AT keyword in order to set the right LMA that contains
13   * the physical address where the section should be loaded. This is
14   * needed for the Xen loader which honours the LMA.
15   */
16  .interp         : AT (kernphys + SIZEOF_HEADERS) { *(.interp) }
17  .hash           : { *(.hash) }
18  .gnu.hash       : { *(.gnu.hash) }
19  .dynsym         : { *(.dynsym) }
20  .dynstr         : { *(.dynstr) }
21  .gnu.version    : { *(.gnu.version) }
22  .gnu.version_d  : { *(.gnu.version_d) }
23  .gnu.version_r  : { *(.gnu.version_r) }
24  .rel.init       : { *(.rel.init) }
25  .rela.init      : { *(.rela.init) }
26  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
27  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
28  .rel.fini       : { *(.rel.fini) }
29  .rela.fini      : { *(.rela.fini) }
30  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
31  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
32  .rel.data.rel.ro   : { *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) }
33  .rela.data.rel.ro   : { *(.rela.data.rel.ro* .rela.gnu.linkonce.d.rel.ro.*) }
34  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
35  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
36  .rel.tdata	  : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
37  .rela.tdata	  : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
38  .rel.tbss	  : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
39  .rela.tbss	  : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
40  .rel.ctors      : { *(.rel.ctors) }
41  .rela.ctors     : { *(.rela.ctors) }
42  .rel.dtors      : { *(.rel.dtors) }
43  .rela.dtors     : { *(.rela.dtors) }
44  .rel.got        : { *(.rel.got) }
45  .rela.got       : { *(.rela.got) }
46  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
47  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
48  .rel.ldata      : { *(.rel.ldata .rel.ldata.* .rel.gnu.linkonce.l.*) }
49  .rela.ldata     : { *(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*) }
50  .rel.lbss       : { *(.rel.lbss .rel.lbss.* .rel.gnu.linkonce.lb.*) }
51  .rela.lbss      : { *(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*) }
52  .rel.lrodata    : { *(.rel.lrodata .rel.lrodata.* .rel.gnu.linkonce.lr.*) }
53  .rela.lrodata   : { *(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*) }
54  .rel.plt        : { *(.rel.plt) }
55  .rela.plt       : { *(.rela.plt) }
56  .init           :
57  {
58    KEEP (*(.init))
59  } =0xCCCCCCCC
60  .plt            : { *(.plt) }
61  .text           :
62  {
63    *(.text .stub .text.* .gnu.linkonce.t.*)
64    KEEP (*(.text.*personality*))
65    /* .gnu.warning sections are handled specially by elf32.em.  */
66    *(.gnu.warning)
67  } =0xCCCCCCCC
68  .fini           :
69  {
70    KEEP (*(.fini))
71  } =0xCCCCCCCC
72  PROVIDE (__etext = .);
73  PROVIDE (_etext = .);
74  PROVIDE (etext = .);
75  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
76  .rodata1        : { *(.rodata1) }
77  .eh_frame_hdr : { *(.eh_frame_hdr) }
78  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
79  .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
80  /* Adjust the address for the data segment.  We want to adjust up to
81     the same address within the page on the next page up.  */
82  . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
83  PROVIDE (brwsection = .);
84  /* Exception handling  */
85  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
86  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
87  /* Thread Local Storage sections  */
88  .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
89  .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
90  .preinit_array     :
91  {
92    PROVIDE_HIDDEN (__preinit_array_start = .);
93    KEEP (*(.preinit_array))
94    PROVIDE_HIDDEN (__preinit_array_end = .);
95  }
96  .init_array     :
97  {
98     PROVIDE_HIDDEN (__init_array_start = .);
99     KEEP (*(SORT(.init_array.*)))
100     KEEP (*(.init_array))
101     PROVIDE_HIDDEN (__init_array_end = .);
102  }
103  .fini_array     :
104  {
105    PROVIDE_HIDDEN (__fini_array_start = .);
106    KEEP (*(.fini_array))
107    KEEP (*(SORT(.fini_array.*)))
108    PROVIDE_HIDDEN (__fini_array_end = .);
109  }
110  _start_ctors = .;
111  PROVIDE (start_ctors = .);
112  .ctors          :
113  {
114    /* gcc uses crtbegin.o to find the start of
115       the constructors, so we make sure it is
116       first.  Because this is a wildcard, it
117       doesn't matter if the user does not
118       actually link against crtbegin.o; the
119       linker won't look for a file to match a
120       wildcard.  The wildcard also means that it
121       doesn't matter which directory crtbegin.o
122       is in.  */
123    KEEP (*crtbegin.o(.ctors))
124    KEEP (*crtbegin?.o(.ctors))
125    /* We don't want to include the .ctor section from
126       the crtend.o file until after the sorted ctors.
127       The .ctor section from the crtend file contains the
128       end of ctors marker and it must be last */
129    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
130    KEEP (*(SORT(.ctors.*)))
131    KEEP (*(.ctors))
132  }
133  _stop_ctors = .;
134  PROVIDE (stop_ctors = .);
135  .dtors          :
136  {
137    KEEP (*crtbegin.o(.dtors))
138    KEEP (*crtbegin?.o(.dtors))
139    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
140    KEEP (*(SORT(.dtors.*)))
141    KEEP (*(.dtors))
142  }
143  .jcr            : { KEEP (*(.jcr)) }
144  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
145  .dynamic        : { *(.dynamic) }
146  .got            : { *(.got) }
147  . = DATA_SEGMENT_RELRO_END (24, .);
148  .got.plt        : { *(.got.plt) }
149  . = ALIGN(128);
150  .data.read_frequently :
151  {
152    *(SORT_BY_ALIGNMENT(.data.read_frequently))
153  }
154  .data.read_mostly :
155  {
156    *(.data.read_mostly)
157  }
158  . = ALIGN(128);
159  .data.exclusive_cache_line :
160  {
161    *(.data.exclusive_cache_line)
162  }
163  . = ALIGN(128);
164  .data           :
165  {
166    *(.data .data.* .gnu.linkonce.d.*)
167    KEEP (*(.gnu.linkonce.d.*personality*))
168  }
169  .data1          : { *(.data1) }
170  _edata = .; PROVIDE (edata = .);
171  __bss_start = .;
172  .bss            :
173  {
174   *(.dynbss)
175   *(.bss .bss.* .gnu.linkonce.b.*)
176   *(COMMON)
177   /* Align here to ensure that the .bss section occupies space up to
178      _end.  Align after .bss to ensure correct alignment even if the
179      .bss section disappears because there are no input sections.
180      FIXME: Why do we need it? When there is no .bss section, we don't
181      pad the .data section.  */
182   . = ALIGN(. != 0 ? 64 / 8 : 1);
183  }
184  .lbss   :
185  {
186    *(.dynlbss)
187    *(.lbss .lbss.* .gnu.linkonce.lb.*)
188    *(LARGE_COMMON)
189  }
190  . = ALIGN(64 / 8);
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  /* DWARF debug sections.
212     Symbols in the DWARF debugging sections are relative to the beginning
213     of the section so we begin them at 0.  */
214  /* DWARF 1 */
215  .debug          0 : { *(.debug) }
216  .line           0 : { *(.line) }
217  /* GNU DWARF 1 extensions */
218  .debug_srcinfo  0 : { *(.debug_srcinfo) }
219  .debug_sfnames  0 : { *(.debug_sfnames) }
220  /* DWARF 1.1 and DWARF 2 */
221  .debug_aranges  0 : { *(.debug_aranges) }
222  .debug_pubnames 0 : { *(.debug_pubnames) }
223  /* DWARF 2 */
224  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
225  .debug_abbrev   0 : { *(.debug_abbrev) }
226  .debug_line     0 : { *(.debug_line) }
227  .debug_frame    0 : { *(.debug_frame) }
228  .debug_str      0 : { *(.debug_str) }
229  .debug_loc      0 : { *(.debug_loc) }
230  .debug_macinfo  0 : { *(.debug_macinfo) }
231  /* SGI/MIPS DWARF 2 extensions */
232  .debug_weaknames 0 : { *(.debug_weaknames) }
233  .debug_funcnames 0 : { *(.debug_funcnames) }
234  .debug_typenames 0 : { *(.debug_typenames) }
235  .debug_varnames  0 : { *(.debug_varnames) }
236  /* DWARF 3 */
237  .debug_pubtypes 0 : { *(.debug_pubtypes) }
238  .debug_ranges   0 : { *(.debug_ranges) }
239  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
240  /DISCARD/ : { *(.note.GNU-stack) }
241}
242