mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
builder: don't count non-writable SHT_NOBITS sections as RAM/bss
A SHT_NOBITS section was unconditionally treated as .bss (RAM) unless it was the stack. The ESP linker scripts emit non-writable SHT_NOBITS sections (.irom_dummy / .rodata_dummy) that merely reserve the flash-mapped XIP virtual address ranges and occupy no RAM. Counting them inflated the reported bss/RAM usage. Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
+8
-2
@@ -501,8 +501,9 @@ func loadProgramSize(path string, packagePathMap map[string]string) (*programSiz
|
|||||||
Align: section.Addralign,
|
Align: section.Addralign,
|
||||||
Type: memoryStack,
|
Type: memoryStack,
|
||||||
})
|
})
|
||||||
} else {
|
} else if section.Flags&elf.SHF_WRITE != 0 {
|
||||||
// Regular .bss section.
|
// Regular .bss section. Zero-initialized RAM is always
|
||||||
|
// writable, so require SHF_WRITE here.
|
||||||
sections = append(sections, memorySection{
|
sections = append(sections, memorySection{
|
||||||
Address: section.Addr,
|
Address: section.Addr,
|
||||||
Size: section.Size,
|
Size: section.Size,
|
||||||
@@ -510,6 +511,11 @@ func loadProgramSize(path string, packagePathMap map[string]string) (*programSiz
|
|||||||
Type: memoryBSS,
|
Type: memoryBSS,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// Other (non-writable) SHT_NOBITS sections are address-space
|
||||||
|
// placeholders that occupy no RAM, such as the ESP linker
|
||||||
|
// script's .irom_dummy / .rodata_dummy sections which reserve
|
||||||
|
// the flash-mapped XIP virtual address ranges. They must not be
|
||||||
|
// counted as bss/RAM usage.
|
||||||
} else if section.Type == elf.SHT_PROGBITS && section.Flags&elf.SHF_EXECINSTR != 0 {
|
} else if section.Type == elf.SHT_PROGBITS && section.Flags&elf.SHF_EXECINSTR != 0 {
|
||||||
// .text
|
// .text
|
||||||
sections = append(sections, memorySection{
|
sections = append(sections, memorySection{
|
||||||
|
|||||||
Reference in New Issue
Block a user