Index: lib/MC/MCSectionELF.cpp =================================================================== --- lib/MC/MCSectionELF.cpp +++ lib/MC/MCSectionELF.cpp @@ -14,6 +14,7 @@ #include "llvm/MC/MCSymbol.h" #include "llvm/Support/ELF.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/Format.h" using namespace llvm; @@ -88,30 +89,35 @@ } OS << ",\""; - if (Flags & ELF::SHF_ALLOC) - OS << 'a'; - if (Flags & ELF::SHF_EXCLUDE) - OS << 'e'; - if (Flags & ELF::SHF_EXECINSTR) - OS << 'x'; - if (Flags & ELF::SHF_GROUP) - OS << 'G'; - if (Flags & ELF::SHF_WRITE) - OS << 'w'; - if (Flags & ELF::SHF_MERGE) - OS << 'M'; - if (Flags & ELF::SHF_STRINGS) - OS << 'S'; - if (Flags & ELF::SHF_TLS) - OS << 'T'; - - // If there are target-specific flags, print them. - if (Flags & ELF::XCORE_SHF_CP_SECTION) - OS << 'c'; - if (Flags & ELF::XCORE_SHF_DP_SECTION) - OS << 'd'; - if (Flags & ELF::SHF_ARM_PURECODE) - OS << 'y'; + + // If the flag has OS or processor-specific bits set, print the whole numeric + // flag, otherwise use the symbolic representation + if (Flags & (ELF::SHF_MASKOS | ELF::SHF_MASKPROC)) { + OS << format_hex(Flags, 0); + } else { + if (Flags & ELF::SHF_ALLOC) + OS << 'a'; + if (Flags & ELF::SHF_EXCLUDE) + OS << 'e'; + if (Flags & ELF::SHF_EXECINSTR) + OS << 'x'; + if (Flags & ELF::SHF_GROUP) + OS << 'G'; + if (Flags & ELF::SHF_WRITE) + OS << 'w'; + if (Flags & ELF::SHF_MERGE) + OS << 'M'; + if (Flags & ELF::SHF_STRINGS) + OS << 'S'; + if (Flags & ELF::SHF_TLS) + OS << 'T'; + + // If there are target-specific flags, print them. + if (Flags & ELF::XCORE_SHF_CP_SECTION) + OS << 'c'; + if (Flags & ELF::XCORE_SHF_DP_SECTION) + OS << 'd'; + } OS << '"'; Index: test/CodeGen/ARM/execute-only-section.ll =================================================================== --- test/CodeGen/ARM/execute-only-section.ll +++ test/CodeGen/ARM/execute-only-section.ll @@ -2,7 +2,7 @@ ; RUN: llc < %s -mtriple=thumbv8m.base -arm-execute-only %s -o - | FileCheck %s ; RUN: llc < %s -mtriple=thumbv8m.main -arm-execute-only %s -o - | FileCheck %s -; CHECK: .section .text,"axy",%progbits,unique,0 +; CHECK: .section .text,"0x20000006",%progbits,unique,0 ; CHECK-NOT: .section ; CHECK-NOT: .text ; CHECK: .globl test_SectionForGlobal @@ -12,7 +12,7 @@ ret void } -; CHECK: .section .test,"axy",%progbits +; CHECK: .section .test,"0x20000006",%progbits ; CHECK-NOT: .section ; CHECK-NOT: .text ; CHECK: .globl test_ExplicitSectionForGlobal