Ld
Jump to navigation
Jump to search
GNU and LLVM linker notes.
Overview
This NN page a starting point for notes, links to external references and examples of `ld` linker scripts. As of page creation time 2024 Q1 there appear to be two major linker variants: GNU ld and LLVM linker implementation.
Introductory References
- https://lld.llvm.org/ELF/linker_script.html . . . LLVM linker documentation
Use of 'KEEP' key word in linker scripts:
How to place C global variables at a particular address:
- https://global.epson.com/products_and_drivers/semicon/products/micro_controller/pdf/lnk_03e.pdf
- https://stackoverflow.com/questions/39998485/how-to-access-variable-define-in-linker-script-in-c
A reference to gcc linker documentation:
2024-08-05 MON
Interesting linker script macro in one of Zephy's header files . . .
"
167
168 #ifndef BUILD_ASSERT
169 /* Compile-time assertion that makes the build to fail.
170 * Common implementation swallows the message.
171 */
172 #define BUILD_ASSERT(EXPR, MSG...) \
173 enum _CONCAT(__build_assert_enum, __COUNTER__) { \
174 _CONCAT(__build_assert, __COUNTER__) = 1 / !!(EXPR) \
175 }
176 #endif
177
178 /*
179 * This is meant to be used in conjunction with __in_section() and similar
180 * where scattered structure instances are concatenated together by the linker
181 * and walked by the code at run time just like a contiguous array of such
182 * structures.
183 *
184 * Assemblers and linkers may insert alignment padding by default whose
185 * size is larger than the natural alignment for those structures when
186 * gathering various section segments together, messing up the array walk.
187 * To prevent this, we need to provide an explicit alignment not to rely
188 * on the default that might just work by luck.
189 *
190 * Alignment statements in linker scripts are not sufficient as
191 * the assembler may add padding by itself to each segment when switching
192 * between sections within the same file even if it merges many such segments
193 * into a single section in the end.
194 */
195 #define Z_DECL_ALIGN(type) __aligned(__alignof(type)) type
196
"~/projects-sandbox/workspace-for-nexus/zephyr/include/zephyr/toolchain/common.h" 214 lines --99%--