Skip to content

Commit

Permalink
ARM: take care not to set the ThumbFunc bit on TLS data symbols
Browse files Browse the repository at this point in the history
This fixes LNT SingleSource/UnitTests/Threads with -mthumb.

Differential Revision: http://reviews.llvm.org/D4324

llvm-svn: 212029
  • Loading branch information
Scott Douglass committed Jun 30, 2014
1 parent 06812bc commit 7650a9b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions llvm/include/llvm/MC/MCELFSymbolFlags.h
Expand Up @@ -41,6 +41,7 @@ namespace llvm {
ELF_STT_File = (ELF::STT_FILE << ELF_STT_Shift),
ELF_STT_Common = (ELF::STT_COMMON << ELF_STT_Shift),
ELF_STT_Tls = (ELF::STT_TLS << ELF_STT_Shift),
ELF_STT_GnuIFunc = (ELF::STT_GNU_IFUNC << ELF_STT_Shift),
ELF_STT_Loproc = (ELF::STT_LOPROC << ELF_STT_Shift),
ELF_STT_Hiproc = (ELF::STT_HIPROC << ELF_STT_Shift),

Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
Expand Up @@ -992,7 +992,8 @@ void ARMTargetELFStreamer::emitLabel(MCSymbol *Symbol) {
return;

const MCSymbolData &SD = Streamer.getOrCreateSymbolData(Symbol);
if (MCELF::GetType(SD) & (ELF::STT_FUNC << ELF_STT_Shift))
unsigned Type = MCELF::GetType(SD);
if (Type == ELF_STT_Func || Type == ELF_STT_GnuIFunc)
Streamer.EmitThumbFunc(Symbol);
}

Expand Down
26 changes: 26 additions & 0 deletions llvm/test/MC/ARM/thumb-types.s
Expand Up @@ -29,6 +29,12 @@ untyped_text_label:
explicit_function:
nop

.long tls(TPOFF)

.type indirect_function,%gnu_indirect_function
indirect_function:
nop

.data

untyped_data_label:
Expand All @@ -38,6 +44,14 @@ untyped_data_label:
explicit_data:
.long 0

.section .tdata,"awT",%progbits
.type tls,%object
.align 2
tls:
.long 42
.size tls, 4


@ CHECK: Symbol {
@ CHECK: Name: arm_function
@ CHECK: Value: 0x6
Expand Down Expand Up @@ -68,6 +82,18 @@ explicit_data:
@ CHECK: Type: Function
@ CHECK: }

@ CHECK: Symbol {
@ CHECK: Name: indirect_function
@ CHECK: Value: 0x13
@ CHECK: Type: GNU_IFunc
@ CHECK: }

@ CHECK: Symbol {
@ CHECK: Name: tls
@ CHECK: Value: 0x0
@ CHECK: Type: TLS
@ CHECK: }

@ CHECK: Symbol {
@ CHECK: Name: untyped_data_label
@ CHECK: Value: 0x0
Expand Down

0 comments on commit 7650a9b

Please sign in to comment.