Skip to content

feat: Support --hash-style={sysv, both}#1281

Merged
lapla-cogito merged 13 commits into
wild-linker:mainfrom
lapla-cogito:sysv
Nov 9, 2025
Merged

feat: Support --hash-style={sysv, both}#1281
lapla-cogito merged 13 commits into
wild-linker:mainfrom
lapla-cogito:sysv

Conversation

@lapla-cogito
Copy link
Copy Markdown
Member

--hash-style=sysv is still widely used in many places. I found it being used in gvisor builds.

Creating a .hash section requires determining the total number of entries in the .dynsym table before calculating the chain array length for the SysV hash table. The update_existing_dynsym_entries function 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).

@lapla-cogito lapla-cogito marked this pull request as draft November 8, 2025 11:41
@lapla-cogito lapla-cogito force-pushed the sysv branch 3 times, most recently from 9ebf11a to d59b717 Compare November 8, 2025 12:35
@lapla-cogito lapla-cogito marked this pull request as ready for review November 8, 2025 12:41
Copy link
Copy Markdown
Member

@davidlattimore davidlattimore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! That's great to fill this gap in our supported features :-)

Comment thread libwild/src/layout.rs
Comment thread libwild/src/layout.rs
Comment thread libwild/src/layout.rs
}
}) {
let size = epilogue_layout.sysv_hash_size.unwrap_or(0);
*self.common.mem_sizes.get_mut(part_id::SYSV_HASH) = size;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this and the computation of sysv_hash_size move to EpilogueLayoutState::finalise_sizes?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread libwild/src/layout.rs Outdated
@lapla-cogito lapla-cogito merged commit 3dbebc5 into wild-linker:main Nov 9, 2025
20 checks passed
@lapla-cogito lapla-cogito deleted the sysv branch November 9, 2025 05:09
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.

2 participants