mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 00:24:26 +00:00
This patch adds new functions to the SectionRef and ObjectFile interfaces to determine whether or not a section is meant to be read-only. These functions will be used by the MCJIT RuntimeDyld to give hints to the memory manager during the object loading process in a future patch.
Patch by Ashok Thirumurthi. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165586 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -128,6 +128,7 @@ protected:
|
|||||||
virtual error_code isSectionBSS(DataRefImpl Sec, bool &Res) const;
|
virtual error_code isSectionBSS(DataRefImpl Sec, bool &Res) const;
|
||||||
virtual error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const;
|
virtual error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const;
|
||||||
virtual error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const;
|
virtual error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const;
|
||||||
|
virtual error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const;
|
||||||
virtual error_code isSectionRequiredForExecution(DataRefImpl Sec,
|
virtual error_code isSectionRequiredForExecution(DataRefImpl Sec,
|
||||||
bool &Res) const;
|
bool &Res) const;
|
||||||
virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
|
virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
|
||||||
|
@ -640,6 +640,7 @@ protected:
|
|||||||
bool &Res) const;
|
bool &Res) const;
|
||||||
virtual error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const;
|
virtual error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const;
|
||||||
virtual error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const;
|
virtual error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const;
|
||||||
|
virtual error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const;
|
||||||
virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
|
virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
|
||||||
bool &Result) const;
|
bool &Result) const;
|
||||||
virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const;
|
virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const;
|
||||||
@ -1288,7 +1289,8 @@ error_code ELFObjectFile<target_endianness, is64Bits>
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<support::endianness target_endianness, bool is64Bits>
|
template<support::endianness target_endianness, bool is64Bits>
|
||||||
error_code ELFObjectFile<target_endianness, is64Bits>::isSectionZeroInit(DataRefImpl Sec,
|
error_code ELFObjectFile<target_endianness, is64Bits>
|
||||||
|
::isSectionZeroInit(DataRefImpl Sec,
|
||||||
bool &Result) const {
|
bool &Result) const {
|
||||||
const Elf_Shdr *sec = reinterpret_cast<const Elf_Shdr *>(Sec.p);
|
const Elf_Shdr *sec = reinterpret_cast<const Elf_Shdr *>(Sec.p);
|
||||||
// For ELF, all zero-init sections are virtual (that is, they occupy no space
|
// For ELF, all zero-init sections are virtual (that is, they occupy no space
|
||||||
@ -1300,6 +1302,18 @@ error_code ELFObjectFile<target_endianness, is64Bits>::isSectionZeroInit(DataRef
|
|||||||
return object_error::success;
|
return object_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<support::endianness target_endianness, bool is64Bits>
|
||||||
|
error_code ELFObjectFile<target_endianness, is64Bits>
|
||||||
|
::isSectionReadOnlyData(DataRefImpl Sec,
|
||||||
|
bool &Result) const {
|
||||||
|
const Elf_Shdr *sec = reinterpret_cast<const Elf_Shdr *>(Sec.p);
|
||||||
|
if (sec->sh_flags & ELF::SHF_WRITE || sec->sh_flags & ELF::SHF_EXECINSTR)
|
||||||
|
Result = false;
|
||||||
|
else
|
||||||
|
Result = true;
|
||||||
|
return object_error::success;
|
||||||
|
}
|
||||||
|
|
||||||
template<support::endianness target_endianness, bool is64Bits>
|
template<support::endianness target_endianness, bool is64Bits>
|
||||||
error_code ELFObjectFile<target_endianness, is64Bits>
|
error_code ELFObjectFile<target_endianness, is64Bits>
|
||||||
::sectionContainsSymbol(DataRefImpl Sec,
|
::sectionContainsSymbol(DataRefImpl Sec,
|
||||||
|
@ -76,6 +76,7 @@ protected:
|
|||||||
bool &Res) const;
|
bool &Res) const;
|
||||||
virtual error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const;
|
virtual error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const;
|
||||||
virtual error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const;
|
virtual error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const;
|
||||||
|
virtual error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const;
|
||||||
virtual error_code sectionContainsSymbol(DataRefImpl DRI, DataRefImpl S,
|
virtual error_code sectionContainsSymbol(DataRefImpl DRI, DataRefImpl S,
|
||||||
bool &Result) const;
|
bool &Result) const;
|
||||||
virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const;
|
virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const;
|
||||||
|
@ -163,6 +163,7 @@ public:
|
|||||||
error_code isRequiredForExecution(bool &Result) const;
|
error_code isRequiredForExecution(bool &Result) const;
|
||||||
error_code isVirtual(bool &Result) const;
|
error_code isVirtual(bool &Result) const;
|
||||||
error_code isZeroInit(bool &Result) const;
|
error_code isZeroInit(bool &Result) const;
|
||||||
|
error_code isReadOnlyData(bool &Result) const;
|
||||||
|
|
||||||
error_code containsSymbol(SymbolRef S, bool &Result) const;
|
error_code containsSymbol(SymbolRef S, bool &Result) const;
|
||||||
|
|
||||||
@ -316,6 +317,7 @@ protected:
|
|||||||
// A section is 'virtual' if its contents aren't present in the object image.
|
// A section is 'virtual' if its contents aren't present in the object image.
|
||||||
virtual error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const = 0;
|
virtual error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const = 0;
|
||||||
virtual error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const = 0;
|
virtual error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const = 0;
|
||||||
|
virtual error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const = 0;
|
||||||
virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
|
virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
|
||||||
bool &Result) const = 0;
|
bool &Result) const = 0;
|
||||||
virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const = 0;
|
virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const = 0;
|
||||||
@ -510,6 +512,10 @@ inline error_code SectionRef::isZeroInit(bool &Result) const {
|
|||||||
return OwningObject->isSectionZeroInit(SectionPimpl, Result);
|
return OwningObject->isSectionZeroInit(SectionPimpl, Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline error_code SectionRef::isReadOnlyData(bool &Result) const {
|
||||||
|
return OwningObject->isSectionReadOnlyData(SectionPimpl, Result);
|
||||||
|
}
|
||||||
|
|
||||||
inline error_code SectionRef::containsSymbol(SymbolRef S, bool &Result) const {
|
inline error_code SectionRef::containsSymbol(SymbolRef S, bool &Result) const {
|
||||||
return OwningObject->sectionContainsSymbol(SectionPimpl, S.SymbolPimpl,
|
return OwningObject->sectionContainsSymbol(SectionPimpl, S.SymbolPimpl,
|
||||||
Result);
|
Result);
|
||||||
|
@ -377,6 +377,13 @@ error_code COFFObjectFile::isSectionZeroInit(DataRefImpl Sec,
|
|||||||
return object_error::success;
|
return object_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_code COFFObjectFile::isSectionReadOnlyData(DataRefImpl Sec,
|
||||||
|
bool &Result) const {
|
||||||
|
// FIXME: Unimplemented.
|
||||||
|
Result = false;
|
||||||
|
return object_error::success;
|
||||||
|
}
|
||||||
|
|
||||||
error_code COFFObjectFile::sectionContainsSymbol(DataRefImpl Sec,
|
error_code COFFObjectFile::sectionContainsSymbol(DataRefImpl Sec,
|
||||||
DataRefImpl Symb,
|
DataRefImpl Symb,
|
||||||
bool &Result) const {
|
bool &Result) const {
|
||||||
|
@ -612,6 +612,17 @@ error_code MachOObjectFile::isSectionZeroInit(DataRefImpl DRI,
|
|||||||
return object_error::success;
|
return object_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_code MachOObjectFile::isSectionReadOnlyData(DataRefImpl Sec,
|
||||||
|
bool &Result) const {
|
||||||
|
// Consider using the code from isSectionText to look for __const sections.
|
||||||
|
// Alternately, emit S_ATTR_PURE_INSTRUCTIONS and/or S_ATTR_SOME_INSTRUCTIONS
|
||||||
|
// to use section attributes to distinguish code from data.
|
||||||
|
|
||||||
|
// FIXME: Unimplemented.
|
||||||
|
Result = false;
|
||||||
|
return object_error::success;
|
||||||
|
}
|
||||||
|
|
||||||
error_code MachOObjectFile::sectionContainsSymbol(DataRefImpl Sec,
|
error_code MachOObjectFile::sectionContainsSymbol(DataRefImpl Sec,
|
||||||
DataRefImpl Symb,
|
DataRefImpl Symb,
|
||||||
bool &Result) const {
|
bool &Result) const {
|
||||||
|
Reference in New Issue
Block a user