xref: /netbsd-src/sys/arch/amd64/conf/kern.ldscript (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1/*	$NetBSD: kern.ldscript,v 1.1 2003/04/26 18:39:35 fvdl Exp $	*/
2
3/*
4 * Kernel linker script for NetBSD/amd64.  This script is based on
5 * elf_x86_64.x, but puts _etext after all of the read-only sections.
6 */
7
8/* Default linker script, for normal executables */
9OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
10	      "elf64-x86-64")
11OUTPUT_ARCH(i386:x86-64)
12ENTRY(_start)
13 SEARCH_DIR(/usr/local/gnu/x86_64-unknown-netbsd/lib);
14/* Do we need any of these for elf?
15   __DYNAMIC = 0;    */
16SECTIONS
17{
18  /* Read-only sections, merged into text segment: */
19  . = 0x400000 + SIZEOF_HEADERS;
20  .interp         : { *(.interp) }
21  .hash           : { *(.hash) }
22  .dynsym         : { *(.dynsym) }
23  .dynstr         : { *(.dynstr) }
24  .gnu.version    : { *(.gnu.version) }
25  .gnu.version_d  : { *(.gnu.version_d) }
26  .gnu.version_r  : { *(.gnu.version_r) }
27  .rel.init       : { *(.rel.init) }
28  .rela.init      : { *(.rela.init) }
29  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
30  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
31  .rel.fini       : { *(.rel.fini) }
32  .rela.fini      : { *(.rela.fini) }
33  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
34  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
35  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
36  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
37  .rel.ctors      : { *(.rel.ctors) }
38  .rela.ctors     : { *(.rela.ctors) }
39  .rel.dtors      : { *(.rel.dtors) }
40  .rela.dtors     : { *(.rela.dtors) }
41  .rel.got        : { *(.rel.got) }
42  .rela.got       : { *(.rela.got) }
43  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
44  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
45  .rel.plt        : { *(.rel.plt) }
46  .rela.plt       : { *(.rela.plt) }
47  .init           :
48  {
49    KEEP (*(.init))
50  } =0x90909090
51  .plt            : { *(.plt) }
52  .text           :
53  {
54    *(.text .stub .text.* .gnu.linkonce.t.*)
55    /* .gnu.warning sections are handled specially by elf32.em.  */
56    *(.gnu.warning)
57  } =0x90909090
58  .fini           :
59  {
60    KEEP (*(.fini))
61  } =0x90909090
62  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
63  .rodata1        : { *(.rodata1) }
64  .eh_frame_hdr : { *(.eh_frame_hdr) }
65  PROVIDE (__etext = .);
66  PROVIDE (_etext = .);
67  PROVIDE (etext = .);
68  /* Adjust the address for the data segment.  We want to adjust up to
69     the same address within the page on the next page up.  */
70  . = ALIGN(0x100000) + (. & (0x100000 - 1));
71  .data           :
72  {
73    *(.data .data.* .gnu.linkonce.d.*)
74    SORT(CONSTRUCTORS)
75  }
76  .data1          : { *(.data1) }
77  .eh_frame       : { KEEP (*(.eh_frame)) }
78  .gcc_except_table   : { *(.gcc_except_table) }
79  .dynamic        : { *(.dynamic) }
80  .ctors          :
81  {
82    /* gcc uses crtbegin.o to find the start of
83       the constructors, so we make sure it is
84       first.  Because this is a wildcard, it
85       doesn't matter if the user does not
86       actually link against crtbegin.o; the
87       linker won't look for a file to match a
88       wildcard.  The wildcard also means that it
89       doesn't matter which directory crtbegin.o
90       is in.  */
91    KEEP (*crtbegin.o(.ctors))
92    /* We don't want to include the .ctor section from
93       from the crtend.o file until after the sorted ctors.
94       The .ctor section from the crtend file contains the
95       end of ctors marker and it must be last */
96    KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
97    KEEP (*(SORT(.ctors.*)))
98    KEEP (*(.ctors))
99  }
100  .dtors          :
101  {
102    KEEP (*crtbegin.o(.dtors))
103    KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
104    KEEP (*(SORT(.dtors.*)))
105    KEEP (*(.dtors))
106  }
107  .jcr            : { KEEP (*(.jcr)) }
108  .got            : { *(.got.plt) *(.got) }
109  _edata = .;
110  PROVIDE (edata = .);
111  __bss_start = .;
112  .bss            :
113  {
114   *(.dynbss)
115   *(.bss .bss.* .gnu.linkonce.b.*)
116   *(COMMON)
117   /* Align here to ensure that the .bss section occupies space up to
118      _end.  Align after .bss to ensure correct alignment even if the
119      .bss section disappears because there are no input sections.  */
120   . = ALIGN(64 / 8);
121  }
122  . = ALIGN(64 / 8);
123  _end = .;
124  PROVIDE (end = .);
125  /* Stabs debugging sections.  */
126  .stab          0 : { *(.stab) }
127  .stabstr       0 : { *(.stabstr) }
128  .stab.excl     0 : { *(.stab.excl) }
129  .stab.exclstr  0 : { *(.stab.exclstr) }
130  .stab.index    0 : { *(.stab.index) }
131  .stab.indexstr 0 : { *(.stab.indexstr) }
132  .comment       0 : { *(.comment) }
133  /* DWARF debug sections.
134     Symbols in the DWARF debugging sections are relative to the beginning
135     of the section so we begin them at 0.  */
136  /* DWARF 1 */
137  .debug          0 : { *(.debug) }
138  .line           0 : { *(.line) }
139  /* GNU DWARF 1 extensions */
140  .debug_srcinfo  0 : { *(.debug_srcinfo) }
141  .debug_sfnames  0 : { *(.debug_sfnames) }
142  /* DWARF 1.1 and DWARF 2 */
143  .debug_aranges  0 : { *(.debug_aranges) }
144  .debug_pubnames 0 : { *(.debug_pubnames) }
145  /* DWARF 2 */
146  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
147  .debug_abbrev   0 : { *(.debug_abbrev) }
148  .debug_line     0 : { *(.debug_line) }
149  .debug_frame    0 : { *(.debug_frame) }
150  .debug_str      0 : { *(.debug_str) }
151  .debug_loc      0 : { *(.debug_loc) }
152  .debug_macinfo  0 : { *(.debug_macinfo) }
153  /* SGI/MIPS DWARF 2 extensions */
154  .debug_weaknames 0 : { *(.debug_weaknames) }
155  .debug_funcnames 0 : { *(.debug_funcnames) }
156  .debug_typenames 0 : { *(.debug_typenames) }
157  .debug_varnames  0 : { *(.debug_varnames) }
158}
159