summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-11-24 18:51:21 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-11-24 18:51:21 +0000
commitbf8209daf875fa533a379290a91d01be5152597d (patch)
tree5d31263a56a6ed2d2512da57a03fabe5afe92084
parent5c7106b2e375edca4b63ab48b218654f978698a4 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120100 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/MC/MCELFStreamer.cpp18
-rw-r--r--test/MC/ELF/tls-i386.s64
-rw-r--r--test/MC/ELF/tls.s43
3 files changed, 109 insertions, 16 deletions
diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp
index 1eddda9fefc..ec28a902a20 100644
--- a/lib/MC/MCELFStreamer.cpp
+++ b/lib/MC/MCELFStreamer.cpp
@@ -467,12 +467,20 @@ void MCELFStreamer::fixSymbolsInTLSFixups(const MCExpr *expr) {
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;
diff --git a/test/MC/ELF/tls-i386.s b/test/MC/ELF/tls-i386.s
new file mode 100644
index 00000000000..459d4cc69df
--- /dev/null
+++ b/test/MC/ELF/tls-i386.s
@@ -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@NTPOFF(%eax), %eax
+ movl foo2@GOTNTPOFF(%eax), %eax
+ movl foo3@TLSGD(%eax), %eax
+ movl foo4@TLSLDM(%eax), %eax
+ movl foo5@TPOFF(%eax), %eax
+ movl foo6@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: ),
diff --git a/test/MC/ELF/tls.s b/test/MC/ELF/tls.s
index 19e0c763e04..2591659f7eb 100644
--- a/test/MC/ELF/tls.s
+++ b/test/MC/ELF/tls.s
@@ -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@TLSGD(%rip), %rdi
+ leaq foo1@TLSGD(%rip), %rdi
+ leaq foo2@GOTTPOFF(%rip), %rdi
+ leaq foo3@TLSLD(%rip), %rdi
.section .zed,"awT",@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 @@ foobar:
// 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: ),