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