[PATCH] D141733: [BOLT][NFC] Replace ambiguous BinarySection::isReadOnly with isWritable
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 18 14:53:17 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG69a9bbf106eb: [BOLT][NFC] Replace ambiguous BinarySection::isReadOnly with isWritable (authored by Amir).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141733/new/
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
@@ -2581,7 +2581,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());
@@ -3913,7 +3913,7 @@
if (!Section.hasValidSectionID())
continue;
- if (Section.isReadOnly() != (SType == ST_READONLY))
+ if (Section.isWritable() == (SType == ST_READONLY))
continue;
if (Section.getOutputAddress()) {
@@ -4163,7 +4163,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
@@ -1152,7 +1152,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.490306.patch
Type: text/x-patch
Size: 3452 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230118/09b8c7c1/attachment.bin>
More information about the llvm-commits
mailing list