xref: /freebsd/sys/conf/ldscript.amd64 (revision a0ee8cc636cd5c2374ec44ca71226564ea0bca95)
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 = CONSTANT (MAXPAGESIZE);
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  } =0x90909090
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  } =0x90909090
68  .fini           :
69  {
70    KEEP (*(.fini))
71  } =0x90909090
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  /* Exception handling  */
84  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
85  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
86  /* Thread Local Storage sections  */
87  .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
88  .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
89  .preinit_array     :
90  {
91    PROVIDE_HIDDEN (__preinit_array_start = .);
92    KEEP (*(.preinit_array))
93    PROVIDE_HIDDEN (__preinit_array_end = .);
94  }
95  .init_array     :
96  {
97     PROVIDE_HIDDEN (__init_array_start = .);
98     KEEP (*(SORT(.init_array.*)))
99     KEEP (*(.init_array))
100     PROVIDE_HIDDEN (__init_array_end = .);
101  }
102  .fini_array     :
103  {
104    PROVIDE_HIDDEN (__fini_array_start = .);
105    KEEP (*(.fini_array))
106    KEEP (*(SORT(.fini_array.*)))
107    PROVIDE_HIDDEN (__fini_array_end = .);
108  }
109  _start_ctors = .;
110  PROVIDE (start_ctors = .);
111  .ctors          :
112  {
113    /* gcc uses crtbegin.o to find the start of
114       the constructors, so we make sure it is
115       first.  Because this is a wildcard, it
116       doesn't matter if the user does not
117       actually link against crtbegin.o; the
118       linker won't look for a file to match a
119       wildcard.  The wildcard also means that it
120       doesn't matter which directory crtbegin.o
121       is in.  */
122    KEEP (*crtbegin.o(.ctors))
123    KEEP (*crtbegin?.o(.ctors))
124    /* We don't want to include the .ctor section from
125       the crtend.o file until after the sorted ctors.
126       The .ctor section from the crtend file contains the
127       end of ctors marker and it must be last */
128    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
129    KEEP (*(SORT(.ctors.*)))
130    KEEP (*(.ctors))
131  }
132  _stop_ctors = .;
133  PROVIDE (stop_ctors = .);
134  .dtors          :
135  {
136    KEEP (*crtbegin.o(.dtors))
137    KEEP (*crtbegin?.o(.dtors))
138    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
139    KEEP (*(SORT(.dtors.*)))
140    KEEP (*(.dtors))
141  }
142  .jcr            : { KEEP (*(.jcr)) }
143  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
144  .dynamic        : { *(.dynamic) }
145  .got            : { *(.got) }
146  . = DATA_SEGMENT_RELRO_END (24, .);
147  .got.plt        : { *(.got.plt) }
148  .data           :
149  {
150    *(.data .data.* .gnu.linkonce.d.*)
151    KEEP (*(.gnu.linkonce.d.*personality*))
152    SORT(CONSTRUCTORS)
153  }
154  .data1          : { *(.data1) }
155  _edata = .; PROVIDE (edata = .);
156  __bss_start = .;
157  .bss            :
158  {
159   *(.dynbss)
160   *(.bss .bss.* .gnu.linkonce.b.*)
161   *(COMMON)
162   /* Align here to ensure that the .bss section occupies space up to
163      _end.  Align after .bss to ensure correct alignment even if the
164      .bss section disappears because there are no input sections.
165      FIXME: Why do we need it? When there is no .bss section, we don't
166      pad the .data section.  */
167   . = ALIGN(. != 0 ? 64 / 8 : 1);
168  }
169  .lbss   :
170  {
171    *(.dynlbss)
172    *(.lbss .lbss.* .gnu.linkonce.lb.*)
173    *(LARGE_COMMON)
174  }
175  . = ALIGN(64 / 8);
176  .lrodata   ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
177  {
178    *(.lrodata .lrodata.* .gnu.linkonce.lr.*)
179  }
180  .ldata   ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
181  {
182    *(.ldata .ldata.* .gnu.linkonce.l.*)
183    . = ALIGN(. != 0 ? 64 / 8 : 1);
184  }
185  . = ALIGN(64 / 8);
186  _end = .; PROVIDE (end = .);
187  . = DATA_SEGMENT_END (.);
188  /* Stabs debugging sections.  */
189  .stab          0 : { *(.stab) }
190  .stabstr       0 : { *(.stabstr) }
191  .stab.excl     0 : { *(.stab.excl) }
192  .stab.exclstr  0 : { *(.stab.exclstr) }
193  .stab.index    0 : { *(.stab.index) }
194  .stab.indexstr 0 : { *(.stab.indexstr) }
195  .comment       0 : { *(.comment) }
196  /* DWARF debug sections.
197     Symbols in the DWARF debugging sections are relative to the beginning
198     of the section so we begin them at 0.  */
199  /* DWARF 1 */
200  .debug          0 : { *(.debug) }
201  .line           0 : { *(.line) }
202  /* GNU DWARF 1 extensions */
203  .debug_srcinfo  0 : { *(.debug_srcinfo) }
204  .debug_sfnames  0 : { *(.debug_sfnames) }
205  /* DWARF 1.1 and DWARF 2 */
206  .debug_aranges  0 : { *(.debug_aranges) }
207  .debug_pubnames 0 : { *(.debug_pubnames) }
208  /* DWARF 2 */
209  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
210  .debug_abbrev   0 : { *(.debug_abbrev) }
211  .debug_line     0 : { *(.debug_line) }
212  .debug_frame    0 : { *(.debug_frame) }
213  .debug_str      0 : { *(.debug_str) }
214  .debug_loc      0 : { *(.debug_loc) }
215  .debug_macinfo  0 : { *(.debug_macinfo) }
216  /* SGI/MIPS DWARF 2 extensions */
217  .debug_weaknames 0 : { *(.debug_weaknames) }
218  .debug_funcnames 0 : { *(.debug_funcnames) }
219  .debug_typenames 0 : { *(.debug_typenames) }
220  .debug_varnames  0 : { *(.debug_varnames) }
221  /* DWARF 3 */
222  .debug_pubtypes 0 : { *(.debug_pubtypes) }
223  .debug_ranges   0 : { *(.debug_ranges) }
224  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
225  /DISCARD/ : { *(.note.GNU-stack) }
226}
227