0

As part of challenging my self I was trying to run a program that doesn't exist on Catlina taken from Big Sur.

I had to extract the dylibs from the shared cache by using this tool.

The library called ChatKit, after the extraction it seems there are missing values under the Dynamic Loader Info and isn't expanded, see an example:

enter image description here

In addition, trying to open the program or by import it externally, e.g:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>

int main(int argc, char** argv)
{
    void *handle;

    handle = dlopen("./Chatkit", RTLD_LAZY);
    if (!handle) {
        /* fail to load the library */
        fprintf(stderr, "Error: %s\n", dlerror());
        return EXIT_FAILURE;
    }

    dlclose(handle);

    return EXIT_SUCCESS;
}

dyld throwing an error: Overlapping segments, because the segments' address lower is bigger than the higher? https://opensource.apple.com/source/dyld/dyld-360.21/src/ImageLoaderMachO.cpp

...
    if ( this->segmentsCanSlide() && this->segmentsMustSlideTogether() ) {
        bool needsToSlide = false;
        bool imageHasPreferredLoadAddress = segHasPreferredLoadAddress(0);
        uintptr_t lowAddr = (unsigned long)(-1);
        uintptr_t highAddr = 0;
        for(unsigned int i=0, e=segmentCount(); i < e; ++i) {
            const uintptr_t segLow = segPreferredLoadAddress(i);
            const uintptr_t segHigh = dyld_page_round(segLow + segSize(i));
            if ( segLow < highAddr ) {
                if ( dyld_page_size > 4096 )
                    dyld::throwf("can't map segments into 16KB pages");
                else
                    dyld::throwf("overlapping segments");
            }
            if ( segLow < lowAddr )
                lowAddr = segLow;
            if ( segHigh > highAddr )
                highAddr = segHigh;
                
            if ( needsToSlide || !imageHasPreferredLoadAddress || inPIE || !reserveAddressRange(segPreferredLoadAddress(i), segSize(i)) )
                needsToSlide = true;
        }

you can retrieve ChatKit dylib from here

4
  • How did you extract the dylib? – Igor Skochinsky Dec 29 '20 at 21:37
  • @IgorSkochinsky I used this tool to extract the dylibs, if that is what you ask? – Pi Pony Dec 29 '20 at 21:43
  • Yes thank you. Could you add this info to the question? – Igor Skochinsky Dec 29 '20 at 21:44
  • @IgorSkochinsky done, is there anything else you would like to add? – Pi Pony Dec 29 '20 at 21:53
0

It seems the tool you are using is optimized for getting correct disassembly/symbols and not necessarily getting a runnable(acceptable by dyld) binary. Besides, the readme mentions that it does not support format changes in Beta 9 and later so it probably won’t work with the final release.

The dyld cache format is highly optimized and a lot of information is shared by multiple libraries so it’s not easy to extract just the information used by the one you need (and put it back in correct locations). You can try opening an issue on GitHub but I expect you’ll have to implement it yourself if you really want to get this working.

2
  • α) You didn't understand the question: "not necessarily getting a runnable binary" that isn't what I'm trying to accomplish.. β) "The dyld cache format is highly optimized" - How to get the specs of dyld cache format for each version? γ) "a lot of information is shared by multiple libraries so it’s not easy to extract just the information used by the one you need (and put it back in correct locations)" - how would you do that? – Pi Pony Dec 29 '20 at 22:24
  • @PiPony there’s no dedicated documentation but a lot can be deduced by reading the dyld sources from opensource.apple.com – Igor Skochinsky Jan 6 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.