[PATCH] D96234: [MC][WebAssembly] Fix provisional values for data alias relocations

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 8 17:00:31 PST 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG01a48535c311: [MC][WebAssembly] Fix provisional values for data alias relocations (authored by sbc100).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96234/new/

https://reviews.llvm.org/D96234

Files:
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/test/MC/WebAssembly/alias-offset.s


Index: llvm/test/MC/WebAssembly/alias-offset.s
===================================================================
--- llvm/test/MC/WebAssembly/alias-offset.s
+++ llvm/test/MC/WebAssembly/alias-offset.s
@@ -27,8 +27,8 @@
 
 # CHECK-LABEL: <main>:
 # CHECK-EMPTY:
-# CHECK-NEXT:       3: 41 88 80 80 80 00     i32.const       8
+# CHECK-NEXT:       3: 41 84 80 80 80 00     i32.const       4
 # CHECK-NEXT:                        00000004:  R_WASM_MEMORY_ADDR_SLEB      sym_a+0
-# CHECK-NEXT:       9: 36 02 8c 80 80 80 00  i32.store       12
+# CHECK-NEXT:       9: 36 02 88 80 80 80 00  i32.store       8
 # CHECK-NEXT:                        0000000b:  R_WASM_MEMORY_ADDR_LEB      sym_b+0
 # CHECK-NEXT:      10: 0b            end
Index: llvm/lib/MC/WasmObjectWriter.cpp
===================================================================
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -610,16 +610,13 @@
   case wasm::R_WASM_MEMORY_ADDR_I64:
   case wasm::R_WASM_MEMORY_ADDR_TLS_SLEB: {
     // Provisional value is address of the global plus the offset
-    const MCSymbolWasm *Base =
-        cast<MCSymbolWasm>(Layout.getBaseSymbol(*RelEntry.Symbol));
     // For undefined symbols, use zero
-    if (!Base->isDefined())
+    if (!RelEntry.Symbol->isDefined())
       return 0;
-    const wasm::WasmDataReference &BaseRef = DataLocations[Base],
-                                  &SymRef = DataLocations[RelEntry.Symbol];
-    const WasmDataSegment &Segment = DataSegments[BaseRef.Segment];
+    const wasm::WasmDataReference &SymRef = DataLocations[RelEntry.Symbol];
+    const WasmDataSegment &Segment = DataSegments[SymRef.Segment];
     // Ignore overflow. LLVM allows address arithmetic to silently wrap.
-    return Segment.Offset + BaseRef.Offset + SymRef.Offset + RelEntry.Addend;
+    return Segment.Offset + SymRef.Offset + RelEntry.Addend;
   }
   default:
     llvm_unreachable("invalid relocation type");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96234.322243.patch
Type: text/x-patch
Size: 1954 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210209/56cf3036/attachment.bin>


More information about the llvm-commits mailing list