On elf, undefined symbols can start with .L.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 28 Sep 2010 16:19:11 +0000 (16:19 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 28 Sep 2010 16:19:11 +0000 (16:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114958 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/ELFObjectWriter.cpp
test/MC/ELF/undef.s [new file with mode: 0644]

index 120789b6fd0c26c85149195977f957a8566d9f22..b60271f1b2009a85b0c9a1c6c303e594c6d4d4e7 100644 (file)
@@ -689,12 +689,15 @@ void ELFObjectWriterImpl::ComputeSymbolTable(MCAssembler &Asm) {
     const MCSymbol &Symbol = it->getSymbol();
 
     // Ignore non-linker visible symbols.
-    if (!Asm.isSymbolLinkerVisible(Symbol))
+    if (!Asm.isSymbolLinkerVisible(Symbol) && !Symbol.isUndefined())
       continue;
 
     if (!it->isExternal() && !Symbol.isUndefined())
       continue;
 
+    if (Symbol.isVariable())
+      continue;
+
     uint64_t &Entry = StringIndexMap[Symbol.getName()];
     if (!Entry) {
       Entry = StringTable.size();
diff --git a/test/MC/ELF/undef.s b/test/MC/ELF/undef.s
new file mode 100644 (file)
index 0000000..59bcc9f
--- /dev/null
@@ -0,0 +1,15 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump  | FileCheck %s
+
+// Test that there is an undefined reference to .Lset0, but not .Lset1
+
+        .long  .Lset0
+foo:
+bar:
+.Lset1 = foo - bar
+        .long  .Lset1
+
+// CHECK: ('_symbols', [
+// CHECK-NOT: Lset1
+// CHECK:  (('st_name', 9) # '.Lset0'
+// CHECK-NOT: Lset1
+// CHECK: (('sh_name', 36) # '.strtab'