Skip to content

Support Aarch64Call relocations for Mach-O#465

Merged
philipc merged 2 commits into
gimli-rs:masterfrom
nathanwhit:aarch64-macho-call-relocs
Oct 4, 2022
Merged

Support Aarch64Call relocations for Mach-O#465
philipc merged 2 commits into
gimli-rs:masterfrom
nathanwhit:aarch64-macho-call-relocs

Conversation

@nathanwhit

@nathanwhit nathanwhit commented Sep 19, 2022

Copy link
Copy Markdown
Contributor

This PR adds support for relocations with RelocationEncoding::Aarch64Call on Mach-O. Before this PR we would error out, as the relocation has a size of 26 which was unhandled, and we weren't setting the appropriate r_type. After this PR we support relocations with RelocationEncoding::Aarch64Call and an arbitrary addend.

This PR also handles a few extra cases of the relocation size (21 and 12) in order to support the usage of Mach-O specific relocations like ARM64_RELOC_PAGE21 and ARM64_RELOC_PAGEOFF12, respectively.

@philipc

philipc commented Sep 19, 2022

Copy link
Copy Markdown
Contributor

Thanks! Based on a brief look this is good. Where was the panic occurring?

@nathanwhit

nathanwhit commented Sep 19, 2022

Copy link
Copy Markdown
Contributor Author

The original panic was at

_ => return Err(Error(format!("unimplemented reloc size {:?}", reloc))),
Once that was fixed, it was hitting this case
return Err(Error(format!("unimplemented relocation {:?}", reloc)));

@philipc

philipc commented Sep 19, 2022

Copy link
Copy Markdown
Contributor

Ah okay, so not panics, just returning errors (maybe your crate was unwrapping that error).

@nathanwhit

nathanwhit commented Sep 19, 2022

Copy link
Copy Markdown
Contributor Author

Ah sorry, of course, don't know how I managed to mix that up. (The panic I was seeing was from cranelift unwrapping that error, here to be precise).

Comment thread src/write/mod.rs Outdated
Comment thread src/write/macho.rs Outdated
Comment thread src/write/macho.rs Outdated

@philipc philipc left a comment

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.

Thanks! I'll merge this after the unrelated archive code has been fixed.

@nathanwhit nathanwhit force-pushed the aarch64-macho-call-relocs branch from 9c5bdf6 to 76877fe Compare September 30, 2022 22:20
@nathanwhit

Copy link
Copy Markdown
Contributor Author

(Rebased so that CI passes now that the formatting issue has been fixed on master)

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.

2 participants