Repository navigation
Conversation
ld.lld keeps the init/fini arrays and the GOT in one RELRO range. With .got after the CCM sections the range was split, and the ST Arm Clang STARM_NEWLIB profile failed to link with ".got is not contiguous with other relro sections". The .got section moves directly after .fini_array, still in FLASH. GCC, STARM_HYBRID and STARM_PICOLIBC images are byte-identical to before; STARM_NEWLIB links again.
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.
把链接脚本中的
.got段移到紧跟.fini_array的位置,修复 ST Arm ClangSTARM_NEWLIB配置的链接失败:原因
ld.lld 把
.preinit_array、.init_array、.fini_array和.got归入同一段 RELRO 范围,要求它们连续(脚本中的READONLY对 ld.lld 不起作用)。.got原来在.ccmram、.ccm_heap之后,这两个段把范围隔开了。MC02、F103、OpenCR 的.got本来就紧跟.fini_array,各配置都能链接。.got仍在 FLASH 中,只改位置,并在注释中写明必须紧跟.fini_array。验证
Release 构建,GCC 14.2 与 ST Arm Clang 21.1.1:
.bin逐字节相同STARM_HYBRID.bin逐字节相同STARM_PICOLIBC.bin逐字节相同STARM_NEWLIB.bin119780 B,.data加载地址紧接 Flash 内容未上板。
相关:xrobot-org/LibXR_CppCodeGenerator#35 让
libxr stm32 setup为新工程在.fini_array之后加入.got;对.got位置不对的已有脚本只给出警告。