Index: lib/MC/MCObjectFileInfo.cpp =================================================================== --- lib/MC/MCObjectFileInfo.cpp +++ lib/MC/MCObjectFileInfo.cpp @@ -598,7 +598,10 @@ // Set the `IMAGE_SCN_MEM_16BIT` flag when compiling for thumb mode. This is // used to indicate to the linker that the text segment contains thumb instructions // and to set the ISA selection bit for calls accordingly. - const bool IsThumb = T.getArch() == Triple::thumb; + // In practice, COFF currently is only supported on Windows, and Windows + // on ARM is thumb only. When invoked via the clang driver, the triple + // is set to arm-* since the assembler always should start in ARM mode. + const bool IsThumb = T.getArch() == Triple::arm || T.getArch() == Triple::thumb; CommDirectiveSupportsAlignment = true; Index: test/MC/ARM/Windows/thumb-attributes.s =================================================================== --- /dev/null +++ test/MC/ARM/Windows/thumb-attributes.s @@ -0,0 +1,25 @@ +@ RUN: llvm-mc -triple armv7-windows-itanium -filetype obj -o - %s \ +@ RUN: | llvm-readobj -s - | FileCheck %s + + .syntax unified + .thumb + + .text + + .global function + .thumb_func +function: + bx lr + +@ CHECK: Sections [ +@ CHECK: Section { +@ CHECK: Name: .text +@ CHECK: Characteristics [ +@ CHECK: IMAGE_SCN_ALIGN_4BYTES +@ CHECK: IMAGE_SCN_CNT_CODE +@ CHECK: IMAGE_SCN_MEM_16BIT +@ CHECK: IMAGE_SCN_MEM_EXECUTE +@ CHECK: IMAGE_SCN_MEM_READ +@ CHECK: ] +@ CHECK: } +@ CHECK: ]