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())
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();
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
// 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) ||
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());
if (!Section.hasValidSectionID())
continue;
- if (Section.isReadOnly() != (SType == ST_READONLY))
+ if (Section.isWritable() == (SType == ST_READONLY))
continue;
if (Section.getOutputAddress()) {
// 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);