aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/WasmObjectWriter.cpp
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2021-02-07 18:51:42 -0800
committerSam Clegg <sbc@chromium.org>2021-02-08 16:56:57 -0800
commit01a48535c31169461d4eedddb48c00b79277f388 (patch)
tree0709a465c5e43b72c5c01e1178735a19bce5f841 /llvm/lib/MC/WasmObjectWriter.cpp
parent622611f7e5b2c42ad3c34aec4a77a82adf6d9e36 (diff)
downloadllvm-01a48535c31169461d4eedddb48c00b79277f388.zip
llvm-01a48535c31169461d4eedddb48c00b79277f388.tar.gz
llvm-01a48535c31169461d4eedddb48c00b79277f388.tar.bz2
[MC][WebAssembly] Fix provisional values for data alias relocations
When calculating the symbol offsets to write as provisitonal values in object files we are only interested in the offset of the symbol itself. For aliases this offset already includes the offset of the base symbol. The testin question was added back in https://reviews.llvm.org/D87407 but I believe the expectations here were incorrect. sym_a lives at offset 4 and sym_b lives 4 bytes into that (should be 8). The addresses of the 3 symbosl in this object file are: foo : 0 sym_a: 4 sym_b: 8 Differential Revision: https://reviews.llvm.org/D96234
Diffstat (limited to 'llvm/lib/MC/WasmObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/WasmObjectWriter.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 6b775e1..d16be49 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -610,16 +610,13 @@ WasmObjectWriter::getProvisionalValue(const WasmRelocationEntry &RelEntry,
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");