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

arm: generate thumb stub if is thumb mode #35

Merged
merged 1 commit into from
Dec 17, 2023
Merged

Conversation

iDings
Copy link
Contributor

@iDings iDings commented Dec 13, 2023

arm have thumb state and arm state, when pc is last bit is 1 which indicate that current is thumb state, on thumb state,
stub instruction should use thumb instructions.

https://www.embedded.com/introduction-to-arm-thumb/

@iDings
Copy link
Contributor Author

iDings commented Dec 13, 2023

#28 应该是类似的问题,这个跳转的话跟__thumb__的一样,但是有个疑问是为什么__thumb__的时候要跳过前面两个16bit的thumb指令?

cpp-stub/src/stub.h

Lines 62 to 69 in 41c1a8e

char *f = (char *)clearBit0;\
if (clearBit0 % 4 != 0) {\
*(uint16_t *)&f[0] = 0xbe00;\
}\
*(uint16_t *)&f[2] = 0xf8df;\
*(uint16_t *)&f[4] = 0xf000;\
*(uint16_t *)&f[6] = (uint16_t)(fn_stub & 0xffff);\
*(uint16_t *)&f[8] = (uint16_t)(fn_stub >> 16);\

@iDings
Copy link
Contributor Author

iDings commented Dec 13, 2023

这个改动在rtthread上验证是ok的

@coolxv coolxv merged commit 7de3a28 into coolxv:master Dec 17, 2023
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.

None yet

2 participants