mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 05:24:01 +00:00
Remove bogus std::error_code returns form SectionRef.
There are two methods in SectionRef that can fail: * getName: The index into the string table can be invalid. * getContents: The section might point to invalid contents. Every other method will always succeed and returning and std::error_code just complicates the code. For example, a section can have an invalid alignment, but if we are able to get to the section structure at all and create a SectionRef, we will always be able to read that invalid alignment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219314 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -89,24 +89,19 @@ protected:
|
||||
void moveSectionNext(DataRefImpl &Sec) const override;
|
||||
std::error_code getSectionName(DataRefImpl Sec,
|
||||
StringRef &Res) const override;
|
||||
std::error_code getSectionAddress(DataRefImpl Sec,
|
||||
uint64_t &Res) const override;
|
||||
std::error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const override;
|
||||
uint64_t getSectionAddress(DataRefImpl Sec) const override;
|
||||
uint64_t getSectionSize(DataRefImpl Sec) const override;
|
||||
std::error_code getSectionContents(DataRefImpl Sec,
|
||||
StringRef &Res) const override;
|
||||
std::error_code getSectionAlignment(DataRefImpl Sec,
|
||||
uint64_t &Res) const override;
|
||||
std::error_code isSectionText(DataRefImpl Sec, bool &Res) const override;
|
||||
std::error_code isSectionData(DataRefImpl Sec, bool &Res) const override;
|
||||
std::error_code isSectionBSS(DataRefImpl Sec, bool &Res) const override;
|
||||
std::error_code isSectionRequiredForExecution(DataRefImpl Sec,
|
||||
bool &Res) const override;
|
||||
std::error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const override;
|
||||
std::error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const override;
|
||||
std::error_code isSectionReadOnlyData(DataRefImpl Sec,
|
||||
bool &Res) const override;
|
||||
std::error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
|
||||
bool &Result) const override;
|
||||
uint64_t getSectionAlignment(DataRefImpl Sec) const override;
|
||||
bool isSectionText(DataRefImpl Sec) const override;
|
||||
bool isSectionData(DataRefImpl Sec) const override;
|
||||
bool isSectionBSS(DataRefImpl Sec) const override;
|
||||
bool isSectionRequiredForExecution(DataRefImpl Sec) const override;
|
||||
bool isSectionVirtual(DataRefImpl Sec) const override;
|
||||
bool isSectionZeroInit(DataRefImpl Sec) const override;
|
||||
bool isSectionReadOnlyData(DataRefImpl Sec) const override;
|
||||
bool sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb) const override;
|
||||
relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
|
||||
relocation_iterator section_rel_end(DataRefImpl Sec) const override;
|
||||
section_iterator getRelocatedSection(DataRefImpl Sec) const override;
|
||||
@ -413,17 +408,13 @@ std::error_code ELFObjectFile<ELFT>::getSectionName(DataRefImpl Sec,
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec,
|
||||
uint64_t &Result) const {
|
||||
Result = toELFShdrIter(Sec)->sh_addr;
|
||||
return object_error::success;
|
||||
uint64_t ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const {
|
||||
return toELFShdrIter(Sec)->sh_addr;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec,
|
||||
uint64_t &Result) const {
|
||||
Result = toELFShdrIter(Sec)->sh_size;
|
||||
return object_error::success;
|
||||
uint64_t ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const {
|
||||
return toELFShdrIter(Sec)->sh_size;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
@ -436,79 +427,59 @@ ELFObjectFile<ELFT>::getSectionContents(DataRefImpl Sec,
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code
|
||||
ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec,
|
||||
uint64_t &Result) const {
|
||||
Result = toELFShdrIter(Sec)->sh_addralign;
|
||||
return object_error::success;
|
||||
uint64_t ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const {
|
||||
return toELFShdrIter(Sec)->sh_addralign;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec,
|
||||
bool &Result) const {
|
||||
Result = toELFShdrIter(Sec)->sh_flags & ELF::SHF_EXECINSTR;
|
||||
return object_error::success;
|
||||
bool ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const {
|
||||
return toELFShdrIter(Sec)->sh_flags & ELF::SHF_EXECINSTR;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec,
|
||||
bool &Result) const {
|
||||
bool ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const {
|
||||
Elf_Shdr_Iter EShdr = toELFShdrIter(Sec);
|
||||
Result = EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
|
||||
EShdr->sh_type == ELF::SHT_PROGBITS;
|
||||
return object_error::success;
|
||||
return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
|
||||
EShdr->sh_type == ELF::SHT_PROGBITS;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec,
|
||||
bool &Result) const {
|
||||
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
|
||||
Elf_Shdr_Iter EShdr = toELFShdrIter(Sec);
|
||||
Result = EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
|
||||
EShdr->sh_type == ELF::SHT_NOBITS;
|
||||
return object_error::success;
|
||||
return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
|
||||
EShdr->sh_type == ELF::SHT_NOBITS;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code
|
||||
ELFObjectFile<ELFT>::isSectionRequiredForExecution(DataRefImpl Sec,
|
||||
bool &Result) const {
|
||||
Result = toELFShdrIter(Sec)->sh_flags & ELF::SHF_ALLOC;
|
||||
return object_error::success;
|
||||
bool ELFObjectFile<ELFT>::isSectionRequiredForExecution(DataRefImpl Sec) const {
|
||||
return toELFShdrIter(Sec)->sh_flags & ELF::SHF_ALLOC;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec,
|
||||
bool &Result) const {
|
||||
Result = toELFShdrIter(Sec)->sh_type == ELF::SHT_NOBITS;
|
||||
return object_error::success;
|
||||
bool ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const {
|
||||
return toELFShdrIter(Sec)->sh_type == ELF::SHT_NOBITS;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code ELFObjectFile<ELFT>::isSectionZeroInit(DataRefImpl Sec,
|
||||
bool &Result) const {
|
||||
Result = toELFShdrIter(Sec)->sh_type == ELF::SHT_NOBITS;
|
||||
return object_error::success;
|
||||
bool ELFObjectFile<ELFT>::isSectionZeroInit(DataRefImpl Sec) const {
|
||||
return toELFShdrIter(Sec)->sh_type == ELF::SHT_NOBITS;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code ELFObjectFile<ELFT>::isSectionReadOnlyData(DataRefImpl Sec,
|
||||
bool &Result) const {
|
||||
bool ELFObjectFile<ELFT>::isSectionReadOnlyData(DataRefImpl Sec) const {
|
||||
Elf_Shdr_Iter EShdr = toELFShdrIter(Sec);
|
||||
Result = !(EShdr->sh_flags & (ELF::SHF_WRITE | ELF::SHF_EXECINSTR));
|
||||
return object_error::success;
|
||||
return !(EShdr->sh_flags & (ELF::SHF_WRITE | ELF::SHF_EXECINSTR));
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code ELFObjectFile<ELFT>::sectionContainsSymbol(DataRefImpl Sec,
|
||||
DataRefImpl Symb,
|
||||
bool &Result) const {
|
||||
bool ELFObjectFile<ELFT>::sectionContainsSymbol(DataRefImpl Sec,
|
||||
DataRefImpl Symb) const {
|
||||
Elf_Sym_Iter ESym = toELFSymIter(Symb);
|
||||
|
||||
uintX_t Index = ESym->st_shndx;
|
||||
bool Reserved = Index >= ELF::SHN_LORESERVE && Index <= ELF::SHN_HIRESERVE;
|
||||
|
||||
Result = !Reserved && (&*toELFShdrIter(Sec) == EF.getSection(ESym->st_shndx));
|
||||
return object_error::success;
|
||||
return !Reserved && (&*toELFShdrIter(Sec) == EF.getSection(ESym->st_shndx));
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
|
Reference in New Issue
Block a user