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

Mach-O: Add the ability to parse the dyld binding info #597

Open
PaulDance opened this issue Nov 20, 2023 · 2 comments
Open

Mach-O: Add the ability to parse the dyld binding info #597

PaulDance opened this issue Nov 20, 2023 · 2 comments

Comments

@PaulDance
Copy link

Mach-O objects can contain a dyld info command that points to various data structures. Among those is the generic, weak and lazy binding info that store the set of symbol information to be imported upon loading by dyld, if I understand things correctly.

Parsing such data is really not trivial, as it involves traversing through various operation codes that gradually build symbols one by one, so having it in object would be nice. Currently, the mach_object crate offers a correct implementation: I've been using it for a work project and it seems to behave well. However, this crate does not seem to be maintained anymore and the maintainer seems unreachable. We would therefore gladly work on porting the functionality to object instead and therefore upstream part of our work.

A few questions about the contribution then:

  • Does this even have its place in object?
  • What would go in macho vs. read::macho? There aren't much definitions similar to the rest of macho, it's mostly the parsing algorithm that needs implementation.
  • Would it be desirable to add it to a higher-level API?
  • If so, should it be added directly onto MachOFile or to the Object trait and its implementation of it? Having it outside of the trait makes more sense to me because it would not be behavior common to all formats, but I'm just checking anyways.
@mstange
Copy link
Contributor

mstange commented Nov 22, 2023

Here's some code you could take for the implementation: https://github.com/mstange/macho-stubs/blob/6dbb225e43002afe97a539682bbba731029c0fc9/src/main.rs#L140-L298

(see #377 for my use case)

@PaulDance
Copy link
Author

I was initially going to simply port it from mach_object, but this should indeed prove to be another source of inspiration. Thanks!

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