From d51721c49b0d8bad9eec761a1de2973c71f8c944 Mon Sep 17 00:00:00 2001 From: Jiu-xiao <2592509183@qq.com> Date: Wed, 14 Oct 2026 16:55:06 +0100 Subject: [PATCH] Place the GOT directly after .fini_array 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. --- STM32F407xx_FLASH.ld | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/STM32F407xx_FLASH.ld b/STM32F407xx_FLASH.ld index 88d959e..e445a70 100644 --- a/STM32F407xx_FLASH.ld +++ b/STM32F407xx_FLASH.ld @@ -148,6 +148,15 @@ SECTIONS . = ALIGN(4); } >FLASH + /* GOT entries are link-time constants in this static image. ld.lld puts the init/fini + arrays and the GOT in one RELRO range, so .got must directly follow .fini_array. */ + .got : + { + . = ALIGN(4); + *(.got .got.*) + . = ALIGN(4); + } >FLASH + _siccmram = LOADADDR(.ccmram); /* CCM-RAM section @@ -177,14 +186,6 @@ SECTIONS . = ALIGN(4); } >CCMRAM - /* GOT entries are link-time constants in this static image */ - .got : - { - . = ALIGN(4); - *(.got .got.*) - . = ALIGN(4); - } >FLASH - /* used by the startup to initialize data */ _sidata = LOADADDR(.data);