Index: include/llvm/MC/MCSectionELF.h =================================================================== --- include/llvm/MC/MCSectionELF.h +++ include/llvm/MC/MCSectionELF.h @@ -91,6 +91,8 @@ static bool classof(const MCSection *S) { return S->getVariant() == SV_ELF; } + + bool isAlloc() const; }; } // end namespace llvm Index: lib/MC/MCSectionELF.cpp =================================================================== --- lib/MC/MCSectionELF.cpp +++ lib/MC/MCSectionELF.cpp @@ -171,3 +171,7 @@ bool MCSectionELF::isVirtualSection() const { return getType() == ELF::SHT_NOBITS; } + +bool MCSectionELF::isAlloc() const { + return (Flags & ELF::SHF_ALLOC); +} Index: lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp =================================================================== --- lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp +++ lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp @@ -528,7 +528,10 @@ /// ARM streamer overrides it to add the appropriate mapping symbol ($d) if /// necessary. void EmitBytes(StringRef Data) override { - EmitDataMappingSymbol(); + MCSectionELF *CurSection = + cast(getCurrentSectionOnly()); + if (CurSection->isAlloc()) + EmitDataMappingSymbol(); MCELFStreamer::EmitBytes(Data); } Index: test/MC/ARM/data-in-code.ll =================================================================== --- test/MC/ARM/data-in-code.ll +++ test/MC/ARM/data-in-code.ll @@ -70,13 +70,6 @@ ;; ARM-NEXT: Section: .ARM.exidx ;; ARM-NEXT: } -;; ARM: Symbol { -;; ARM: Name: $d -;; ARM-NEXT: Value: 0 -;; ARM-NEXT: Size: 0 -;; ARM-NEXT: Binding: Local -;; ARM-NEXT: Type: None - ;; ARM-NOT: ${{[atd]}} ;; TMB: Symbol { Index: test/MC/ARM/nonallocmappingsymbols.s =================================================================== --- /dev/null +++ test/MC/ARM/nonallocmappingsymbols.s @@ -0,0 +1,6 @@ +@ RUN: llvm-mc -triple armv7-none-linux -filetype=obj -o %t.o %s +@ RUN: llvm-readobj -symbols %t.o | FileCheck %s + +#CHECK-NOT: $d + +.ident "LLVM ARM Compiler" Index: test/Object/ARM/nm-mapping-symbol.s =================================================================== --- test/Object/ARM/nm-mapping-symbol.s +++ test/Object/ARM/nm-mapping-symbol.s @@ -7,5 +7,5 @@ // CHECK: Name: $d.0 // NM-NOT: $d.0 - .section .foobar,"",%progbits + .section .foobar,"ax",%progbits .asciz "foo"