[llvm] r299104 - [Object] Remove check for BIND_OPCODE_DONE/REBASE_OPCODE_DONE.

Juergen Ributzka via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 30 12:56:51 PDT 2017


Author: ributzka
Date: Thu Mar 30 14:56:50 2017
New Revision: 299104

URL: http://llvm.org/viewvc/llvm-project?rev=299104&view=rev
Log:
[Object] Remove check for BIND_OPCODE_DONE/REBASE_OPCODE_DONE.

BIND_OPCODE_DONE/REBASE_OPCODE_DONE may appear at the end of the opcode array,
but they are not required to. The linker only adds them as padding to align the
opcodes to pointer size.

This fixes rdar://problem/31285560.

Removed:
    llvm/trunk/test/tools/llvm-objdump/Inputs/macho-bind-missing-done
    llvm/trunk/test/tools/llvm-objdump/Inputs/macho-rebase-missing-done
Modified:
    llvm/trunk/lib/Object/MachOObjectFile.cpp
    llvm/trunk/test/tools/llvm-objdump/macho-bad-bind.test

Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=299104&r1=299103&r2=299104&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Thu Mar 30 14:56:50 2017
@@ -2780,12 +2780,10 @@ void MachORebaseEntry::moveNext() {
     --RemainingLoopCount;
     return;
   }
-  if (Ptr >= Opcodes.end()) {
-    if (Opcodes.begin() != Opcodes.end() && Done != true) {
-      *E = malformedError("missing REBASE_OPCODE_DONE at end of opcodes");
-      moveToEnd();
-      return;
-    }
+  // REBASE_OPCODE_DONE is only used for padding if we are not aligned to
+  // pointer size. Therefore it is possible to reach the end without ever having
+  // seen REBASE_OPCODE_DONE.
+  if (Ptr == Opcodes.end()) {
     Done = true;
     return;
   }
@@ -3164,12 +3162,10 @@ void MachOBindEntry::moveNext() {
     --RemainingLoopCount;
     return;
   }
-  if (Ptr >= Opcodes.end()) {
-    if (Opcodes.begin() != Opcodes.end() && Done != true) {
-      *E = malformedError("missing BIND_OPCODE_DONE at end of opcodes");
-      moveToEnd();
-      return;
-    }
+  // BIND_OPCODE_DONE is only used for padding if we are not aligned to
+  // pointer size. Therefore it is possible to reach the end without ever having
+  // seen BIND_OPCODE_DONE.
+  if (Ptr == Opcodes.end()) {
     Done = true;
     return;
   }

Removed: llvm/trunk/test/tools/llvm-objdump/Inputs/macho-bind-missing-done
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/Inputs/macho-bind-missing-done?rev=299103&view=auto
==============================================================================
Binary file - no diff available.

Removed: llvm/trunk/test/tools/llvm-objdump/Inputs/macho-rebase-missing-done
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/Inputs/macho-rebase-missing-done?rev=299103&view=auto
==============================================================================
Binary file - no diff available.

Modified: llvm/trunk/test/tools/llvm-objdump/macho-bad-bind.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/macho-bad-bind.test?rev=299104&r1=299103&r2=299104&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/macho-bad-bind.test (original)
+++ llvm/trunk/test/tools/llvm-objdump/macho-bad-bind.test Thu Mar 30 14:56:50 2017
@@ -67,9 +67,6 @@ WEAK-BIND-SET-DYLIB-ORDINAL-ULEB: macho-
 RUN: not llvm-objdump -macho -weak-bind %p/Inputs/macho-weak-bind-set-dylib-special-imm 2>&1 | FileCheck -check-prefix WEAK-BIND-SET-DYLIB-SPECIAL-IMM %s 
 WEAK-BIND-SET-DYLIB-SPECIAL-IMM: macho-weak-bind-set-dylib-special-imm': truncated or malformed object (BIND_OPCODE_SET_DYLIB_SPECIAL_IMM not allowed in weak bind table for opcode at: 0x2)
 
-RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-missing-done 2>&1 | FileCheck -check-prefix BIND-MISSING-DONE %s 
-BIND-MISSING-DONE: macho-bind-missing-done': truncated or malformed object (missing BIND_OPCODE_DONE at end of opcodes)
-
 RUN: not llvm-objdump -macho -rebase %p/Inputs/macho-rebase-set-type-imm 2>&1 | FileCheck -check-prefix REBASE-SET-TYPE-IMM %s 
 REBASE-SET-TYPE-IMM: macho-rebase-set-type-imm': truncated or malformed object (for REBASE_OPCODE_SET_TYPE_IMM bad bind type: 5 for opcode at: 0x0)
 
@@ -102,6 +99,3 @@ REBASE-ULEB-TIMES-SKIPPING-ULEB: macho-r
 
 RUN: not llvm-objdump -macho -rebase %p/Inputs/macho-rebase-bad-opcode-value 2>&1 | FileCheck -check-prefix REBASE-BAD-OPCODE-VALUE %s 
 REBASE-BAD-OPCODE-VALUE: macho-rebase-bad-opcode-value': truncated or malformed object (bad rebase info (bad opcode value 0xD0 for opcode at: 0x4)
-
-RUN: not llvm-objdump -macho -rebase %p/Inputs/macho-rebase-missing-done 2>&1 | FileCheck -check-prefix REBASE-MISSING-DONE %s 
-REBASE-MISSING-DONE: macho-rebase-missing-done': truncated or malformed object (missing REBASE_OPCODE_DONE at end of opcodes)




More information about the llvm-commits mailing list