if (IsAddressTaken.count(&WS))
TableElems.push_back(Index);
} else {
- if (WS.getOffset() != 0)
- report_fatal_error("data sections must contain one variable each");
- if (!WS.getSize())
- report_fatal_error("data symbols must have a size set with .size");
-
- int64_t Size = 0;
- if (!WS.getSize()->evaluateAsAbsolute(Size, Layout))
- report_fatal_error(".size expression must be evaluatable");
+ if (WS.isTemporary() && !WS.getSize())
+ continue;
if (WS.isDefined(false)) {
+ if (WS.getOffset() != 0)
+ report_fatal_error("data sections must contain one variable each: " +
+ WS.getName());
+ if (!WS.getSize())
+ report_fatal_error("data symbols must have a size set with .size: " +
+ WS.getName());
+
+ int64_t Size = 0;
+ if (!WS.getSize()->evaluateAsAbsolute(Size, Layout))
+ report_fatal_error(".size expression must be evaluatable");
+
MCSectionWasm &DataSection =
static_cast<MCSectionWasm &>(WS.getSection());
--- /dev/null
+; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj %s -o - | obj2yaml | FileCheck %s
+; Verify relocations are correctly generated for addresses of externals
+; in the data section.
+
+declare i32 @f1(...)
+
+@foo = global i64 7, align 4
+@far = local_unnamed_addr global i32 (...)* @f1, align 4
+
+; CHECK: - Type: DATA
+; CHECK: Relocations:
+; CHECK: - Type: R_WEBASSEMBLY_GLOBAL_ADDR_I32
+; CHECK: Index: 0
+; CHECK: Offset: 0x0000000E
+; CHECK: Segments:
+; CHECK: - Index: 0
+; CHECK: Offset:
+; CHECK: Opcode: I32_CONST
+; CHECK: Value: 0
+; CHECK: Content: 0700000000000000FFFFFFFF
+