Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
linker-tool-gcc.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-2014, Wind River Systems, Inc.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
14
15#ifndef ZEPHYR_INCLUDE_LINKER_LINKER_TOOL_GCC_H_
16#define ZEPHYR_INCLUDE_LINKER_LINKER_TOOL_GCC_H_
17
18#include <zephyr/kernel/mm.h>
19
20#if defined(CONFIG_ARM)
21 #if defined(CONFIG_BIG_ENDIAN)
22 #define OUTPUT_FORMAT_ "elf32-bigarm"
23 #else
24 #define OUTPUT_FORMAT_ "elf32-littlearm"
25 #endif
26 OUTPUT_FORMAT(OUTPUT_FORMAT_)
27#elif defined(CONFIG_ARM64)
28 OUTPUT_FORMAT("elf64-littleaarch64")
29#elif defined(CONFIG_ARC)
30 #if defined(CONFIG_ISA_ARCV3) && defined(CONFIG_64BIT)
31 OUTPUT_FORMAT("elf64-littlearc64")
32 #elif defined(CONFIG_ISA_ARCV3) && !defined(CONFIG_64BIT)
33 OUTPUT_FORMAT("elf32-littlearc64")
34 #else
35 OUTPUT_FORMAT("elf32-littlearc", "elf32-bigarc", "elf32-littlearc")
36 #endif
37#elif defined(CONFIG_X86)
38 #if defined(CONFIG_X86_64)
39 OUTPUT_FORMAT("elf64-x86-64")
40 OUTPUT_ARCH("i386:x86-64")
41 #else
42 OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
43 OUTPUT_ARCH("i386")
44 #endif
45#elif defined(CONFIG_RISCV)
46 OUTPUT_ARCH("riscv")
47#ifdef CONFIG_64BIT
48 OUTPUT_FORMAT("elf64-littleriscv")
49#else
50 OUTPUT_FORMAT("elf32-littleriscv")
51#endif
52#elif defined(CONFIG_XTENSA)
53 /* Not needed */
54#elif defined(CONFIG_MIPS)
55 OUTPUT_ARCH("mips")
56#elif defined(CONFIG_ARCH_POSIX)
57 /* Not needed */
58#elif defined(CONFIG_SPARC)
59 OUTPUT_FORMAT("elf32-sparc")
60#elif defined(CONFIG_RX)
61 OUTPUT_FORMAT("elf32-rx-le")
62#elif defined(CONFIG_OPENRISC)
63 OUTPUT_FORMAT("elf32-or1k")
64#elif defined(CONFIG_HEXAGON)
65 OUTPUT_FORMAT("elf32-hexagon")
66#else
67 #error Arch not supported.
68#endif
69
70/*
71 * The GROUP_START() and GROUP_END() macros are used to define a group
72 * of sections located in one memory area, such as RAM, ROM, etc.
73 * The <where> parameter is the name of the memory area.
74 */
75#define GROUP_START(where)
76#define GROUP_END(where)
77
94#if defined(CONFIG_ARCH_POSIX)
95#define GROUP_LINK_IN(where)
96#elif !defined(K_MEM_IS_VM_KERNEL)
97#define GROUP_LINK_IN(where) > where
98#endif
99
118#if defined(CONFIG_ARCH_POSIX)
119#define GROUP_ROM_LINK_IN(vregion, lregion)
120#elif defined(K_MEM_IS_VM_KERNEL)
121#define GROUP_ROM_LINK_IN(vregion, lregion) > vregion AT > lregion
122#else
123#define GROUP_ROM_LINK_IN(vregion, lregion) > lregion
124#endif
125
138#if defined(CONFIG_ARCH_POSIX)
139#define GROUP_DATA_LINK_IN(vregion, lregion)
140#elif defined(CONFIG_XIP) || defined(K_MEM_IS_VM_KERNEL)
141#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT > lregion
142#else
143#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion
144#endif
145
156#if defined(CONFIG_ARCH_POSIX)
157#define GROUP_NOLOAD_LINK_IN(vregion, lregion)
158#elif defined(K_MEM_IS_VM_KERNEL)
159#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion AT > lregion
160#elif defined(CONFIG_XIP)
161#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion AT > vregion
162#else
163#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion
164#endif
165
179#ifdef K_MEM_IS_VM_KERNEL
180/* If we have a virtual memory map we need ALIGN_WITH_INPUT in all sections */
181#define SECTION_PROLOGUE(name, options, align) \
182 name options : ALIGN_WITH_INPUT align
183#else
184#define SECTION_PROLOGUE(name, options, align) \
185 name options : align
186#endif
187
205#if defined(CONFIG_XIP)
206#define SECTION_DATA_PROLOGUE(name, options, align) \
207 name options : ALIGN_WITH_INPUT
208#else
209#define SECTION_DATA_PROLOGUE(name, options, align) \
210 SECTION_PROLOGUE(name, options, align)
211#endif
212
213#define COMMON_SYMBOLS *(COMMON)
214
215#endif /* ZEPHYR_INCLUDE_LINKER_LINKER_TOOL_GCC_H_ */