xref: /freebsd/sys/conf/ldscript.amd64 (revision e18380e341410ce70d97560a22827591f4b2d373)
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: */
9*e18380e3SKonstantin Belousov  . = kernbase + kernload + SIZEOF_HEADERS;
107e748038SRoger Pau Monné  /*
117e748038SRoger Pau Monné   * Use the AT keyword in order to set the right LMA that contains
127e748038SRoger Pau Monné   * the physical address where the section should be loaded. This is
137e748038SRoger Pau Monné   * needed for the Xen loader which honours the LMA.
147e748038SRoger Pau Monné   */
15*e18380e3SKonstantin Belousov  .interp         : AT (kernload + SIZEOF_HEADERS) { *(.interp) }
166b7a14ceSPeter Wemm  .hash           : { *(.hash) }
178ba66bb8SDimitry Andric  .gnu.hash       : { *(.gnu.hash) }
186b7a14ceSPeter Wemm  .dynsym         : { *(.dynsym) }
196b7a14ceSPeter Wemm  .dynstr         : { *(.dynstr) }
206b7a14ceSPeter Wemm  .gnu.version    : { *(.gnu.version) }
216b7a14ceSPeter Wemm  .gnu.version_d  : { *(.gnu.version_d) }
226b7a14ceSPeter Wemm  .gnu.version_r  : { *(.gnu.version_r) }
23b05deb9bSPeter Wemm  .rel.init       : { *(.rel.init) }
24b05deb9bSPeter Wemm  .rela.init      : { *(.rela.init) }
25b05deb9bSPeter Wemm  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
26b05deb9bSPeter Wemm  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
27b05deb9bSPeter Wemm  .rel.fini       : { *(.rel.fini) }
28b05deb9bSPeter Wemm  .rela.fini      : { *(.rela.fini) }
29b05deb9bSPeter Wemm  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
30b05deb9bSPeter Wemm  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
318ba66bb8SDimitry Andric  .rel.data.rel.ro   : { *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) }
328ba66bb8SDimitry Andric  .rela.data.rel.ro   : { *(.rela.data.rel.ro* .rela.gnu.linkonce.d.rel.ro.*) }
33b05deb9bSPeter Wemm  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
34b05deb9bSPeter Wemm  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
35b05deb9bSPeter Wemm  .rel.tdata	  : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
36b05deb9bSPeter Wemm  .rela.tdata	  : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
37b05deb9bSPeter Wemm  .rel.tbss	  : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
38b05deb9bSPeter Wemm  .rela.tbss	  : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
396b7a14ceSPeter Wemm  .rel.ctors      : { *(.rel.ctors) }
406b7a14ceSPeter Wemm  .rela.ctors     : { *(.rela.ctors) }
416b7a14ceSPeter Wemm  .rel.dtors      : { *(.rel.dtors) }
426b7a14ceSPeter Wemm  .rela.dtors     : { *(.rela.dtors) }
43b05deb9bSPeter Wemm  .rel.got        : { *(.rel.got) }
44b05deb9bSPeter Wemm  .rela.got       : { *(.rela.got) }
45b05deb9bSPeter Wemm  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
46b05deb9bSPeter Wemm  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
476b7a14ceSPeter Wemm  .rel.plt        : { *(.rel.plt) }
486b7a14ceSPeter Wemm  .rela.plt       : { *(.rela.plt) }
49b05deb9bSPeter Wemm  .init           :
50b05deb9bSPeter Wemm  {
51b05deb9bSPeter Wemm    KEEP (*(.init))
52bd4e4054SEd Maste  } =0xCCCCCCCC
536b7a14ceSPeter Wemm  .plt            : { *(.plt) }
546b7a14ceSPeter Wemm  .text           :
556b7a14ceSPeter Wemm  {
56b05deb9bSPeter Wemm    *(.text .stub .text.* .gnu.linkonce.t.*)
578ba66bb8SDimitry Andric    KEEP (*(.text.*personality*))
586b7a14ceSPeter Wemm    /* .gnu.warning sections are handled specially by elf32.em.  */
596b7a14ceSPeter Wemm    *(.gnu.warning)
60bd4e4054SEd Maste  } =0xCCCCCCCC
61b05deb9bSPeter Wemm  .fini           :
62b05deb9bSPeter Wemm  {
63b05deb9bSPeter Wemm    KEEP (*(.fini))
64bd4e4054SEd Maste  } =0xCCCCCCCC
65b05deb9bSPeter Wemm  PROVIDE (__etext = .);
66b05deb9bSPeter Wemm  PROVIDE (_etext = .);
676b7a14ceSPeter Wemm  PROVIDE (etext = .);
68b05deb9bSPeter Wemm  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
696b7a14ceSPeter Wemm  .rodata1        : { *(.rodata1) }
7074cd06b4SEd Maste  .note.gnu.build-id : {
7174cd06b4SEd Maste    PROVIDE (__build_id_start = .);
7274cd06b4SEd Maste    *(.note.gnu.build-id)
7374cd06b4SEd Maste    PROVIDE (__build_id_end = .);
7474cd06b4SEd Maste  }
75b05deb9bSPeter Wemm  .eh_frame_hdr : { *(.eh_frame_hdr) }
768ba66bb8SDimitry Andric  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
778ba66bb8SDimitry Andric  .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
786b7a14ceSPeter Wemm  /* Adjust the address for the data segment.  We want to adjust up to
796b7a14ceSPeter Wemm     the same address within the page on the next page up.  */
808ba66bb8SDimitry Andric  . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
81beb24065SJonathan T. Looney  PROVIDE (brwsection = .);
828ba66bb8SDimitry Andric  /* Exception handling  */
838ba66bb8SDimitry Andric  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
848ba66bb8SDimitry Andric  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
858ba66bb8SDimitry Andric  /* Thread Local Storage sections  */
86b05deb9bSPeter Wemm  .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
87b05deb9bSPeter Wemm  .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
888ba66bb8SDimitry Andric  .preinit_array     :
898ba66bb8SDimitry Andric  {
908ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__preinit_array_start = .);
918ba66bb8SDimitry Andric    KEEP (*(.preinit_array))
928ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__preinit_array_end = .);
938ba66bb8SDimitry Andric  }
948ba66bb8SDimitry Andric  .init_array     :
958ba66bb8SDimitry Andric  {
968ba66bb8SDimitry Andric     PROVIDE_HIDDEN (__init_array_start = .);
978ba66bb8SDimitry Andric     KEEP (*(SORT(.init_array.*)))
988ba66bb8SDimitry Andric     KEEP (*(.init_array))
998ba66bb8SDimitry Andric     PROVIDE_HIDDEN (__init_array_end = .);
1008ba66bb8SDimitry Andric  }
1018ba66bb8SDimitry Andric  .fini_array     :
1028ba66bb8SDimitry Andric  {
1038ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__fini_array_start = .);
1048ba66bb8SDimitry Andric    KEEP (*(.fini_array))
1058ba66bb8SDimitry Andric    KEEP (*(SORT(.fini_array.*)))
1068ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__fini_array_end = .);
1078ba66bb8SDimitry Andric  }
108907cb02fSTim J. Robbins  _start_ctors = .;
109907cb02fSTim J. Robbins  PROVIDE (start_ctors = .);
1106b7a14ceSPeter Wemm  .ctors          :
1116b7a14ceSPeter Wemm  {
112b05deb9bSPeter Wemm    /* gcc uses crtbegin.o to find the start of
113b05deb9bSPeter Wemm       the constructors, so we make sure it is
114b05deb9bSPeter Wemm       first.  Because this is a wildcard, it
115b05deb9bSPeter Wemm       doesn't matter if the user does not
116b05deb9bSPeter Wemm       actually link against crtbegin.o; the
117b05deb9bSPeter Wemm       linker won't look for a file to match a
118b05deb9bSPeter Wemm       wildcard.  The wildcard also means that it
119b05deb9bSPeter Wemm       doesn't matter which directory crtbegin.o
120b05deb9bSPeter Wemm       is in.  */
121b05deb9bSPeter Wemm    KEEP (*crtbegin.o(.ctors))
1228ba66bb8SDimitry Andric    KEEP (*crtbegin?.o(.ctors))
123b05deb9bSPeter Wemm    /* We don't want to include the .ctor section from
1248ba66bb8SDimitry Andric       the crtend.o file until after the sorted ctors.
125b05deb9bSPeter Wemm       The .ctor section from the crtend file contains the
126b05deb9bSPeter Wemm       end of ctors marker and it must be last */
1278ba66bb8SDimitry Andric    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
128b05deb9bSPeter Wemm    KEEP (*(SORT(.ctors.*)))
129b05deb9bSPeter Wemm    KEEP (*(.ctors))
1306b7a14ceSPeter Wemm  }
131907cb02fSTim J. Robbins  _stop_ctors = .;
132907cb02fSTim J. Robbins  PROVIDE (stop_ctors = .);
1336b7a14ceSPeter Wemm  .dtors          :
1346b7a14ceSPeter Wemm  {
135b05deb9bSPeter Wemm    KEEP (*crtbegin.o(.dtors))
1368ba66bb8SDimitry Andric    KEEP (*crtbegin?.o(.dtors))
1378ba66bb8SDimitry Andric    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
138b05deb9bSPeter Wemm    KEEP (*(SORT(.dtors.*)))
139b05deb9bSPeter Wemm    KEEP (*(.dtors))
1406b7a14ceSPeter Wemm  }
141b05deb9bSPeter Wemm  .jcr            : { KEEP (*(.jcr)) }
1428ba66bb8SDimitry Andric  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
1438ba66bb8SDimitry Andric  .dynamic        : { *(.dynamic) }
1448ba66bb8SDimitry Andric  .got            : { *(.got) }
1458ba66bb8SDimitry Andric  . = DATA_SEGMENT_RELRO_END (24, .);
1468ba66bb8SDimitry Andric  .got.plt        : { *(.got.plt) }
14710c51654SMateusz Guzik  . = ALIGN(128);
148cf558f10SMateusz Guzik  .data.read_frequently :
149cf558f10SMateusz Guzik  {
15010c51654SMateusz Guzik    *(SORT_BY_ALIGNMENT(.data.read_frequently))
151cf558f10SMateusz Guzik  }
15221b73749SMateusz Guzik  .data.read_mostly :
15321b73749SMateusz Guzik  {
15421b73749SMateusz Guzik    *(.data.read_mostly)
15521b73749SMateusz Guzik  }
156726f22e0SMateusz Guzik  . = ALIGN(128);
15721b73749SMateusz Guzik  .data.exclusive_cache_line :
15821b73749SMateusz Guzik  {
15921b73749SMateusz Guzik    *(.data.exclusive_cache_line)
16021b73749SMateusz Guzik  }
161726f22e0SMateusz Guzik  . = ALIGN(128);
1628ba66bb8SDimitry Andric  .data           :
1638ba66bb8SDimitry Andric  {
1648ba66bb8SDimitry Andric    *(.data .data.* .gnu.linkonce.d.*)
1658ba66bb8SDimitry Andric    KEEP (*(.gnu.linkonce.d.*personality*))
1668ba66bb8SDimitry Andric  }
1678ba66bb8SDimitry Andric  .data1          : { *(.data1) }
1688ba66bb8SDimitry Andric  _edata = .; PROVIDE (edata = .);
1696b7a14ceSPeter Wemm  __bss_start = .;
1706b7a14ceSPeter Wemm  .bss            :
1716b7a14ceSPeter Wemm  {
1726b7a14ceSPeter Wemm   *(.dynbss)
173b05deb9bSPeter Wemm   *(.bss .bss.* .gnu.linkonce.b.*)
1746b7a14ceSPeter Wemm   *(COMMON)
17514327f53SMark Johnston   /* Ensure that the .bss section ends at a superpage boundary.
17614327f53SMark Johnston      This way it can be mapped using non-executable large pages. */
17714327f53SMark Johnston   . = ALIGN(0x200000);
1788ba66bb8SDimitry Andric  }
1798ba66bb8SDimitry Andric  _end = .; PROVIDE (end = .);
180b05deb9bSPeter Wemm  . = DATA_SEGMENT_END (.);
1816b7a14ceSPeter Wemm  /* Stabs debugging sections.  */
1826b7a14ceSPeter Wemm  .stab          0 : { *(.stab) }
1836b7a14ceSPeter Wemm  .stabstr       0 : { *(.stabstr) }
1846b7a14ceSPeter Wemm  .stab.excl     0 : { *(.stab.excl) }
1856b7a14ceSPeter Wemm  .stab.exclstr  0 : { *(.stab.exclstr) }
1866b7a14ceSPeter Wemm  .stab.index    0 : { *(.stab.index) }
1876b7a14ceSPeter Wemm  .stab.indexstr 0 : { *(.stab.indexstr) }
1886b7a14ceSPeter Wemm  .comment       0 : { *(.comment) }
1896b7a14ceSPeter Wemm  /* DWARF debug sections.
1906b7a14ceSPeter Wemm     Symbols in the DWARF debugging sections are relative to the beginning
1916b7a14ceSPeter Wemm     of the section so we begin them at 0.  */
1926b7a14ceSPeter Wemm  /* DWARF 1 */
1936b7a14ceSPeter Wemm  .debug          0 : { *(.debug) }
1946b7a14ceSPeter Wemm  .line           0 : { *(.line) }
1956b7a14ceSPeter Wemm  /* GNU DWARF 1 extensions */
1966b7a14ceSPeter Wemm  .debug_srcinfo  0 : { *(.debug_srcinfo) }
1976b7a14ceSPeter Wemm  .debug_sfnames  0 : { *(.debug_sfnames) }
1986b7a14ceSPeter Wemm  /* DWARF 1.1 and DWARF 2 */
1996b7a14ceSPeter Wemm  .debug_aranges  0 : { *(.debug_aranges) }
2006b7a14ceSPeter Wemm  .debug_pubnames 0 : { *(.debug_pubnames) }
2016b7a14ceSPeter Wemm  /* DWARF 2 */
202b05deb9bSPeter Wemm  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
2036b7a14ceSPeter Wemm  .debug_abbrev   0 : { *(.debug_abbrev) }
2046b7a14ceSPeter Wemm  .debug_line     0 : { *(.debug_line) }
2056b7a14ceSPeter Wemm  .debug_frame    0 : { *(.debug_frame) }
2066b7a14ceSPeter Wemm  .debug_str      0 : { *(.debug_str) }
2076b7a14ceSPeter Wemm  .debug_loc      0 : { *(.debug_loc) }
2086b7a14ceSPeter Wemm  .debug_macinfo  0 : { *(.debug_macinfo) }
2096b7a14ceSPeter Wemm  /* SGI/MIPS DWARF 2 extensions */
2106b7a14ceSPeter Wemm  .debug_weaknames 0 : { *(.debug_weaknames) }
2116b7a14ceSPeter Wemm  .debug_funcnames 0 : { *(.debug_funcnames) }
2126b7a14ceSPeter Wemm  .debug_typenames 0 : { *(.debug_typenames) }
2136b7a14ceSPeter Wemm  .debug_varnames  0 : { *(.debug_varnames) }
2148ba66bb8SDimitry Andric  /* DWARF 3 */
2158ba66bb8SDimitry Andric  .debug_pubtypes 0 : { *(.debug_pubtypes) }
2168ba66bb8SDimitry Andric  .debug_ranges   0 : { *(.debug_ranges) }
2178ba66bb8SDimitry Andric  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
2188ba66bb8SDimitry Andric  /DISCARD/ : { *(.note.GNU-stack) }
2196b7a14ceSPeter Wemm}
220