Skip to content

[ObjC] Enable removal of more memory management functions - #8524

Closed
AngeloD2022 wants to merge 2 commits into
Vector35:devfrom
AngeloD2022:objc-additional-mem-management-funcs
Closed

[ObjC] Enable removal of more memory management functions#8524
AngeloD2022 wants to merge 2 commits into
Vector35:devfrom
AngeloD2022:objc-additional-mem-management-funcs

Conversation

@AngeloD2022

Copy link
Copy Markdown
Contributor
  • Added _objc_claimAutoreleasedReturnValue to the list of ignorable memory management functions.
  • Added normalization for the name of register-specific ARC functions, like _objc_release_x19.
  • Added a more robust runtime function check for dyld shared cache binaries.

…g the suffix of register-specific ARC functions. Also added a more robust check that verifies the origin of runtime functions on dyld shared cache binaries.
@CLAassistant

CLAassistant commented Sep 6, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@AngeloD2022
AngeloD2022 marked this pull request as ready for review September 6, 2026 19:49
b"_objc_claimAutoreleasedReturnValue",
];

fn is_objc_rt_symbol_dscview(view: &BinaryView, symbol: &Symbol) -> bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify what the purpose of this function is? What is it guarding against?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added that check just to be as precise as possible and reduce the reliance on only symbol names– because if I'm not mistaken, it's possible in principle for multiple different symbols with the same name to exist in a binary view. So although it's unlikely– if Apple includes a function in one of their shared cache libraries with the same name as a runtime memory management function, it won't be hidden like one.


IGNORABLE_MEMORY_MANAGEMENT_FUNCTIONS.contains(&symbol_name)
// Normalize the name to also include register-specific functions (e.g. _objc_release_x19).
let symbol_name = util::strip_arc_reg_suffix(symbol_name);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in incorrect handling of objc_retain_xN calls. Converting them to a no-op will result in x0 having the incorrect value.

Consider this example:

Image

This change results in:

Image

It should be result->_internal = _initWithCFURLResponse[1]

@AngeloD2022

Copy link
Copy Markdown
Contributor Author

Fixed by #8535

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.

3 participants