1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

Move all PSTRs to own section, allow string dedup (#6565)

* Move all PSTRs to own section, allow string dedup

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.

* Give each PSTR its own segment

* Allow disposing of unused strings before merging

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.
This commit is contained in:
Earle F. Philhower, III
2019-09-30 16:27:10 -07:00
committed by david gauchard
parent d4757542e4
commit 97c926ea91
2 changed files with 10 additions and 1 deletions

View File

@ -181,6 +181,9 @@ SECTIONS
*libwps.a:(.literal.* .text.*)
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom0.text.* .irom.text .irom.text.*)
/* Constant strings in flash (PSTRs) */
*(.irom0.pstr.*)
/* __FUNCTION__ locals */
*(.rodata._ZZ*__FUNCTION__)
*(.rodata._ZZ*__PRETTY_FUNCTION__)