diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -425,7 +425,8 @@ MMI, Streamer); } -static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K) { +static SectionKind getELFKindForNamedSection(MCContext &Ctx, StringRef Name, + SectionKind K) { // N.B.: The defaults used in here are not the same ones used in MC. // We follow gcc, MC follows gas. For example, given ".section .eh_frame", // both gas and MC will produce a section with no flags. Given @@ -441,7 +442,8 @@ return SectionKind::getMetadata(); if (Name == getInstrProfSectionName(IPSK_cnts, Triple::ELF, - /*AddSegmentInfo=*/false)) + /*AddSegmentInfo=*/false) && + Ctx.getAsmInfo()->binutilsIsAtLeast(2, 28)) return SectionKind::getBSS(); if (Name.empty() || Name[0] != '.') return K; @@ -674,7 +676,7 @@ } // Infer section flags from the section name if we can. - Kind = getELFKindForNamedSection(SectionName, Kind); + Kind = getELFKindForNamedSection(getContext(), SectionName, Kind); StringRef Group = ""; bool IsComdat = false;