[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.
llvm-svn: 299104
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index 8124c18..f2c2aea 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -2780,12 +2780,10 @@
--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 @@
--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;
}