This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Apply data relocations at runtime in shared objects
ClosedPublic

Authored by sbc100 on Mar 12 2019, 4:06 PM.

Details

Summary

See: https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md

Data section relocations in wasm shared libraries are applied by the library
itself at static constructor time. This change adds a new synthetic function
that applies relocations to relevant memory locations on startup.

Event Timeline

sbc100 created this revision.Mar 12 2019, 4:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 12 2019, 4:06 PM
sbc100 updated this revision to Diff 190356.Mar 12 2019, 4:41 PM
  • clang-format
  • comments
  • cleanup
sbc100 updated this revision to Diff 190357.Mar 12 2019, 4:42 PM
  • comments
Harbormaster completed remote builds in B29060: Diff 190357.
sbc100 retitled this revision from [WebAssembly] Create runtime relocations in shared objects to [WebAssembly] Apply data relocations at runtime in shared objects.Mar 12 2019, 4:46 PM
sbc100 edited the summary of this revision. (Show Details)
sbc100 added a reviewer: ruiu.
ruiu added inline comments.Mar 13 2019, 2:50 PM
lld/wasm/Driver.cpp
284

Is the combination of --entry and --relocatable valid? Maybe we should reject that combination in the driver?

lld/wasm/InputChunks.cpp
303

Instead of creating a table for the run-time loader to fix these addresses, do we generate code in the linker to do it as part of process initialization?

304

Should be uint32_t?

sbc100 marked an inline comment as done.Mar 14 2019, 8:56 AM
sbc100 added inline comments.
lld/wasm/InputChunks.cpp
303

Yes. And only for the data section. The keeps the dynamic linker very simple avoids the need to spec an ABI for runtime relocations.

sbc100 updated this revision to Diff 193411.Apr 2 2019, 6:51 PM
  • rebase
sbc100 updated this revision to Diff 193419.Apr 2 2019, 7:42 PM
sbc100 marked 4 inline comments as done.
  • feedback
lld/wasm/Driver.cpp
284

We already do check for this in checkOptions (see error("entry point specified for relocatable output file"))

ruiu accepted this revision.Apr 2 2019, 10:09 PM

LGTM

This revision is now accepted and ready to land.Apr 2 2019, 10:09 PM
This revision was automatically updated to reflect the committed changes.