Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
clearbluejar opened this issue Feb 21, 2025 · 1 comment

Comments

@clearbluejar
Copy link

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
@ryanmkurtz
Copy link
Collaborator

I don't recall revamping reexports in the last couple of years, so I'm not surprised there is an issue. I'll take a look on Monday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants