xref: /freebsd/sys/conf/ldscript.amd64 (revision e15b5ba77d693609c9a452d1b0a1cdd5eb29350d)
1491fb274SDimitry AndricOUTPUT_FORMAT("elf64-x86-64-freebsd", "elf64-x86-64-freebsd", "elf64-x86-64-freebsd")
2b05deb9bSPeter WemmOUTPUT_ARCH(i386:x86-64)
36b7a14ceSPeter WemmENTRY(btext)
4b05deb9bSPeter WemmSEARCH_DIR("/usr/lib");
56b7a14ceSPeter WemmSECTIONS
66b7a14ceSPeter Wemm{
76b7a14ceSPeter Wemm  /* Read-only sections, merged into text segment: */
8e18380e3SKonstantin Belousov  . = kernbase + kernload + SIZEOF_HEADERS;
97e748038SRoger Pau Monné  /*
107e748038SRoger Pau Monné   * Use the AT keyword in order to set the right LMA that contains
117e748038SRoger Pau Monné   * the physical address where the section should be loaded. This is
127e748038SRoger Pau Monné   * needed for the Xen loader which honours the LMA.
137e748038SRoger Pau Monné   */
14e18380e3SKonstantin Belousov  .interp         : AT (kernload + SIZEOF_HEADERS) { *(.interp) }
156b7a14ceSPeter Wemm  .hash           : { *(.hash) }
168ba66bb8SDimitry Andric  .gnu.hash       : { *(.gnu.hash) }
176b7a14ceSPeter Wemm  .dynsym         : { *(.dynsym) }
186b7a14ceSPeter Wemm  .dynstr         : { *(.dynstr) }
196b7a14ceSPeter Wemm  .gnu.version    : { *(.gnu.version) }
206b7a14ceSPeter Wemm  .gnu.version_d  : { *(.gnu.version_d) }
216b7a14ceSPeter Wemm  .gnu.version_r  : { *(.gnu.version_r) }
22b05deb9bSPeter Wemm  .rel.init       : { *(.rel.init) }
23b05deb9bSPeter Wemm  .rela.init      : { *(.rela.init) }
24b05deb9bSPeter Wemm  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
25b05deb9bSPeter Wemm  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
26b05deb9bSPeter Wemm  .rel.fini       : { *(.rel.fini) }
27b05deb9bSPeter Wemm  .rela.fini      : { *(.rela.fini) }
28b05deb9bSPeter Wemm  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
29b05deb9bSPeter Wemm  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
308ba66bb8SDimitry Andric  .rel.data.rel.ro   : { *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) }
318ba66bb8SDimitry Andric  .rela.data.rel.ro   : { *(.rela.data.rel.ro* .rela.gnu.linkonce.d.rel.ro.*) }
32b05deb9bSPeter Wemm  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
33b05deb9bSPeter Wemm  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
34b05deb9bSPeter Wemm  .rel.tdata	  : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
35b05deb9bSPeter Wemm  .rela.tdata	  : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
36b05deb9bSPeter Wemm  .rel.tbss	  : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
37b05deb9bSPeter Wemm  .rela.tbss	  : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
386b7a14ceSPeter Wemm  .rel.ctors      : { *(.rel.ctors) }
396b7a14ceSPeter Wemm  .rela.ctors     : { *(.rela.ctors) }
406b7a14ceSPeter Wemm  .rel.dtors      : { *(.rel.dtors) }
416b7a14ceSPeter Wemm  .rela.dtors     : { *(.rela.dtors) }
42b05deb9bSPeter Wemm  .rel.got        : { *(.rel.got) }
43b05deb9bSPeter Wemm  .rela.got       : { *(.rela.got) }
44b05deb9bSPeter Wemm  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
45b05deb9bSPeter Wemm  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
466b7a14ceSPeter Wemm  .rel.plt        : { *(.rel.plt) }
476b7a14ceSPeter Wemm  .rela.plt       : { *(.rela.plt) }
48b05deb9bSPeter Wemm  .init           :
49b05deb9bSPeter Wemm  {
50b05deb9bSPeter Wemm    KEEP (*(.init))
51bd4e4054SEd Maste  } =0xCCCCCCCC
526b7a14ceSPeter Wemm  .plt            : { *(.plt) }
536b7a14ceSPeter Wemm  .text           :
546b7a14ceSPeter Wemm  {
55b05deb9bSPeter Wemm    *(.text .stub .text.* .gnu.linkonce.t.*)
568ba66bb8SDimitry Andric    KEEP (*(.text.*personality*))
576b7a14ceSPeter Wemm    /* .gnu.warning sections are handled specially by elf32.em.  */
586b7a14ceSPeter Wemm    *(.gnu.warning)
59bd4e4054SEd Maste  } =0xCCCCCCCC
60b05deb9bSPeter Wemm  .fini           :
61b05deb9bSPeter Wemm  {
62b05deb9bSPeter Wemm    KEEP (*(.fini))
63bd4e4054SEd Maste  } =0xCCCCCCCC
64b05deb9bSPeter Wemm  PROVIDE (__etext = .);
65b05deb9bSPeter Wemm  PROVIDE (_etext = .);
666b7a14ceSPeter Wemm  PROVIDE (etext = .);
67b05deb9bSPeter Wemm  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
686b7a14ceSPeter Wemm  .rodata1        : { *(.rodata1) }
6974cd06b4SEd Maste  .note.gnu.build-id : {
7074cd06b4SEd Maste    PROVIDE (__build_id_start = .);
7174cd06b4SEd Maste    *(.note.gnu.build-id)
7274cd06b4SEd Maste    PROVIDE (__build_id_end = .);
7374cd06b4SEd Maste  }
74b05deb9bSPeter Wemm  .eh_frame_hdr : { *(.eh_frame_hdr) }
758ba66bb8SDimitry Andric  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
768ba66bb8SDimitry Andric  .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
776b7a14ceSPeter Wemm  /* Adjust the address for the data segment.  We want to adjust up to
786b7a14ceSPeter Wemm     the same address within the page on the next page up.  */
798ba66bb8SDimitry Andric  . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
80beb24065SJonathan T. Looney  PROVIDE (brwsection = .);
818ba66bb8SDimitry Andric  /* Exception handling  */
828ba66bb8SDimitry Andric  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
838ba66bb8SDimitry Andric  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
848ba66bb8SDimitry Andric  /* Thread Local Storage sections  */
85b05deb9bSPeter Wemm  .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
86b05deb9bSPeter Wemm  .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
878ba66bb8SDimitry Andric  .preinit_array     :
888ba66bb8SDimitry Andric  {
898ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__preinit_array_start = .);
908ba66bb8SDimitry Andric    KEEP (*(.preinit_array))
918ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__preinit_array_end = .);
928ba66bb8SDimitry Andric  }
938ba66bb8SDimitry Andric  .init_array     :
948ba66bb8SDimitry Andric  {
958ba66bb8SDimitry Andric     PROVIDE_HIDDEN (__init_array_start = .);
96*e15b5ba7SZhenlei Huang     KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))
978ba66bb8SDimitry Andric     KEEP (*(.init_array))
988ba66bb8SDimitry Andric     PROVIDE_HIDDEN (__init_array_end = .);
998ba66bb8SDimitry Andric  }
1008ba66bb8SDimitry Andric  .fini_array     :
1018ba66bb8SDimitry Andric  {
1028ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__fini_array_start = .);
103*e15b5ba7SZhenlei Huang    KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))
1048ba66bb8SDimitry Andric    KEEP (*(.fini_array))
1058ba66bb8SDimitry Andric    PROVIDE_HIDDEN (__fini_array_end = .);
1068ba66bb8SDimitry Andric  }
107907cb02fSTim J. Robbins  _start_ctors = .;
108907cb02fSTim J. Robbins  PROVIDE (start_ctors = .);
1096b7a14ceSPeter Wemm  .ctors          :
1106b7a14ceSPeter Wemm  {
111b05deb9bSPeter Wemm    /* gcc uses crtbegin.o to find the start of
112b05deb9bSPeter Wemm       the constructors, so we make sure it is
113b05deb9bSPeter Wemm       first.  Because this is a wildcard, it
114b05deb9bSPeter Wemm       doesn't matter if the user does not
115b05deb9bSPeter Wemm       actually link against crtbegin.o; the
116b05deb9bSPeter Wemm       linker won't look for a file to match a
117b05deb9bSPeter Wemm       wildcard.  The wildcard also means that it
118b05deb9bSPeter Wemm       doesn't matter which directory crtbegin.o
119b05deb9bSPeter Wemm       is in.  */
120b05deb9bSPeter Wemm    KEEP (*crtbegin.o(.ctors))
1218ba66bb8SDimitry Andric    KEEP (*crtbegin?.o(.ctors))
122b05deb9bSPeter Wemm    /* We don't want to include the .ctor section from
1238ba66bb8SDimitry Andric       the crtend.o file until after the sorted ctors.
124b05deb9bSPeter Wemm       The .ctor section from the crtend file contains the
125b05deb9bSPeter Wemm       end of ctors marker and it must be last */
1268ba66bb8SDimitry Andric    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
127b05deb9bSPeter Wemm    KEEP (*(SORT(.ctors.*)))
128b05deb9bSPeter Wemm    KEEP (*(.ctors))
1296b7a14ceSPeter Wemm  }
130907cb02fSTim J. Robbins  _stop_ctors = .;
131907cb02fSTim J. Robbins  PROVIDE (stop_ctors = .);
1326b7a14ceSPeter Wemm  .dtors          :
1336b7a14ceSPeter Wemm  {
134b05deb9bSPeter Wemm    KEEP (*crtbegin.o(.dtors))
1358ba66bb8SDimitry Andric    KEEP (*crtbegin?.o(.dtors))
1368ba66bb8SDimitry Andric    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
137b05deb9bSPeter Wemm    KEEP (*(SORT(.dtors.*)))
138b05deb9bSPeter Wemm    KEEP (*(.dtors))
1396b7a14ceSPeter Wemm  }
140b05deb9bSPeter Wemm  .jcr            : { KEEP (*(.jcr)) }
1418ba66bb8SDimitry Andric  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
1428ba66bb8SDimitry Andric  .dynamic        : { *(.dynamic) }
1438ba66bb8SDimitry Andric  .got            : { *(.got) }
1448ba66bb8SDimitry Andric  . = DATA_SEGMENT_RELRO_END (24, .);
1458ba66bb8SDimitry Andric  .got.plt        : { *(.got.plt) }
14610c51654SMateusz Guzik  . = ALIGN(128);
147cf558f10SMateusz Guzik  .data.read_frequently :
148cf558f10SMateusz Guzik  {
14910c51654SMateusz Guzik    *(SORT_BY_ALIGNMENT(.data.read_frequently))
150cf558f10SMateusz Guzik  }
15121b73749SMateusz Guzik  .data.read_mostly :
15221b73749SMateusz Guzik  {
15321b73749SMateusz Guzik    *(.data.read_mostly)
15421b73749SMateusz Guzik  }
155726f22e0SMateusz Guzik  . = ALIGN(128);
15621b73749SMateusz Guzik  .data.exclusive_cache_line :
15721b73749SMateusz Guzik  {
15821b73749SMateusz Guzik    *(.data.exclusive_cache_line)
15921b73749SMateusz Guzik  }
160726f22e0SMateusz Guzik  . = ALIGN(128);
1618ba66bb8SDimitry Andric  .data           :
1628ba66bb8SDimitry Andric  {
1638ba66bb8SDimitry Andric    *(.data .data.* .gnu.linkonce.d.*)
1648ba66bb8SDimitry Andric    KEEP (*(.gnu.linkonce.d.*personality*))
1658ba66bb8SDimitry Andric  }
1668ba66bb8SDimitry Andric  .data1          : { *(.data1) }
1678ba66bb8SDimitry Andric  _edata = .; PROVIDE (edata = .);
1686b7a14ceSPeter Wemm  __bss_start = .;
1696b7a14ceSPeter Wemm  .bss            :
1706b7a14ceSPeter Wemm  {
1716b7a14ceSPeter Wemm   *(.dynbss)
172b05deb9bSPeter Wemm   *(.bss .bss.* .gnu.linkonce.b.*)
1736b7a14ceSPeter Wemm   *(COMMON)
17414327f53SMark Johnston   /* Ensure that the .bss section ends at a superpage boundary.
17514327f53SMark Johnston      This way it can be mapped using non-executable large pages. */
17614327f53SMark Johnston   . = ALIGN(0x200000);
1778ba66bb8SDimitry Andric  }
1788ba66bb8SDimitry Andric  _end = .; PROVIDE (end = .);
179b05deb9bSPeter Wemm  . = DATA_SEGMENT_END (.);
18037d6d682SWarner Losh
18137d6d682SWarner Losh  /* Debug */
18237d6d682SWarner Losh  INCLUDE debuginfo.ldscript
18323dff4fdSWarner Losh
1848ba66bb8SDimitry Andric  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
1858ba66bb8SDimitry Andric  /DISCARD/ : { *(.note.GNU-stack) }
1866b7a14ceSPeter Wemm}
187