diff options
| author | Sam Clegg <sbc@chromium.org> | 2018-05-22 17:06:55 +0000 |
|---|---|---|
| committer | Sam Clegg <sbc@chromium.org> | 2018-05-22 17:06:55 +0000 |
| commit | 65a91288fcbf128538bd1bd227de5f8bb29784b5 (patch) | |
| tree | 783ed1fa31a1add85f75b7c27b649a1d11e2dcb8 | |
| parent | 7701360308067676a2e5500b4c9470c6caac7dcb (diff) | |
| download | bcm5719-llvm-65a91288fcbf128538bd1bd227de5f8bb29784b5.tar.gz bcm5719-llvm-65a91288fcbf128538bd1bd227de5f8bb29784b5.zip | |
[WebAssembly] Fix two bugs in LEB compression: properly calculate function body offset, and write I32 values.
* Gets function size field from right location
* Writes I32 values during compression
Patch by Yury Delendik
Differential Revision: https://reviews.llvm.org/D47204
llvm-svn: 333002
| -rw-r--r-- | lld/wasm/InputChunks.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lld/wasm/InputChunks.cpp b/lld/wasm/InputChunks.cpp index a28f81f24dd..b14a6791180 100644 --- a/lld/wasm/InputChunks.cpp +++ b/lld/wasm/InputChunks.cpp @@ -195,6 +195,7 @@ static unsigned writeCompressedReloc(uint8_t *Buf, const WasmRelocation &Rel, return encodeSLEB128(static_cast<int32_t>(Value), Buf); case R_WEBASSEMBLY_TABLE_INDEX_I32: case R_WEBASSEMBLY_MEMORY_ADDR_I32: + write32le(Buf, Value); return 4; default: llvm_unreachable("unknown relocation type"); @@ -279,7 +280,7 @@ void InputFunction::writeTo(uint8_t *Buf) const { const uint8_t *FuncStart = SecStart + getInputSectionOffset(); const uint8_t *End = FuncStart + Function->Size; uint32_t Count; - decodeULEB128(Buf, &Count); + decodeULEB128(FuncStart, &Count); FuncStart += Count; DEBUG(dbgs() << "write func: " << getName() << "\n"); |

