This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Fix offsets for data relocations
ClosedPublic

Authored by sbc100 on Apr 25 2017, 5:25 PM.

Details

Summary

The code relocations getSectionOffset() returns the offset into the code
section for the data relocations it returns the offset into the data payload
which doesn't take into account the header of the data section.

As an alternative to this approach we could fixup all the FixupSection
fields of the data relocations once we know the header size.

The added test fails without this change (generates an invalid wasm
file).

Event Timeline

sbc100 created this revision.Apr 25 2017, 5:25 PM
sbc100 retitled this revision from [WebAssembly] Add size of section header to data relocation offsets. to [WebAssembly] Fix offsets for data relocations.Apr 25 2017, 5:31 PM
sbc100 edited the summary of this revision. (Show Details)
sbc100 added a reviewer: sunfish.
sbc100 updated this revision to Diff 96827.Apr 26 2017, 2:44 PM
  • Merge remote-tracking branch 'origin/master' into fix_data_relocations
  • Add test
sbc100 edited the summary of this revision. (Show Details)Apr 26 2017, 2:45 PM
sbc100 updated this revision to Diff 96829.Apr 26 2017, 2:48 PM
  • update comment
dschuff accepted this revision.Apr 26 2017, 3:04 PM

Don't have a strong opinion but this seems better than fixing up the relocations separately. Maybe the comment on the SectionOffset field of MCSectionWasm should be updated (or some other place) to say that the section offsets don't include headers. Also it says "code section" when it's really more general than that now.

This revision is now accepted and ready to land.Apr 26 2017, 3:04 PM
sbc100 updated this revision to Diff 96968.Apr 27 2017, 12:06 PM
  • simplify
sbc100 updated this revision to Diff 97152.Apr 28 2017, 1:28 PM
  • Merge remote-tracking branch 'origin/master' into fix_data_relocations
  • add offsets
  • Merge remote-tracking branch 'origin/master' into fix_data_relocations
  • Merge remote-tracking branch 'origin/master' into fix_data_relocations
  • use signed addend
sbc100 updated this revision to Diff 97156.Apr 28 2017, 1:49 PM
  • formatting + comment fix

Don't have a strong opinion but this seems better than fixing up the relocations separately. Maybe the comment on the SectionOffset field of MCSectionWasm should be updated (or some other place) to say that the section offsets don't include headers. Also it says "code section" when it's really more general than that now.

Done.

LGTM, this is even better.

lib/MC/WasmObjectWriter.cpp
470–471

should these be on separate lines to match the rest?

sbc100 updated this revision to Diff 97163.Apr 28 2017, 2:32 PM
  • Merge remote-tracking branch 'origin/master' into fix_data_relocations
  • formatting
sbc100 added inline comments.Apr 28 2017, 2:33 PM
lib/MC/WasmObjectWriter.cpp
470–471

Ran clang format to fix correctly.

This revision was automatically updated to reflect the committed changes.