Index: lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp =================================================================== --- lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp +++ lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp @@ -97,7 +97,8 @@ AMDGPUTargetELFStreamer::EmitDirectiveHSACodeObjectVersion(uint32_t Major, uint32_t Minor) { MCStreamer &OS = getStreamer(); - MCSectionELF *Note = OS.getContext().getELFSection(".note", ELF::SHT_NOTE, 0); + MCSectionELF *Note = + OS.getContext().getELFSection(".note", ELF::SHT_NOTE, ELF::SHF_ALLOC); unsigned NameSZ = 4; @@ -120,7 +121,8 @@ StringRef VendorName, StringRef ArchName) { MCStreamer &OS = getStreamer(); - MCSectionELF *Note = OS.getContext().getELFSection(".note", ELF::SHT_NOTE, 0); + MCSectionELF *Note = + OS.getContext().getELFSection(".note", ELF::SHT_NOTE, ELF::SHF_ALLOC); unsigned NameSZ = 4; uint16_t VendorNameSize = VendorName.size() + 1; Index: test/CodeGen/AMDGPU/hsa.ll =================================================================== --- test/CodeGen/AMDGPU/hsa.ll +++ test/CodeGen/AMDGPU/hsa.ll @@ -17,11 +17,16 @@ ; ELF: } ; ELF: SHT_NOTE +; ELF: Flags [ (0x2) +; ELF: SHF_ALLOC (0x2) +; ELF: ] +; ELF: SectionData ( ; ELF: 0000: 04000000 08000000 01000000 414D4400 ; ELF: 0010: 02000000 01000000 04000000 1B000000 ; ELF: 0020: 03000000 414D4400 04000700 07000000 ; ELF: 0030: 00000000 00000000 414D4400 414D4447 ; ELF: 0040: 50550000 +; ELF: ) ; ELF: Symbol { ; ELF: Name: simple