Skip to content

Linking: find a free name for a renamed symbol by binary search - #9631

Draft
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:kiro/linking-rename-search
Draft

tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:kiro/linking-rename-search

Conversation

@tautschnig

Copy link
Copy Markdown
Collaborator

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.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

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

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.34%. Comparing base (3e1f386) to head (b6bf24e).
⚠️ Report is 36 commits behind head on develop.

Files with missing lines Patch % Lines
src/linking/linking.cpp 93.75% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant