Index: llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp =================================================================== --- llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp +++ llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp @@ -587,6 +587,20 @@ } } + bool EmitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) { + bool val = MCELFStreamer::EmitSymbolAttribute(S, Attribute); + + if (!IsThumb) + return val; + + auto *Symbol = cast(S); + unsigned Type = cast(Symbol)->getType(); + if (Type == ELF::STT_FUNC || Type == ELF::STT_GNU_IFUNC) + getAssembler().setIsThumbFunc(Symbol); + + return val; + }; + private: enum ElfMappingSymbol { EMS_None, Index: llvm/test/MC/ARM/thumb-function-address.s =================================================================== --- /dev/null +++ llvm/test/MC/ARM/thumb-function-address.s @@ -0,0 +1,20 @@ +@ RUN: llvm-mc -filetype=obj -triple=armv7-linux-gnueabi %s -o %t +@ RUN: llvm-readobj --symbols %t | FileCheck %s + + .syntax unified + .text + .thumb +func_label: + .type func_label, %function + +@ Check func_label address has bit 1 set. +@ CHECK: Symbol { +@ CHECK: Name: func_label (7) +@ CHECK: Value: 0x1 +@ CHECK: Size: 0 +@ CHECK: Binding: Local (0x0) +@ CHECK: Type: Function (0x2) +@ CHECK: Other: 0 +@ CHECK: Section: .text (0x2) +@ CHECK: } +