This is an archive of the discontinued LLVM Phabricator instance.

[lld][WebAssembly] Add suppport for PIC + passive data initialization
ClosedPublic

Authored by sbc100 on Dec 3 2020, 4:55 PM.

Details

Summary

This change improves our support for shared memory to include
PIC executables (and shared libraries).

To handle this case the linker-generated __wasm_init_memory
function (that only exists in shared memory builds) must be
capable of loading memory segements at non-const offsets based
on the runtime value of __memory_base.

Diff Detail

Unit TestsFailed

Event Timeline

sbc100 created this revision.Dec 3 2020, 4:55 PM
sbc100 requested review of this revision.Dec 3 2020, 4:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 3 2020, 4:55 PM

Still need to add testing..

dschuff added inline comments.Dec 3 2020, 4:58 PM
lld/wasm/Writer.cpp
880

should this be conditionalized for wasm64?
alternatively, throw a nice error if we don't want to implement it right now.

Looks good so far!

lld/wasm/Writer.cpp
934
961–962

This repeated code chunk could be extracted into a small lambda to reduce repetition.

sbc100 updated this revision to Diff 309444.Dec 3 2020, 7:15 PM
  • rebase + add test
sbc100 updated this revision to Diff 309445.EditedDec 3 2020, 7:17 PM
sbc100 marked 3 inline comments as done.

feedback

tlively accepted this revision.Dec 3 2020, 8:11 PM
tlively added inline comments.
lld/wasm/Writer.cpp
941–948

I think this will make the logic clearer.

This revision is now accepted and ready to land.Dec 3 2020, 8:11 PM
sbc100 updated this revision to Diff 309450.Dec 3 2020, 8:21 PM
  • fix start
This revision was landed with ongoing or failed builds.Dec 4 2020, 5:29 PM
This revision was automatically updated to reflect the committed changes.
sbc100 marked an inline comment as done.