« macOS Big Sur arrived… | Home | MBS Xojo Plugins, ver… »

Extract the system libraries on macOS Big Sur


On macOS Big Sur we can load libiodbc, libiconv and other open source libraries just fine, but where are they?

The folder /usr/bin has only a few symlinks, but not the real library files.


Fellow Thomas Tempelmann pointed me to a blog post from Jeff Johnson (who made StopTheMadness!) about Extract the system libraries on macOS Big Sur. And this article informed us how to get the libraries extracted.


The steps are quite accurate, but for Xcode 12.2, I had to adjust a bit.

  • Download dyld-733.8.tar.gz from Apple OpenSource website.
  • Select target to build only dyld_shared_cache_util and not the other stuff.
  • Changed SDK to macos.
  • In dyld.h we change __API_UNAVAILABLE and __API_AVAILABLE defines to not do anything.
    #undef __API_UNAVAILABLE
    #define __API_UNAVAILABLE(...)
    
    #undef __API_AVAILABLE
    #define __API_AVAILABLE(...)
  • In Diagnostics.h we add C declarations for SIMPLE string:
    extern "C" {
    
    typedef struct _SIMPLE*    _SIMPLE_STRING;
    extern void                _simple_vdprintf(int __fd, const char *__fmt, va_list __ap);
    extern void                _simple_dprintf(int __fd, const char *__fmt, ...);
    extern _SIMPLE_STRING    _simple_salloc(void);
    extern int                _simple_vsprintf(_SIMPLE_STRING __b, const char *__fmt, va_list __ap);
    extern void                _simple_sfree(_SIMPLE_STRING __b);
    extern char *            _simple_string(_SIMPLE_STRING __b);
    }
    Further down, change void* buffer variable to _SIMPLE_STRING _buffer = nullptr;, so the _buffer variable has a type.
  • In MachOLoaded.cpp comment out all corecrypto includes.
  • In Diagnostics.cpp we comment out _simple.h and libc_private.h includes. We could have put above definitions into a _simple.h file instead of course. Further down we change abort_report_np to have extern "C" in front to avoid link error.
  • In Closure.cpp we comment out corecrypto includes and System/machine/cpu_capabilities.h include. In hashBootAndFileInfo further below we change the #if to #if 0 to disable the block.
  • Finally build it and run it in terminal: dyld_shared_cache_util -extract ~/Desktop /System/Library/dyld/dyld_shared_cache_x86_64

For all you out there, here is my copy with modifications and the built command-line tool (x86_64 + arm64). No warranties as I have no idea whether the commented out code has side effects: dyld_shared_cache_util-dyld-733.8.zip

13 11 20 - 12:16