Skip to content

Warning: changing start of section .bss by x bytes #465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lorol opened this issue Mar 5, 2019 · 4 comments
Closed

Warning: changing start of section .bss by x bytes #465

lorol opened this issue Mar 5, 2019 · 4 comments
Assignees
Milestone

Comments

@lorol
Copy link

lorol commented Mar 5, 2019

Info

  • OS: Win 10
  • Arduino IDE version: 1.8.8
  • STM32 core version: 1.4.0 and 1.5.0
  • Upload method: Mass Storage

Board

  • Name: Nucleo L152RE

Additional context
Here is an .ino file (it needs few lib's but you can figure out) to reproduce the warning.
https://gist.github.com/b41c43db7f3ac0990b5639921658f024.git
The cause is a double (64-bit) var at line 96. If you are using float, no problems.
If you move the position where it is declared, it may affect the warning output (or not)
It works ... but the difference is: with warning it takes +4 RAM bytes more :)
With corrected .bss ALIGN(4) no warnings and less memory.

Related commit:
d52e577#commitcomment-32583137

@fpistm fpistm self-assigned this Mar 5, 2019
@fpistm
Copy link
Member

fpistm commented Mar 27, 2019

@lorol
I have not exactly the same result with your example.
With no .bss alignment I have:

Sketch uses 53696 bytes (10%) of program storage space. Maximum is 524288 bytes.
Global variables use 4596 bytes (5%) of dynamic memory, leaving 77324 bytes for local variables. Maximum is 81920 bytes.

while with ALIGN(4):

Sketch uses 53696 bytes (10%) of program storage space. Maximum is 524288 bytes.
Global variables use 4600 bytes (5%) of dynamic memory, leaving 77320 bytes for local variables. Maximum is 81920 bytes.

So I lost 4 bytes with alignment.

What I will do is to remove the warn section alignment as by default, SECTIONS command
does not specify a start address for the section, let ld do the work.
If a start address is specified no warn was displayed.

fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Mar 27, 2019
Remove ld option 'warn-section-align', as by default, SECTIONS command
does not specify a start address for the section, let ld do the work.
If a start address is specified no warn was displayed.

--warn-section-align
    Warn if the address of an output section is changed because of
    alignment. Typically, the alignment will be set by an input section.
    The address will only be changed if it not explicitly specified;
    that is, if the SECTIONS command does not specify a start address
    for the section.

Fix stm32duino#465

Signed-off-by: Frederic.Pillon <[email protected]>
@fpistm fpistm added this to the 1.6.0 milestone Mar 27, 2019
@lorol
Copy link
Author

lorol commented Mar 27, 2019

Hi
Yes, it makes sense, if you solve the warning and the RAM is actually better managed by ld - no problems.
However, on my builds:

IDE 1.8.8 STM32 1.5.0 NUCLEO L152
one double variable in sketch
See here:
https://gist.github.com/lorol/b41c43db7f3ac0990b5639921658f024
With this customized lib: https://github.com/lorol/AD9833-Library-Arduino

-----------------ORIGINAL ld---------------------------
/* Uninitialized data section */
. = ALIGN(4);
.bss :

./../../arm-none-eabi/bin/ld.exe: warning: changing start of section .bss by 4 bytes

Sketch uses 54552 bytes (10%) of program storage space. Maximum is 524288 bytes.
Global variables use 5016 bytes (6%) of dynamic memory, leaving 76904 bytes for local variables. Maximum is 81920 bytes.

----------------PATCHED ld----------------------------
/* Uninitialized data section */
. = ALIGN(4);
.bss ALIGN(4) :

Sketch uses 54552 bytes (10%) of program storage space. Maximum is 524288 bytes.
Global variables use 5012 bytes (6%) of dynamic memory, leaving 76908 bytes for local variables. Maximum is 81920 bytes.

@fpistm
Copy link
Member

fpistm commented Mar 27, 2019

Well it is fairly depends on your sketch.
With other variable addition, optimizations, ... you will have the opposite.
I've build the sketch for several targets and several have the warning with different +/- 4 bytes with ALIGN(x).
Then to be as generic as possible, I guess the best way is to let ld handle this.

fpistm added a commit that referenced this issue Mar 27, 2019
Remove ld option 'warn-section-align', as by default, SECTIONS command
does not specify a start address for the section, let ld do the work.
If a start address is specified no warn was displayed.

--warn-section-align
    Warn if the address of an output section is changed because of
    alignment. Typically, the alignment will be set by an input section.
    The address will only be changed if it not explicitly specified;
    that is, if the SECTIONS command does not specify a start address
    for the section.

Fix #465

Signed-off-by: Frederic.Pillon <[email protected]>
@lorol
Copy link
Author

lorol commented Mar 27, 2019

Great!

benwaffle pushed a commit to benwaffle/Arduino_Core_STM32 that referenced this issue Apr 10, 2019
Remove ld option 'warn-section-align', as by default, SECTIONS command
does not specify a start address for the section, let ld do the work.
If a start address is specified no warn was displayed.

--warn-section-align
    Warn if the address of an output section is changed because of
    alignment. Typically, the alignment will be set by an input section.
    The address will only be changed if it not explicitly specified;
    that is, if the SECTIONS command does not specify a start address
    for the section.

Fix stm32duino#465

Signed-off-by: Frederic.Pillon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants