================ @@ -1677,6 +1677,22 @@ MCSection *TargetLoweringObjectFileCOFF::getExplicitSectionGlobal( Name == getInstrProfSectionName(IPSK_covname, Triple::COFF, /*AddSegmentInfo=*/false)) Kind = SectionKind::getMetadata(); + + const GlobalVariable *GV = dyn_cast<GlobalVariable>(GO); + if (GV && GV->hasImplicitSection()) { + auto Attrs = GV->getAttributes(); + if (Attrs.hasAttribute("bss-section") && Kind.isBSS()) { + Name = Attrs.getAttribute("bss-section").getValueAsString(); + } else if (Attrs.hasAttribute("rodata-section") && Kind.isReadOnly()) { + Name = Attrs.getAttribute("rodata-section").getValueAsString(); + } else if (Attrs.hasAttribute("relro-section") && + Kind.isReadOnlyWithRel()) { + Name = Attrs.getAttribute("relro-section").getValueAsString(); + } else if (Attrs.hasAttribute("data-section") && Kind.isData()) { + Name = Attrs.getAttribute("data-section").getValueAsString(); + } ---------------- vtz wrote:
"would falling through without setting name be ok?" yes, in this case we would keep the section's original name, I don't see the need for an explicit else here. https://github.com/llvm/llvm-project/pull/112714 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits