[llvm] [BOLT][NFC] Use getEHFrameHdrSectionName() (PR #90257)
Maksim Panchenko via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 26 14:05:44 PDT 2024
https://github.com/maksfb updated https://github.com/llvm/llvm-project/pull/90257
>From b8198b3c97906b2a31399e9e1f46a05bcfc25cef Mon Sep 17 00:00:00 2001
From: Maksim Panchenko <maks at fb.com>
Date: Fri, 26 Apr 2024 12:18:33 -0700
Subject: [PATCH] [BOLT][NFC] Use getEHFrameHdrSectionName()
Reference section name via wrapper.
---
bolt/include/bolt/Rewrite/RewriteInstance.h | 1 +
bolt/lib/Rewrite/RewriteInstance.cpp | 18 ++++++++++--------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/bolt/include/bolt/Rewrite/RewriteInstance.h b/bolt/include/bolt/Rewrite/RewriteInstance.h
index 2561468a0f99af..f4bffba96b1d4e 100644
--- a/bolt/include/bolt/Rewrite/RewriteInstance.h
+++ b/bolt/include/bolt/Rewrite/RewriteInstance.h
@@ -424,6 +424,7 @@ class RewriteInstance {
/// Common section names.
static StringRef getEHFrameSectionName() { return ".eh_frame"; }
+ static StringRef getEHFrameHdrSectionName() { return ".eh_frame_hdr"; }
static StringRef getRelaDynSectionName() { return ".rela.dyn"; }
/// FILE symbol name used for local fragments of global functions.
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 3cf0e749f9d667..409835537fdeee 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -3978,8 +3978,8 @@ void RewriteInstance::patchELFPHDRTable() {
NewPhdr.p_filesz = sizeof(NewPhdr) * Phnum;
NewPhdr.p_memsz = sizeof(NewPhdr) * Phnum;
} else if (Phdr.p_type == ELF::PT_GNU_EH_FRAME) {
- ErrorOr<BinarySection &> EHFrameHdrSec =
- BC->getUniqueSectionByName(getNewSecPrefix() + ".eh_frame_hdr");
+ ErrorOr<BinarySection &> EHFrameHdrSec = BC->getUniqueSectionByName(
+ getNewSecPrefix() + getEHFrameHdrSectionName());
if (EHFrameHdrSec && EHFrameHdrSec->isAllocatable() &&
EHFrameHdrSec->isFinalized()) {
NewPhdr.p_offset = EHFrameHdrSec->getOutputFileOffset();
@@ -5692,7 +5692,8 @@ void RewriteInstance::writeEHFrameHeader() {
BC->AsmInfo->getCodePointerSize()));
check_error(std::move(Er), "failed to parse EH frame");
- LLVM_DEBUG(dbgs() << "BOLT: writing a new .eh_frame_hdr\n");
+ LLVM_DEBUG(dbgs() << "BOLT: writing a new " << getEHFrameHdrSectionName()
+ << '\n');
NextAvailableAddress =
appendPadding(Out->os(), NextAvailableAddress, EHFrameHdrAlign);
@@ -5710,16 +5711,17 @@ void RewriteInstance::writeEHFrameHeader() {
const unsigned Flags = BinarySection::getFlags(/*IsReadOnly=*/true,
/*IsText=*/false,
/*IsAllocatable=*/true);
- BinarySection *OldEHFrameHdrSection = getSection(".eh_frame_hdr");
+ BinarySection *OldEHFrameHdrSection = getSection(getEHFrameHdrSectionName());
if (OldEHFrameHdrSection)
- OldEHFrameHdrSection->setOutputName(getOrgSecPrefix() + ".eh_frame_hdr");
+ OldEHFrameHdrSection->setOutputName(getOrgSecPrefix() +
+ getEHFrameHdrSectionName());
BinarySection &EHFrameHdrSec = BC->registerOrUpdateSection(
- getNewSecPrefix() + ".eh_frame_hdr", ELF::SHT_PROGBITS, Flags, nullptr,
- NewEHFrameHdr.size(), /*Alignment=*/1);
+ getNewSecPrefix() + getEHFrameHdrSectionName(), ELF::SHT_PROGBITS, Flags,
+ nullptr, NewEHFrameHdr.size(), /*Alignment=*/1);
EHFrameHdrSec.setOutputFileOffset(EHFrameHdrFileOffset);
EHFrameHdrSec.setOutputAddress(EHFrameHdrOutputAddress);
- EHFrameHdrSec.setOutputName(".eh_frame_hdr");
+ EHFrameHdrSec.setOutputName(getEHFrameHdrSectionName());
NextAvailableAddress += EHFrameHdrSec.getOutputSize();
More information about the llvm-commits
mailing list