Repository navigation
Linking: find a free name for a renamed symbol by binary search - #9631
Draft
tautschnig wants to merge 1 commit into
Draft
tautschnig wants to merge 1 commit into
tautschnig wants to merge 1 commit into
Conversation
linkingt::rename names the k-th symbol called id that linking renames id$link<k>: it tried id$link1, id$link2, ... in turn until it found one that the main symbol table does not have. Renaming k symbols of the same name therefore takes time quadratic in k. Programs linked from many files have many such symbols, notably the copies of each static inline function that a header defines and many of the files use: linking the Linux kernel's vmlinux.o (4320 goto binaries) spent 6 % of its time in these probes. Find the first number that the main symbol table does not have by exponential and then binary search, assuming that the numbers taken are 1 to n, as linking chose them; the further checks (against the names this linking step chose already, and against the symbol table being linked) continue linearly from there, as before. Where the numbers taken have gaps, the number found is still not taken, but may be larger than the first gap. Measured with the goto-ld link of vmlinux.o (v7.4-rc4, arm64 defconfig), on a branch with further goto-cc and linking fixes (CMake Release): 250 s instead of 318 s. The goto binary written is not byte-identical, but has the same 2,367,638 symbol names, and the output of goto-instrument --show-goto-functions is identical. Probing names interns strings that the linear search did not create, which changes the numbers of later strings and so the order in which the symbol table is written. The output of --show-symbol-table differs in 343 lines, all in the printed values of functions, where a different one of two block-local variables of the same base name is shown with its full identifier. The new test cbmc/Linking_file_local_renames links six files that each define a static function helper and checks the names the five that are renamed get. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9631 +/- ##
===========================================
+ Coverage 81.29% 81.34% +0.04%
===========================================
Files 1725 1727 +2
Lines 191680 191723 +43
Branches 73 73
===========================================
+ Hits 155835 155958 +123
+ Misses 35845 35765 -80 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
linkingt::rename names the k-th symbol called id that linking renames id$link: it tried id$link1, id$link2, ... in turn until it found one that the main symbol table does not have. Renaming k symbols of the same name therefore takes time quadratic in k. Programs linked from many files have many such symbols, notably the copies of each static inline function that a header defines and many of the files use: linking the Linux kernel's vmlinux.o (4320 goto binaries) spent 6 % of its time in these probes.
Find the first number that the main symbol table does not have by exponential and then binary search, assuming that the numbers taken are 1 to n, as linking chose them; the further checks (against the names this linking step chose already, and against the symbol table being linked) continue linearly from there, as before. Where the numbers taken have gaps, the number found is still not taken, but may be larger than the first gap.
Measured with the goto-ld link of vmlinux.o (v7.4-rc4, arm64 defconfig), on a branch with further goto-cc and linking fixes (CMake Release): 250 s instead of 318 s. The goto binary written is not byte-identical, but has the same 2,367,638 symbol names, and the output of goto-instrument --show-goto-functions is identical. Probing names interns strings that the linear search did not create, which changes the numbers of later strings and so the order in which the symbol table is written. The output of --show-symbol-table differs in 343 lines, all in the printed values of functions, where a different one of two block-local variables of the same base name is shown with its full identifier.
The new test cbmc/Linking_file_local_renames links six files that each define a static function helper and checks the names the five that are renamed get.