[clang] [llvm] [PATCH] [COFF] Implement pragma clang section on COFF targets (PR #112714)
David Spickett via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 1 02:26:35 PDT 2024
================
@@ -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();
+ }
+ }
+
----------------
DavidSpickett wrote:
I'm not sure if it's required / possible / useful to test this in llvm as well, but if you haven't looked into it already, you might want to look at the commits that added the Macho and ELF versions and see if there are llvm tests there too.
https://github.com/llvm/llvm-project/pull/112714
More information about the cfe-commits
mailing list