[PATCH] D141733: [BOLT][NFC] Replace ambiguous BinarySection::isReadOnly with isWritable
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 13 18:03:39 PST 2023
Amir created this revision.
Herald added a reviewer: rafauler.
Herald added subscribers: treapster, ayermolo.
Herald added a reviewer: maksfb.
Herald added a project: All.
Amir updated this revision to Diff 489159.
Amir added a comment.
Amir edited the summary of this revision.
Amir added a reviewer: bolt.
Amir added a subscriber: MaskRay.
Amir published this revision for review.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.
Typo
Address feedback in https://reviews.llvm.org/D102284#2755060
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D141733
Files:
bolt/include/bolt/Core/BinarySection.h
bolt/lib/Core/BinaryFunction.cpp
bolt/lib/Passes/BinaryPasses.cpp
bolt/lib/Rewrite/RewriteInstance.cpp
Index: bolt/lib/Rewrite/RewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/RewriteInstance.cpp
+++ bolt/lib/Rewrite/RewriteInstance.cpp
@@ -2574,7 +2574,7 @@
ReferencedBF->registerReferencedOffset(RefFunctionOffset);
}
if (opts::Verbosity > 1 &&
- !BinarySection(*BC, RelocatedSection).isReadOnly())
+ BinarySection(*BC, RelocatedSection).isWritable())
errs() << "BOLT-WARNING: writable reference into the middle of the "
<< formatv("function {0} detected at address {1:x}\n",
*ReferencedBF, Rel.getOffset());
@@ -3908,7 +3908,7 @@
if (!Section.hasValidSectionID())
continue;
- if (Section.isReadOnly() != (SType == ST_READONLY))
+ if (Section.isWritable() == (SType == ST_READONLY))
continue;
if (Section.getOutputAddress()) {
@@ -4158,7 +4158,7 @@
// Set/modify section info.
BinarySection &NewSection = BC->registerOrUpdateNoteSection(
SectionName, SectionData, Size, Section.sh_addralign,
- BSec->isReadOnly(), BSec->getELFType());
+ !BSec->isWritable(), BSec->getELFType());
NewSection.setOutputAddress(0);
NewSection.setOutputFileOffset(NextAvailableOffset);
Index: bolt/lib/Passes/BinaryPasses.cpp
===================================================================
--- bolt/lib/Passes/BinaryPasses.cpp
+++ bolt/lib/Passes/BinaryPasses.cpp
@@ -1164,7 +1164,7 @@
// memory operand. We are only interested in read-only sections.
ErrorOr<BinarySection &> DataSection =
BC.getSectionForAddress(TargetAddress);
- if (!DataSection || !DataSection->isReadOnly())
+ if (!DataSection || DataSection->isWritable())
continue;
if (BC.getRelocationAt(TargetAddress) ||
Index: bolt/lib/Core/BinaryFunction.cpp
===================================================================
--- bolt/lib/Core/BinaryFunction.cpp
+++ bolt/lib/Core/BinaryFunction.cpp
@@ -891,7 +891,7 @@
if (!Value)
return IndirectBranchType::UNKNOWN;
- if (!BC.getSectionForAddress(ArrayStart)->isReadOnly())
+ if (BC.getSectionForAddress(ArrayStart)->isWritable())
return IndirectBranchType::UNKNOWN;
outs() << "BOLT-INFO: fixed indirect branch detected in " << *this
Index: bolt/include/bolt/Core/BinarySection.h
===================================================================
--- bolt/include/bolt/Core/BinarySection.h
+++ bolt/include/bolt/Core/BinarySection.h
@@ -232,8 +232,8 @@
return isText() > Other.isText();
// Read-only before writable.
- if (isReadOnly() != Other.isReadOnly())
- return isReadOnly() > Other.isReadOnly();
+ if (isWritable() != Other.isWritable())
+ return isWritable() < Other.isWritable();
// BSS at the end.
if (isBSS() != Other.isBSS())
@@ -275,10 +275,7 @@
bool isTBSS() const { return isBSS() && isTLS(); }
bool isVirtual() const { return ELFType == ELF::SHT_NOBITS; }
bool isRela() const { return ELFType == ELF::SHT_RELA; }
- bool isReadOnly() const {
- return ((ELFFlags & ELF::SHF_ALLOC) && !(ELFFlags & ELF::SHF_WRITE) &&
- ELFType == ELF::SHT_PROGBITS);
- }
+ bool isWritable() const { return (ELFFlags & ELF::SHF_WRITE); }
bool isAllocatable() const {
if (isELF()) {
return (ELFFlags & ELF::SHF_ALLOC) && !isTBSS();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141733.489159.patch
Type: text/x-patch
Size: 3452 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230114/44ad9686/attachment.bin>
More information about the llvm-commits
mailing list