Skip to content

fix: ifunc address equality for GOT-relative relocations#1446

Merged
lapla-cogito merged 3 commits into
wild-linker:mainfrom
lapla-cogito:ifunc_got_relative
Jan 13, 2026
Merged

fix: ifunc address equality for GOT-relative relocations#1446
lapla-cogito merged 3 commits into
wild-linker:mainfrom
lapla-cogito:ifunc_got_relative

Conversation

@lapla-cogito
Copy link
Copy Markdown
Member

When code takes the address of an ifunc symbol via a GOT-relative relocation (e.g., R_X86_64_REX_GOTPCRELX), it should return the same address as direct references to the ifunc, which is the PLT stub address. Previously, wild used a single GOT entry for both the PLT stub (with R_IRELATIVE) and GOT-relative references. This caused address inequality: direct references returned the PLT stub address, while GOT-relative references returned the resolver result (the actual function address). For non-PIE executables, we now allocate a separate GOT entry for address equality that contains the PLT stub address statically. This ensures all references to an ifunc return the same address.

Comment thread libwild/src/layout.rs Outdated
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.

Nice fix! This now shows no change in performance. I only benchmarked zed, but I expect that's sufficient.

@lapla-cogito lapla-cogito merged commit ac676cb into wild-linker:main Jan 13, 2026
20 checks passed
@lapla-cogito lapla-cogito deleted the ifunc_got_relative branch January 13, 2026 01:35
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