Index: lib/MC/MCObjectFileInfo.cpp =================================================================== --- lib/MC/MCObjectFileInfo.cpp +++ lib/MC/MCObjectFileInfo.cpp @@ -599,6 +599,13 @@ // 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; + // Windows on ARM is thumb only, and thus needs to set the IMAGE_SCN_MEM_16BIT + // flag. When the assembler is invoked via the clang driver, the triple is + // always set to arm-* (since the assembler always should start in ARM mode). + // Check for windows here, since we can't easily check the attributes of the + // contained individual functions here. + const bool IsWinARM = (T.isOSWindows() && + (T.getArch() == Triple::arm || T.getArch() == Triple::thumb)); CommDirectiveSupportsAlignment = true; @@ -609,7 +616,7 @@ SectionKind::getBSS()); TextSection = Ctx->getCOFFSection( ".text", - (IsThumb ? COFF::IMAGE_SCN_MEM_16BIT : (COFF::SectionCharacteristics)0) | + ((IsThumb || IsWinARM) ? COFF::IMAGE_SCN_MEM_16BIT : (COFF::SectionCharacteristics)0) | COFF::IMAGE_SCN_CNT_CODE | COFF::IMAGE_SCN_MEM_EXECUTE | COFF::IMAGE_SCN_MEM_READ, SectionKind::getText()); Index: test/MC/ARM/Windows/thumb-attributes.s =================================================================== --- /dev/null +++ test/MC/ARM/Windows/thumb-attributes.s @@ -0,0 +1,22 @@ +@ 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-DAG: IMAGE_SCN_CNT_CODE +@ CHECK-DAG: IMAGE_SCN_MEM_16BIT +@ CHECK: ] +@ CHECK: } +@ CHECK: ]