[PATCH] D44136: [WebAssebmly] Remove reloc ordering constraint

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 5 23:13:18 PST 2018


sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin.

The MC layer doesn't currently emit relocations in offset
order for the entire code section so this check was causing
failures on the wasm waterfall.

Perhaps we can re-instate this check if we devide the relocations
per-function, or add extra ordering the MC object writer.


Repository:
  rL LLVM

https://reviews.llvm.org/D44136

Files:
  lib/Object/WasmObjectFile.cpp


Index: lib/Object/WasmObjectFile.cpp
===================================================================
--- lib/Object/WasmObjectFile.cpp
+++ lib/Object/WasmObjectFile.cpp
@@ -554,7 +554,6 @@
     return make_error<GenericBinaryError>("Invalid section code",
                                           object_error::parse_failed);
   uint32_t RelocCount = readVaruint32(Ptr);
-  uint32_t LastOffset = 0;
   uint32_t EndOffset = Section->Content.size();
   while (RelocCount--) {
     wasm::WasmRelocation Reloc = {};
@@ -593,17 +592,17 @@
                                             object_error::parse_failed);
     }
 
+    DEBUG(dbgs() << "Adding relocation: " << Reloc.Offset << "\n");
     // Relocations must fit inside the section, and must appear in order.  They
     // also shouldn't overlap a function/element boundary, but we don't bother
     // to check that.
     uint64_t Size = 5;
     if (Reloc.Type == wasm::R_WEBASSEMBLY_TABLE_INDEX_I32 ||
         Reloc.Type == wasm::R_WEBASSEMBLY_MEMORY_ADDR_I32)
       Size = 4;
-    if (Reloc.Offset < LastOffset || Reloc.Offset + Size > EndOffset)
+    if (Reloc.Offset + Size > EndOffset)
       return make_error<GenericBinaryError>("Bad relocation offset",
                                             object_error::parse_failed);
-    LastOffset = Reloc.Offset;
 
     Section->Relocations.push_back(Reloc);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44136.137130.patch
Type: text/x-patch
Size: 1379 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180306/95d211a7/attachment.bin>


More information about the llvm-commits mailing list