From 77a7615eb28e13ba43859ba54abba7e4be2a5ae2 Mon Sep 17 00:00:00 2001 From: Torsten Rasmussen Date: Fri, 7 Jan 2022 12:36:25 +0100 Subject: [PATCH] linker: update posix linker template, linker.ld The function `zephyr_linker_sources()` states: > When placing into NOINIT, RWDATA, RODATA, ROM_START, the contents of > the files will be placed inside an output section, so assume the > section definition is already present. However, in the posix linker.ld template the NOINIT, RWDATA, RODATA, and ROM_START was not placed inside a pre-defined output section, which means that linker scripts created for native_posix when `zephyr_linker_sources()` is used are invalid This result in the following failure: > /usr/bin/ld:zephyr/linker_zephyr_prebuilt.cmd:81: syntax error > collect2: error: ld returned 1 exit status This PR fixes this issue be predefining output sections according to the documented behavior. Signed-off-by: Torsten Rasmussen --- include/arch/posix/linker.ld | 44 +++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/include/arch/posix/linker.ld b/include/arch/posix/linker.ld index d56260e76af..dccb4593c58 100644 --- a/include/arch/posix/linker.ld +++ b/include/arch/posix/linker.ld @@ -22,22 +22,31 @@ SECTIONS { -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. - */ -#include +SECTION_PROLOGUE(rom_start,,) +{ + /* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ + #include +} GROUP_LINK_IN(ROMABLE_REGION) #include -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. - */ -#include +SECTION_PROLOGUE(_RODATA_SECTION_NAME,,) +{ + /* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ + #include +} GROUP_LINK_IN(ROMABLE_REGION) -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. - */ -#include +SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,) +{ + /* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ + #include +} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) #include @@ -55,10 +64,13 @@ SECTIONS __data_region_end = .; -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. - */ -#include +SECTION_DATA_PROLOGUE(_NOINIT_SECTION_NAME,,) +{ + /* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ + #include +} GROUP_LINK_IN(RAMABLE_REGION) /* Located in generated directory. This file is populated by the * zephyr_linker_sources() Cmake function.