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

Please make aeabi division functions use weak linkage, because they are incorrect for ARMv4T #477

Closed
Lokathor opened this issue Jul 22, 2022 · 3 comments · Fixed by #478
Closed

Comments

@Lokathor
Copy link
Contributor

The division functions included in this crate pop the link-register value directly into pc to return. This is correct for interworking code with v5T and later, but it is incorrect for v4T.

With v4T, you must use bx to switch code modes.

At this time I'm not aware of a way to cfg on the ARM version of a target. I think the best fix is to just declare the functions as weak linkage, and then v4T users can just override the functions on their end.

@Amanieu
Copy link
Member

Amanieu commented Jul 22, 2022

You can use cfg(target_feature = "v5te") for this.

@Lokathor
Copy link
Contributor Author

Hmm. Interesting!

Would you also be willing to accept a PR for weak linkage on the division functions anyway? Because even if I use that target_feature to fix up these general functions with the correct return instructions (which I'll try to do later today) I would also like to be able to define my own versions that are stored in RAM rather than ROM because of the speed difference (it's like a 5x time difference in my case).

@Amanieu
Copy link
Member

Amanieu commented Jul 22, 2022

I think that we should have weak linkage on all functions in compiler-builtins actually, subject to target support. Anything except apple/windows uses ELF where this should work fine.

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 a pull request may close this issue.

2 participants