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

fix: decoding struct and union fields with ambiguous types #59

Merged
merged 4 commits into from
Jun 2, 2024

Conversation

t0rr3sp3dr0
Copy link
Contributor

@t0rr3sp3dr0 t0rr3sp3dr0 commented Jun 2, 2024

The @" sequence is ambiguous when used inside structs and unions. This patch makes go-macho correctly decode these types based on the behaviour of clang.

Encoded Type Decoded Type
{S="Id"@"NSString"^{S}} struct S { id Id; struct S *NSString; }
{S="Id"@"NSString""NSString"^{S}} struct S { NSString *Id; struct S *NSString; }
{?=@"NSString"^{S}} struct { NSString *; struct S *; }

Before:

@class next;

@interface __CFPrefsWeakObservers : NSObject <NSMutableCopying> {
    /* instance variables */
    struct __cfobservers_t { next *slot; struct __cfobservers_t *x1; } values;

After:

@interface __CFPrefsWeakObservers : NSObject <NSMutableCopying> {
    /* instance variables */
    struct __cfobservers_t { id slot; struct __cfobservers_t *next; } values;

@t0rr3sp3dr0 t0rr3sp3dr0 marked this pull request as draft June 2, 2024 01:53
@t0rr3sp3dr0 t0rr3sp3dr0 changed the title fix: decoding struct fields with ambiguous types fix: decoding struct and union fields with ambiguous types Jun 2, 2024
@t0rr3sp3dr0 t0rr3sp3dr0 marked this pull request as ready for review June 2, 2024 02:32
@blacktop blacktop merged commit b5c7468 into blacktop:master Jun 2, 2024
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

Successfully merging this pull request may close these issues.

None yet

2 participants