[llvm-commits] [llvm] r120100 - in /llvm/trunk: lib/MC/MCELFStreamer.cpp test/MC/ELF/tls-i386.s test/MC/ELF/tls.s

Rafael Espindola rafael.espindola at gmail.com
Wed Nov 24 10:51:21 PST 2010


Author: rafael
Date: Wed Nov 24 12:51:21 2010
New Revision: 120100

URL: http://llvm.org/viewvc/llvm-project?rev=120100&view=rev
Log:
Fix and add tests for all cases in x86 and x86_64 where gnu as implicitly
sets the type of a symbol to STT_TLS.

Added:
    llvm/trunk/test/MC/ELF/tls-i386.s
Modified:
    llvm/trunk/lib/MC/MCELFStreamer.cpp
    llvm/trunk/test/MC/ELF/tls.s

Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=120100&r1=120099&r2=120100&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.cpp Wed Nov 24 12:51:21 2010
@@ -467,12 +467,20 @@
 
   case MCExpr::SymbolRef: {
     const MCSymbolRefExpr &symRef = *cast<MCSymbolRefExpr>(expr);
-    MCSymbolRefExpr::VariantKind kind = symRef.getKind();
-    if (kind != MCSymbolRefExpr::VK_TLSGD &&
-	kind != MCSymbolRefExpr::VK_TLSLD &&
-	kind != MCSymbolRefExpr::VK_TLSLDM &&
-	kind != MCSymbolRefExpr::VK_ARM_TLSGD)
+    switch (symRef.getKind()) {
+    default:
       return;
+    case MCSymbolRefExpr::VK_NTPOFF:
+    case MCSymbolRefExpr::VK_GOTNTPOFF:
+    case MCSymbolRefExpr::VK_TLSGD:
+    case MCSymbolRefExpr::VK_TLSLDM:
+    case MCSymbolRefExpr::VK_TPOFF:
+    case MCSymbolRefExpr::VK_DTPOFF:
+    case MCSymbolRefExpr::VK_GOTTPOFF:
+    case MCSymbolRefExpr::VK_TLSLD:
+    case MCSymbolRefExpr::VK_ARM_TLSGD:
+      break;
+    }
     MCSymbolData &SD = getAssembler().getOrCreateSymbolData(symRef.getSymbol());
     SetType(SD, ELF::STT_TLS);
     break;

Added: llvm/trunk/test/MC/ELF/tls-i386.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/tls-i386.s?rev=120100&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/tls-i386.s (added)
+++ llvm/trunk/test/MC/ELF/tls-i386.s Wed Nov 24 12:51:21 2010
@@ -0,0 +1,64 @@
+// RUN: llvm-mc -filetype=obj -triple i386-pc-linux-gnu %s -o - | elf-dump  | FileCheck %s
+
+// Test that all symbols are of type STT_TLS.
+
+        movl    foo1 at NTPOFF(%eax), %eax
+        movl    foo2 at GOTNTPOFF(%eax), %eax
+        movl    foo3 at TLSGD(%eax), %eax
+        movl    foo4 at TLSLDM(%eax), %eax
+        movl    foo5 at TPOFF(%eax), %eax
+        movl    foo6 at DTPOFF(%eax), %eax
+
+// CHECK:       (('st_name', 0x00000001) # 'foo1'
+// CHECK-NEXT:   ('st_value', 0x00000000)
+// CHECK-NEXT:   ('st_size', 0x00000000)
+// CHECK-NEXT:   ('st_bind', 0x00000001)
+// CHECK-NEXT:   ('st_type', 0x00000006)
+// CHECK-NEXT:   ('st_other', 0x00000000)
+// CHECK-NEXT:   ('st_shndx', 0x00000000)
+// CHECK-NEXT:  ),
+// CHECK-NEXT:  # Symbol 0x00000006
+// CHECK-NEXT:  (('st_name', 0x00000006) # 'foo2'
+// CHECK-NEXT:   ('st_value', 0x00000000)
+// CHECK-NEXT:   ('st_size', 0x00000000)
+// CHECK-NEXT:   ('st_bind', 0x00000001)
+// CHECK-NEXT:   ('st_type', 0x00000006)
+// CHECK-NEXT:   ('st_other', 0x00000000)
+// CHECK-NEXT:   ('st_shndx', 0x00000000)
+// CHECK-NEXT:  ),
+// CHECK-NEXT:  # Symbol 0x00000007
+// CHECK-NEXT:  (('st_name', 0x0000000b) # 'foo3'
+// CHECK-NEXT:   ('st_value', 0x00000000)
+// CHECK-NEXT:   ('st_size', 0x00000000)
+// CHECK-NEXT:   ('st_bind', 0x00000001)
+// CHECK-NEXT:   ('st_type', 0x00000006)
+// CHECK-NEXT:   ('st_other', 0x00000000)
+// CHECK-NEXT:   ('st_shndx', 0x00000000)
+// CHECK-NEXT:  ),
+// CHECK-NEXT:  # Symbol 0x00000008
+// CHECK-NEXT:  (('st_name', 0x00000010) # 'foo4'
+// CHECK-NEXT:   ('st_value', 0x00000000)
+// CHECK-NEXT:   ('st_size', 0x00000000)
+// CHECK-NEXT:   ('st_bind', 0x00000001)
+// CHECK-NEXT:   ('st_type', 0x00000006)
+// CHECK-NEXT:   ('st_other', 0x00000000)
+// CHECK-NEXT:   ('st_shndx', 0x00000000)
+// CHECK-NEXT:  ),
+// CHECK-NEXT:  # Symbol 0x00000009
+// CHECK-NEXT:  (('st_name', 0x00000015) # 'foo5'
+// CHECK-NEXT:   ('st_value', 0x00000000)
+// CHECK-NEXT:   ('st_size', 0x00000000)
+// CHECK-NEXT:   ('st_bind', 0x00000001)
+// CHECK-NEXT:   ('st_type', 0x00000006)
+// CHECK-NEXT:   ('st_other', 0x00000000)
+// CHECK-NEXT:   ('st_shndx', 0x00000000)
+// CHECK-NEXT:  ),
+// CHECK-NEXT:  # Symbol 0x0000000a
+// CHECK-NEXT:  (('st_name', 0x0000001a) # 'foo6'
+// CHECK-NEXT:   ('st_value', 0x00000000)
+// CHECK-NEXT:   ('st_size', 0x00000000)
+// CHECK-NEXT:   ('st_bind', 0x00000001)
+// CHECK-NEXT:   ('st_type', 0x00000006)
+// CHECK-NEXT:   ('st_other', 0x00000000)
+// CHECK-NEXT:   ('st_shndx', 0x00000000)
+// CHECK-NEXT:  ),

Modified: llvm/trunk/test/MC/ELF/tls.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/tls.s?rev=120100&r1=120099&r2=120100&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/tls.s (original)
+++ llvm/trunk/test/MC/ELF/tls.s Wed Nov 24 12:51:21 2010
@@ -1,14 +1,16 @@
 // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump  | FileCheck %s
 
-// Test that foo and foobar is of type STT_TLS.
+// Test that all symbols are of type STT_TLS.
 
-	leaq	foo at TLSGD(%rip), %rdi
+	leaq	foo1 at TLSGD(%rip), %rdi
+        leaq    foo2 at GOTTPOFF(%rip), %rdi
+        leaq    foo3 at TLSLD(%rip), %rdi
 
 	.section	.zed,"awT", at progbits
 foobar:
 	.long	43
 
-// CHECK:      (('st_name', 0x00000005) # 'foobar'
+// CHECK:      (('st_name', 0x00000010) # 'foobar'
 // CHECK-NEXT:  ('st_bind', 0x00000000)
 // CHECK-NEXT:  ('st_type', 0x00000006)
 // CHECK-NEXT:  ('st_other', 0x00000000)
@@ -17,11 +19,30 @@
 // CHECK-NEXT:  ('st_size', 0x00000000)
 // CHECK-NEXT: ),
 
-// CHECK:      (('st_name', 0x00000001) # 'foo'
-// CHECK-NEXT:  ('st_bind', 0x00000001)
-// CHECK-NEXT:  ('st_type', 0x00000006)
-// CHECK-NEXT:  ('st_other', 0x00000000)
-// CHECK-NEXT:  ('st_shndx', 0x00000000)
-// CHECK-NEXT:  ('st_value', 0x00000000)
-// CHECK-NEXT:  ('st_size', 0x00000000)
-// CHECK-NEXT: ),
+// CHECK:       # Symbol 0x00000007
+// CHECK-NEXT:  (('st_name', 0x00000001) # 'foo1'
+// CHECK-NEXT:   ('st_bind', 0x00000001)
+// CHECK-NEXT:   ('st_type', 0x00000006)
+// CHECK-NEXT:   ('st_other', 0x00000000)
+// CHECK-NEXT:   ('st_shndx', 0x00000000)
+// CHECK-NEXT:   ('st_value', 0x00000000)
+// CHECK-NEXT:   ('st_size', 0x00000000)
+// CHECK-NEXT:  ),
+// CHECK-NEXT:  # Symbol 0x00000008
+// CHECK-NEXT:  (('st_name', 0x00000006) # 'foo2'
+// CHECK-NEXT:   ('st_bind', 0x00000001)
+// CHECK-NEXT:   ('st_type', 0x00000006)
+// CHECK-NEXT:   ('st_other', 0x00000000)
+// CHECK-NEXT:   ('st_shndx', 0x00000000)
+// CHECK-NEXT:   ('st_value', 0x00000000)
+// CHECK-NEXT:   ('st_size', 0x00000000)
+// CHECK-NEXT:  ),
+// CHECK-NEXT:  # Symbol 0x00000009
+// CHECK-NEXT:  (('st_name', 0x0000000b) # 'foo3'
+// CHECK-NEXT:   ('st_bind', 0x00000001)
+// CHECK-NEXT:   ('st_type', 0x00000006)
+// CHECK-NEXT:   ('st_other', 0x00000000)
+// CHECK-NEXT:   ('st_shndx', 0x00000000)
+// CHECK-NEXT:   ('st_value', 0x00000000)
+// CHECK-NEXT:   ('st_size', 0x00000000)
+// CHECK-NEXT:  ),





More information about the llvm-commits mailing list