Line data Source code
1 1 : /*
2 : * Copyright (c) 2023, Google, Inc.
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : /**
8 : * @file
9 : * @brief LLVM LLD linker defs
10 : *
11 : * This header file defines the necessary macros used by the linker script for
12 : * use with the LLD linker.
13 : */
14 :
15 : #ifndef ZEPHYR_INCLUDE_LINKER_LINKER_TOOL_LLD_H_
16 : #define ZEPHYR_INCLUDE_LINKER_LINKER_TOOL_LLD_H_
17 :
18 : #include <zephyr/linker/linker-tool-gcc.h>
19 :
20 : /**
21 : * @def SECTION_PROLOGUE
22 : *
23 : * The SECTION_PROLOGUE() macro is used to define the beginning of a section.
24 : *
25 : * When --omagic (-N) option is provided to LLD then only the first output
26 : * section of given region has aligned LMA (by default, without --omagic, LLD
27 : * aligns LMA and VMA of every section to the same value) and the difference
28 : * between VMA addresses (0 is this is the first section) is added.
29 : * The difference between LMA and VMA is constant for every section, so this
30 : * emulates ALIGN_WITH_INPUT option present in GNU LD (required by XIP systems).
31 : *
32 : * The --omagic flag is defined in cmake/linker/lld/target_baremetal.cmake
33 : *
34 : * @param name Name of the output section
35 : * @param options Section options, such as (NOLOAD), or left blank
36 : * @param align Alignment directives, such as SUBALIGN(). May be blank.
37 : */
38 : #undef SECTION_PROLOGUE
39 1 : #define SECTION_PROLOGUE(name, options, align) \
40 : name options : align
41 :
42 : /**
43 : * @def SECTION_DATA_PROLOGUE
44 : *
45 : * Same as for SECTION_PROLOGUE(), except that this one must be used
46 : * for data sections which on XIP platforms will have differing
47 : * virtual and load addresses (i.e. they'll be copied into RAM at
48 : * program startup). Such a section must also use
49 : * GROUP_DATA_LINK_IN to specify the correct output load address.
50 : *
51 : * This is equivalent to SECTION_PROLOGUE() when linking using LLD.
52 : *
53 : * @param name Name of the output section
54 : * @param options Section options, or left blank
55 : * @param align Alignment directives, such as SUBALIGN(). May be blank.
56 : */
57 : #undef SECTION_DATA_PROLOGUE
58 1 : #define SECTION_DATA_PROLOGUE(name, options, align) \
59 : SECTION_PROLOGUE(name, options, align)
60 :
61 : #endif /* ZEPHYR_INCLUDE_LINKER_LINKER_TOOL_LLD_H_ */
|