From: David Meyer Date: Wed, 15 Feb 2012 15:09:06 +0000 (+0000) Subject: For ELF, also call fixSymbolsInTLSFixups() on expressions passed to EmitValue (litera... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5f7692604d44192206fbaf390085a95c9fb1a40b;p=oota-llvm.git For ELF, also call fixSymbolsInTLSFixups() on expressions passed to EmitValue (literal values). Previously only called on expressions in instructions. New test cases added to tls.s, tls-i386.s. Resolves PR11981. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150582 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp index 607e01cd821..6c4d0e33a11 100644 --- a/lib/MC/MCELFStreamer.cpp +++ b/lib/MC/MCELFStreamer.cpp @@ -102,6 +102,8 @@ public: unsigned MaxBytesToEmit = 0); virtual void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit = 0); + virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, + unsigned AddrSpace); virtual void EmitFileDirective(StringRef Filename); @@ -387,6 +389,13 @@ void MCELFStreamer::EmitCodeAlignment(unsigned ByteAlignment, getCurrentSectionData()->setAlignment(ByteAlignment); } +void MCELFStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, + unsigned AddrSpace) { + fixSymbolsInTLSFixups(Value); + MCObjectStreamer::EmitValueImpl(Value, Size, AddrSpace); +} + + // Add a symbol for the file name of this module. This is the second // entry in the module's symbol table (the first being the null symbol). void MCELFStreamer::EmitFileDirective(StringRef Filename) { diff --git a/test/MC/ELF/tls-i386.s b/test/MC/ELF/tls-i386.s index 197418d93ce..922d4c6e6c2 100644 --- a/test/MC/ELF/tls-i386.s +++ b/test/MC/ELF/tls-i386.s @@ -9,6 +9,13 @@ movl foo5@TPOFF(%eax), %eax movl foo6@DTPOFF(%eax), %eax movl foo7@INDNTPOFF, %eax + .long foo8@NTPOFF + .long foo9@GOTNTPOFF + .long fooA@TLSGD + .long fooB@TLSLDM + .long fooC@TPOFF + .long fooD@DTPOFF + .long fooE@INDNTPOFF // CHECK: (('st_name', 0x00000001) # 'foo1' // CHECK-NEXT: ('st_value', 0x00000000) @@ -72,3 +79,67 @@ // CHECK-NEXT: ('st_other', 0x00) // CHECK-NEXT: ('st_shndx', 0x0000) // CHECK-NEXT: ), +// CHECK-NEXT: # Symbol 12 +// CHECK-NEXT: (('st_name', 0x00000024) # 'foo8' +// CHECK-NEXT: ('st_value', 0x00000000) +// CHECK-NEXT: ('st_size', 0x00000000) +// CHECK-NEXT: ('st_bind', 0x1) +// CHECK-NEXT: ('st_type', 0x6) +// CHECK-NEXT: ('st_other', 0x00) +// CHECK-NEXT: ('st_shndx', 0x0000) +// CHECK-NEXT: ), +// CHECK-NEXT: # Symbol 13 +// CHECK-NEXT: (('st_name', 0x00000029) # 'foo9' +// CHECK-NEXT: ('st_value', 0x00000000) +// CHECK-NEXT: ('st_size', 0x00000000) +// CHECK-NEXT: ('st_bind', 0x1) +// CHECK-NEXT: ('st_type', 0x6) +// CHECK-NEXT: ('st_other', 0x00) +// CHECK-NEXT: ('st_shndx', 0x0000) +// CHECK-NEXT: ), +// CHECK-NEXT: # Symbol 14 +// CHECK-NEXT: (('st_name', 0x0000002e) # 'fooA' +// CHECK-NEXT: ('st_value', 0x00000000) +// CHECK-NEXT: ('st_size', 0x00000000) +// CHECK-NEXT: ('st_bind', 0x1) +// CHECK-NEXT: ('st_type', 0x6) +// CHECK-NEXT: ('st_other', 0x00) +// CHECK-NEXT: ('st_shndx', 0x0000) +// CHECK-NEXT: ), +// CHECK-NEXT: # Symbol 15 +// CHECK-NEXT: (('st_name', 0x00000033) # 'fooB' +// CHECK-NEXT: ('st_value', 0x00000000) +// CHECK-NEXT: ('st_size', 0x00000000) +// CHECK-NEXT: ('st_bind', 0x1) +// CHECK-NEXT: ('st_type', 0x6) +// CHECK-NEXT: ('st_other', 0x00) +// CHECK-NEXT: ('st_shndx', 0x0000) +// CHECK-NEXT: ), +// CHECK-NEXT: # Symbol 16 +// CHECK-NEXT: (('st_name', 0x00000038) # 'fooC' +// CHECK-NEXT: ('st_value', 0x00000000) +// CHECK-NEXT: ('st_size', 0x00000000) +// CHECK-NEXT: ('st_bind', 0x1) +// CHECK-NEXT: ('st_type', 0x6) +// CHECK-NEXT: ('st_other', 0x00) +// CHECK-NEXT: ('st_shndx', 0x0000) +// CHECK-NEXT: ), +// CHECK-NEXT: # Symbol 17 +// CHECK-NEXT: (('st_name', 0x0000003d) # 'fooD' +// CHECK-NEXT: ('st_value', 0x00000000) +// CHECK-NEXT: ('st_size', 0x00000000) +// CHECK-NEXT: ('st_bind', 0x1) +// CHECK-NEXT: ('st_type', 0x6) +// CHECK-NEXT: ('st_other', 0x00) +// CHECK-NEXT: ('st_shndx', 0x0000) +// CHECK-NEXT: ), +// CHECK-NEXT: # Symbol 18 +// CHECK-NEXT: (('st_name', 0x00000042) # 'fooE' +// CHECK-NEXT: ('st_value', 0x00000000) +// CHECK-NEXT: ('st_size', 0x00000000) +// CHECK-NEXT: ('st_bind', 0x1) +// CHECK-NEXT: ('st_type', 0x6) +// CHECK-NEXT: ('st_other', 0x00) +// CHECK-NEXT: ('st_shndx', 0x0000) +// CHECK-NEXT: ), + diff --git a/test/MC/ELF/tls.s b/test/MC/ELF/tls.s index d6d7de6ff2c..fe2bb4e7330 100644 --- a/test/MC/ELF/tls.s +++ b/test/MC/ELF/tls.s @@ -5,12 +5,14 @@ leaq foo1@TLSGD(%rip), %rdi leaq foo2@GOTTPOFF(%rip), %rdi leaq foo3@TLSLD(%rip), %rdi - + .long foo4@GOTTPOFF + .long foo5@TLSLD + .long foo6@TLSGD .section .zed,"awT",@progbits foobar: .long 43 -// CHECK: (('st_name', 0x00000010) # 'foobar' +// CHECK: (('st_name', 0x0000001f) # 'foobar' // CHECK-NEXT: ('st_bind', 0x0) // CHECK-NEXT: ('st_type', 0x6) // CHECK-NEXT: ('st_other', 0x00) @@ -46,3 +48,30 @@ foobar: // CHECK-NEXT: ('st_value', 0x0000000000000000) // CHECK-NEXT: ('st_size', 0x0000000000000000) // CHECK-NEXT: ), +// CHECK-NEXT: # Symbol 10 +// CHECK-NEXT: (('st_name', 0x00000010) # 'foo4' +// CHECK-NEXT: ('st_bind', 0x1) +// CHECK-NEXT: ('st_type', 0x6) +// CHECK-NEXT: ('st_other', 0x00) +// CHECK-NEXT: ('st_shndx', 0x0000) +// CHECK-NEXT: ('st_value', 0x0000000000000000) +// CHECK-NEXT: ('st_size', 0x0000000000000000) +// CHECK-NEXT: ), +// CHECK-NEXT: # Symbol 11 +// CHECK-NEXT: (('st_name', 0x00000015) # 'foo5' +// CHECK-NEXT: ('st_bind', 0x1) +// CHECK-NEXT: ('st_type', 0x6) +// CHECK-NEXT: ('st_other', 0x00) +// CHECK-NEXT: ('st_shndx', 0x0000) +// CHECK-NEXT: ('st_value', 0x0000000000000000) +// CHECK-NEXT: ('st_size', 0x0000000000000000) +// CHECK-NEXT: ), +// CHECK-NEXT: # Symbol 12 +// CHECK-NEXT: (('st_name', 0x0000001a) # 'foo6' +// CHECK-NEXT: ('st_bind', 0x1) +// CHECK-NEXT: ('st_type', 0x6) +// CHECK-NEXT: ('st_other', 0x00) +// CHECK-NEXT: ('st_shndx', 0x0000) +// CHECK-NEXT: ('st_value', 0x0000000000000000) +// CHECK-NEXT: ('st_size', 0x0000000000000000) +// CHECK-NEXT: ),