Skip to content

[SharedCache] Fix detection of the class name of categories#6553

Closed
bdash wants to merge 1 commit into
Vector35:devfrom
bdash:dsc-category-class-names
Closed

[SharedCache] Fix detection of the class name of categories#6553
bdash wants to merge 1 commit into
Vector35:devfrom
bdash:dsc-category-class-names

Conversation

@bdash
Copy link
Copy Markdown
Contributor

@bdash bdash commented Apr 3, 2025

The logic for determining the class name of a category did not correctly handle classes defined in other images in the shared cache. There were two problems:

  1. If the class is defined in another image that is already loaded, ObjCProcessor has already renamed the symbol from _OBJC_CLASS_$_ to cls_. Both forms of symbol name are now handled.
  2. If the class is defined in an image that is not yet loaded, no symbol name is available. The category's class is now looked up in the shared cache symbol table, and the symbol's name is parsed as if it were an import symbol.

This fixes all cases of "Failed to determine base classname for category" that I have come across.

The logic for determining the class name of a category did not correctly
handle classes defined in other images in the shared cache. There were
two problems:

1. If the class is defined in another image that is already loaded,
   `ObjCProcessor` has already renamed the symbol from `_OBJC_CLASS_$_`
   to `cls_`. Both forms of symbol name are now handled.

2. If the class is defined in an image that is not yet loaded, no symbol
   name is available. The category's class is now looked up in the
   shared cache symbol table, and the symbol's name is parsed as if it
   were an import symbol.

This fixes almost all cases of "Failed to determine base classname for
category" that I have come across.
@emesare emesare self-requested a review April 3, 2025 14:32
@emesare emesare self-assigned this Apr 3, 2025
@emesare emesare added this to the Gallifrey milestone Apr 3, 2025
@emesare
Copy link
Copy Markdown
Member

emesare commented Apr 3, 2025

Would something like this be ok with you? fb1d9e1

Nothing functionally changes I just think that is easier to understand from the base classes perspective, to always call GetSymbol rather than two separate calls which ultimately do the same thing.

If you are fine with that change I will fix it up into your commit with you being the author, or i can leave it separate, ill leave that up to you.
If you are not fine with that change I am still OK with merging without my change.

@emesare emesare added File Format: Mach-O File Format: SharedCache Issue with the dyld_shared_cache plugin labels Apr 3, 2025
@bdash
Copy link
Copy Markdown
Contributor Author

bdash commented Apr 3, 2025

I wasn't happy with the naming / factoring of SymbolForUnmappedAddress so fb1d9e1 is a clear improvement. Feel free to squash it if that is what works for you.

@emesare
Copy link
Copy Markdown
Member

emesare commented Apr 3, 2025

Cherry-picked onto dev with 254fd7b

Will be on dev build >7154. Thank you again!

@emesare emesare closed this Apr 3, 2025
@bdash bdash deleted the dsc-category-class-names branch April 8, 2025 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

File Format: Mach-O File Format: SharedCache Issue with the dyld_shared_cache plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants