blob: 7071163234f4375653c74bd2ced66dda459cb370 [file] [log] [blame]
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -07001/*
2 * Copyright (c) 2013-2014, Wind River Systems, Inc.
3 *
David B. Kinderac74d8b2017-01-18 17:01:01 -08004 * SPDX-License-Identifier: Apache-2.0
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -07005 */
6
Anas Nashif275ca602015-12-04 10:09:39 -05007/**
8 * @file
9 * @brief GCC toolchain linker defs
10 *
Dan Kalowskyda67b292015-10-20 09:42:33 -070011 * This header file defines the necessary macros used by the linker script for
12 * use with the GCC linker.
Anas Nashifea0d0b22015-07-01 17:22:39 -040013 */
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070014
15#ifndef __LINKER_TOOL_GCC_H
16#define __LINKER_TOOL_GCC_H
17
Andrew Boiea9a3cdd2016-04-26 10:22:39 -070018#if defined(CONFIG_ARM)
19 OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070020#elif defined(CONFIG_ARC)
Andrew Boiea9a3cdd2016-04-26 10:22:39 -070021 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 Boie94338952016-04-21 14:47:09 -070030#elif defined(CONFIG_NIOS2)
31 OUTPUT_FORMAT("elf32-littlenios2", "elf32-bignios2", "elf32-littlenios2")
Jean-Paul Etiennecd83e852017-01-11 00:24:30 +010032#elif defined(CONFIG_RISCV32)
33 OUTPUT_ARCH(riscv)
34 OUTPUT_FORMAT("elf32-littleriscv")
Mazen NEIFERaf2593e2017-01-22 17:25:40 +010035#elif defined(CONFIG_XTENSA)
36 /* Not needed */
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070037#else
Andrew Boiea9a3cdd2016-04-26 10:22:39 -070038 #error Arch not supported.
Anas Nashif9aeb0822015-06-19 23:37:23 -040039#endif
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070040
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 Ross6b3c5e82016-09-22 14:20:56 -070057 * 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-Gonzalez8ddf82c2015-04-10 16:44:37 -070074 * 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 Ross6b3c5e82016-09-22 14:20:56 -070092 * As for SECTION_PROLOGUE(), except that this one must (!) be used
David B. Kinder8b986d72017-04-18 15:56:26 -070093 * for data sections which on XIP platforms will have differing
Andy Ross6b3c5e82016-09-22 14:20:56 -070094 * 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-Gonzalez8ddf82c2015-04-10 16:44:37 -070097 */
Andy Ross6b3c5e82016-09-22 14:20:56 -070098#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-Gonzalez8ddf82c2015-04-10 16:44:37 -0700104
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -0700105#define SORT_BY_NAME(x) SORT(x)
106#define OPTIONAL
107
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -0700108#define COMMON_SYMBOLS *(COMMON)
109
110#endif /* !__LINKER_TOOL_GCC_H */