mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[Object] Rename getRelrRelocationType to getRelativeRelocationType
Summary: The two utility functions were added in D47919 to support SHT_RELR. However, these are just relative relocations types and are't necessarily be named Relr. Reviewers: phosek, dberris Reviewed By: dberris Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D55691 llvm-svn: 349133
This commit is contained in:
parent
6a4e651274
commit
1f32d67d40
@ -32,7 +32,7 @@ namespace llvm {
|
|||||||
namespace object {
|
namespace object {
|
||||||
|
|
||||||
StringRef getELFRelocationTypeName(uint32_t Machine, uint32_t Type);
|
StringRef getELFRelocationTypeName(uint32_t Machine, uint32_t Type);
|
||||||
uint32_t getELFRelrRelocationType(uint32_t Machine);
|
uint32_t getELFRelativeRelocationType(uint32_t Machine);
|
||||||
StringRef getELFSectionTypeName(uint32_t Machine, uint32_t Type);
|
StringRef getELFSectionTypeName(uint32_t Machine, uint32_t Type);
|
||||||
|
|
||||||
// Subclasses of ELFFile may need this for template instantiation
|
// Subclasses of ELFFile may need this for template instantiation
|
||||||
@ -113,7 +113,7 @@ public:
|
|||||||
StringRef getRelocationTypeName(uint32_t Type) const;
|
StringRef getRelocationTypeName(uint32_t Type) const;
|
||||||
void getRelocationTypeName(uint32_t Type,
|
void getRelocationTypeName(uint32_t Type,
|
||||||
SmallVectorImpl<char> &Result) const;
|
SmallVectorImpl<char> &Result) const;
|
||||||
uint32_t getRelrRelocationType() const;
|
uint32_t getRelativeRelocationType() const;
|
||||||
|
|
||||||
const char *getDynamicTagAsString(unsigned Arch, uint64_t Type) const;
|
const char *getDynamicTagAsString(unsigned Arch, uint64_t Type) const;
|
||||||
const char *getDynamicTagAsString(uint64_t Type) const;
|
const char *getDynamicTagAsString(uint64_t Type) const;
|
||||||
@ -415,8 +415,8 @@ void ELFFile<ELFT>::getRelocationTypeName(uint32_t Type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
uint32_t ELFFile<ELFT>::getRelrRelocationType() const {
|
uint32_t ELFFile<ELFT>::getRelativeRelocationType() const {
|
||||||
return getELFRelrRelocationType(getHeader()->e_machine);
|
return getELFRelativeRelocationType(getHeader()->e_machine);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
|
@ -154,7 +154,7 @@ StringRef llvm::object::getELFRelocationTypeName(uint32_t Machine,
|
|||||||
|
|
||||||
#undef ELF_RELOC
|
#undef ELF_RELOC
|
||||||
|
|
||||||
uint32_t llvm::object::getELFRelrRelocationType(uint32_t Machine) {
|
uint32_t llvm::object::getELFRelativeRelocationType(uint32_t Machine) {
|
||||||
switch (Machine) {
|
switch (Machine) {
|
||||||
case ELF::EM_X86_64:
|
case ELF::EM_X86_64:
|
||||||
return ELF::R_X86_64_RELATIVE;
|
return ELF::R_X86_64_RELATIVE;
|
||||||
@ -300,7 +300,7 @@ ELFFile<ELFT>::decode_relrs(Elf_Relr_Range relrs) const {
|
|||||||
Elf_Rela Rela;
|
Elf_Rela Rela;
|
||||||
Rela.r_info = 0;
|
Rela.r_info = 0;
|
||||||
Rela.r_addend = 0;
|
Rela.r_addend = 0;
|
||||||
Rela.setType(getRelrRelocationType(), false);
|
Rela.setType(getRelativeRelocationType(), false);
|
||||||
std::vector<Elf_Rela> Relocs;
|
std::vector<Elf_Rela> Relocs;
|
||||||
|
|
||||||
// Word type: uint32_t for Elf32, and uint64_t for Elf64.
|
// Word type: uint32_t for Elf32, and uint64_t for Elf64.
|
||||||
|
@ -85,22 +85,22 @@ loadObj(StringRef Filename, object::OwningBinary<object::ObjectFile> &ObjFile,
|
|||||||
|
|
||||||
RelocMap Relocs;
|
RelocMap Relocs;
|
||||||
if (ObjFile.getBinary()->isELF()) {
|
if (ObjFile.getBinary()->isELF()) {
|
||||||
uint32_t RelrRelocationType = [](object::ObjectFile *ObjFile) {
|
uint32_t RelativeRelocation = [](object::ObjectFile *ObjFile) {
|
||||||
if (const auto *ELFObj = dyn_cast<object::ELF32LEObjectFile>(ObjFile))
|
if (const auto *ELFObj = dyn_cast<object::ELF32LEObjectFile>(ObjFile))
|
||||||
return ELFObj->getELFFile()->getRelrRelocationType();
|
return ELFObj->getELFFile()->getRelativeRelocationType();
|
||||||
else if (const auto *ELFObj = dyn_cast<object::ELF32BEObjectFile>(ObjFile))
|
else if (const auto *ELFObj = dyn_cast<object::ELF32BEObjectFile>(ObjFile))
|
||||||
return ELFObj->getELFFile()->getRelrRelocationType();
|
return ELFObj->getELFFile()->getRelativeRelocationType();
|
||||||
else if (const auto *ELFObj = dyn_cast<object::ELF64LEObjectFile>(ObjFile))
|
else if (const auto *ELFObj = dyn_cast<object::ELF64LEObjectFile>(ObjFile))
|
||||||
return ELFObj->getELFFile()->getRelrRelocationType();
|
return ELFObj->getELFFile()->getRelativeRelocationType();
|
||||||
else if (const auto *ELFObj = dyn_cast<object::ELF64BEObjectFile>(ObjFile))
|
else if (const auto *ELFObj = dyn_cast<object::ELF64BEObjectFile>(ObjFile))
|
||||||
return ELFObj->getELFFile()->getRelrRelocationType();
|
return ELFObj->getELFFile()->getRelativeRelocationType();
|
||||||
else
|
else
|
||||||
return static_cast<uint32_t>(0);
|
return static_cast<uint32_t>(0);
|
||||||
}(ObjFile.getBinary());
|
}(ObjFile.getBinary());
|
||||||
|
|
||||||
for (const object::SectionRef &Section : Sections) {
|
for (const object::SectionRef &Section : Sections) {
|
||||||
for (const object::RelocationRef &Reloc : Section.relocations()) {
|
for (const object::RelocationRef &Reloc : Section.relocations()) {
|
||||||
if (Reloc.getType() != RelrRelocationType)
|
if (Reloc.getType() != RelativeRelocation)
|
||||||
continue;
|
continue;
|
||||||
if (auto AddendOrErr = object::ELFRelocationRef(Reloc).getAddend())
|
if (auto AddendOrErr = object::ELFRelocationRef(Reloc).getAddend())
|
||||||
Relocs.insert({Reloc.getOffset(), *AddendOrErr});
|
Relocs.insert({Reloc.getOffset(), *AddendOrErr});
|
||||||
|
Loading…
Reference in New Issue
Block a user