[PATCH] D130877: [MCObjectFileInfo] Add getPCSection() helper
Marco Elver via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 1 01:55:44 PDT 2022
melver created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
melver requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Add MCObjectFileInfo::getPCSection() helper to get a section for PCs
requested via MD_pcsections.
Depends on D130876 <https://reviews.llvm.org/D130876>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D130877
Files:
llvm/include/llvm/MC/MCObjectFileInfo.h
llvm/lib/MC/MCObjectFileInfo.cpp
Index: llvm/lib/MC/MCObjectFileInfo.cpp
===================================================================
--- llvm/lib/MC/MCObjectFileInfo.cpp
+++ llvm/lib/MC/MCObjectFileInfo.cpp
@@ -1179,3 +1179,25 @@
}
return PseudoProbeDescSection;
}
+
+MCSection *MCObjectFileInfo::getPCSection(StringRef Name,
+ const MCSection *TextSec) const {
+ if (Ctx->getObjectFileType() != MCContext::IsELF)
+ return nullptr;
+
+ // SHF_WRITE for relocations, and let user post-process data in-place.
+ unsigned Flags = ELF::SHF_WRITE | ELF::SHF_ALLOC | ELF::SHF_LINK_ORDER;
+
+ if (!TextSec)
+ TextSec = getTextSection();
+
+ StringRef GroupName;
+ const auto &ElfSec = static_cast<const MCSectionELF &>(*TextSec);
+ if (const MCSymbol *Group = ElfSec.getGroup()) {
+ GroupName = Group->getName();
+ Flags |= ELF::SHF_GROUP;
+ }
+ return Ctx->getELFSection(Name, ELF::SHT_PROGBITS, Flags, 0, GroupName, true,
+ ElfSec.getUniqueID(),
+ cast<MCSymbolELF>(TextSec->getBeginSymbol()));
+}
Index: llvm/include/llvm/MC/MCObjectFileInfo.h
===================================================================
--- llvm/include/llvm/MC/MCObjectFileInfo.h
+++ llvm/include/llvm/MC/MCObjectFileInfo.h
@@ -363,6 +363,8 @@
MCSection *getPseudoProbeDescSection(StringRef FuncName) const;
+ MCSection *getPCSection(StringRef Name, const MCSection *TextSec) const;
+
// ELF specific sections.
MCSection *getDataRelROSection() const { return DataRelROSection; }
const MCSection *getMergeableConst4Section() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130877.448945.patch
Type: text/x-patch
Size: 1618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220801/f3877927/attachment.bin>
More information about the llvm-commits
mailing list