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

AArch64: Fix passing function pointers #5896

Closed
wants to merge 3 commits into from

Conversation

agu-z
Copy link
Collaborator

@agu-z agu-z commented Oct 8, 2023

In the ARM dev backend, we use LinkedData for function pointers, but object_builder only added undefined RC procs for LinkedFunction relocs, leading to a crash later when looking up its symbol.

This fixes 52 tests 🎉

@agu-z agu-z requested a review from folkertdev October 8, 2023 04:03
@agu-z agu-z changed the title AArch64: Fix passing function pointers to builtins AArch64: Fix passing function pointers Oct 8, 2023
@@ -920,6 +920,8 @@ fn build_proc<'a, B: Backend<'a>>(
}
}
Relocation::LinkedData { offset, name } => {
add_undefined_rc_proc(output, name, &rc_proc_names);
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't it weird that an RC proc ends up here? I'm happy it works but would like to understand why a bit beter

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@folkertdev Yeah, it took me a while to figure out what was going on here, but I think it's expected.

Mono IR does not include these specific helper/wrappers as Procs, but they are instead generated by the dev backend when it encounters CallType::HigherOrder here.

Since we don't pass a mutable Object reference to backend.build_proc, it can't add any extra Procs itself, but it instead returns them so we can add them in object_builder as it already did for LinkedFunction.

I agree it's a little subtle, but I didn't want to make too invasive of a change. Let me know if you think we should, though!

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the missing piece for me was that we use the data_pointer function to create function pointers in this case. Then things make more sense. I think this is fine then

@lukewilliamboswell
Copy link
Collaborator

Thank you, commits included in #5839

@agu-z agu-z deleted the agu-z/fix-aarch64-fn-pointer branch October 8, 2023 14:44
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