Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013-2014, Wind River Systems, Inc. |
| 3 | * |
David B. Kinder | ac74d8b | 2017-01-18 17:01:01 -0800 | [diff] [blame] | 4 | * SPDX-License-Identifier: Apache-2.0 |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
Anas Nashif | 275ca60 | 2015-12-04 10:09:39 -0500 | [diff] [blame] | 7 | /** |
| 8 | * @file |
| 9 | * @brief GCC toolchain linker defs |
| 10 | * |
Dan Kalowsky | da67b29 | 2015-10-20 09:42:33 -0700 | [diff] [blame] | 11 | * This header file defines the necessary macros used by the linker script for |
| 12 | * use with the GCC linker. |
Anas Nashif | ea0d0b2 | 2015-07-01 17:22:39 -0400 | [diff] [blame] | 13 | */ |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 14 | |
| 15 | #ifndef __LINKER_TOOL_GCC_H |
| 16 | #define __LINKER_TOOL_GCC_H |
| 17 | |
Andrew Boie | a9a3cdd | 2016-04-26 10:22:39 -0700 | [diff] [blame] | 18 | #if defined(CONFIG_ARM) |
| 19 | OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 20 | #elif defined(CONFIG_ARC) |
Andrew Boie | a9a3cdd | 2016-04-26 10:22:39 -0700 | [diff] [blame] | 21 | OUTPUT_FORMAT("elf32-littlearc", "elf32-bigarc", "elf32-littlearc") |
| 22 | #elif defined(CONFIG_X86) |
| 23 | #if defined(__IAMCU) |
| 24 | OUTPUT_FORMAT("elf32-iamcu") |
| 25 | OUTPUT_ARCH(iamcu:intel) |
| 26 | #else |
| 27 | OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") |
| 28 | OUTPUT_ARCH(i386) |
| 29 | #endif |
Andrew Boie | 9433895 | 2016-04-21 14:47:09 -0700 | [diff] [blame] | 30 | #elif defined(CONFIG_NIOS2) |
| 31 | OUTPUT_FORMAT("elf32-littlenios2", "elf32-bignios2", "elf32-littlenios2") |
Jean-Paul Etienne | cd83e85 | 2017-01-11 00:24:30 +0100 | [diff] [blame] | 32 | #elif defined(CONFIG_RISCV32) |
| 33 | OUTPUT_ARCH(riscv) |
| 34 | OUTPUT_FORMAT("elf32-littleriscv") |
Mazen NEIFER | af2593e | 2017-01-22 17:25:40 +0100 | [diff] [blame] | 35 | #elif defined(CONFIG_XTENSA) |
| 36 | /* Not needed */ |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 37 | #else |
Andrew Boie | a9a3cdd | 2016-04-26 10:22:39 -0700 | [diff] [blame] | 38 | #error Arch not supported. |
Anas Nashif | 9aeb082 | 2015-06-19 23:37:23 -0400 | [diff] [blame] | 39 | #endif |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 40 | |
| 41 | /* |
| 42 | * The GROUP_START() and GROUP_END() macros are used to define a group |
| 43 | * of sections located in one memory area, such as RAM, ROM, etc. |
| 44 | * The <where> parameter is the name of the memory area. |
| 45 | */ |
| 46 | #define GROUP_START(where) |
| 47 | #define GROUP_END(where) |
| 48 | |
| 49 | /* |
| 50 | * The GROUP_LINK_IN() macro is located at the end of the section |
| 51 | * description and tells the linker that this section is located in |
| 52 | * the memory area specified by <where> argument. |
| 53 | */ |
| 54 | #define GROUP_LINK_IN(where) > where |
| 55 | |
| 56 | /* |
Andy Ross | 6b3c5e8 | 2016-09-22 14:20:56 -0700 | [diff] [blame] | 57 | * As GROUP_LINK_IN(), but takes a second argument indicating the |
| 58 | * memory region (e.g. "ROM") for the load address. Used for |
| 59 | * initialized data sections that on XIP platforms must be copied at |
| 60 | * startup. |
| 61 | * |
| 62 | * And, because output directives in GNU ld are "sticky", this must |
| 63 | * also be used on the first section *after* such an initialized data |
| 64 | * section, specifying the same memory region (e.g. "RAM") for both |
| 65 | * vregion and lregion. |
| 66 | */ |
| 67 | #ifdef CONFIG_XIP |
| 68 | #define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT> lregion |
| 69 | #else |
| 70 | #define GROUP_DATA_LINK_IN(vregion, lregion) > vregion |
| 71 | #endif |
| 72 | |
| 73 | /* |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 74 | * The GROUP_FOLLOWS_AT() macro is located at the end of the section |
| 75 | * and indicates that the section does not specify an address at which |
| 76 | * it is to be loaded, but that it follows a section which did specify |
| 77 | * such an address |
| 78 | */ |
| 79 | #define GROUP_FOLLOWS_AT(where) AT > where |
| 80 | |
| 81 | /* |
| 82 | * The SECTION_PROLOGUE() macro is used to define the beginning of a section. |
| 83 | * The <name> parameter is the name of the section, and the <option> parameter |
| 84 | * is to include any special options such as (NOLOAD). Page alignment has its |
| 85 | * own parameter since it needs abstraction across the different toolchains. |
| 86 | * If not required, the <options> and <align> parameters should be left blank. |
| 87 | */ |
| 88 | |
| 89 | #define SECTION_PROLOGUE(name, options, align) name options : align |
| 90 | |
| 91 | /* |
Andy Ross | 6b3c5e8 | 2016-09-22 14:20:56 -0700 | [diff] [blame] | 92 | * As for SECTION_PROLOGUE(), except that this one must (!) be used |
David B. Kinder | 8b986d7 | 2017-04-18 15:56:26 -0700 | [diff] [blame] | 93 | * for data sections which on XIP platforms will have differing |
Andy Ross | 6b3c5e8 | 2016-09-22 14:20:56 -0700 | [diff] [blame] | 94 | * virtual and load addresses (i.e. they'll be copied into RAM at |
| 95 | * program startup). Such a section must (!) also use |
| 96 | * GROUP_LINK_IN_LMA to specify the correct output load address. |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 97 | */ |
Andy Ross | 6b3c5e8 | 2016-09-22 14:20:56 -0700 | [diff] [blame] | 98 | #ifdef CONFIG_XIP |
| 99 | #define SECTION_DATA_PROLOGUE(name, options, align) \ |
| 100 | name options : ALIGN_WITH_INPUT align |
| 101 | #else |
| 102 | #define SECTION_DATA_PROLOGUE(name, options, align) name options : align |
| 103 | #endif |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 104 | |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 105 | #define SORT_BY_NAME(x) SORT(x) |
| 106 | #define OPTIONAL |
| 107 | |
Inaky Perez-Gonzalez | 8ddf82c | 2015-04-10 16:44:37 -0700 | [diff] [blame] | 108 | #define COMMON_SYMBOLS *(COMMON) |
| 109 | |
| 110 | #endif /* !__LINKER_TOOL_GCC_H */ |