This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Fix R_WEBASSEMBLY_FUNCTION_OFFSET_I32 relocation entries
ClosedPublic

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

Details

Summary

Fixes: lld: warning: unexpected existing value for R_WEBASSEMBLY_FUNCTION_OFFSET_I32: existing=839 expected=838

The existing solution is trying to erroneously recover correct offset of the
function code from the body (which is not a function segment that includes its
size, locals, and code).

The D46763 is trying to maintain the offset of the function code allowing
properly calculate the new relocation entry.

(Test case is possible, but will require 128+ bytes function code segments)

Diff Detail

Repository
rL LLVM

Event Timeline

yurydelendik created this revision.May 11 2018, 11:34 AM
sbc100 accepted this revision.May 14 2018, 11:11 AM
sbc100 added inline comments.
wasm/InputFiles.cpp
48 ↗(On Diff #146371)

Where is the actual bug? This code looks like its doing the right thing, no?

This revision is now accepted and ready to land.May 14 2018, 11:11 AM
yurydelendik added inline comments.May 14 2018, 11:30 AM
wasm/InputFiles.cpp
48 ↗(On Diff #146371)

Actual bug is: Function->getFunctionBody() returns only operators data (without function size and params/locals), but I assumed it will be an entire function data (inculding function size).

The actual intent was to know function code offset (+params/locals) to properly perform calcNewValue and calcExpectedValue

I think you can remove getFunctionBody()?

Remove getFunctionBody()

sbc100 accepted this revision.May 15 2018, 12:34 PM
This revision was automatically updated to reflect the committed changes.