This is an archive of the discontinued LLVM Phabricator instance.

[lld][WebAssembly] Perform data relocations during start function
ClosedPublic

Authored by sbc100 on Jan 15 2022, 6:10 PM.

Details

Summary

We already perform memory initialization and apply global relocations
during start. It makes sense to performs data relocations too. I think
the reason we were not doing this already is solely historical.

Diff Detail

Event Timeline

sbc100 created this revision.Jan 15 2022, 6:10 PM
sbc100 requested review of this revision.Jan 15 2022, 6:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 15 2022, 6:10 PM
sbc100 updated this revision to Diff 400334.Jan 15 2022, 6:12 PM
  • update
sbc100 updated this revision to Diff 400337.Jan 15 2022, 7:09 PM
  • update
sbc100 updated this revision to Diff 400384.Jan 16 2022, 7:52 AM
  • rebase

Who was previously responsible for applying the data relocs? If it was Emscripten runtime code, does that mean this change will have to land alongside the corresponding Emscripten change? Is there anyone who would be broken by this ABI break who we should notify?

lld/wasm/Writer.cpp
1261–1268

Can we add a test that exercises this case?

Who was previously responsible for applying the data relocs? If it was Emscripten runtime code, does that mean this change will have to land alongside the corresponding Emscripten change? Is there anyone who would be broken by this ABI break who we should notify?

Previously it was treated as the very first ctor in __wasm_call_ctors.. (which emscripten take care of calling). Now it happens earlier, removing that window where the relocations have not yet been applied.

sbc100 updated this revision to Diff 400959.Jan 18 2022, 12:54 PM
  • add testing
sbc100 updated this revision to Diff 400962.Jan 18 2022, 12:59 PM
  • add tests
sbc100 added inline comments.Jan 18 2022, 1:00 PM
lld/wasm/Writer.cpp
1261–1268

I think we have coverage of all three branches above now.

tlively accepted this revision.Jan 18 2022, 2:04 PM
This revision is now accepted and ready to land.Jan 18 2022, 2:04 PM