Skip to content

External Linking of libc and other external libs within libsystem.b.dylib is broken - handle LC_REEXPORT_DYLIB #7537

Open
@clearbluejar

Description

Describe the bug
The external linking of any dylibs that are exported by libsystem.b.dylib is broken. Several mac dylibs import libsystem.b.dylib to provide libc and other functionality.

Image

libSystem.B.dylib actually doesn't implement any of the functionality, rather...

Yet, libSystem itself relies on several libraries internal to it — which are found in /usr/lib/system. It imports these libraries, and then re-exports their public symbols as if they are its own.

Image

If I wanted to externally link _copyfile in my binary...

Image

It will directly link to libsystem.b.dylib and error saying that it can't find copyfile...

Image

It actually needs to link through to /usr/lib/system/libcopyfile.dylib...

I know I can manually create an external link to make copyfile work, but then all the other rexported symbols would try to resolve in libcopyfile.dylib.

Expected behavior
Would it be possible to properly handle the external LC_REEXPORT_DYLIB case in libsystem.b.dylib?

Screenshots
If applicable, add screenshots to help explain your problem.

Attachments
If applicable, please attach any files that caused problems or log files generated by the software.

Environment (please complete the following information):

  • OS: macOS 14
  • Java Version: 21
  • Ghidra Version: 11.3
  • Ghidra Origin: official GitHub distro

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions