From cad124910683d12220eb3a137992317dc36bfd32 Mon Sep 17 00:00:00 2001 From: Juergen Ributzka Date: Thu, 30 Mar 2017 19:56:50 +0000 Subject: [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 --- llvm/lib/Object/MachOObjectFile.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'llvm/lib/Object/MachOObjectFile.cpp') diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index 8124c18f30e..f2c2aead5a9 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -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; } -- cgit v1.2.3