foss-for-synopsys-dwc-arc-processors / embarc_osp

embARC Open Software Platform (OSP) - An embedded software distribution for IoT and other embedded applications for ARC
https://www.embarc.org/
BSD 3-Clause "New" or "Revised" License
70 stars 62 forks source link

GNU build sets GP to _f_sdata instead of __SDATA_BEGIN__ #148

Open iguryanov opened 3 years ago

iguryanov commented 3 years ago

Issue Summary


Bug

Development Environment

Bug Description

gcc builds use linker scripts with both _f_sdata and __SDATA_BEGIN__. Normally they are the same in our scripts. Native GNU toolchain startup uses __SDATA_BEGIN__ to configure %GP register. But embARC startup sticks to MWDT agreement and uses _f_sdata.

This works ok until user decides to put __SDATA_BEGIN__ in the middle of the section to extend it's range. (GP-based offset is signed). And linker uses __SDATA_BEGIN__ to calculate relocations and actual offsets.

So when user changes related line in the script to something like this - __SDATA_BEGIN__ = . + 0x100; small data access becomes wrong. Runtime offsets will be 0x100 less (easily driving into negative zone), while startup still sets %GP to the beginning of small data section.


Question

Is it possible to change arc_startup.s in a way that for GCC builds it will choose __SDATA_BEGIN__ for GP?