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
This commit is contained in:
David Meyer 2012-02-15 15:09:06 +00:00
parent 4a1ff2fb3e
commit 5f7692604d
3 changed files with 111 additions and 2 deletions

View File

@ -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) {

View File

@ -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: ),

View File

@ -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: ),