xref: /freebsd/sys/conf/ldscript.amd64 (revision 74cd06b42ea6f7b46f4782c511757bdfc038d6e8)
1d0e12656SPeter Wemm/* $FreeBSD$ */
2491fb274SDimitry AndricOUTPUT_FORMAT("elf64-x86-64-freebsd", "elf64-x86-64-freebsd", "elf64-x86-64-freebsd")
3b05deb9bSPeter WemmOUTPUT_ARCH(i386:x86-64)
46b7a14ceSPeter WemmENTRY(btext)
5b05deb9bSPeter WemmSEARCH_DIR("/usr/lib");
66b7a14ceSPeter WemmSECTIONS
76b7a14ceSPeter Wemm{
86b7a14ceSPeter Wemm  /* Read-only sections, merged into text segment: */
9c4698decSEd Maste  kernphys = 0x200000; /* 2MB superpage size */
101c675a3bSAlan Cox  . = kernbase + kernphys + SIZEOF_HEADERS;
117e748038SRoger Pau Monné  /*
127e748038SRoger Pau Monné   * Use the AT keyword in order to set the right LMA that contains
137e748038SRoger Pau Monné   * the physical address where the section should be loaded. This is
147e748038SRoger Pau Monné   * needed for the Xen loader which honours the LMA.
157e748038SRoger Pau Monné   */
167e748038SRoger Pau Monné  .interp         : AT (kernphys + SIZEOF_HEADERS) { *(.interp) }
176b7a14ceSPeter Wemm  .hash           : { *(.hash) }
188ba66bb8SDimitry Andric  .gnu.hash       : { *(.gnu.hash) }
196b7a14ceSPeter Wemm  .dynsym         : { *(.dynsym) }
206b7a14ceSPeter Wemm  .dynstr         : { *(.dynstr) }
216b7a14ceSPeter Wemm  .gnu.version    : { *(.gnu.version) }
226b7a14ceSPeter Wemm  .gnu.version_d  : { *(.gnu.version_d) }
236b7a14ceSPeter Wemm  .gnu.version_r  : { *(.gnu.version_r) }
24b05deb9bSPeter Wemm  .rel.init       : { *(.rel.init) }
25b05deb9bSPeter Wemm  .rela.init      : { *(.rela.init) }
26b05deb9bSPeter Wemm  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
27b05deb9bSPeter Wemm  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
28b05deb9bSPeter Wemm  .rel.fini       : { *(.rel.fini) }
29b05deb9bSPeter Wemm  .rela.fini      : { *(.rela.fini) }
30b05deb9bSPeter Wemm  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
31b05deb9bSPeter Wemm  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
328ba66bb8SDimitry Andric  .rel.data.rel.ro   : { *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) }
338ba66bb8SDimitry Andric  .rela.data.rel.ro   : { *(.rela.data.rel.ro* .rela.gnu.linkonce.d.rel.ro.*) }
34b05deb9bSPeter Wemm  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
35b05deb9bSPeter Wemm  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
36b05deb9bSPeter Wemm  .rel.tdata	  : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
37b05deb9bSPeter Wemm  .rela.tdata	  : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
38b05deb9bSPeter Wemm  .rel.tbss	  : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
39b05deb9bSPeter Wemm  .rela.tbss	  : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
406b7a14ceSPeter Wemm  .rel.ctors      : { *(.rel.ctors) }
416b7a14ceSPeter Wemm  .rela.ctors     : { *(.rela.ctors) }
426b7a14ceSPeter Wemm  .rel.dtors      : { *(.rel.dtors) }
436b7a14ceSPeter Wemm  .rela.dtors     : { *(.rela.dtors) }
44b05deb9bSPeter Wemm  .rel.got        : { *(.rel.got) }
45b05deb9bSPeter Wemm  .rela.got       : { *(.rela.got) }
46b05deb9bSPeter Wemm  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
47b05deb9bSPeter Wemm  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
488ba66bb8SDimitry Andric  .rel.ldata      : { *(.rel.ldata .rel.ldata.* .rel.gnu.linkonce.l.*) }
498ba66bb8SDimitry Andric  .rela.ldata     : { *(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*) }
508ba66bb8SDimitry Andric  .rel.lbss       : { *(.rel.lbss .rel.lbss.* .rel.gnu.linkonce.lb.*) }
518ba66bb8SDimitry Andric  .rela.lbss      : { *(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*) }
528ba66bb8SDimitry Andric  .rel.lrodata    : { *(.rel.lrodata .rel.lrodata.* .rel.gnu.linkonce.lr.*) }
538ba66bb8SDimitry Andric  .rela.lrodata   : { *(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*) }
546b7a14ceSPeter Wemm  .rel.plt        : { *(.rel.plt) }
556b7a14ceSPeter Wemm  .rela.plt       : { *(.rela.plt) }
56b05deb9bSPeter Wemm  .init           :
57b05deb9bSPeter Wemm  {
58b05deb9bSPeter Wemm    KEEP (*(.init))
59bd4e4054SEd Maste  } =0xCCCCCCCC
606b7a14ceSPeter Wemm  .plt            : { *(.plt) }
616b7a14ceSPeter Wemm  .text           :
626b7a14ceSPeter Wemm  {
63b05deb9bSPeter Wemm    *(.text .stub .text.* .gnu.linkonce.t.*)
648ba66bb8SDimitry Andric    KEEP (*(.text.*personality*))
656b7a14ceSPeter Wemm    /* .gnu.warning sections are handled specially by elf32.em.  */
666b7a14ceSPeter Wemm    *(.gnu.warning)
67bd4e4054SEd Maste  } =0xCCCCCCCC
68b05deb9bSPeter Wemm  .fini           :
69b05deb9bSPeter Wemm  {
70b05deb9bSPeter Wemm    KEEP (*(.fini))
71bd4e4054SEd Maste  } =0xCCCCCCCC
72b05deb9bSPeter Wemm  PROVIDE (__etext = .);
73b05deb9bSPeter Wemm  PROVIDE (_etext = .);
746b7a14ceSPeter Wemm  PROVIDE (etext = .);
75b05deb9bSPeter Wemm  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
766b7a14ceSPeter Wemm  .rodata1        : { *(.rodata1) }
77*74cd06b4SEd Maste  .note.gnu.build-id : {
78*74cd06b4SEd Maste    PROVIDE (__build_id_start = .);
79*74cd06b4SEd Maste    *(.note.gnu.build-id)
80*74cd06b4SEd Maste    PROVIDE (__build_id_end = .);
81*74cd06b4SEd Maste  }
82b05deb9bSPeter Wemm  .eh_frame_hdr : { *(.eh_frame_hdr) }
838ba66bb8SDimitry Andric  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
848ba66bb8SDimitry Andric  .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
856b7a14ceSPeter Wemm  /* Adjust the address for the data segment.  We want to adjust up to
866b7a14ceSPeter Wemm     the same address within the page on the next page up.  */
878ba66bb8SDimitry Andric  . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
88beb24065SJonathan T. Looney  PROVIDE (brwsection = .);
898ba66bb8SDimitry Andric  /* Exception handling  */
908ba66bb8SDimitry Andric  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
918ba66bb8SDimitry Andric  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
928ba66bb8SDimitry Andric  /* Thread Local Storage sections  */
93b05deb9bSPeter Wemm  .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
94b05deb9bSPeter Wemm  .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
958ba66bb8SDimitry Andric  .preinit_array     :
968ba66bb8SDimitry Andric  {
978ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__preinit_array_start = .);
988ba66bb8SDimitry Andric    KEEP (*(.preinit_array))
998ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__preinit_array_end = .);
1008ba66bb8SDimitry Andric  }
1018ba66bb8SDimitry Andric  .init_array     :
1028ba66bb8SDimitry Andric  {
1038ba66bb8SDimitry Andric     PROVIDE_HIDDEN (__init_array_start = .);
1048ba66bb8SDimitry Andric     KEEP (*(SORT(.init_array.*)))
1058ba66bb8SDimitry Andric     KEEP (*(.init_array))
1068ba66bb8SDimitry Andric     PROVIDE_HIDDEN (__init_array_end = .);
1078ba66bb8SDimitry Andric  }
1088ba66bb8SDimitry Andric  .fini_array     :
1098ba66bb8SDimitry Andric  {
1108ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__fini_array_start = .);
1118ba66bb8SDimitry Andric    KEEP (*(.fini_array))
1128ba66bb8SDimitry Andric    KEEP (*(SORT(.fini_array.*)))
1138ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__fini_array_end = .);
1148ba66bb8SDimitry Andric  }
115907cb02fSTim J. Robbins  _start_ctors = .;
116907cb02fSTim J. Robbins  PROVIDE (start_ctors = .);
1176b7a14ceSPeter Wemm  .ctors          :
1186b7a14ceSPeter Wemm  {
119b05deb9bSPeter Wemm    /* gcc uses crtbegin.o to find the start of
120b05deb9bSPeter Wemm       the constructors, so we make sure it is
121b05deb9bSPeter Wemm       first.  Because this is a wildcard, it
122b05deb9bSPeter Wemm       doesn't matter if the user does not
123b05deb9bSPeter Wemm       actually link against crtbegin.o; the
124b05deb9bSPeter Wemm       linker won't look for a file to match a
125b05deb9bSPeter Wemm       wildcard.  The wildcard also means that it
126b05deb9bSPeter Wemm       doesn't matter which directory crtbegin.o
127b05deb9bSPeter Wemm       is in.  */
128b05deb9bSPeter Wemm    KEEP (*crtbegin.o(.ctors))
1298ba66bb8SDimitry Andric    KEEP (*crtbegin?.o(.ctors))
130b05deb9bSPeter Wemm    /* We don't want to include the .ctor section from
1318ba66bb8SDimitry Andric       the crtend.o file until after the sorted ctors.
132b05deb9bSPeter Wemm       The .ctor section from the crtend file contains the
133b05deb9bSPeter Wemm       end of ctors marker and it must be last */
1348ba66bb8SDimitry Andric    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
135b05deb9bSPeter Wemm    KEEP (*(SORT(.ctors.*)))
136b05deb9bSPeter Wemm    KEEP (*(.ctors))
1376b7a14ceSPeter Wemm  }
138907cb02fSTim J. Robbins  _stop_ctors = .;
139907cb02fSTim J. Robbins  PROVIDE (stop_ctors = .);
1406b7a14ceSPeter Wemm  .dtors          :
1416b7a14ceSPeter Wemm  {
142b05deb9bSPeter Wemm    KEEP (*crtbegin.o(.dtors))
1438ba66bb8SDimitry Andric    KEEP (*crtbegin?.o(.dtors))
1448ba66bb8SDimitry Andric    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
145b05deb9bSPeter Wemm    KEEP (*(SORT(.dtors.*)))
146b05deb9bSPeter Wemm    KEEP (*(.dtors))
1476b7a14ceSPeter Wemm  }
148b05deb9bSPeter Wemm  .jcr            : { KEEP (*(.jcr)) }
1498ba66bb8SDimitry Andric  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
1508ba66bb8SDimitry Andric  .dynamic        : { *(.dynamic) }
1518ba66bb8SDimitry Andric  .got            : { *(.got) }
1528ba66bb8SDimitry Andric  . = DATA_SEGMENT_RELRO_END (24, .);
1538ba66bb8SDimitry Andric  .got.plt        : { *(.got.plt) }
15410c51654SMateusz Guzik  . = ALIGN(128);
155cf558f10SMateusz Guzik  .data.read_frequently :
156cf558f10SMateusz Guzik  {
15710c51654SMateusz Guzik    *(SORT_BY_ALIGNMENT(.data.read_frequently))
158cf558f10SMateusz Guzik  }
15921b73749SMateusz Guzik  .data.read_mostly :
16021b73749SMateusz Guzik  {
16121b73749SMateusz Guzik    *(.data.read_mostly)
16221b73749SMateusz Guzik  }
163726f22e0SMateusz Guzik  . = ALIGN(128);
16421b73749SMateusz Guzik  .data.exclusive_cache_line :
16521b73749SMateusz Guzik  {
16621b73749SMateusz Guzik    *(.data.exclusive_cache_line)
16721b73749SMateusz Guzik  }
168726f22e0SMateusz Guzik  . = ALIGN(128);
1698ba66bb8SDimitry Andric  .data           :
1708ba66bb8SDimitry Andric  {
1718ba66bb8SDimitry Andric    *(.data .data.* .gnu.linkonce.d.*)
1728ba66bb8SDimitry Andric    KEEP (*(.gnu.linkonce.d.*personality*))
1738ba66bb8SDimitry Andric  }
1748ba66bb8SDimitry Andric  .data1          : { *(.data1) }
1758ba66bb8SDimitry Andric  _edata = .; PROVIDE (edata = .);
1766b7a14ceSPeter Wemm  __bss_start = .;
1776b7a14ceSPeter Wemm  .bss            :
1786b7a14ceSPeter Wemm  {
1796b7a14ceSPeter Wemm   *(.dynbss)
180b05deb9bSPeter Wemm   *(.bss .bss.* .gnu.linkonce.b.*)
1816b7a14ceSPeter Wemm   *(COMMON)
182b05deb9bSPeter Wemm   /* Align here to ensure that the .bss section occupies space up to
183b05deb9bSPeter Wemm      _end.  Align after .bss to ensure correct alignment even if the
1848ba66bb8SDimitry Andric      .bss section disappears because there are no input sections.
1858ba66bb8SDimitry Andric      FIXME: Why do we need it? When there is no .bss section, we don't
1868ba66bb8SDimitry Andric      pad the .data section.  */
1878ba66bb8SDimitry Andric   . = ALIGN(. != 0 ? 64 / 8 : 1);
1888ba66bb8SDimitry Andric  }
1898ba66bb8SDimitry Andric  .lbss   :
1908ba66bb8SDimitry Andric  {
1918ba66bb8SDimitry Andric    *(.dynlbss)
1928ba66bb8SDimitry Andric    *(.lbss .lbss.* .gnu.linkonce.lb.*)
1938ba66bb8SDimitry Andric    *(LARGE_COMMON)
1946b7a14ceSPeter Wemm  }
195b05deb9bSPeter Wemm  . = ALIGN(64 / 8);
1968ba66bb8SDimitry Andric  .lrodata   ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
1978ba66bb8SDimitry Andric  {
1988ba66bb8SDimitry Andric    *(.lrodata .lrodata.* .gnu.linkonce.lr.*)
1998ba66bb8SDimitry Andric  }
2008ba66bb8SDimitry Andric  .ldata   ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
2018ba66bb8SDimitry Andric  {
2028ba66bb8SDimitry Andric    *(.ldata .ldata.* .gnu.linkonce.l.*)
2038ba66bb8SDimitry Andric    . = ALIGN(. != 0 ? 64 / 8 : 1);
2048ba66bb8SDimitry Andric  }
2058ba66bb8SDimitry Andric  . = ALIGN(64 / 8);
2068ba66bb8SDimitry Andric  _end = .; PROVIDE (end = .);
207b05deb9bSPeter Wemm  . = DATA_SEGMENT_END (.);
2086b7a14ceSPeter Wemm  /* Stabs debugging sections.  */
2096b7a14ceSPeter Wemm  .stab          0 : { *(.stab) }
2106b7a14ceSPeter Wemm  .stabstr       0 : { *(.stabstr) }
2116b7a14ceSPeter Wemm  .stab.excl     0 : { *(.stab.excl) }
2126b7a14ceSPeter Wemm  .stab.exclstr  0 : { *(.stab.exclstr) }
2136b7a14ceSPeter Wemm  .stab.index    0 : { *(.stab.index) }
2146b7a14ceSPeter Wemm  .stab.indexstr 0 : { *(.stab.indexstr) }
2156b7a14ceSPeter Wemm  .comment       0 : { *(.comment) }
2166b7a14ceSPeter Wemm  /* DWARF debug sections.
2176b7a14ceSPeter Wemm     Symbols in the DWARF debugging sections are relative to the beginning
2186b7a14ceSPeter Wemm     of the section so we begin them at 0.  */
2196b7a14ceSPeter Wemm  /* DWARF 1 */
2206b7a14ceSPeter Wemm  .debug          0 : { *(.debug) }
2216b7a14ceSPeter Wemm  .line           0 : { *(.line) }
2226b7a14ceSPeter Wemm  /* GNU DWARF 1 extensions */
2236b7a14ceSPeter Wemm  .debug_srcinfo  0 : { *(.debug_srcinfo) }
2246b7a14ceSPeter Wemm  .debug_sfnames  0 : { *(.debug_sfnames) }
2256b7a14ceSPeter Wemm  /* DWARF 1.1 and DWARF 2 */
2266b7a14ceSPeter Wemm  .debug_aranges  0 : { *(.debug_aranges) }
2276b7a14ceSPeter Wemm  .debug_pubnames 0 : { *(.debug_pubnames) }
2286b7a14ceSPeter Wemm  /* DWARF 2 */
229b05deb9bSPeter Wemm  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
2306b7a14ceSPeter Wemm  .debug_abbrev   0 : { *(.debug_abbrev) }
2316b7a14ceSPeter Wemm  .debug_line     0 : { *(.debug_line) }
2326b7a14ceSPeter Wemm  .debug_frame    0 : { *(.debug_frame) }
2336b7a14ceSPeter Wemm  .debug_str      0 : { *(.debug_str) }
2346b7a14ceSPeter Wemm  .debug_loc      0 : { *(.debug_loc) }
2356b7a14ceSPeter Wemm  .debug_macinfo  0 : { *(.debug_macinfo) }
2366b7a14ceSPeter Wemm  /* SGI/MIPS DWARF 2 extensions */
2376b7a14ceSPeter Wemm  .debug_weaknames 0 : { *(.debug_weaknames) }
2386b7a14ceSPeter Wemm  .debug_funcnames 0 : { *(.debug_funcnames) }
2396b7a14ceSPeter Wemm  .debug_typenames 0 : { *(.debug_typenames) }
2406b7a14ceSPeter Wemm  .debug_varnames  0 : { *(.debug_varnames) }
2418ba66bb8SDimitry Andric  /* DWARF 3 */
2428ba66bb8SDimitry Andric  .debug_pubtypes 0 : { *(.debug_pubtypes) }
2438ba66bb8SDimitry Andric  .debug_ranges   0 : { *(.debug_ranges) }
2448ba66bb8SDimitry Andric  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
2458ba66bb8SDimitry Andric  /DISCARD/ : { *(.note.GNU-stack) }
2466b7a14ceSPeter Wemm}
247