fix: Hide linker-defined symbols in shared libraries to match GNU ld#1686
fix: Hide linker-defined symbols in shared libraries to match GNU ld#1686Blazearth wants to merge 1 commit intowild-linker:mainfrom
Conversation
davidlattimore
left a comment
There was a problem hiding this comment.
Thanks for looking at this.
Could you add an integration test? I'd suggest a test that produces a shared object (not an executable). You can do that something like:
//#LinkArgs:-shared -z now
//#RunEnabled:falseYou could then add some //#ExpectSym or //ExpectDynSym assertions. You might need to extend the symbol properties that can be asserted to support asserting the symbol visibility.
| symbols.section_end(output_section_id::TEXT, "__etext"); | ||
| // GNU ld doesn't emit these symbols in shared libraries, so we hide them | ||
| if output_kind.is_shared_object() { | ||
| symbols.section_end(output_section_id::TEXT, "etext").hide(); |
There was a problem hiding this comment.
I think it might read slightly nicer if we had a set_hidden function that took a bool, then we could do something like the following and avoid repeating all the symbols:
symbols.section_end(output_section_id::TEXT, "etext").set_hidden(hidden);`|
Those were symtab entries: After some testing I see that GNU ld always outputs Secondly, Wild never puts them into So, we might want to settle on least bad workaround for now, and rework the concept later. |
|
Fair enough i will add an intergration test that links a shared object and see linker defined symbols dont appear in .dynsym unless they are referenced and i will also look into extending the symbol assertions to support checking visibility if needed. |
Addresses #1508 (comment)
GNU ld suppresses linker-defined layout symbols (etext, edata, end, etc.) when producing shared objects. Wild previously emitted them as GLOBAL DEFAULT, causing them to appear as exported ABI symbols in .dynsym. This change hides them when linking shared libraries so they remain local in .symtab but are not exported.