Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
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_ARCH_POSIX)
55 /* Not needed */
56#elif defined(CONFIG_SPARC)
57 OUTPUT_FORMAT("elf32-sparc")
58#else
59 #error Arch not supported.
60#endif
61
62/*
63 * The GROUP_START() and GROUP_END() macros are used to define a group
64 * of sections located in one memory area, such as RAM, ROM, etc.
65 * The <where> parameter is the name of the memory area.
66 */
67#define GROUP_START(where)
68#define GROUP_END(where)
69
86#if defined(CONFIG_ARCH_POSIX)
87#define GROUP_LINK_IN(where)
88#elif !defined(Z_VM_KERNEL)
89#define GROUP_LINK_IN(where) > where
90#endif
91
110#if defined(CONFIG_ARCH_POSIX)
111#define GROUP_ROM_LINK_IN(vregion, lregion)
112#elif defined(Z_VM_KERNEL)
113#define GROUP_ROM_LINK_IN(vregion, lregion) > vregion AT > lregion
114#else
115#define GROUP_ROM_LINK_IN(vregion, lregion) > lregion
116#endif
117
130#if defined(CONFIG_ARCH_POSIX)
131#define GROUP_DATA_LINK_IN(vregion, lregion)
132#elif defined(CONFIG_XIP) || defined(Z_VM_KERNEL)
133#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT > lregion
134#else
135#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion
136#endif
137
148#if defined(CONFIG_ARCH_POSIX)
149#define GROUP_NOLOAD_LINK_IN(vregion, lregion)
150#elif defined(Z_VM_KERNEL)
151#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion AT > lregion
152#elif defined(CONFIG_XIP)
153#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion AT > vregion
154#else
155#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion
156#endif
157
171#ifdef Z_VM_KERNEL
172/* If we have a virtual memory map we need ALIGN_WITH_INPUT in all sections */
173#define SECTION_PROLOGUE(name, options, align) \
174 name options : ALIGN_WITH_INPUT align
175#else
176#define SECTION_PROLOGUE(name, options, align) \
177 name options : align
178#endif
179
197#if defined(CONFIG_XIP)
198#define SECTION_DATA_PROLOGUE(name, options, align) \
199 name options : ALIGN_WITH_INPUT align
200#else
201#define SECTION_DATA_PROLOGUE(name, options, align) \
202 SECTION_PROLOGUE(name, options, align)
203#endif
204
205#define COMMON_SYMBOLS *(COMMON)
206
207#endif /* ZEPHYR_INCLUDE_LINKER_LINKER_TOOL_GCC_H_ */