Skip to content

boards: Link libgcc after the user libraries of a protected build. - #21469

Merged
acassis merged 1 commit into
apache:masterfrom
casaroli:protected-libgcc-order-up
Nov 5, 2026
Merged

acassis merged 1 commit into
apache:masterfrom
casaroli:protected-libgcc-order-up

Conversation

@casaroli

@casaroli casaroli commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Five boards linked libgcc inside the group of the user libraries of a protected build: at32f437-mini, qemu-armv7r, stm32f4discovery, lm3s6965-ek and fvp-armv8r. Inside the group, the linker takes a function from libgcc as soon as the applications refer to it, before it scans libc again. So a function that both libc and libgcc define comes from libgcc.

This PR links libgcc after the group, as the other boards do: --start-group $(USER_LDLIBS) --end-group $(USER_LIBGCC) in place of --start-group $(USER_LDLIBS) $(USER_LIBGCC) --end-group.

Today no function in these images is in both, so this PR fixes nothing that a program can see. It matters when libc defines such a function, as #20723 does for __emutls_get_address(): with the old order these boards link the copy of libgcc.

[skip-cmake-parity]: only these five Make files have this order.

Impact

Only the user image of a protected build of the five boards, with Make. The images keep the same archive members and the same symbols. The libgcc code moves to another place in the image. No ABI change. Not a breaking change.

Testing

Link maps with and without this PR, on master 6b9b216, Arm GNU 13.2 and AArch64 GNU 14.2:

Configuration Archive members, master with this PR
lm3s6965-ek:qemu-protected 418 (8 from libgcc) the same 418
fvp-armv8r:pnsh 342 (none from libgcc) the same 342

nm of the user image, with and without this PR: qemu-armv7r:pnsh, stm32f4discovery:kostest, lm3s6965-ek:qemu-kostest, lm3s6965-ek:qemu-protected and fvp-armv8r:pnsh have the same symbols. These images were not run. at32f437-mini has no protected configuration in the tree, so its Makefile is not built.

With #20723 and a program with a __thread variable, the user image links libgcc's emutls.o without this PR and libc's tls_emutls.o with it, on lm3s6965-ek:qemu-protected and fvp-armv8r:pnsh.

Builds with EXTRAFLAGS="-Wno-cpp -Werror", each OK: the five configurations above, and qemu-armv8a:nsh, rv-virt:pnsh64, mps2-an500:knsh.

tools/checkpatch.sh -c -u -m -g passes.

Five boards linked libgcc inside the group of the user libraries of a
protected build: at32f437-mini, qemu-armv7r, stm32f4discovery,
lm3s6965-ek and fvp-armv8r.  Inside the group, the linker takes a
function from libgcc as soon as the applications refer to it, before it
scans libc again.  So a function that both libc and libgcc define comes
from libgcc.

Link libgcc after the group, as the other boards do.  Today no function
in these images is in both, so the images keep the same archive members,
and only the place of the libgcc code changes.

[skip-cmake-parity]

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@acassis
acassis merged commit 24f08da into apache:master Nov 5, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Board: arm Board: arm64 Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants