-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Implement __morestack for ARM #4489
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
Comments
I have little idea at the moment, if someone find this explanation wrong please correct.
|
--- just in addition to above ---- Following seems to be red zone function inside prologue in i386 Following is the current Prolog for ARM for same simple function: (with out red zone) To implement in ARM we should have proper RZ implementation followed by __morestack insertion. |
The x86 segment registers that the prologue is looking in contain the thread control block, where pthreads stores it's per-thread data structures, in particular the task-local storage slots. The pthreads implementation reserves a number of slots for various platform-specific things and the prologue (and the accessors in For the ARM port we want to figure out where that thread control block lives and identify a reserved slot that we can 'steal'. For example, on x86_64 Linux we are using There is a big comment about bionic's TLS implementation that might offer some leads. There are apparently some reserved TLS slots that we may be able to use. Finally, there are two different mechanisms for accessing TLS on bionic depending on the hardware/software revision in use. With all this information presumably we can find a free word somewhere to hold the stack pointer. If you haven't seen it here is the original gcc split stack proposal, containing some useful details. |
I mentioned this elsewhere but I'll record it here too: Rust doesn't depend on a C++ compiler with |
A lot of ARM processors don't have the TLS register and implement TLS with a syscall (or a trap). Making a syscall on every function call is not going to work, so we may need to support a configuration that doesn't do stack growth. My impression is that newer generation processors should have the register. Some info here: http://elinux.org/Android_on_OMAP#TLS_issue |
Thanks @brson , I put more effort to understand the problem and what need to be done. So in order to get started , I first created a morestack.s with simple return for ARM i.e. mov pc, lr and statically compiled linked with rustrt using ndk tool chain. However LLVM when generate code for ARM even with -segmented-stacks option does not insert __morestack external symbol into the generated code. From rust side I have verified there is no problem as EnableSegmentedStack option is true while calling LLVM. so I started implementing adjustForSegmentedStacks method in ARMFrameLowering.cpp. Since I hardly know that big code so its being really hard and taking lot of time. Any way I believe once it is done it would give a ground to do some experiments to detect bottom of stack in case of arm-android and finally will lead to filling in empty morestack.S |
I'm working on this and I believe I've almost done with this. My current working branches are |
@ILyoan Wow! Nice work. I'm glad we can assume the presence of TLS. That makes things easier. |
Being managed without cmake |
There are some difficulties with implementing
__morestack
for ARM, but I don't know what they are. @amuxtux can you explain?For the time being it looks like we're just going to want to disable stack growth completely on ARM. To do this I think we should turn off the LLVM split stack feature for the ARM target (not use
no_split_stack
#1226).The text was updated successfully, but these errors were encountered: