-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Linker sometimes moves non-PROGMEM data into PROGMEM #9835
Comments
Isn't that arduino/toolchain-avr#59? |
Certainly looks the same to me. I guess that makes this report a duplicate, and can be closed as such. |
Hm, but that bug suggests that this is solved by upgrading to gcc 7.3, which I think is used in the latest AVR core, which @MHotchin implies to run (given the board manager "reports everything up to date", though he does have IDE 1.8.10 which is not the latest). @MHotchin could you tell use what version of the AVR core and gcc you are seeing this with exactly? Easiest would be to just paste the output of a verbose compilation, which should tell us enough. |
IDE reports using tools from "Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5". |
There seems to be another bug lurking: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92606 Johann suggests |
Just tested - |
So, going back to my original sketch that I was debugging: Program GateController size: 62,156 bytes (used 24% of a 253,952 byte maximum) (23.27 secs) WITH the flag (functionality untested as yet): So, both RAM and FLASH usage went up,and by the same amount, which is a bit unexpected. I'll have to dig into the map files to see what the differences are. |
RAM usage went up 36 bytes. 12 are from the 'monthDays' array, as expected. The other 24 bytes are unaccounted for in the MAP files. |
@MHotchin for comparing symbols and sizes in an .elf file, https://github.com/matthijskooijman/scripts/blob/master/Arduino/diff-elf-symbols might be helpful. It compares |
Here's the output from avr-objdump -t --special_syms for both configurations. |
My script agreess:
The flag you used completely disables the "merge duplicate symbols" optimization pass (https://github.com/gcc-mirror/gcc/blob/master/gcc/ipa-icf.c). What I suspect, is that this pass might cause multiple symbols to become aliases and though they remain distinct symbols, they end up at the same address, so they take up space only once. Looking through the map file (using the regex `` to find subsequent lines with identical addresses, after sorting the file), I found for example:
vs
So thats 2 times 0xc bytes, so 24 extra bytes in Flash and RAM, explaining the difference (I did not find any others, there were more duplicate addresses in .text, but they were duplicate in both, so probably produced by another optimization pass, or explicitly specified in the code maybe).
A very easy way to get bash is to install git, the default version comes with "git bash" (bash compiled by/for the git project) which just works. |
I've just verified that this fix does the trick in my original project. For now I'm going to keep the flag in my platform.local.txt, so I have a work around. The small increase in RAM usage doesn't bother me, seeing as I saved three times as much by fixing the INADDR_NONE bug in my local copy (#1007). I guess it's up to the AVR platform maintainers now to decide if this flag should be added to platform.txt until g++ is fixed (if ever). |
I have been chasing a problem with time calculations that has now boiled down to the linker is moving non-PROGMEM data into PROGMEM, because it's the same as other data that IS supposed to be in PROGMEM.
I'm running IDE 1.8.10, and the board manager and library manager report everything up to date. OS is Windows7 SP1 fully patched. Reproduces on both an UNO and a Mega 2560.
Before I go further, here's the sketch I've boiled things down to:
As is, the sketch botches the time calculation in makeTime(). I traced through the code, and found that in this case, the array of month lengths in the 'Time' library was complete nonsense.
Comment out the following line, and everything works!
Looking at the map files from this web-site:
https://sparks.gogo.co.nz/avr-ram-use.html
The WORKING version has the following:
The BROKEN version is:
Note that the 'monthDays' array has moved to flash! It's a global variable in the 'Time' library, and is NOT marked PROGMEM. If I change any of the values in 'daysArray', then everything works again:
The text was updated successfully, but these errors were encountered: