Skip to content

Commit

Permalink
linker: __data_region_start equal to __data_start
Browse files Browse the repository at this point in the history
Fixes: zephyrproject-rtos#38591, zephyrproject-rtos#38207, zephyrproject-rtos#37861

The commit 65a2de8 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 <Torsten.Rasmussen@nordicsemi.no>
  • Loading branch information
tejlmand committed Sep 24, 2021
1 parent 6112840 commit 70c4322
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 13 deletions.
3 changes: 1 addition & 2 deletions include/arch/arc/v2/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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.*")
Expand Down
3 changes: 1 addition & 2 deletions include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,9 @@ SECTIONS

#include <linker/common-noinit.ld>

__data_region_start = .;

SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,)
{
__data_region_start = .;
__data_start = .;
*(.data)
*(".data.*")
Expand Down
3 changes: 1 addition & 2 deletions include/arch/arm/aarch32/cortex_m/scripts/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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.*")
Expand Down
3 changes: 1 addition & 2 deletions include/arch/arm64/scripts/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,9 @@ SECTIONS

#include <linker/common-noinit.ld>

__data_region_start = .;

SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,)
{
__data_region_start = .;
__data_start = .;
*(.data)
*(".data.*")
Expand Down
3 changes: 1 addition & 2 deletions include/arch/riscv/common/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,11 @@ SECTIONS
#include <linker/common-noinit.ld>
#include <linker/cplusplus-ram.ld>

__data_region_start = .;

SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,)
{
. = ALIGN(4);
/* _image_ram_start = .; */
__data_region_start = .;
__data_start = .;

*(.data)
Expand Down
2 changes: 1 addition & 1 deletion include/arch/sparc/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ SECTIONS
__rom_region_end = .;

__data_region_load_start = .;
__data_region_start = .;


SECTION_PROLOGUE(.plt,,)
Expand All @@ -85,6 +84,7 @@ SECTIONS
{
. = ALIGN(8);
_image_ram_start = .;
__data_region_start = .;
__data_start = .;

*(.data)
Expand Down
3 changes: 1 addition & 2 deletions soc/riscv/openisa_rv32m1/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 70c4322

Please sign in to comment.