xref: /freebsd/sys/conf/ldscript.amd64 (revision 10c51654ef53761b35a72d8c2d63c3c8b8658210)
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: */
99d99bb0aSEd Maste  kernphys = 0x200000;
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) }
77b05deb9bSPeter Wemm  .eh_frame_hdr : { *(.eh_frame_hdr) }
788ba66bb8SDimitry Andric  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
798ba66bb8SDimitry Andric  .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
806b7a14ceSPeter Wemm  /* Adjust the address for the data segment.  We want to adjust up to
816b7a14ceSPeter Wemm     the same address within the page on the next page up.  */
828ba66bb8SDimitry Andric  . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
83beb24065SJonathan T. Looney  PROVIDE (brwsection = .);
848ba66bb8SDimitry Andric  /* Exception handling  */
858ba66bb8SDimitry Andric  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
868ba66bb8SDimitry Andric  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
878ba66bb8SDimitry Andric  /* Thread Local Storage sections  */
88b05deb9bSPeter Wemm  .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
89b05deb9bSPeter Wemm  .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
908ba66bb8SDimitry Andric  .preinit_array     :
918ba66bb8SDimitry Andric  {
928ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__preinit_array_start = .);
938ba66bb8SDimitry Andric    KEEP (*(.preinit_array))
948ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__preinit_array_end = .);
958ba66bb8SDimitry Andric  }
968ba66bb8SDimitry Andric  .init_array     :
978ba66bb8SDimitry Andric  {
988ba66bb8SDimitry Andric     PROVIDE_HIDDEN (__init_array_start = .);
998ba66bb8SDimitry Andric     KEEP (*(SORT(.init_array.*)))
1008ba66bb8SDimitry Andric     KEEP (*(.init_array))
1018ba66bb8SDimitry Andric     PROVIDE_HIDDEN (__init_array_end = .);
1028ba66bb8SDimitry Andric  }
1038ba66bb8SDimitry Andric  .fini_array     :
1048ba66bb8SDimitry Andric  {
1058ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__fini_array_start = .);
1068ba66bb8SDimitry Andric    KEEP (*(.fini_array))
1078ba66bb8SDimitry Andric    KEEP (*(SORT(.fini_array.*)))
1088ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__fini_array_end = .);
1098ba66bb8SDimitry Andric  }
110907cb02fSTim J. Robbins  _start_ctors = .;
111907cb02fSTim J. Robbins  PROVIDE (start_ctors = .);
1126b7a14ceSPeter Wemm  .ctors          :
1136b7a14ceSPeter Wemm  {
114b05deb9bSPeter Wemm    /* gcc uses crtbegin.o to find the start of
115b05deb9bSPeter Wemm       the constructors, so we make sure it is
116b05deb9bSPeter Wemm       first.  Because this is a wildcard, it
117b05deb9bSPeter Wemm       doesn't matter if the user does not
118b05deb9bSPeter Wemm       actually link against crtbegin.o; the
119b05deb9bSPeter Wemm       linker won't look for a file to match a
120b05deb9bSPeter Wemm       wildcard.  The wildcard also means that it
121b05deb9bSPeter Wemm       doesn't matter which directory crtbegin.o
122b05deb9bSPeter Wemm       is in.  */
123b05deb9bSPeter Wemm    KEEP (*crtbegin.o(.ctors))
1248ba66bb8SDimitry Andric    KEEP (*crtbegin?.o(.ctors))
125b05deb9bSPeter Wemm    /* We don't want to include the .ctor section from
1268ba66bb8SDimitry Andric       the crtend.o file until after the sorted ctors.
127b05deb9bSPeter Wemm       The .ctor section from the crtend file contains the
128b05deb9bSPeter Wemm       end of ctors marker and it must be last */
1298ba66bb8SDimitry Andric    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
130b05deb9bSPeter Wemm    KEEP (*(SORT(.ctors.*)))
131b05deb9bSPeter Wemm    KEEP (*(.ctors))
1326b7a14ceSPeter Wemm  }
133907cb02fSTim J. Robbins  _stop_ctors = .;
134907cb02fSTim J. Robbins  PROVIDE (stop_ctors = .);
1356b7a14ceSPeter Wemm  .dtors          :
1366b7a14ceSPeter Wemm  {
137b05deb9bSPeter Wemm    KEEP (*crtbegin.o(.dtors))
1388ba66bb8SDimitry Andric    KEEP (*crtbegin?.o(.dtors))
1398ba66bb8SDimitry Andric    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
140b05deb9bSPeter Wemm    KEEP (*(SORT(.dtors.*)))
141b05deb9bSPeter Wemm    KEEP (*(.dtors))
1426b7a14ceSPeter Wemm  }
143b05deb9bSPeter Wemm  .jcr            : { KEEP (*(.jcr)) }
1448ba66bb8SDimitry Andric  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
1458ba66bb8SDimitry Andric  .dynamic        : { *(.dynamic) }
1468ba66bb8SDimitry Andric  .got            : { *(.got) }
1478ba66bb8SDimitry Andric  . = DATA_SEGMENT_RELRO_END (24, .);
1488ba66bb8SDimitry Andric  .got.plt        : { *(.got.plt) }
149*10c51654SMateusz Guzik  . = ALIGN(128);
150cf558f10SMateusz Guzik  .data.read_frequently :
151cf558f10SMateusz Guzik  {
152*10c51654SMateusz Guzik    *(SORT_BY_ALIGNMENT(.data.read_frequently))
153cf558f10SMateusz Guzik  }
15421b73749SMateusz Guzik  .data.read_mostly :
15521b73749SMateusz Guzik  {
15621b73749SMateusz Guzik    *(.data.read_mostly)
15721b73749SMateusz Guzik  }
158726f22e0SMateusz Guzik  . = ALIGN(128);
15921b73749SMateusz Guzik  .data.exclusive_cache_line :
16021b73749SMateusz Guzik  {
16121b73749SMateusz Guzik    *(.data.exclusive_cache_line)
16221b73749SMateusz Guzik  }
163726f22e0SMateusz Guzik  . = ALIGN(128);
1648ba66bb8SDimitry Andric  .data           :
1658ba66bb8SDimitry Andric  {
1668ba66bb8SDimitry Andric    *(.data .data.* .gnu.linkonce.d.*)
1678ba66bb8SDimitry Andric    KEEP (*(.gnu.linkonce.d.*personality*))
1688ba66bb8SDimitry Andric  }
1698ba66bb8SDimitry Andric  .data1          : { *(.data1) }
1708ba66bb8SDimitry Andric  _edata = .; PROVIDE (edata = .);
1716b7a14ceSPeter Wemm  __bss_start = .;
1726b7a14ceSPeter Wemm  .bss            :
1736b7a14ceSPeter Wemm  {
1746b7a14ceSPeter Wemm   *(.dynbss)
175b05deb9bSPeter Wemm   *(.bss .bss.* .gnu.linkonce.b.*)
1766b7a14ceSPeter Wemm   *(COMMON)
177b05deb9bSPeter Wemm   /* Align here to ensure that the .bss section occupies space up to
178b05deb9bSPeter Wemm      _end.  Align after .bss to ensure correct alignment even if the
1798ba66bb8SDimitry Andric      .bss section disappears because there are no input sections.
1808ba66bb8SDimitry Andric      FIXME: Why do we need it? When there is no .bss section, we don't
1818ba66bb8SDimitry Andric      pad the .data section.  */
1828ba66bb8SDimitry Andric   . = ALIGN(. != 0 ? 64 / 8 : 1);
1838ba66bb8SDimitry Andric  }
1848ba66bb8SDimitry Andric  .lbss   :
1858ba66bb8SDimitry Andric  {
1868ba66bb8SDimitry Andric    *(.dynlbss)
1878ba66bb8SDimitry Andric    *(.lbss .lbss.* .gnu.linkonce.lb.*)
1888ba66bb8SDimitry Andric    *(LARGE_COMMON)
1896b7a14ceSPeter Wemm  }
190b05deb9bSPeter Wemm  . = ALIGN(64 / 8);
1918ba66bb8SDimitry Andric  .lrodata   ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
1928ba66bb8SDimitry Andric  {
1938ba66bb8SDimitry Andric    *(.lrodata .lrodata.* .gnu.linkonce.lr.*)
1948ba66bb8SDimitry Andric  }
1958ba66bb8SDimitry Andric  .ldata   ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
1968ba66bb8SDimitry Andric  {
1978ba66bb8SDimitry Andric    *(.ldata .ldata.* .gnu.linkonce.l.*)
1988ba66bb8SDimitry Andric    . = ALIGN(. != 0 ? 64 / 8 : 1);
1998ba66bb8SDimitry Andric  }
2008ba66bb8SDimitry Andric  . = ALIGN(64 / 8);
2018ba66bb8SDimitry Andric  _end = .; PROVIDE (end = .);
202b05deb9bSPeter Wemm  . = DATA_SEGMENT_END (.);
2036b7a14ceSPeter Wemm  /* Stabs debugging sections.  */
2046b7a14ceSPeter Wemm  .stab          0 : { *(.stab) }
2056b7a14ceSPeter Wemm  .stabstr       0 : { *(.stabstr) }
2066b7a14ceSPeter Wemm  .stab.excl     0 : { *(.stab.excl) }
2076b7a14ceSPeter Wemm  .stab.exclstr  0 : { *(.stab.exclstr) }
2086b7a14ceSPeter Wemm  .stab.index    0 : { *(.stab.index) }
2096b7a14ceSPeter Wemm  .stab.indexstr 0 : { *(.stab.indexstr) }
2106b7a14ceSPeter Wemm  .comment       0 : { *(.comment) }
2116b7a14ceSPeter Wemm  /* DWARF debug sections.
2126b7a14ceSPeter Wemm     Symbols in the DWARF debugging sections are relative to the beginning
2136b7a14ceSPeter Wemm     of the section so we begin them at 0.  */
2146b7a14ceSPeter Wemm  /* DWARF 1 */
2156b7a14ceSPeter Wemm  .debug          0 : { *(.debug) }
2166b7a14ceSPeter Wemm  .line           0 : { *(.line) }
2176b7a14ceSPeter Wemm  /* GNU DWARF 1 extensions */
2186b7a14ceSPeter Wemm  .debug_srcinfo  0 : { *(.debug_srcinfo) }
2196b7a14ceSPeter Wemm  .debug_sfnames  0 : { *(.debug_sfnames) }
2206b7a14ceSPeter Wemm  /* DWARF 1.1 and DWARF 2 */
2216b7a14ceSPeter Wemm  .debug_aranges  0 : { *(.debug_aranges) }
2226b7a14ceSPeter Wemm  .debug_pubnames 0 : { *(.debug_pubnames) }
2236b7a14ceSPeter Wemm  /* DWARF 2 */
224b05deb9bSPeter Wemm  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
2256b7a14ceSPeter Wemm  .debug_abbrev   0 : { *(.debug_abbrev) }
2266b7a14ceSPeter Wemm  .debug_line     0 : { *(.debug_line) }
2276b7a14ceSPeter Wemm  .debug_frame    0 : { *(.debug_frame) }
2286b7a14ceSPeter Wemm  .debug_str      0 : { *(.debug_str) }
2296b7a14ceSPeter Wemm  .debug_loc      0 : { *(.debug_loc) }
2306b7a14ceSPeter Wemm  .debug_macinfo  0 : { *(.debug_macinfo) }
2316b7a14ceSPeter Wemm  /* SGI/MIPS DWARF 2 extensions */
2326b7a14ceSPeter Wemm  .debug_weaknames 0 : { *(.debug_weaknames) }
2336b7a14ceSPeter Wemm  .debug_funcnames 0 : { *(.debug_funcnames) }
2346b7a14ceSPeter Wemm  .debug_typenames 0 : { *(.debug_typenames) }
2356b7a14ceSPeter Wemm  .debug_varnames  0 : { *(.debug_varnames) }
2368ba66bb8SDimitry Andric  /* DWARF 3 */
2378ba66bb8SDimitry Andric  .debug_pubtypes 0 : { *(.debug_pubtypes) }
2388ba66bb8SDimitry Andric  .debug_ranges   0 : { *(.debug_ranges) }
2398ba66bb8SDimitry Andric  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
2408ba66bb8SDimitry Andric  /DISCARD/ : { *(.note.GNU-stack) }
2416b7a14ceSPeter Wemm}
242