forked from OSchip/llvm-project
[BOLT] Make the methods isText/isData more robust
Summary: Make the methods isText/isData work for MachO. (cherry picked from FBD19849460)
This commit is contained in:
parent
c3c4b15a2e
commit
d5b8fc8fbe
|
@ -24,6 +24,10 @@ extern cl::opt<bool> PrintRelocations;
|
|||
extern cl::opt<bool> HotData;
|
||||
}
|
||||
|
||||
bool BinarySection::isELF() const {
|
||||
return BC.Ctx->getObjectFileInfo()->getTargetTriple().isOSBinFormatELF();
|
||||
}
|
||||
|
||||
uint64_t
|
||||
BinarySection::hash(const BinaryData &BD,
|
||||
std::map<const BinaryData *, uint64_t> &Cache) const {
|
||||
|
|
|
@ -230,17 +230,22 @@ public:
|
|||
///
|
||||
/// Basic proprety access.
|
||||
///
|
||||
bool isELF() const;
|
||||
StringRef getName() const { return Name; }
|
||||
uint64_t getAddress() const { return Address; }
|
||||
uint64_t getEndAddress() const { return Address + Size; }
|
||||
uint64_t getSize() const { return Size; }
|
||||
uint64_t getAlignment() const { return Alignment; }
|
||||
bool isText() const {
|
||||
return (ELFFlags & ELF::SHF_EXECINSTR);
|
||||
if (isELF())
|
||||
return (ELFFlags & ELF::SHF_EXECINSTR);
|
||||
return getSectionRef().isText();
|
||||
}
|
||||
bool isData() const {
|
||||
return (ELFType == ELF::SHT_PROGBITS &&
|
||||
(ELFFlags & (ELF::SHF_ALLOC | ELF::SHF_WRITE)));
|
||||
if (isELF())
|
||||
return (ELFType == ELF::SHT_PROGBITS &&
|
||||
(ELFFlags & (ELF::SHF_ALLOC | ELF::SHF_WRITE)));
|
||||
return getSectionRef().isData();
|
||||
}
|
||||
bool isBSS() const {
|
||||
return (ELFType == ELF::SHT_NOBITS &&
|
||||
|
|
Loading…
Reference in New Issue