avrdudes / avr-libc

The AVR-LibC package provides a subset of the standard C library for AVR 8-bit RISC microcontrollers.
https://avrdudes.github.io/avr-libc/
Other
261 stars 56 forks source link

Only define __DATA_REGION_ORIGIN__ and __DATA_REGION_LENGTH__ when the linker script is using both of them. #971

Closed sprintersb closed 4 months ago

sprintersb commented 4 months ago

Since v2.2.0's implementation of issue #936, gcrt1.S defines symbols __DATA_REGION_ORIGIN__ and __DATA_REGION_LENGTH__.

These symbols are used in the default linker scripts to define the beginning and extent of the data memory region — but only since the recent implementation of PR29741 in Binutils v2.40. Prior to that, the data region started at a core specific value of $DATA_ORIGIN together with a length of __DATA_REGION_LENGTH__.

Outcome is that #936 may set the data region length to the correct length, but misses to set data origin as the linker script does not use __DATA_REGION_ORIGIN__. This may lead to errors from the linker when user data starting at -Tdata extends beyond $DATA_ORIGIN + __DATA_REGION_LENGTH__.

The user can work around this by compiling with, say, -Wl,--defsym,__DATA_REGION_LENGTH__=64k.

On the AVR-LibC side, two approaches are possible:

sprintersb commented 4 months ago

Solved by https://github.com/avrdudes/avr-libc/commit/26e6ce4b308184b24f83d4781add08c9e56f2a05 (and by https://github.com/avrdudes/avr-libc/commit/2951de0ee8d2d5592fcf00e9d573d40f8be5b052 on the v2.2 release branch).

sprintersb commented 4 months ago

closed