-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Move all PSTRs to own section, allow string dedup #6565
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
Conversation
GNU ld can deduplicate strings, and does so for most normal char *s automatically. However, for PSTRs we were using a unique section per string *and* the section was not flagges as containing dedupable 0-terminated strings. Modify the PSTR macro to emit assembly, which lets us set the section flags required (SM) for the variables, and use inline assembly to get the asm-block defined address. Should result in smaller compiled binaries if any strings are duplicated.
Add the "a" section flag to allow the linker to throw away unneeded strings. Without this flag, the linker will not discard unreferenced strings and ROMs will increase in size, possibly dramatically.
With the latest push ROM sizes look to have decreased between 32 bytes to 2.2KB, depending on the example, so it's saving some flash even in our own code. |
And now for some real example :) Some build I made last night and built again this morning with this PR included:
So I would say it does indeed make some difference :) |
Only problem is, my unit does constantly crash reboot.
Edit: Edit2:
There are also some .bin builds in the 'custom' dir which I made yesterday. |
@TD-er, please do a stack decode on the crash. |
Is that already possible on PlatformIO builds? |
Try https://github.com./me21/EspArduinoExceptionDecoder , I was in process of adding it to the repo to do CLI based decodes. |
Has it been tested on Windows?
|
Ah bug found in decoder. You have to move the Like this:
Decoded result:
|
GNU ld can deduplicate strings, and does so for most normal char *s
automatically. However, for PSTRs we were using a unique section per
string and the section was not flagged as containing dedupable
0-terminated strings.
Modify the PSTR macro to emit assembly, which lets us set the section
flags required (SM) for the variables, and use inline assembly to get
the asm-block defined address.
Should result in smaller compiled binaries if any strings are
duplicated.