Repository navigation
fix(nid): rebuild SysV hashes after renaming ELF symbols - #6904
Merged
Merged
Conversation
11 tasks done
Collaborator
|
Checked the SysV hash rebuild against ELF ABI 8.5: names come from the final symbol list (after the GNU reorder, retained exports included), geometry and |
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.
What
A normal GCC shared library linked with
--hash-style=sysvpatches successfully but then loses lookup access to its renamed exports: the actual tool printsOK, while a fresh Linux process resolves only 1 of 18 NIDs. Export names changed without rebuilding the SysV hash table.Rebuild the existing SysV buckets and chains in place using the final dynamic-symbol names, after any GNU hash symbol reorder. Validate table geometry and its symbol-table link before mutation. SysV-only files retain their symbol indices; files with both hash formats keep both tables consistent. The layout and algorithm follow ELF ABI section 8.5.
Tested
Linux x86-64, GCC/G++ 13.3, glibc 2.39, main
d9b696ddbb. Built the actualnid_patcherfrom all nine sources listed by its CMake target, with C++20 and O2.A real PIC shared library provides 18 functions returning 100 through 117 plus a retained no-patch export returning 901. Unchanged main resolves 1/18 renamed exports; the fix resolves 18/18 with all expected values. Retained, missing and old-name controls pass. GNU+SysV output passes direct table lookup after actual symbol reordering; a separate copy with the GNU dynamic tag disabled also resolves every expected value through the native SysV loader path. Independent review reproduced both native outcomes.
All eight hash regression methods pass, including SysV-only and dual-hash layouts with 1, 3 and 7 buckets, collision chains, preserved symbols and malformed geometry rejection without writing. All eight applicable NID Python test groups pass. Conventions and whitespace checks pass. The full runtime build and retail titles were not exercised. Checked the 829-open-PR inventory and the actual #6901 shared source; no competing implementation was found.
Combined validation with #6906 also passes: both commits merge cleanly, the rebuilt actual tool passes all eight applicable NID groups, native SysV/dual-hash export lookup controls and zero/partial-write error controls.
Checklist
main; no other open PR implements the same fix.mdfiles or images added to the repository