namespace llvm {
namespace jitlink {
-EHFrameSplitter::EHFrameSplitter(StringRef EHFrameSectionName)
- : EHFrameSectionName(EHFrameSectionName) {}
+DWARFRecordSectionSplitter::DWARFRecordSectionSplitter(StringRef SectionName)
+ : SectionName(SectionName) {}
-Error EHFrameSplitter::operator()(LinkGraph &G) {
- auto *EHFrame = G.findSectionByName(EHFrameSectionName);
+Error DWARFRecordSectionSplitter::operator()(LinkGraph &G) {
+ auto *Section = G.findSectionByName(SectionName);
- if (!EHFrame) {
+ if (!Section) {
LLVM_DEBUG({
- dbgs() << "EHFrameSplitter: No " << EHFrameSectionName
+ dbgs() << "DWARFRecordSectionSplitter: No " << SectionName
<< " section. Nothing to do\n";
});
return Error::success();
}
LLVM_DEBUG({
- dbgs() << "EHFrameSplitter: Processing " << EHFrameSectionName << "...\n";
+ dbgs() << "DWARFRecordSectionSplitter: Processing " << SectionName
+ << "...\n";
});
DenseMap<Block *, LinkGraph::SplitBlockCache> Caches;
{
// Pre-build the split caches.
- for (auto *B : EHFrame->blocks())
+ for (auto *B : Section->blocks())
Caches[B] = LinkGraph::SplitBlockCache::value_type();
- for (auto *Sym : EHFrame->symbols())
+ for (auto *Sym : Section->symbols())
Caches[&Sym->getBlock()]->push_back(Sym);
- for (auto *B : EHFrame->blocks())
+ for (auto *B : Section->blocks())
llvm::sort(*Caches[B], [](const Symbol *LHS, const Symbol *RHS) {
return LHS->getOffset() > RHS->getOffset();
});
}
// Iterate over blocks (we do this by iterating over Caches entries rather
- // than EHFrame->blocks() as we will be inserting new blocks along the way,
+ // than Section->blocks() as we will be inserting new blocks along the way,
// which would invalidate iterators in the latter sequence.
for (auto &KV : Caches) {
auto &B = *KV.first;
return Error::success();
}
-Error EHFrameSplitter::processBlock(LinkGraph &G, Block &B,
- LinkGraph::SplitBlockCache &Cache) {
+Error DWARFRecordSectionSplitter::processBlock(
+ LinkGraph &G, Block &B, LinkGraph::SplitBlockCache &Cache) {
LLVM_DEBUG(dbgs() << " Processing block at " << B.getAddress() << "\n");
- // eh-frame should not contain zero-fill blocks.
+ // Section should not contain zero-fill blocks.
if (B.isZeroFill())
return make_error<JITLinkError>("Unexpected zero-fill block in " +
- EHFrameSectionName + " section");
+ SectionName + " section");
if (B.getSize() == 0) {
LLVM_DEBUG(dbgs() << " Block is empty. Skipping.\n");
namespace llvm {
namespace jitlink {
-/// A LinkGraph pass that splits blocks in an eh-frame section into sub-blocks
-/// representing individual eh-frames.
-/// EHFrameSplitter should not be run without EHFrameEdgeFixer, which is
-/// responsible for adding FDE-to-CIE edges.
-class EHFrameSplitter {
+/// A LinkGraph pass that splits blocks in a section that follows the DWARF
+/// Record format into sub-blocks where each header gets its own block.
+/// When splitting EHFrames, DWARFRecordSectionSplitter should not be run
+/// without EHFrameEdgeFixer, which is responsible for adding FDE-to-CIE edges.
+class DWARFRecordSectionSplitter {
public:
- EHFrameSplitter(StringRef EHFrameSectionName);
+ DWARFRecordSectionSplitter(StringRef SectionName);
Error operator()(LinkGraph &G);
private:
Error processBlock(LinkGraph &G, Block &B, LinkGraph::SplitBlockCache &Cache);
- StringRef EHFrameSectionName;
+ StringRef SectionName;
};
/// A LinkGraph pass that adds missing FDE-to-CIE, FDE-to-PC and FDE-to-LSDA
// Add eh-frame passses.
// FIXME: Prune eh-frames for which compact-unwind is available once
// we support compact-unwind registration with libunwind.
- Config.PrePrunePasses.push_back(EHFrameSplitter("__TEXT,__eh_frame"));
+ Config.PrePrunePasses.push_back(
+ DWARFRecordSectionSplitter("__TEXT,__eh_frame"));
Config.PrePrunePasses.push_back(
EHFrameEdgeFixer("__TEXT,__eh_frame", 8, Delta64, Delta32, NegDelta32));