diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-04-24 16:10:49 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-04-24 16:10:49 +0000 |
commit | 51cc82887cdd6795caaffc0ece500481b697bced (patch) | |
tree | 548051b14592f21e5b6914d6e7acadfaf7c638b3 /lib/Object | |
parent | e38afe1e335084134f7830ba6f2208e2ddde59b4 (diff) |
Revert r180189.
This should bring the ppc bots back. I will try to write a test that would
have found the problem on a little endian system too.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180194 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Object')
-rw-r--r-- | lib/Object/MachOObjectFile.cpp | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index e4b3350843..4e6e0bdada 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/lib/Object/MachOObjectFile.cpp @@ -769,47 +769,31 @@ MachOObjectFile::sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, } relocation_iterator MachOObjectFile::getSectionRelBegin(DataRefImpl Sec) const { - uint32_t Offset; - if (is64Bit()) { - macho::Section64 Sect = getSection64(Sec); - Offset = Sect.RelocationTableOffset; - } else { - macho::Section Sect = getSection(Sec); - Offset = Sect.RelocationTableOffset; - } - - DataRefImpl Ret; - Ret.p = reinterpret_cast<uintptr_t>(getPtr(this, Offset)); - return relocation_iterator(RelocationRef(Ret, this)); + DataRefImpl ret; + ret.d.b = Sec.d.a; + return relocation_iterator(RelocationRef(ret, this)); } relocation_iterator MachOObjectFile::getSectionRelEnd(DataRefImpl Sec) const { - uint32_t Offset; - uint32_t Num; + uint32_t LastReloc; if (is64Bit()) { macho::Section64 Sect = getSection64(Sec); - Offset = Sect.RelocationTableOffset; - Num = Sect.NumRelocationTableEntries; + LastReloc = Sect.NumRelocationTableEntries; } else { macho::Section Sect = getSection(Sec); - Offset = Sect.RelocationTableOffset; - Num = Sect.NumRelocationTableEntries; + LastReloc = Sect.NumRelocationTableEntries; } - const macho::RelocationEntry *P = - reinterpret_cast<const macho::RelocationEntry*>(getPtr(this, Offset)); - DataRefImpl Ret; - Ret.p = reinterpret_cast<uintptr_t>(P + Num); + Ret.d.a = LastReloc; + Ret.d.b = Sec.d.a; return relocation_iterator(RelocationRef(Ret, this)); } -error_code MachOObjectFile::getRelocationNext(DataRefImpl Rel, - RelocationRef &Res) const { - const macho::RelocationEntry *P = - reinterpret_cast<const macho::RelocationEntry *>(Rel.p); - Rel.p = reinterpret_cast<uintptr_t>(P + 1); + error_code MachOObjectFile::getRelocationNext(DataRefImpl Rel, + RelocationRef &Res) const { + ++Rel.d.a; Res = RelocationRef(Rel, this); return object_error::success; } @@ -1402,8 +1386,19 @@ MachOObjectFile::getLinkeditDataLoadCommand(const MachOObjectFile::LoadCommandIn macho::RelocationEntry MachOObjectFile::getRelocation(DataRefImpl Rel) const { - const char *P = reinterpret_cast<const char *>(Rel.p); - return getStruct<macho::RelocationEntry>(this, P); + uint32_t RelOffset; + DataRefImpl Sec; + Sec.d.a = Rel.d.b; + if (is64Bit()) { + macho::Section64 Sect = getSection64(Sec); + RelOffset = Sect.RelocationTableOffset; + } else { + macho::Section Sect = getSection(Sec); + RelOffset = Sect.RelocationTableOffset; + } + + uint64_t Offset = RelOffset + Rel.d.a * sizeof(macho::RelocationEntry); + return getStruct<macho::RelocationEntry>(this, getPtr(this, Offset)); } macho::Header MachOObjectFile::getHeader() const { |