Repository navigation
yaff: rodata anchor without GOT relocations; 912 on the RP2350 DCP; chk_calls in libtcc1 - #30
Merged
Merged
Conversation
Code under -share-rodata reaches .rodata through GOT index 3 ([r9, #24]), which the loader fills from a local relocation. The writer returned before emitting it when .got had no relocations -- a module that imports nothing. libsoftfp.so is one since divc3.c gave it constants: its anchor stayed 0, so __divsc3 faulted on QEMU and __divdc3 read the board's ROM as constants (912_complex_div_runtime on the device). libm.so had the same latent hole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The RP2350's double coprocessor reads a subnormal operand as zero (the reason yasos skips ieee/cdivchkd on the device), and 912's double vectors are cdivchkd's: on the board __divdc3 of vector 0 came out +0 for -0x1.e9095e311e706p-900. Where a subnormal double compares equal to zero the vectors holding one are skipped; (1+2i)/(3+4i), cdivchkd's normal vector and the Annex G cases still run. Checked against x86 with DAZ/FTZ on for doubles: the old test fails exactly as the board did, the new one passes. test_yaff_rodata_anchor skips on a cross without TARGETOS_YasOS: only a YasOS cross reserves the anchor slot and shares .rodata by default (CI's cross is "ARM Linux"). Its docstring no longer blames the board's failure on the anchor -- the board links the runtime statically. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yasos libc defined chk_calls (bounds.c) for libtcc1's __tcc_*_chk functions to count into; libtcc1 only referenced it weakly. It is now a weak definition in builtin.c, so the counter works with any libc, and a program's own definition (gcc's builtins/lib/chk.c) still wins. Without a libc definition a program reading chk_calls linked anyway and read address 0: libtcc1's weak reference left the symbol weak-undefined. test_fortify.py: test_chk_calls_counter, both ways, at -O0 and -O2 on QEMU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
912_complex_div_runtimefailed on the device, for two unrelated reasons.QEMU (an524): crash. Under
-share-rodata, code reads.rodatathrough GOT index 3 ([r9, #24]). The loader fills that slot from a local relocation.tcc_yaff_write_local_relocationsreturned before writing it when.gothad no relocations, i.e. for a module that imports nothing.libsoftfp.sobecame such a module oncedivc3.cgave it constants. Its anchor slot stayed 0, so__divsc3faulted reading address 4.libm.sohas the same shape and was affected too.test_yaff_rodata_anchor.py(needs a YasOS cross; it skips on CI's "ARM Linux" cross, which reserves no anchor slot).Pico Plus 2:
FAIL divdc3 0. The board links the runtime statically, so the anchor was not the problem there. The RP2350 double coprocessor reads a subnormal operand as zero. That is why yasos already skipsieee/cdivchkdon the device, and 912's double vectors are cdivchkd's.0 18446744073709551615 ulps) and the new one passes.libtcc1:
chk_callsmoved in from yasos libc. libtcc1's__tcc_*_chkfunctions increment a counter that gcc's builtins chk tests read. Until now yasos libc defined it (bounds.c) and libtcc1 only held a weak reference.lib/builtin.cnow defines it, weak, so it works with any libc and a program's own definition (gcc'sbuiltins/lib/chk.c) still wins. The yasos libc PR removesbounds.c.chk_callslinked anyway and read address 0. libtcc1's weak reference left the symbol weak-undefined, and tcc's linker accepted the program's strong reference. GNU ld would report an undefined reference. Not fixed here.test_fortify.py::test_chk_calls_counteron QEMU at -O0/-O2, once with libtcc1's counter and once with the program's own. The libtcc1 case printed junk before the change.test_fortify.pypasses 32/32 with the yasos libc headers.Verification:
qemu_gatepassed with the anchor fix.🤖 Generated with Claude Code