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