Zephyr API Documentation  3.0.0
A Scalable Open Source RTOS
3.0.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 <sys/mem_manage.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_64BIT)
31 OUTPUT_FORMAT("elf64-littlearc")
32 #else
33 OUTPUT_FORMAT("elf32-littlearc", "elf32-bigarc", "elf32-littlearc")
34 #endif
35#elif defined(CONFIG_X86)
36 #if defined(CONFIG_X86_64)
37 OUTPUT_FORMAT("elf64-x86-64")
38 OUTPUT_ARCH("i386:x86-64")
39 #else
40 OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
41 OUTPUT_ARCH("i386")
42 #endif
43#elif defined(CONFIG_NIOS2)
44 OUTPUT_FORMAT("elf32-littlenios2", "elf32-bignios2", "elf32-littlenios2")
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#else
61 #error Arch not supported.
62#endif
63
64/*
65 * The GROUP_START() and GROUP_END() macros are used to define a group
66 * of sections located in one memory area, such as RAM, ROM, etc.
67 * The <where> parameter is the name of the memory area.
68 */
69#define GROUP_START(where)
70#define GROUP_END(where)
71
88#if defined(CONFIG_ARCH_POSIX)
89#define GROUP_LINK_IN(where)
90#elif !defined(Z_VM_KERNEL)
91#define GROUP_LINK_IN(where) > where
92#endif
93
112#if defined(CONFIG_ARCH_POSIX)
113#define GROUP_ROM_LINK_IN(vregion, lregion)
114#elif defined(Z_VM_KERNEL)
115#define GROUP_ROM_LINK_IN(vregion, lregion) > vregion AT > lregion
116#else
117#define GROUP_ROM_LINK_IN(vregion, lregion) > lregion
118#endif
119
132#if defined(CONFIG_ARCH_POSIX)
133#define GROUP_DATA_LINK_IN(vregion, lregion)
134#elif defined(CONFIG_XIP) || defined(Z_VM_KERNEL)
135#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT > lregion
136#else
137#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion
138#endif
139
150#if defined(CONFIG_ARCH_POSIX)
151#define GROUP_NOLOAD_LINK_IN(vregion, lregion)
152#elif defined(Z_VM_KERNEL)
153#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion AT > lregion
154#elif defined(CONFIG_XIP)
155#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion AT > vregion
156#else
157#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion
158#endif
159
173#ifdef Z_VM_KERNEL
174/* If we have a virtual memory map we need ALIGN_WITH_INPUT in all sections */
175#define SECTION_PROLOGUE(name, options, align) \
176 name options : ALIGN_WITH_INPUT align
177#else
178#define SECTION_PROLOGUE(name, options, align) \
179 name options : align
180#endif
181
199#if defined(CONFIG_XIP)
200#define SECTION_DATA_PROLOGUE(name, options, align) \
201 name options : ALIGN_WITH_INPUT align
202#else
203#define SECTION_DATA_PROLOGUE(name, options, align) \
204 SECTION_PROLOGUE(name, options, align)
205#endif
206
207#define COMMON_SYMBOLS *(COMMON)
208
209#endif /* ZEPHYR_INCLUDE_LINKER_LINKER_TOOL_GCC_H_ */