Zephyr API 3.6.99
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
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_NIOS2)
46 OUTPUT_FORMAT("elf32-littlenios2", "elf32-bignios2", "elf32-littlenios2")
47#elif defined(CONFIG_RISCV)
48 OUTPUT_ARCH("riscv")
49#ifdef CONFIG_64BIT
50 OUTPUT_FORMAT("elf64-littleriscv")
51#else
52 OUTPUT_FORMAT("elf32-littleriscv")
53#endif
54#elif defined(CONFIG_XTENSA)
55 /* Not needed */
56#elif defined(CONFIG_MIPS)
57 OUTPUT_ARCH("mips")
58#elif defined(CONFIG_ARCH_POSIX)
59 /* Not needed */
60#elif defined(CONFIG_SPARC)
61 OUTPUT_FORMAT("elf32-sparc")
62#else
63 #error Arch not supported.
64#endif
65
66/*
67 * The GROUP_START() and GROUP_END() macros are used to define a group
68 * of sections located in one memory area, such as RAM, ROM, etc.
69 * The <where> parameter is the name of the memory area.
70 */
71#define GROUP_START(where)
72#define GROUP_END(where)
73
90#if defined(CONFIG_ARCH_POSIX)
91#define GROUP_LINK_IN(where)
92#elif !defined(K_MEM_IS_VM_KERNEL)
93#define GROUP_LINK_IN(where) > where
94#endif
95
114#if defined(CONFIG_ARCH_POSIX)
115#define GROUP_ROM_LINK_IN(vregion, lregion)
116#elif defined(K_MEM_IS_VM_KERNEL)
117#define GROUP_ROM_LINK_IN(vregion, lregion) > vregion AT > lregion
118#else
119#define GROUP_ROM_LINK_IN(vregion, lregion) > lregion
120#endif
121
134#if defined(CONFIG_ARCH_POSIX)
135#define GROUP_DATA_LINK_IN(vregion, lregion)
136#elif defined(CONFIG_XIP) || defined(K_MEM_IS_VM_KERNEL)
137#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT > lregion
138#else
139#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion
140#endif
141
152#if defined(CONFIG_ARCH_POSIX)
153#define GROUP_NOLOAD_LINK_IN(vregion, lregion)
154#elif defined(K_MEM_IS_VM_KERNEL)
155#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion AT > lregion
156#elif defined(CONFIG_XIP)
157#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion AT > vregion
158#else
159#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion
160#endif
161
175#ifdef K_MEM_IS_VM_KERNEL
176/* If we have a virtual memory map we need ALIGN_WITH_INPUT in all sections */
177#define SECTION_PROLOGUE(name, options, align) \
178 name options : ALIGN_WITH_INPUT align
179#else
180#define SECTION_PROLOGUE(name, options, align) \
181 name options : align
182#endif
183
201#if defined(CONFIG_XIP)
202#define SECTION_DATA_PROLOGUE(name, options, align) \
203 name options : ALIGN_WITH_INPUT
204#else
205#define SECTION_DATA_PROLOGUE(name, options, align) \
206 SECTION_PROLOGUE(name, options, align)
207#endif
208
209#define COMMON_SYMBOLS *(COMMON)
210
211#endif /* ZEPHYR_INCLUDE_LINKER_LINKER_TOOL_GCC_H_ */