From 15e834a6878cb6271cf5d94f56d5f9d4c0a0a915 Mon Sep 17 00:00:00 2001 From: Torsten Rasmussen Date: Thu, 23 Sep 2021 22:36:09 +0200 Subject: [PATCH] linker: __data_region_start equal to __data_start Fixes: #38591, #38207, #37861 The commit 65a2de84a9d5c535167951bf1cf610c4f7967ea5 aligned the data linker symbol for sections and regions. The data region symbol start has been placed outside the sections thus being defined as the address of the region before alignment of the first section in the data region, usually the `datas` section. The symbol defining the start address of the data section is after section alignment. In most cases the address of the data region start and datas section start will be identical, but not always. The data region symbol is a new linker symbol and existing code has been depending on the old data section start symbol. Thus, the update to the use of the data region start symbol instead of data ram start symbol thus results in a different address when the section is aligned to a different address. To ensure the original behavior in all cases, the data region start address is now moved inside the data section. Signed-off-by: Torsten Rasmussen --- include/arch/arc/v2/linker.ld | 3 +-- include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld | 3 +-- include/arch/arm/aarch32/cortex_m/scripts/linker.ld | 3 +-- include/arch/arm64/scripts/linker.ld | 3 +-- include/arch/riscv/common/linker.ld | 3 +-- include/arch/sparc/linker.ld | 2 +- soc/riscv/openisa_rv32m1/linker.ld | 3 +-- 7 files changed, 7 insertions(+), 13 deletions(-) diff --git a/include/arch/arc/v2/linker.ld b/include/arch/arc/v2/linker.ld index 5b54b2256ad..dfd5017c5b0 100644 --- a/include/arch/arc/v2/linker.ld +++ b/include/arch/arc/v2/linker.ld @@ -173,11 +173,10 @@ SECTIONS { GROUP_START(DATA_REGION) - __data_region_start = .; - SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,) { /* when XIP, .text is in ROM, but vector table must be at start of .data */ + __data_region_start = .; __data_start = .; *(".data") *(".data.*") diff --git a/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld b/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld index 3f2e2f9be17..57a0dd33b78 100644 --- a/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld +++ b/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld @@ -278,10 +278,9 @@ SECTIONS #include - __data_region_start = .; - SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,) { + __data_region_start = .; __data_start = .; *(.data) *(".data.*") diff --git a/include/arch/arm/aarch32/cortex_m/scripts/linker.ld b/include/arch/arm/aarch32/cortex_m/scripts/linker.ld index a279b689780..da045f7b90f 100644 --- a/include/arch/arm/aarch32/cortex_m/scripts/linker.ld +++ b/include/arch/arm/aarch32/cortex_m/scripts/linker.ld @@ -294,10 +294,9 @@ SECTIONS GROUP_START(DATA_REGION) - __data_region_start = .; - SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,) { + __data_region_start = .; __data_start = .; *(.data) *(".data.*") diff --git a/include/arch/arm64/scripts/linker.ld b/include/arch/arm64/scripts/linker.ld index d3e82241ea1..8ff175c87ac 100644 --- a/include/arch/arm64/scripts/linker.ld +++ b/include/arch/arm64/scripts/linker.ld @@ -248,10 +248,9 @@ SECTIONS #include - __data_region_start = .; - SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,) { + __data_region_start = .; __data_start = .; *(.data) *(".data.*") diff --git a/include/arch/riscv/common/linker.ld b/include/arch/riscv/common/linker.ld index 13bbbfd9f3c..6d932cafbf9 100644 --- a/include/arch/riscv/common/linker.ld +++ b/include/arch/riscv/common/linker.ld @@ -229,12 +229,11 @@ SECTIONS #include #include - __data_region_start = .; - SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,) { . = ALIGN(4); /* _image_ram_start = .; */ + __data_region_start = .; __data_start = .; *(.data) diff --git a/include/arch/sparc/linker.ld b/include/arch/sparc/linker.ld index e68f29cecc3..cc60c90eea5 100644 --- a/include/arch/sparc/linker.ld +++ b/include/arch/sparc/linker.ld @@ -68,7 +68,6 @@ SECTIONS __rom_region_end = .; __data_region_load_start = .; - __data_region_start = .; SECTION_PROLOGUE(.plt,,) @@ -85,6 +84,7 @@ SECTIONS { . = ALIGN(8); _image_ram_start = .; + __data_region_start = .; __data_start = .; *(.data) diff --git a/soc/riscv/openisa_rv32m1/linker.ld b/soc/riscv/openisa_rv32m1/linker.ld index b1b218176c7..56c32439f33 100644 --- a/soc/riscv/openisa_rv32m1/linker.ld +++ b/soc/riscv/openisa_rv32m1/linker.ld @@ -159,12 +159,11 @@ SECTIONS GROUP_START(RAM) - __data_region_start = .; - SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,) { . = ALIGN(4); _image_ram_start = .; + __data_region_start = .; __data_start = .; *(.data)