Skip to content

chore: replace TODO with a comment#1798

Merged
mati865 merged 2 commits intowild-linker:mainfrom
mati865:push-xmkystoqvouk
Apr 6, 2026
Merged

chore: replace TODO with a comment#1798
mati865 merged 2 commits intowild-linker:mainfrom
mati865:push-xmkystoqvouk

Conversation

@mati865
Copy link
Copy Markdown
Member

@mati865 mati865 commented Apr 3, 2026

The context: #1654 (comment)

//#DiffIgnore:rel.extra-got-plt-got
//#DiffIgnore:section.rela.plt.link
// TODO: This is likely an important issue.
// GNU ld unlike LLD and us, doesn't sort init_array.
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.

I'm pretty sure GNU ld sorts by init priority. I suspect what's happening though is that all the init_array sections are the same priority. Wild will then place them in the order in which the files appeared on the command-line, while GNU ld likely places them in the order in which it decided to load them. This can be different if for example an archive entry didn't get activated when first encountered, but was then encountered a second time, either due to a -group flag or due to repeating the input file on the command-line. In that case, Wild will use the earlier instance of the archive entry, while GNU ld uses the latter.

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.

I though they would be sorted by priority, then by name. I though I may enable LLD to get rid of some of the diff ignores, but init_array still triggers despite Wild and LLD being the same (it passes once I disable GNU ld and add LLD specific diff ignores):

    Validation failed.
    wild: /home/mateusz/Projects/wild/wild/tests/build/elf/x86_64/cpp-integration/static-no-relax/cpp-integration.cc.wild
    ld: /home/mateusz/Projects/wild/wild/tests/build/elf/x86_64/cpp-integration/static-no-relax/cpp-integration.cc.ld
    lld: /home/mateusz/Projects/wild/wild/tests/build/elf/x86_64/cpp-integration/static-no-relax/cpp-integration.cc.lld
    init_array
      ┌──────────────────────────────────────┬──────────────────────────────────────┬──────────────────────────────────────┐
      │ wild                                 │ ld                                   │ lld                                  │
      ├──────────────────────────────────────┼──────────────────────────────────────┼──────────────────────────────────────┤
      │ _GLOBAL__sub_I.00090_globals_io.cc   │ _GLOBAL__sub_I.00090_globals_io.cc   │ _GLOBAL__sub_I.00090_globals_io.cc   │
      │ frame_dummy                          │ frame_dummy                          │ frame_dummy                          │
      │ _GLOBAL__sub_I_eh_alloc.cc           │ _GLOBAL__sub_I_cxx11_wlocale_inst.cc │ _GLOBAL__sub_I_eh_alloc.cc           │
      │ _GLOBAL__sub_I_cxx11_locale_inst.cc  │ _GLOBAL__sub_I_locale_inst.cc        │ _GLOBAL__sub_I_cxx11_locale_inst.cc  │
      │ _GLOBAL__sub_I_cxx11_wlocale_inst.cc │ _GLOBAL__sub_I_wlocale_inst.cc       │ _GLOBAL__sub_I_cxx11_wlocale_inst.cc │
      │ _GLOBAL__sub_I_locale_inst.cc        │ _GLOBAL__sub_I_eh_alloc.cc           │ _GLOBAL__sub_I_locale_inst.cc        │
      │ _GLOBAL__sub_I_wlocale_inst.cc       │ _GLOBAL__sub_I_cxx11_locale_inst.cc  │ _GLOBAL__sub_I_wlocale_inst.cc       │
      │ _IO_stdfiles_init                    │ _IO_stdfiles_init                    │ _IO_stdfiles_init                    │
      └──────────────────────────────────────┴──────────────────────────────────────┴──────────────────────────────────────┘

Shouldn't it pass when matching either ld or LLD?

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.

Sorting by symbol name would be odd, since the linker is sorting input sections not symbols and an input section could contain relocations for multiple symbols. Sorting by section name wouldn't help when most of the input sections are just called .init_array.

Regarding linker-diff match-one vs match-all, it looks like init_array diffing uses header_diff::diff_array, which checks if all values are equal. i.e. the match-any behaviour was never applied to that bit of code.

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.

I must have confused this with something else then.

@mati865 mati865 marked this pull request as draft April 4, 2026 19:50
@mati865 mati865 marked this pull request as ready for review April 6, 2026 10:23
@mati865 mati865 merged commit b3c508e into wild-linker:main Apr 6, 2026
24 checks passed
@mati865 mati865 deleted the push-xmkystoqvouk branch April 6, 2026 11:53
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