[lld] r333002 - [WebAssembly] Fix two bugs in LEB compression: properly calculate function body offset, and write I32 values.

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Tue May 22 10:06:55 PDT 2018


Author: sbc
Date: Tue May 22 10:06:55 2018
New Revision: 333002

URL: http://llvm.org/viewvc/llvm-project?rev=333002&view=rev
Log:
[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

Modified:
    lld/trunk/wasm/InputChunks.cpp

Modified: lld/trunk/wasm/InputChunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputChunks.cpp?rev=333002&r1=333001&r2=333002&view=diff
==============================================================================
--- lld/trunk/wasm/InputChunks.cpp (original)
+++ lld/trunk/wasm/InputChunks.cpp Tue May 22 10:06:55 2018
@@ -195,6 +195,7 @@ static unsigned writeCompressedReloc(uin
     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 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");




More information about the llvm-commits mailing list