Repository navigation
Conversation
This branch has not been deployed
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.
Problem
A relocatable object that tests an undefined weak function before calling it loses the test: the call becomes unconditional and the fallback path disappears. Reproduce with Clang 21:
Current main emits:
Fix
GOT_PAGE/GOT_OFSTreach the same entry.xrefsand the call graph are what main reports. The slot is another address of the same function, so a rename or prototype edit applies through both. Slot membership is a binary search over merged ranges, not a scan per candidate function.HI16/LO16/HIGHER/HIGHEST, x86-64 absolute and PC-relative forms, and full-pointer fields in read-only data. Their slots sit in space reserved ahead of COMMON storage. Other operands, such as x86-64GOTPCREL, get a warning comment; writable data and other architectures are not covered.The example now emits:
Tests
Stage tests
kuna-mipsgot-weak.xmlandkuna-nullable-relocations.xmladd thirteen assertions. On main the existing PIC fixture readsreturn optional();, so the weak-test assertions fail. No existing stage or datatest expectation changes.Checked-in objects built from original sources cover MIPS N32/N64, both byte orders for the GOT forms, and x86-64 small-model, large-model and RIP-relative forms, including COMMON objects and direct calls beside the weak function; CI needs no cross toolchain. CLI tests compile the emitted C and run it with the symbol bound and unbound, checking results, call counts, arguments and COMMON storage, and check that
xrefs --toanddecompile-graphstill find the direct references.Over 300 interleaved runs, median decompile and inventory times on a weak-call object, a COMMON object and a linked MIPS image are within 2.5% of main, none slower. Full Rust workspace tests, datatest/stage parity, tooling, lint and specification checks pass.