Fix PR18381 - print a minimal diagnostic rather than assert on unresolved .secidx...
authorTimur Iskhodzhanov <timurrrr@google.com>
Thu, 30 Jan 2014 21:13:05 +0000 (21:13 +0000)
committerTimur Iskhodzhanov <timurrrr@google.com>
Thu, 30 Jan 2014 21:13:05 +0000 (21:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200490 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCAssembler.h
lib/MC/WinCOFFObjectWriter.cpp
test/MC/COFF/secidx-diagnostic.s [new file with mode: 0644]

index e1cf66d3f9ec84023209f32383649ce461aa2464..0d12a5d5c8d7471c84d45ac699c57db7c507de4e 100644 (file)
@@ -1153,6 +1153,10 @@ public:
     return *Entry;
   }
 
+  bool hasSymbolData(const MCSymbol &Symbol) const {
+    return SymbolMap.lookup(&Symbol) != 0;
+  }
+
   MCSymbolData &getSymbolData(const MCSymbol &Symbol) const {
     MCSymbolData *Entry = SymbolMap.lookup(&Symbol);
     assert(Entry && "Missing symbol data!");
index ed19b7ec69dd2519edf40e3ae0cf61ec6ac74cad..b68e69f2eb3419d28318633c4da6981f07fd028f 100644 (file)
@@ -636,6 +636,11 @@ void WinCOFFObjectWriter::RecordRelocation(const MCAssembler &Asm,
 
   const MCSymbol &Symbol = Target.getSymA()->getSymbol();
   const MCSymbol &A = Symbol.AliasedSymbol();
+  if (!Asm.hasSymbolData(A))
+    Asm.getContext().FatalError(
+        Fixup.getLoc(),
+        Twine("symbol '") + A.getName() + "' can not be undefined");
+
   MCSymbolData &A_SD = Asm.getSymbolData(A);
 
   MCSectionData const *SectionData = Fragment->getParent();
diff --git a/test/MC/COFF/secidx-diagnostic.s b/test/MC/COFF/secidx-diagnostic.s
new file mode 100644 (file)
index 0000000..3e496c3
--- /dev/null
@@ -0,0 +1,8 @@
+// RUN: not llvm-mc -filetype=obj -triple i686-pc-win32 %s 2>%t
+// RUN: FileCheck %s < %t
+
+// CHECK: symbol 'bar' can not be undefined
+
+.data
+foo:
+        .secidx bar