diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-04-03 23:51:28 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-04-03 23:51:28 +0000 |
commit | 128b8111d7b6e7bb002b1867cc7a2fbf6b7d0ebd (patch) | |
tree | 17988c013bf590a6c127617e465a768c0e1a5058 /llvm/lib/Object/MachOObjectFile.cpp | |
parent | 905b6d192cadd43401964f4ff05534a65b007cf2 (diff) | |
download | bcm5719-llvm-128b8111d7b6e7bb002b1867cc7a2fbf6b7d0ebd.tar.gz bcm5719-llvm-128b8111d7b6e7bb002b1867cc7a2fbf6b7d0ebd.zip |
Implement macho relocation iterators with section number + relocation number.
This will make it possible to implement getRelocationAddress.
llvm-svn: 205587
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index 2bd87c970de..dd732aefb0d 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -755,46 +755,31 @@ MachOObjectFile::sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, } relocation_iterator MachOObjectFile::section_rel_begin(DataRefImpl Sec) const { - uint32_t Offset; - if (is64Bit()) { - MachO::section_64 Sect = getSection64(Sec); - Offset = Sect.reloff; - } else { - MachO::section Sect = getSection(Sec); - Offset = Sect.reloff; - } - DataRefImpl Ret; - Ret.p = reinterpret_cast<uintptr_t>(getPtr(this, Offset)); + Ret.d.a = Sec.d.a; + Ret.d.b = 0; return relocation_iterator(RelocationRef(Ret, this)); } relocation_iterator MachOObjectFile::section_rel_end(DataRefImpl Sec) const { - uint32_t Offset; uint32_t Num; if (is64Bit()) { MachO::section_64 Sect = getSection64(Sec); - Offset = Sect.reloff; Num = Sect.nreloc; } else { MachO::section Sect = getSection(Sec); - Offset = Sect.reloff; Num = Sect.nreloc; } - const MachO::any_relocation_info *P = - reinterpret_cast<const MachO::any_relocation_info *>(getPtr(this, Offset)); - DataRefImpl Ret; - Ret.p = reinterpret_cast<uintptr_t>(P + Num); + Ret.d.a = Sec.d.a; + Ret.d.b = Num; return relocation_iterator(RelocationRef(Ret, this)); } void MachOObjectFile::moveRelocationNext(DataRefImpl &Rel) const { - const MachO::any_relocation_info *P = - reinterpret_cast<const MachO::any_relocation_info *>(Rel.p); - Rel.p = reinterpret_cast<uintptr_t>(P + 1); + ++Rel.d.b; } error_code @@ -1476,8 +1461,21 @@ MachOObjectFile::getVersionMinLoadCommand(const LoadCommandInfo &L) const { MachO::any_relocation_info MachOObjectFile::getRelocation(DataRefImpl Rel) const { - const char *P = reinterpret_cast<const char *>(Rel.p); - return getStruct<MachO::any_relocation_info>(this, P); + DataRefImpl Sec; + Sec.d.a = Rel.d.a; + uint32_t Offset; + if (is64Bit()) { + MachO::section_64 Sect = getSection64(Sec); + Offset = Sect.reloff; + } else { + MachO::section Sect = getSection(Sec); + Offset = Sect.reloff; + } + + auto P = reinterpret_cast<const MachO::any_relocation_info *>( + getPtr(this, Offset)) + Rel.d.b; + return getStruct<MachO::any_relocation_info>( + this, reinterpret_cast<const char *>(P)); } MachO::data_in_code_entry |