fix: ELF files too large when addresses not contiguous#6
Merged
github0null merged 2 commits intogithub0null:masterfrom Jan 1, 2026
Merged
fix: ELF files too large when addresses not contiguous#6github0null merged 2 commits intogithub0null:masterfrom
github0null merged 2 commits intogithub0null:masterfrom
Conversation
Owner
|
好的,感谢您的贡献。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
当定义多个加载域后,地址不连续,会导致ELF中填充大量数据,ELF文件巨大:

原因是将其他加载域的section全部放在ENTRY section导致的,因此只要把对应加载域的section用objcopy到对应的section即可。
测试文件axf的elf信息如下(为了避免空间爆掉,测试时EXT_FLASH起始地址为0x08900000):
修改前的elf信息如下:
修改前
EXT_FLASH的大小为0字节,根据axf的信息,0x08900000(EXT_FLASH Start Addr) - 0x08000000 (ER_IROM1 Start Addr) + 330028(EXT_FLASH Size) = 9745212,是可以对的上ER_IROM1的大小的,这证明EXT_FLASH全部被塞到了ER_IROM1中。如果是STM32 QSPI的地址(0x90000000),那么文件体积会达到2G多!而且其中绝大多数都是无用的空数据。
修改后的elf信息如下:
fromelf如果不合并bin,会将bin按照section名称在输出文件下建立bin文件,按照文件名copy就可以了。
调试前,gdb server会下载其他Flash:

且调试时RW段不会变成0xFF:
