Zephyr Project API 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#elif defined(CONFIG_TRICORE)
67 OUTPUT_FORMAT("elf32-tricore")
68#else
69 #error Arch not supported.
70#endif
71
72/*
73 * The GROUP_START() and GROUP_END() macros are used to define a group
74 * of sections located in one memory area, such as RAM, ROM, etc.
75 * The <where> parameter is the name of the memory area.
76 */
77#define GROUP_START(where)
78#define GROUP_END(where)
79
96#if defined(CONFIG_ARCH_POSIX)
97#define GROUP_LINK_IN(where)
98#elif !defined(K_MEM_IS_VM_KERNEL)
99#define GROUP_LINK_IN(where) > where
100#endif
101
120#if defined(CONFIG_ARCH_POSIX)
121#define GROUP_ROM_LINK_IN(vregion, lregion)
122#elif defined(K_MEM_IS_VM_KERNEL)
123#define GROUP_ROM_LINK_IN(vregion, lregion) > vregion AT > lregion
124#else
125#define GROUP_ROM_LINK_IN(vregion, lregion) > lregion
126#endif
127
140#if defined(CONFIG_ARCH_POSIX)
141#define GROUP_DATA_LINK_IN(vregion, lregion)
142#elif defined(CONFIG_XIP) || defined(K_MEM_IS_VM_KERNEL)
143#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT > lregion
144#else
145#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion
146#endif
147
158#if defined(CONFIG_ARCH_POSIX)
159#define GROUP_NOLOAD_LINK_IN(vregion, lregion)
160#elif defined(K_MEM_IS_VM_KERNEL)
161#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion AT > lregion
162#elif defined(CONFIG_XIP)
163#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion AT > vregion
164#else
165#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion
166#endif
167
181#ifdef K_MEM_IS_VM_KERNEL
182/* If we have a virtual memory map we need ALIGN_WITH_INPUT in all sections */
183#define SECTION_PROLOGUE(name, options, align) \
184 name options : ALIGN_WITH_INPUT align
185#else
186#define SECTION_PROLOGUE(name, options, align) \
187 name options : align
188#endif
189
207#if defined(CONFIG_XIP)
208#define SECTION_DATA_PROLOGUE(name, options, align) \
209 name options : ALIGN_WITH_INPUT
210#else
211#define SECTION_DATA_PROLOGUE(name, options, align) \
212 SECTION_PROLOGUE(name, options, align)
213#endif
214
215#define COMMON_SYMBOLS *(COMMON)
216
217#endif /* ZEPHYR_INCLUDE_LINKER_LINKER_TOOL_GCC_H_ */