-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Description
Describe the bug
Non-ld linkers was broken with PR##80768
zephyr_linker_symbol() is only intended with simple math operations, as described by the function:
zephyr/cmake/modules/extensions.cmake
Lines 5366 to 5370 in d6c59f0
| # EXPR <expr> : Expression that defines the symbol. Due to linker limitations | |
| # all expressions should only contain simple math, such as | |
| # `+, -, *` and similar. The expression will go directly into the | |
| # linker, and all `@<symbol>@` will be replaced with the referred | |
| # symbol. |
The changes introduced in #80678 breaks this rule by introducing ADDR() which is a ld specific function not understood by non-ld linkers, such as armlink.
To Reproduce
- Setup Arm Conpiler 6, as described: https://docs.zephyrproject.org/latest/develop/toolchains/arm_compiler.html
- Build a simple sample, such as hello world:
west build -p -b qemu_cortex_m3 samples/hello_world/ -- -DCONFIG_CMAKE_LINKER_GENERATOR=y -DCONFIG_ARMCLANG_STD_LIBC=y - See error:
Error: L6630E: Invalid token start expected number or ( but found A at position 26 on line 498 Error: L6226E: Missing base address for region __ramfunc_region_start. "/projects/github/ncs/zephyr/build/zephyr/linker_zephyr_pre0.cmd", line 498 (column 26): Error: L6292E: Ignoring unknown attribute 'ADDR' specified for region __ramfunc_region_start. Error: L6630E: Invalid token start expected number or ( but found . at position 31 on line 498 Error: L6629E: Unmatched parentheses expecting ) but found . at position 31 on line 498 "/projects/github/ncs/zephyr/build/zephyr/linker_zephyr_pre0.cmd", line 498 (column 31): Error: L6228E: Expected '{', found '....'. "/projects/github/ncs/zephyr/build/zephyr/linker_zephyr_pre0.cmd", line 498 (column 31): Error: L6228E: Expected '}', found 'EOF'.
Offending line:
zephyr/cmake/linker_script/arm/linker.cmake
Line 146 in d6c59f0
| zephyr_linker_symbol(SYMBOL __ramfunc_region_start EXPR "ADDR(.ramfunc)") |
Expected behavior
Successful linking:
[2/109] Generating include/generated/zephyr/version.h
-- Zephyr version: 4.0.0-rc2 (/projects/github/ncs/zephyr), build: v4.0.0-rc2-84-g6984237c0638
[109/109] Linking C executable zephyr/zephyr.elf
Generating files from /projects/github/ncs/zephyr/build/zephyr/zephyr.elf for board: qemu_cortex_m3
Impact
Support for Arm Compiler 6 is broken.
Logs and console output
N/A
Environment (please complete the following information):
- OS: Linux
- Toolchain: Arm compiler 6
- Commit SHA or Version used: 6023d6a or never
Additional context
Offending line:
zephyr/cmake/linker_script/arm/linker.cmake
Line 146 in d6c59f0
| zephyr_linker_symbol(SYMBOL __ramfunc_region_start EXPR "ADDR(.ramfunc)") |