Mac load commands corruption

5

Signing (codesign) on one of our app is failing with malformed object (unknown load command 9). After doing some research online I found that load commands are special commands in executable's header that are used by kernel for segment loading ( http://0xfe.blogspot.in/2006/03/how-os-x-executes-applications.html ). So, I ran otool -l command on my app. Where I found that and command 30 were corrupt. But, launching app works absolutely fine.

How can I resolve this issue? I have no idea about how other team built that app.

The otool -l command snippet

.
.
.
.

Load command 8
     cmd LC_UUID
 cmdsize 24
   uuid F892472C-7463-3549-8FA0-A93F4501FB40
Load command 9
      cmd ?(0x00000024) Unknown load command
  cmdsize 16
000a0600 00000000 
Load command 10
        cmd LC_UNIXTHREAD
    cmdsize 184
     flavor x86_THREAD_STATE64
      count x86_THREAD_STATE64_COUNT
   rax  0x0000000000000000 rbx 0x0000000000000000 rcx  0x0000000000000000
   rdx  0x0000000000000000 rdi 0x0000000000000000 rsi  0x0000000000000000
   rbp  0x0000000000000000 rsp 0x0000000000000000 r8   0x0000000000000000
    r9  0x0000000000000000 r10 0x0000000000000000 r11  0x0000000000000000
   r12  0x0000000000000000 r13 0x0000000000000000 r14  0x0000000000000000
   r15  0x0000000000000000 rip 0x0000000100001970
rflags  0x0000000000000000 cs  0x0000000000000000 fs   0x0000000000000000
    gs  0x0000000000000000

.
.
.
.
.
.
Load command 29
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (offset 24)
   time stamp 2 Thu Jan  1 05:30:02 1970
      current version 1038.36.0
compatibility version 45.0.0
Load command 30
      cmd ?(0x00000026) Unknown load command
  cmdsize 16
001bd748 00000ef8 
macos
osx-snow-leopard
code-signing
asked on Stack Overflow Feb 29, 2012 by Gagandeep Singh

1 Answer

4

@Gagandeep Singh already figured out a solution, but for others who come across this question:

"Unknown load command" errors can happen when an object is built for one Mac OS X version and then used on an earlier Mac OS X version.

Mac OS X 10.6 introduced load command LC_DYLD_INFO_ONLY (0×80000022). To fix problems with that, see here.

Mac OS X 10.7 introduced load commands LC_VERSION_MIN_MACOSX (0×80000024) and LC_FUNCTION_STARTS (0x80000026). To fix problems with those, see here.

A handy list of load command names is in mach-o/loader.h.

answered on Stack Overflow Jan 26, 2013 by jlstrecker • edited Mar 20, 2014 by jlstrecker

User contributions licensed under CC BY-SA 3.0