890086aadd078c966861955bf7561f0f4ab1ecfe
[dragonfly.git] / sys / platform / pc64 / conf / ldscript.x86_64
1 /* Default linker script, for normal executables */
2 OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
3               "elf64-x86-64")
4 OUTPUT_ARCH(i386:x86-64)
5 ENTRY(btext)
6 SEARCH_DIR("/usr/lib");
7 SECTIONS
8 {
9   /* Read-only sections, merged into text segment: */
10   kernphys = 0x200000;
11   kernmxps = CONSTANT (MAXPAGESIZE);
12   kernpage = CONSTANT (COMMONPAGESIZE);
13   . = kernbase + kernphys + SIZEOF_HEADERS;
14   .interp         : { *(.interp) }
15   .note.gnu.build-id : { *(.note.gnu.build-id) }
16   .hash           : { *(.hash) }
17   .gnu.hash       : { *(.gnu.hash) }
18   .dynsym         : { *(.dynsym) }
19   .dynstr         : { *(.dynstr) }
20   .gnu.version    : { *(.gnu.version) }
21   .gnu.version_d  : { *(.gnu.version_d) }
22   .gnu.version_r  : { *(.gnu.version_r) }
23   .rela.init      : { *(.rela.init) }
24   .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
25   .rela.fini      : { *(.rela.fini) }
26   .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
27   .rela.data.rel.ro   : { *(.rela.data.rel.ro* .rela.gnu.linkonce.d.rel.ro.*) }
28   .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
29   .rela.tdata     : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
30   .rela.tbss      : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
31   .rela.ctors     : { *(.rela.ctors) }
32   .rela.dtors     : { *(.rela.dtors) }
33   .rela.got       : { *(.rela.got) }
34   .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
35   .rela.ldata     : { *(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*) }
36   .rela.lbss      : { *(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*) }
37   .rela.lrodata   : { *(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*) }
38   .rela.ifunc     : { *(.rela.ifunc) }
39   .rela.plt       :
40     {
41       *(.rela.plt)
42       PROVIDE_HIDDEN (__rela_iplt_start = .);
43       *(.rela.iplt)
44       PROVIDE_HIDDEN (__rela_iplt_end = .);
45     }
46   .init           :
47   {
48     KEEP (*(.init))
49   } =0x90909090
50   .plt            : { *(.plt) *(.iplt) }
51   .text           :
52   {
53     *(.text.unlikely .text.*_unlikely)
54     *(.text.exit .text.exit.*)
55     *(.text.startup .text.startup.*)
56     *(.text.hot .text.hot.*)
57     *(.text .stub .text.* .gnu.linkonce.t.*)
58     /* .gnu.warning sections are handled specially by elf32.em.  */
59     *(.gnu.warning)
60   } =0x90909090
61   .fini           :
62   {
63     KEEP (*(.fini))
64   } =0x90909090
65   PROVIDE (__etext = .);
66   PROVIDE (_etext = .);
67   PROVIDE (etext = .);
68   .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
69   .rodata1        : { *(.rodata1) }
70   .eh_frame_hdr : { *(.eh_frame_hdr) }
71   .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
72   .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table
73   .gcc_except_table.*) }
74   /* These sections are generated by the Sun/Oracle C++ compiler.  */
75   .exception_ranges   : ONLY_IF_RO { *(.exception_ranges
76   .exception_ranges*) }
77   /* Adjust the address for the data segment.  We want to adjust up to
78      the same address within the page on the next page up.  */
79   . = ALIGN (kernmxps) - ((kernmxps - .) & (kernmxps - 1));
80   . = DATA_SEGMENT_ALIGN (kernmxps, kernpage);
81   /* Exception handling  */
82   .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
83   .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
84   .exception_ranges   : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
85   /* Thread Local Storage sections  */
86   .tdata          : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
87   .tbss           : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
88   .preinit_array     :
89   {
90     PROVIDE_HIDDEN (__preinit_array_start = .);
91     KEEP (*(.preinit_array))
92     PROVIDE_HIDDEN (__preinit_array_end = .);
93   }
94   .init_array     :
95   {
96      PROVIDE_HIDDEN (__init_array_start = .);
97      KEEP (*(SORT(.init_array.*)))
98      KEEP (*(.init_array))
99      PROVIDE_HIDDEN (__init_array_end = .);
100   }
101   .fini_array     :
102   {
103     PROVIDE_HIDDEN (__fini_array_start = .);
104     KEEP (*(SORT(.fini_array.*)))
105     KEEP (*(.fini_array))
106     PROVIDE_HIDDEN (__fini_array_end = .);
107   }
108   _start_ctors = .;
109   PROVIDE (start_ctors = .);
110   .ctors          :
111   {
112     /* gcc uses crtbegin.o to find the start of
113        the constructors, so we make sure it is
114        first.  Because this is a wildcard, it
115        doesn't matter if the user does not
116        actually link against crtbegin.o; the
117        linker won't look for a file to match a
118        wildcard.  The wildcard also means that it
119        doesn't matter which directory crtbegin.o
120        is in.  */
121     KEEP (*crtbegin.o(.ctors))
122     KEEP (*crtbegin?.o(.ctors))
123     /* We don't want to include the .ctor section from
124        the crtend.o file until after the sorted ctors.
125        The .ctor section from the crtend file contains the
126        end of ctors marker and it must be last */
127     KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
128     KEEP (*(SORT(.ctors.*)))
129     KEEP (*(.ctors))
130   }
131   _stop_ctors = .;
132   PROVIDE (stop_ctors = .);
133   .dtors          :
134   {
135     KEEP (*crtbegin.o(.dtors))
136     KEEP (*crtbegin?.o(.dtors))
137     KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
138     KEEP (*(SORT(.dtors.*)))
139     KEEP (*(.dtors))
140   }
141   .jcr            : { KEEP (*(.jcr)) }
142   .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
143   .dynamic        : { *(.dynamic) }
144   .got            : { *(.got) *(.igot) }
145   . = DATA_SEGMENT_RELRO_END (24, .);
146   .got.plt        : { *(.got.plt)  *(.igot.plt) }
147   .data           :
148   {
149     *(.data .data.* .gnu.linkonce.d.*)
150     SORT(CONSTRUCTORS)
151   }
152   .data1          : { *(.data1) }
153   _edata = .; PROVIDE (edata = .);
154   __bss_start = .;
155   .bss            :
156   {
157    *(.dynbss)
158    *(.bss .bss.* .gnu.linkonce.b.*)
159    *(COMMON)
160    /* Align here to ensure that the .bss section occupies space up to
161       _end.  Align after .bss to ensure correct alignment even if the
162       .bss section disappears because there are no input sections.
163       FIXME: Why do we need it? When there is no .bss section, we don't
164       pad the .data section.  */
165    . = ALIGN(. != 0 ? 64 / 8 : 1);
166   }
167   .lbss   :
168   {
169     *(.dynlbss)
170     *(.lbss .lbss.* .gnu.linkonce.lb.*)
171     *(LARGE_COMMON)
172   }
173   . = ALIGN(64 / 8);
174   .lrodata   ALIGN(kernmxps) + (. & (kernmxps - 1)) :
175   {
176     *(.lrodata .lrodata.* .gnu.linkonce.lr.*)
177   }
178   .ldata   ALIGN(kernmxps) + (. & (kernmxps - 1)) :
179   {
180     *(.ldata .ldata.* .gnu.linkonce.l.*)
181     . = ALIGN(. != 0 ? 64 / 8 : 1);
182   }
183   . = ALIGN(64 / 8);
184   _end = .; PROVIDE (end = .);
185   . = DATA_SEGMENT_END (.);
186   /* Stabs debugging sections.  */
187   .stab          0 : { *(.stab) }
188   .stabstr       0 : { *(.stabstr) }
189   .stab.excl     0 : { *(.stab.excl) }
190   .stab.exclstr  0 : { *(.stab.exclstr) }
191   .stab.index    0 : { *(.stab.index) }
192   .stab.indexstr 0 : { *(.stab.indexstr) }
193   .comment       0 : { *(.comment) }
194   /* DWARF debug sections.
195      Symbols in the DWARF debugging sections are relative to the beginning
196      of the section so we begin them at 0.  */
197   /* DWARF 1 */
198   .debug          0 : { *(.debug) }
199   .line           0 : { *(.line) }
200   /* GNU DWARF 1 extensions */
201   .debug_srcinfo  0 : { *(.debug_srcinfo) }
202   .debug_sfnames  0 : { *(.debug_sfnames) }
203   /* DWARF 1.1 and DWARF 2 */
204   .debug_aranges  0 : { *(.debug_aranges) }
205   .debug_pubnames 0 : { *(.debug_pubnames) }
206   /* DWARF 2 */
207   .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
208   .debug_abbrev   0 : { *(.debug_abbrev) }
209   .debug_line     0 : { *(.debug_line) }
210   .debug_frame    0 : { *(.debug_frame) }
211   .debug_str      0 : { *(.debug_str) }
212   .debug_loc      0 : { *(.debug_loc) }
213   .debug_macinfo  0 : { *(.debug_macinfo) }
214   /* SGI/MIPS DWARF 2 extensions */
215   .debug_weaknames 0 : { *(.debug_weaknames) }
216   .debug_funcnames 0 : { *(.debug_funcnames) }
217   .debug_typenames 0 : { *(.debug_typenames) }
218   .debug_varnames  0 : { *(.debug_varnames) }
219   /* DWARF 3 */
220   .debug_pubtypes 0 : { *(.debug_pubtypes) }
221   .debug_ranges   0 : { *(.debug_ranges) }
222   .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
223   /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
224 }