[llvm-objdump] Fix mach-o binding decompression error

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220119 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nick Kledzik 2014-10-18 01:21:02 +00:00
parent 2402e6315d
commit 50ede1623d
3 changed files with 8 additions and 3 deletions

View File

@ -1974,20 +1974,20 @@ void MachOBindEntry::moveNext() {
SegmentOffset) << "\n"); SegmentOffset) << "\n");
return; return;
case MachO::BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: case MachO::BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB:
AdvanceAmount = readULEB128(); AdvanceAmount = readULEB128() + PointerSize;
RemainingLoopCount = 0; RemainingLoopCount = 0;
if (TableKind == Kind::Lazy) if (TableKind == Kind::Lazy)
Malformed = true; Malformed = true;
DEBUG_WITH_TYPE( DEBUG_WITH_TYPE(
"mach-o-bind", "mach-o-bind",
llvm::dbgs() << "BIND_OPCODE_DO_BIND_IMM_TIMES: " llvm::dbgs() << "BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: "
<< format("SegmentOffset=0x%06X", SegmentOffset) << format("SegmentOffset=0x%06X", SegmentOffset)
<< ", AdvanceAmount=" << AdvanceAmount << ", AdvanceAmount=" << AdvanceAmount
<< ", RemainingLoopCount=" << RemainingLoopCount << ", RemainingLoopCount=" << RemainingLoopCount
<< "\n"); << "\n");
return; return;
case MachO::BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED: case MachO::BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED:
AdvanceAmount = ImmValue * PointerSize; AdvanceAmount = ImmValue * PointerSize + PointerSize;
RemainingLoopCount = 0; RemainingLoopCount = 0;
if (TableKind == Kind::Lazy) if (TableKind == Kind::Lazy)
Malformed = true; Malformed = true;

Binary file not shown.

View File

@ -0,0 +1,5 @@
# RUN: llvm-objdump -macho -bind %p/Inputs/bind2.macho-x86_64 | FileCheck %s
# CHECK: __DATA __data 0x00001008 pointer 0 libSystem _malloc
# CHECK: __DATA __data 0x00001050 pointer 0 libSystem _malloc
# CHECK: __DATA __data 0x00001458 pointer 0 libSystem _malloc