From 50ede1623d0fe91baacfdf4b93dc151e2659f13b Mon Sep 17 00:00:00 2001 From: Nick Kledzik Date: Sat, 18 Oct 2014 01:21:02 +0000 Subject: [PATCH] [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 --- lib/Object/MachOObjectFile.cpp | 6 +++--- .../tools/llvm-objdump/Inputs/bind2.macho-x86_64 | Bin 0 -> 8376 bytes test/tools/llvm-objdump/macho-bind2.test | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100755 test/tools/llvm-objdump/Inputs/bind2.macho-x86_64 create mode 100644 test/tools/llvm-objdump/macho-bind2.test diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index 4435815b899..6e83d8182a4 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/lib/Object/MachOObjectFile.cpp @@ -1974,20 +1974,20 @@ void MachOBindEntry::moveNext() { SegmentOffset) << "\n"); return; case MachO::BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: - AdvanceAmount = readULEB128(); + AdvanceAmount = readULEB128() + PointerSize; RemainingLoopCount = 0; if (TableKind == Kind::Lazy) Malformed = true; DEBUG_WITH_TYPE( "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) << ", AdvanceAmount=" << AdvanceAmount << ", RemainingLoopCount=" << RemainingLoopCount << "\n"); return; case MachO::BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED: - AdvanceAmount = ImmValue * PointerSize; + AdvanceAmount = ImmValue * PointerSize + PointerSize; RemainingLoopCount = 0; if (TableKind == Kind::Lazy) Malformed = true; diff --git a/test/tools/llvm-objdump/Inputs/bind2.macho-x86_64 b/test/tools/llvm-objdump/Inputs/bind2.macho-x86_64 new file mode 100755 index 0000000000000000000000000000000000000000..f756fbb4a93fb2bd8ce2c6184ecb978cb9792500 GIT binary patch literal 8376 zcmeI2zfJ-{5XR>e6%~ml7AVcd7~`J=jFp9nV9-c3Mk9sY3LXUl8s$i&l16JfEqwud z8>4SvYvmi*8w%q$$L$@U7Pe+4`La8+JF{~?%HgH?{y9Ko^b%1&6oy`Vh^}Z9JE95b z7E&s+evsivm$k0>LDxr3>VpjTL@7IeVf)v<)%&H6ml2@4x5visE0xS7+fHWf%CGg~>H-?hO{>(o5NJ?7BB%I^$AyAT_{r{Cn2bN*^k zByjJ$m(ObBdgZ#jfTQ LkG=EfT$t?(Rz6U` literal 0 HcmV?d00001 diff --git a/test/tools/llvm-objdump/macho-bind2.test b/test/tools/llvm-objdump/macho-bind2.test new file mode 100644 index 00000000000..2eee2fcb60b --- /dev/null +++ b/test/tools/llvm-objdump/macho-bind2.test @@ -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