feat: Support --hash-style={sysv, both}#1281
Merged
Merged
Conversation
9ebf11a to
d59b717
Compare
Member
davidlattimore
left a comment
There was a problem hiding this comment.
Thanks! That's great to fill this gap in our supported features :-)
| } | ||
| }) { | ||
| let size = epilogue_layout.sysv_hash_size.unwrap_or(0); | ||
| *self.common.mem_sizes.get_mut(part_id::SYSV_HASH) = size; |
Member
There was a problem hiding this comment.
Could this and the computation of sysv_hash_size move to EpilogueLayoutState::finalise_sizes?
Member
Author
There was a problem hiding this comment.
There're doubts about if this approach can correctly compute the hash table. This is because finalise_sizes doesn't have the final starting index for the .dynsym section yet, which could lead to incorrect calculation results. finalize_layout computes the number of buckets and chains after this index is finalized, then uses the sysv_hash_size function to calculate the actual byte size.
davidlattimore
approved these changes
Nov 9, 2025
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.
--hash-style=sysvis still widely used in many places. I found it being used in gvisor builds.Creating a
.hashsection requires determining the total number of entries in the.dynsymtable before calculating the chain array length for the SysV hash table. Theupdate_existing_dynsym_entriesfunction performs this calculation.Additionally, mold appears to also support
--hash-style=none, but since no other linkers implement this feature and I couldn't find any practical use cases, I haven't implemented it this time (though adding it would be relatively straightforward).