Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | /* * Copyright (c) 2013-2014, Wind River Systems, Inc. * * SPDX-License-Identifier: Apache-2.0 */ /** * @file * @brief GCC toolchain linker defs * * This header file defines the necessary macros used by the linker script for * use with the GCC linker. */ #ifndef ZEPHYR_INCLUDE_LINKER_LINKER_TOOL_GCC_H_ #define ZEPHYR_INCLUDE_LINKER_LINKER_TOOL_GCC_H_ #include <sys/mem_manage.h> #if defined(CONFIG_ARM) #if defined(CONFIG_BIG_ENDIAN) #define OUTPUT_FORMAT_ "elf32-bigarm" #else #define OUTPUT_FORMAT_ "elf32-littlearm" #endif OUTPUT_FORMAT(OUTPUT_FORMAT_) #elif defined(CONFIG_ARM64) OUTPUT_FORMAT("elf64-littleaarch64") #elif defined(CONFIG_ARC) #if defined(CONFIG_64BIT) OUTPUT_FORMAT("elf64-littlearc") #else OUTPUT_FORMAT("elf32-littlearc", "elf32-bigarc", "elf32-littlearc") #endif #elif defined(CONFIG_X86) #if defined(CONFIG_X86_64) OUTPUT_FORMAT("elf64-x86-64") OUTPUT_ARCH("i386:x86-64") #else OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") OUTPUT_ARCH("i386") #endif #elif defined(CONFIG_NIOS2) OUTPUT_FORMAT("elf32-littlenios2", "elf32-bignios2", "elf32-littlenios2") #elif defined(CONFIG_RISCV) OUTPUT_ARCH("riscv") #ifdef CONFIG_64BIT OUTPUT_FORMAT("elf64-littleriscv") #else OUTPUT_FORMAT("elf32-littleriscv") #endif #elif defined(CONFIG_XTENSA) /* Not needed */ #elif defined(CONFIG_ARCH_POSIX) /* Not needed */ #elif defined(CONFIG_SPARC) OUTPUT_FORMAT("elf32-sparc") #else #error Arch not supported. #endif /* * The GROUP_START() and GROUP_END() macros are used to define a group * of sections located in one memory area, such as RAM, ROM, etc. * The <where> parameter is the name of the memory area. */ #define GROUP_START(where) #define GROUP_END(where) /** * @def GROUP_LINK_IN * * Route memory to a specified memory area * * The GROUP_LINK_IN() macro is located at the end of the section * description and tells the linker that this section is located in * the memory area specified by 'where' argument. * * This macro is intentionally undefined for CONFIG_MMU systems when * CONFIG_KERNEL_VM_BASE is not the same as CONFIG_SRAM_BASE_ADDRESS, * as both the LMA and VMA destinations must be known for all sections * as this corresponds to physical vs. virtual location. * * @param where Destination memory area */ #if defined(CONFIG_ARCH_POSIX) #define GROUP_LINK_IN(where) #elif !defined(Z_VM_KERNEL) #define GROUP_LINK_IN(where) > where #endif /** * @def GROUP_ROM_LINK_IN * * Route memory for a read-only section * * The GROUP_ROM_LINK_IN() macro is located at the end of the section * description and tells the linker that this a read-only section * that is physically placed at the 'lregion` argument. * * If CONFIG_XIP is active, the 'lregion' area is flash memory. * * If CONFIG_MMU is active, the vregion argument will be used to * determine where this is located in the virtual memory map, otherwise * it is ignored. * * @param vregion Output VMA (only used if CONFIG_MMU where LMA != VMA) * @param lregion Output LMA */ #if defined(CONFIG_ARCH_POSIX) #define GROUP_ROM_LINK_IN(vregion, lregion) #elif defined(Z_VM_KERNEL) #define GROUP_ROM_LINK_IN(vregion, lregion) > vregion AT > lregion #else #define GROUP_ROM_LINK_IN(vregion, lregion) > lregion #endif /** * @def GROUP_DATA_LINK_IN * * Route memory for read-write sections that are loaded. * * Used for initialized data sections that on XIP platforms must be copied at * startup. * * @param vregion Output VMA * @param lregion Output LMA (only used if CONFIG_MMU if VMA != LMA, * or CONFIG_XIP) */ #if defined(CONFIG_ARCH_POSIX) #define GROUP_DATA_LINK_IN(vregion, lregion) #elif defined(CONFIG_XIP) || defined(Z_VM_KERNEL) #define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT > lregion #else #define GROUP_DATA_LINK_IN(vregion, lregion) > vregion #endif /** * @def GROUP_NOLOAD_LINK_IN * * Route memory for read-write sections that are NOT loaded; typically this * is only used for 'BSS' and 'noinit'. * * @param vregion Output VMA * @param lregion Output LMA (only used if CONFIG_MMU if VMA != LMA, * corresponds to physical location) */ #if defined(CONFIG_ARCH_POSIX) #define GROUP_NOLOAD_LINK_IN(vregion, lregion) #elif defined(Z_VM_KERNEL) #define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion AT > lregion #elif defined(CONFIG_XIP) #define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion AT > vregion #else #define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion #endif /** * @def SECTION_PROLOGUE * * The SECTION_PROLOGUE() macro is used to define the beginning of a section. * * On MMU systems where VMA != LMA there is an implicit ALIGN_WITH_INPUT * specified. * * @param name Name of the output sectio * @param options Section options, such as (NOLOAD), or left blank * @param align Alignment directives, such as SUBALIGN(). ALIGN() itself is * not allowed. May be blank. */ #ifdef Z_VM_KERNEL /* If we have a virtual memory map we need ALIGN_WITH_INPUT in all sections */ #define SECTION_PROLOGUE(name, options, align) \ name options : ALIGN_WITH_INPUT align #else #define SECTION_PROLOGUE(name, options, align) \ name options : align #endif /** * @def SECTION_DATA_PROLOGUE * * Same as for SECTION_PROLOGUE(), except that this one must be used * for data sections which on XIP platforms will have differing * virtual and load addresses (i.e. they'll be copied into RAM at * program startup). Such a section must also use * GROUP_DATA_LINK_IN to specify the correct output load address. * * This is equivalent to SECTION_PROLOGUE() on non-XIP systems. * On XIP systems there is an implicit ALIGN_WITH_INPUT specified. * * @param name Name of the output sectio * @param options Section options, or left blank * @param align Alignment directives, such as SUBALIGN(). ALIGN() itself is * not allowed. May be blank. */ #if defined(CONFIG_XIP) #define SECTION_DATA_PROLOGUE(name, options, align) \ name options : ALIGN_WITH_INPUT align #else #define SECTION_DATA_PROLOGUE(name, options, align) \ SECTION_PROLOGUE(name, options, align) #endif #define COMMON_SYMBOLS *(COMMON) #endif /* ZEPHYR_INCLUDE_LINKER_LINKER_TOOL_GCC_H_ */ |