Repository navigation
feat(core): honor .deplibs (SHT_LLVM_DEPENDENT_LIBRARIES) natively (#180) - #181
Merged
Merged
Conversation
) Resolve dependent-library specifiers from relocatable objects in lld's addDependentLibrary order (-l<spec>, bare name on search path, literal path), load them after command-line inputs, and discard .deplibs from full-link output (kept under -r). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
9 of 31 tasks
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.
Closes #180
reld now reads the
.deplibssection (SHT_LLVM_DEPENDENT_LIBRARIES) that clang emits for#pragma comment(lib, ...), and links the libraries it names itself, the same wayld.llddoes.What changed
platform.rs,elf.rs): two new trait methods,ObjectFile::dependent_librariesandSectionHeader::is_dependent_libraries. Only relocatable ELF objects are read.parse_dependent_librarieshas unit tests.input_data.rs): each specifier is looked up in lld'saddDependentLibraryorder: first as-l<spec>, then as a bare name on the library search path, then as a literal path. The libraries are loaded after all command-line inputs, in the order they were found. Linker-script results (e.g. glibc'slibm.so) and nested.deplibsgo through a queue. A specifier that can't be found fails with lld's wording:unable to find library from dependent library specifier: <spec>. Nothing is resolved under-ror for--start-libobjects.layout_rules.rs): a full link drops.deplibs. A-rlink keeps it, as lld does.elf/deplibs:deplibs-are-linkedbuilds with clang and linkscbrtthrough#pragma comment(lib, "m")with no-lm. It compares the output against lld and checks that no.deplibssection is left.deplibs-missingchecks lld's error message.DiffIgnoreentries (section.got.plt.entsize,section.gnu.version_r.alignment), both already tracked under Track and remove inherited reld-diff ignore patterns #13. They are general differences on dynamic links that other lld-compared fixtures also ignore, not.deplibsbehaviour.Known limitations
.deplibsis not yet read from archive members,--start-libobjects or LTO bitcode.--no-dependent-librariesswitch yet..deplibs(static vs shared,--as-needed) are taken from the last input on the command line. lld uses whatever was in effect where each object appeared, so this only approximates it.Validation
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings: cleancargo test -p reld-core --lib: 216 passedcargo test -p reld --test acceptance-policy: 11 passedcargo test -p reld --test acceptance -- deplibs:deplibs-are-linkedanddeplibs-missingboth passinput_data.rs,elf.rs,platform.rsandlayout_rules.rsput back toorigin/main, both deplibs configs fail withreld: error: Undefined symbol cbrt.act -W .github/workflows/ci.yml -j phase1-native --matrix kind:linux-gnu -P ubuntu-24.04=catthehacker/ubuntu:act-24.04 --pull=false --action-offline-mode: Job succeeded🤖 Generated with Claude Code