Search code examples
macosdelphicode-signingfiremonkeydylib

Signing Firemonkey-generated dylib on Mac OS X


When I try to run codesign on a dylib created by Embarcadero's Firemonkey I get an error message:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate: file not in an order that can be processed (local relocation entries out of place): /Users/jwwalker/Documents/libV35SS.dylib

It might be related to this question: Reliable Deployment of Delphi-Generated Dylib on OSX

However, I tried reordering the load commands to make LC_ID_DYLIB come first, as was apparently the solution for that question, and it didn't help. Is there some other way to do binary editing on the file to fix it? Any clues as to the "right" location of the local relocation entries?


Using information from the Mach-o File Format Reference, I put together a tool that (at least in the case of my fairly small and simple dylib) rearranges data in the dylib to make it palatable to codesign. I released my code as open source.


Solution

  • The solution for the other question was patching the paths of the used dylibs directly in the dylib. That was basically doing manually what install_name_tool was supposed to do. But that won't help you for codesigning. That would basically mean you'd have to write your own code signing tool, but then it is still not certain that OSX will accept the signature of a "broken dylib".

    You could take a closer look at the following source file. This is the best I've found so far about the correct order and the structure of the dylib. http://www.opensource.apple.com/source/cctools/cctools-855/libstuff/checkout.c

    Fixing this issue manually will probably be a big challenge. I guess you'd have to take the dylib apart and rewrite it: https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html

    You might want to vote for this QC and tell Embarcadero that they must fix this if they want to support deployment to OSX 10.9.5 or Yosemite:

    Report No: 125607 Status: Open [MacOS] can not codesign libmidas.dylib for Apple Mac Store http://qc.embarcadero.com/wc/qcmain.aspx?d=125607 QCWIN:Defect_No=125607