chore: replace TODO with a comment#1798
Conversation
| //#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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I must have confused this with something else then.
The context: #1654 (comment)