parent
33f250931c
commit
d285d3fbb7
|
|
@ -583,7 +583,7 @@ ELFDefinedAtom<ELFT> *ELFFile<ELFT>::createDefinedAtomAndAssignRelocations(
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
void ELFFile<ELFT>::createRelocationReferences(const Elf_Sym *symbol,
|
void ELFFile<ELFT>::createRelocationReferences(const Elf_Sym *symbol,
|
||||||
ArrayRef<uint8_t> content,
|
ArrayRef<uint8_t> content,
|
||||||
range<Elf_Rela_Iter> rels) {
|
range<const Elf_Rela *> rels) {
|
||||||
bool isMips64EL = _objFile->isMips64EL();
|
bool isMips64EL = _objFile->isMips64EL();
|
||||||
const auto symValue = getSymbolValue(symbol);
|
const auto symValue = getSymbolValue(symbol);
|
||||||
for (const auto &rel : rels) {
|
for (const auto &rel : rels) {
|
||||||
|
|
@ -601,7 +601,7 @@ template <class ELFT>
|
||||||
void ELFFile<ELFT>::createRelocationReferences(const Elf_Sym *symbol,
|
void ELFFile<ELFT>::createRelocationReferences(const Elf_Sym *symbol,
|
||||||
ArrayRef<uint8_t> symContent,
|
ArrayRef<uint8_t> symContent,
|
||||||
ArrayRef<uint8_t> secContent,
|
ArrayRef<uint8_t> secContent,
|
||||||
range<Elf_Rel_Iter> rels) {
|
range<const Elf_Rel *> rels) {
|
||||||
bool isMips64EL = _objFile->isMips64EL();
|
bool isMips64EL = _objFile->isMips64EL();
|
||||||
const auto symValue = getSymbolValue(symbol);
|
const auto symValue = getSymbolValue(symbol);
|
||||||
for (const auto &rel : rels) {
|
for (const auto &rel : rels) {
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,6 @@ template <class ELFT> class ELFFile : public SimpleFile {
|
||||||
typedef llvm::object::Elf_Shdr_Impl<ELFT> Elf_Shdr;
|
typedef llvm::object::Elf_Shdr_Impl<ELFT> Elf_Shdr;
|
||||||
typedef llvm::object::Elf_Rel_Impl<ELFT, false> Elf_Rel;
|
typedef llvm::object::Elf_Rel_Impl<ELFT, false> Elf_Rel;
|
||||||
typedef llvm::object::Elf_Rel_Impl<ELFT, true> Elf_Rela;
|
typedef llvm::object::Elf_Rel_Impl<ELFT, true> Elf_Rela;
|
||||||
typedef typename llvm::object::ELFFile<ELFT>::Elf_Rela_Iter Elf_Rela_Iter;
|
|
||||||
typedef typename llvm::object::ELFFile<ELFT>::Elf_Rel_Iter Elf_Rel_Iter;
|
|
||||||
typedef typename llvm::object::ELFFile<ELFT>::Elf_Word Elf_Word;
|
typedef typename llvm::object::ELFFile<ELFT>::Elf_Word Elf_Word;
|
||||||
|
|
||||||
// A Map is used to hold the atoms that have been divided up
|
// A Map is used to hold the atoms that have been divided up
|
||||||
|
|
@ -137,13 +135,13 @@ protected:
|
||||||
/// \brief Iterate over Elf_Rela relocations list and create references.
|
/// \brief Iterate over Elf_Rela relocations list and create references.
|
||||||
virtual void createRelocationReferences(const Elf_Sym *symbol,
|
virtual void createRelocationReferences(const Elf_Sym *symbol,
|
||||||
ArrayRef<uint8_t> content,
|
ArrayRef<uint8_t> content,
|
||||||
range<Elf_Rela_Iter> rels);
|
range<const Elf_Rela *> rels);
|
||||||
|
|
||||||
/// \brief Iterate over Elf_Rel relocations list and create references.
|
/// \brief Iterate over Elf_Rel relocations list and create references.
|
||||||
virtual void createRelocationReferences(const Elf_Sym *symbol,
|
virtual void createRelocationReferences(const Elf_Sym *symbol,
|
||||||
ArrayRef<uint8_t> symContent,
|
ArrayRef<uint8_t> symContent,
|
||||||
ArrayRef<uint8_t> secContent,
|
ArrayRef<uint8_t> secContent,
|
||||||
range<Elf_Rel_Iter> rels);
|
range<const Elf_Rel *> rels);
|
||||||
|
|
||||||
/// \brief After all the Atoms and References are created, update each
|
/// \brief After all the Atoms and References are created, update each
|
||||||
/// Reference's target with the Atom pointer it refers to.
|
/// Reference's target with the Atom pointer it refers to.
|
||||||
|
|
@ -327,10 +325,11 @@ protected:
|
||||||
/// list of relocations references. In ELF, if a section named, ".text" has
|
/// list of relocations references. In ELF, if a section named, ".text" has
|
||||||
/// relocations will also have a section named ".rel.text" or ".rela.text"
|
/// relocations will also have a section named ".rel.text" or ".rela.text"
|
||||||
/// which will hold the entries.
|
/// which will hold the entries.
|
||||||
std::unordered_map<const Elf_Shdr *, range<Elf_Rela_Iter>>
|
std::unordered_map<const Elf_Shdr *, range<const Elf_Rela *>>
|
||||||
_relocationAddendReferences;
|
_relocationAddendReferences;
|
||||||
MergedSectionMapT _mergedSectionMap;
|
MergedSectionMapT _mergedSectionMap;
|
||||||
std::unordered_map<const Elf_Shdr *, range<Elf_Rel_Iter>> _relocationReferences;
|
std::unordered_map<const Elf_Shdr *, range<const Elf_Rel *>>
|
||||||
|
_relocationReferences;
|
||||||
std::vector<ELFReference<ELFT> *> _references;
|
std::vector<ELFReference<ELFT> *> _references;
|
||||||
llvm::DenseMap<const Elf_Sym *, Atom *> _symbolToAtomMapping;
|
llvm::DenseMap<const Elf_Sym *, Atom *> _symbolToAtomMapping;
|
||||||
llvm::DenseMap<const ELFReference<ELFT> *, const Elf_Sym *>
|
llvm::DenseMap<const ELFReference<ELFT> *, const Elf_Sym *>
|
||||||
|
|
|
||||||
|
|
@ -222,9 +222,9 @@ template <class ELFT> std::error_code MipsELFFile<ELFT>::readAuxData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
void MipsELFFile<ELFT>::createRelocationReferences(const Elf_Sym *symbol,
|
void MipsELFFile<ELFT>::createRelocationReferences(
|
||||||
ArrayRef<uint8_t> content,
|
const Elf_Sym *symbol, ArrayRef<uint8_t> content,
|
||||||
range<Elf_Rela_Iter> rels) {
|
range<const Elf_Rela *> rels) {
|
||||||
const auto value = this->getSymbolValue(symbol);
|
const auto value = this->getSymbolValue(symbol);
|
||||||
for (const auto &rel : rels) {
|
for (const auto &rel : rels) {
|
||||||
if (rel.r_offset < value || value + content.size() <= rel.r_offset)
|
if (rel.r_offset < value || value + content.size() <= rel.r_offset)
|
||||||
|
|
@ -236,12 +236,12 @@ void MipsELFFile<ELFT>::createRelocationReferences(const Elf_Sym *symbol,
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
void MipsELFFile<ELFT>::createRelocationReferences(const Elf_Sym *symbol,
|
void MipsELFFile<ELFT>::createRelocationReferences(
|
||||||
ArrayRef<uint8_t> symContent,
|
const Elf_Sym *symbol, ArrayRef<uint8_t> symContent,
|
||||||
ArrayRef<uint8_t> secContent,
|
ArrayRef<uint8_t> secContent, range<const Elf_Rel *> rels) {
|
||||||
range<Elf_Rel_Iter> rels) {
|
|
||||||
const auto value = this->getSymbolValue(symbol);
|
const auto value = this->getSymbolValue(symbol);
|
||||||
for (Elf_Rel_Iter rit = rels.begin(), eit = rels.end(); rit != eit; ++rit) {
|
for (const Elf_Rel *rit = rels.begin(), *eit = rels.end(); rit != eit;
|
||||||
|
++rit) {
|
||||||
if (rit->r_offset < value || value + symContent.size() <= rit->r_offset)
|
if (rit->r_offset < value || value + symContent.size() <= rit->r_offset)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -303,10 +303,10 @@ uint32_t MipsELFFile<ELFT>::getPairRelocation(const Elf_Rel &rel) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
typename MipsELFFile<ELFT>::Elf_Rel_Iter
|
const typename MipsELFFile<ELFT>::Elf_Rel *
|
||||||
MipsELFFile<ELFT>::findMatchingRelocation(uint32_t pairRelType,
|
MipsELFFile<ELFT>::findMatchingRelocation(uint32_t pairRelType,
|
||||||
Elf_Rel_Iter rit,
|
const Elf_Rel *rit,
|
||||||
Elf_Rel_Iter eit) const {
|
const Elf_Rel *eit) const {
|
||||||
return std::find_if(rit, eit, [&](const Elf_Rel &rel) {
|
return std::find_if(rit, eit, [&](const Elf_Rel &rel) {
|
||||||
return getPrimaryType(rel) == pairRelType &&
|
return getPrimaryType(rel) == pairRelType &&
|
||||||
rel.getSymbol(isMips64EL<ELFT>()) ==
|
rel.getSymbol(isMips64EL<ELFT>()) ==
|
||||||
|
|
|
||||||
|
|
@ -71,9 +71,8 @@ protected:
|
||||||
private:
|
private:
|
||||||
typedef llvm::object::Elf_Sym_Impl<ELFT> Elf_Sym;
|
typedef llvm::object::Elf_Sym_Impl<ELFT> Elf_Sym;
|
||||||
typedef llvm::object::Elf_Shdr_Impl<ELFT> Elf_Shdr;
|
typedef llvm::object::Elf_Shdr_Impl<ELFT> Elf_Shdr;
|
||||||
typedef llvm::object::Elf_Rel_Impl<ELFT, false> Elf_Rel;
|
typedef typename llvm::object::ELFFile<ELFT>::Elf_Rel Elf_Rel;
|
||||||
typedef typename llvm::object::ELFFile<ELFT>::Elf_Rel_Iter Elf_Rel_Iter;
|
typedef typename llvm::object::ELFFile<ELFT>::Elf_Rela Elf_Rela;
|
||||||
typedef typename llvm::object::ELFFile<ELFT>::Elf_Rela_Iter Elf_Rela_Iter;
|
|
||||||
|
|
||||||
enum { TP_OFFSET = 0x7000, DTP_OFFSET = 0x8000 };
|
enum { TP_OFFSET = 0x7000, DTP_OFFSET = 0x8000 };
|
||||||
|
|
||||||
|
|
@ -90,11 +89,11 @@ private:
|
||||||
|
|
||||||
void createRelocationReferences(const Elf_Sym *symbol,
|
void createRelocationReferences(const Elf_Sym *symbol,
|
||||||
ArrayRef<uint8_t> content,
|
ArrayRef<uint8_t> content,
|
||||||
range<Elf_Rela_Iter> rels) override;
|
range<const Elf_Rela *> rels) override;
|
||||||
void createRelocationReferences(const Elf_Sym *symbol,
|
void createRelocationReferences(const Elf_Sym *symbol,
|
||||||
ArrayRef<uint8_t> symContent,
|
ArrayRef<uint8_t> symContent,
|
||||||
ArrayRef<uint8_t> secContent,
|
ArrayRef<uint8_t> secContent,
|
||||||
range<Elf_Rel_Iter> rels) override;
|
range<const Elf_Rel *> rels) override;
|
||||||
|
|
||||||
const Elf_Shdr *findSectionByType(uint64_t type) const;
|
const Elf_Shdr *findSectionByType(uint64_t type) const;
|
||||||
const Elf_Shdr *findSectionByFlags(uint64_t flags) const;
|
const Elf_Shdr *findSectionByFlags(uint64_t flags) const;
|
||||||
|
|
@ -114,8 +113,9 @@ private:
|
||||||
|
|
||||||
uint32_t getPairRelocation(const Elf_Rel &rel) const;
|
uint32_t getPairRelocation(const Elf_Rel &rel) const;
|
||||||
|
|
||||||
Elf_Rel_Iter findMatchingRelocation(uint32_t pairRelType, Elf_Rel_Iter rit,
|
const Elf_Rel *findMatchingRelocation(uint32_t pairRelType,
|
||||||
Elf_Rel_Iter eit) const;
|
const Elf_Rel *rit,
|
||||||
|
const Elf_Rel *eit) const;
|
||||||
|
|
||||||
bool isLocalBinding(const Elf_Rel &rel) const;
|
bool isLocalBinding(const Elf_Rel &rel) const;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue