This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Provide WasmFunction content offset informatin.
ClosedPublic

Authored by yurydelendik on May 11 2018, 11:26 AM.

Details

Summary

WasmObjectWriter mostly operates with function segments offsets that do not
include their size fields. WasmObjectFile needs to have and provide this
information to the lld to maintain proper R_WEBASSEMBLY_FUNCTION_OFFSET_I32
relocations entries.

Diff Detail

Repository
rL LLVM

Event Timeline

yurydelendik created this revision.May 11 2018, 11:26 AM
sbc100 accepted this revision.May 14 2018, 11:09 AM
sbc100 added a subscriber: aardappel.
sbc100 added inline comments.
lib/Object/WasmObjectFile.cpp
878 ↗(On Diff #146370)

As an alternative, perhaps we could just move the const uint8_t *FunctionStart = Ptr; down a couple of lines so that the function body no longer includes its size?

The downside would be that the linker would need to re-encode the size for each function.

@aardappel was recently looking making objdump -d work and he ran into issues relating to pointer the actual start of the instructions.

Having said all that, this seems like a perfectly reasonable interim fix.

This revision is now accepted and ready to land.May 14 2018, 11:09 AM
aardappel added inline comments.May 14 2018, 12:01 PM
lib/Object/WasmObjectFile.cpp
878 ↗(On Diff #146370)

I could already fix objdump to give correct output for wasm disassembly, but that would require a some wasm-specific parsing in objdump. Question is, can we do this more generically such that objdump does things correctly automatically?
Some wasm specific code may be unavoidable, if we'd also like to interleave a disassembly with local/arg annotations etc.

yurydelendik added inline comments.May 15 2018, 11:03 AM
lib/Object/WasmObjectFile.cpp
878 ↗(On Diff #146370)

It looks like it is possible to exclude function size from data and use CodeSectionOffset as a start of the function. (LLD's CodeSection needs to be changed to generate function size/header) Would you like to do that instead?

Should I land this now?

This revision was automatically updated to reflect the committed changes.