xref: /freebsd/sys/conf/ldscript.riscv (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
1/* $FreeBSD$ */
2OUTPUT_ARCH(riscv)
3ENTRY(_start)
4
5SEARCH_DIR(/usr/lib);
6SECTIONS
7{
8  /* Read-only sections, merged into text segment: */
9  . = kernbase;
10  /* The load address kernel_lma is set using --defsym= on the command line. */
11  .text      : AT(kernel_lma)
12  {
13    *(.text)
14    *(.stub)
15    /* .gnu.warning sections are handled specially by elf32.em.  */
16    *(.gnu.warning)
17    *(.gnu.linkonce.t*)
18  } =0x9090
19  _etext = .;
20  PROVIDE (etext = .);
21  .fini      : { *(.fini)    } =0x9090
22  .rodata    : { *(.rodata) *(.gnu.linkonce.r*) }
23  .rodata1   : { *(.rodata1) }
24   .interp     : { *(.interp) 	}
25  .hash          : { *(.hash)		}
26  .dynsym        : { *(.dynsym)		}
27  .dynstr        : { *(.dynstr)		}
28  .gnu.version   : { *(.gnu.version)	}
29  .gnu.version_d   : { *(.gnu.version_d)	}
30  .gnu.version_r   : { *(.gnu.version_r)	}
31  .note.gnu.build-id : {
32    PROVIDE (__build_id_start = .);
33    *(.note.gnu.build-id)
34    PROVIDE (__build_id_end = .);
35  }
36  .rel.text      :
37    { *(.rel.text) *(.rel.gnu.linkonce.t*) }
38  .rela.text     :
39    { *(.rela.text) *(.rela.gnu.linkonce.t*) }
40  .rel.data      :
41    { *(.rel.data) *(.rel.gnu.linkonce.d*) }
42  .rela.data     :
43    { *(.rela.data) *(.rela.gnu.linkonce.d*) }
44  .rel.rodata    :
45    { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
46  .rela.rodata   :
47    { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
48  .rel.got       : { *(.rel.got)		}
49  .rela.got      : { *(.rela.got)		}
50  .rel.ctors     : { *(.rel.ctors)	}
51  .rela.ctors    : { *(.rela.ctors)	}
52  .rel.dtors     : { *(.rel.dtors)	}
53  .rela.dtors    : { *(.rela.dtors)	}
54  .rel.init      : { *(.rel.init)	}
55  .rela.init     : { *(.rela.init)	}
56  .rel.fini      : { *(.rel.fini)	}
57  .rela.fini     : { *(.rela.fini)	}
58  .rel.bss       : { *(.rel.bss)		}
59  .rela.bss      : { *(.rela.bss)		}
60  .rel.plt       : { *(.rel.plt)		}
61  .rela.plt      : { *(.rela.plt)		}
62  .init          : { *(.init)	} =0x9090
63  .plt      : { *(.plt)	}
64
65  /* Adjust the address for the data segment.  We want to adjust up to
66     the same address within the page on the next page up.  */
67  . = ALIGN(0x1000) + (. & (0x1000 - 1)) ;
68  .data    :
69  {
70    *(.data)
71    *(.gnu.linkonce.d*)
72  }
73  .data1   : { *(.data1) }
74  . = ALIGN(32 / 8);
75  _start_ctors = .;
76  PROVIDE (start_ctors = .);
77  .ctors         :
78  {
79    *(.ctors)
80  }
81  _stop_ctors = .;
82  PROVIDE (stop_ctors = .);
83  .dtors         :
84  {
85    *(.dtors)
86  }
87  .got           : { *(.got.plt) *(.got) }
88  .dynamic       : { *(.dynamic) }
89  /* We want the small data sections together, so single-instruction offsets
90     can access them all, and initialized data all before uninitialized, so
91     we can shorten the on-disk segment size.  */
92  . = ALIGN(8);
93  .sdata     :
94  {
95    __global_pointer$ = . + 0x800;
96    *(.sdata)
97  }
98  _edata  =  .;
99  PROVIDE (edata = .);
100  /* Ensure __bss_start is associated with the next section in case orphan
101     sections are placed directly after .sdata, as has been seen to happen with
102     LLD.  */
103  . = ALIGN(8);
104  __bss_start = .;
105  .sbss      : { *(.sbss) *(.scommon) }
106  .bss       :
107  {
108   *(.dynbss)
109   *(.bss)
110   *(COMMON)
111  }
112  . = ALIGN(8);
113  _end = . ;
114  PROVIDE (end = .);
115  /* Stabs debugging sections.  */
116  .stab 0 : { *(.stab) }
117  .stabstr 0 : { *(.stabstr) }
118  .stab.excl 0 : { *(.stab.excl) }
119  .stab.exclstr 0 : { *(.stab.exclstr) }
120  .stab.index 0 : { *(.stab.index) }
121  .stab.indexstr 0 : { *(.stab.indexstr) }
122  .comment 0 : { *(.comment) }
123  /* DWARF debug sections.
124     Symbols in the DWARF debugging sections are relative to the beginning
125     of the section so we begin them at 0.  */
126  /* DWARF 1 */
127  .debug          0 : { *(.debug) }
128  .line           0 : { *(.line) }
129  /* GNU DWARF 1 extensions */
130  .debug_srcinfo  0 : { *(.debug_srcinfo) }
131  .debug_sfnames  0 : { *(.debug_sfnames) }
132  /* DWARF 1.1 and DWARF 2 */
133  .debug_aranges  0 : { *(.debug_aranges) }
134  .debug_pubnames 0 : { *(.debug_pubnames) }
135  /* DWARF 2 */
136  .debug_info     0 : { *(.debug_info) }
137  .debug_abbrev   0 : { *(.debug_abbrev) }
138  .debug_line     0 : { *(.debug_line) }
139  .debug_frame    0 : { *(.debug_frame) }
140  .debug_str      0 : { *(.debug_str) }
141  .debug_loc      0 : { *(.debug_loc) }
142  .debug_macinfo  0 : { *(.debug_macinfo) }
143  /* SGI/MIPS DWARF 2 extensions */
144  .debug_weaknames 0 : { *(.debug_weaknames) }
145  .debug_funcnames 0 : { *(.debug_funcnames) }
146  .debug_typenames 0 : { *(.debug_typenames) }
147  .debug_varnames  0 : { *(.debug_varnames) }
148  /* These must appear regardless of  .  */
149}
150