1/*
2 * Copyright (c) 2019-2020 Cobham Gaisler AB
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7/**
8 * @file
9 * @brief Linker command/script file for SPARC
10 */
11
12#include <soc.h>
13
14#include <zephyr/linker/sections.h>
15
16#include <zephyr/linker/linker-defs.h>
17#include <zephyr/linker/linker-tool.h>
18
19ENTRY(CONFIG_KERNEL_ENTRY)
20
21SECTIONS
22    {
23
24#include <zephyr/linker/rel-sections.ld>
25
26#ifdef CONFIG_LLEXT
27#include <zephyr/linker/llext-sections.ld>
28#endif
29
30    __rom_region_start = .;
31
32    SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
33	{
34		/* Trap table alignment required by SPARC V8 specification. */
35		. = ALIGN(0x1000);
36		__text_region_start = .;
37
38		*(.text.traptable)
39		*(.text)
40		*(.text.*)
41		*(.stub)
42		*(.gnu.linkonce.t.*)
43	} GROUP_LINK_IN(REGION_TEXT)
44
45    __text_region_end = .;
46    __rodata_region_start = .;
47
48#include <zephyr/linker/common-rom.ld>
49/* Located in generated directory. This file is populated by calling
50 * zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
51 */
52#include <snippets-rom-sections.ld>
53#include <zephyr/linker/thread-local-storage.ld>
54
55    SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)
56	{
57		 . = ALIGN(8);
58		 *(.rodata)
59		 *(.rodata.*)
60		 *(.gnu.linkonce.r.*)
61		 *(.rodata1)
62
63/* Located in generated directory. This file is populated by the
64 * zephyr_linker_sources() Cmake function.
65 */
66#include <snippets-rodata.ld>
67
68	} GROUP_LINK_IN(REGION_RODATA)
69
70#include <zephyr/linker/cplusplus-rom.ld>
71
72    __rodata_region_end = .;
73    __rodata_region_size = __rodata_region_end - __rodata_region_start;
74
75    __rom_region_end = .;
76
77    __data_region_load_start = .;
78
79
80    SECTION_PROLOGUE(.plt,,)
81	{
82		*(.plt)
83	}
84
85    SECTION_PROLOGUE(.iplt,,)
86	{
87		*(.iplt)
88	}
89
90    SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,)
91	{
92		 . = ALIGN(8);
93		 _image_ram_start = .;
94		 __data_region_start = .;
95		 __data_start = .;
96
97		 *(.data)
98		 *(.data.*)
99		 *(.gnu.linkonce.d.*)
100		SORT(CONSTRUCTORS)
101
102/* Located in generated directory. This file is populated by the
103 * zephyr_linker_sources() Cmake function.
104 */
105#include <snippets-rwdata.ld>
106
107		 __data_end = .;
108
109	}  GROUP_DATA_LINK_IN(REGION_DATA_VMA, REGION_DATA_LMA)
110    __data_size = __data_end - __data_start;
111    __data_load_start = LOADADDR(_DATA_SECTION_NAME);
112
113#include <zephyr/linker/common-ram.ld>
114
115/* Located in generated directory. This file is populated by the
116 * zephyr_linker_sources() Cmake function.
117 */
118#include <snippets-ram-sections.ld>
119
120/* Located in generated directory. This file is populated by the
121 * zephyr_linker_sources() Cmake function.
122 */
123#include <snippets-data-sections.ld>
124
125    __data_region_end = .;
126
127    SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),)
128	{
129		/*
130		 * For performance, BSS section is assumed to be 4 byte aligned and
131		 * a multiple of 4 bytes
132		 */
133		 . = ALIGN(4);
134		 __bss_start = .;
135		 *(.dynbss)
136		 *(.bss)
137		 *(.bss.*)
138		 *(.gnu.linkonce.b.*)
139		 COMMON_SYMBOLS
140		 /*
141		  * As memory is cleared in words only, it is simpler to ensure the BSS
142		  * section ends on a 4 byte boundary. This wastes a maximum of 3 bytes.
143		  */
144		  __bss_end = ALIGN(4);
145	}  GROUP_LINK_IN(REGION_BSS)
146
147    SECTION_PROLOGUE(_NOINIT_SECTION_NAME,(NOLOAD),)
148	{
149		/*
150		 * This section is used for non-initialized objects that
151		 * will not be cleared during the boot process.
152		 */
153		 *(.noinit)
154		 *(.noinit.*)
155
156/* Located in generated directory. This file is populated by the
157 * zephyr_linker_sources() Cmake function.
158 */
159#include <snippets-noinit.ld>
160
161	} GROUP_LINK_IN(REGION_BSS)
162
163#include <zephyr/linker/cplusplus-ram.ld>
164
165/* Located in generated directory. This file is populated by the
166 * zephyr_linker_sources() Cmake function.
167 */
168#include <snippets-sections.ld>
169
170#include <zephyr/linker/ram-end.ld>
171
172    GROUP_END(RAMABLE_REGION)
173
174#include <zephyr/linker/debug-sections.ld>
175
176    /DISCARD/ : { *(.note.GNU-stack) }
177    /DISCARD/ : { *(.gnu_debuglink) }
178    /DISCARD/ : { *(.gnu.lto_*) }
179
180    SECTION_PROLOGUE(.gnu.attributes, 0,)
181	{
182	KEEP(*(.gnu.attributes))
183	}
184
185}
186