I've been using this patch in my local version for a while now. As the title says, it implements stack probing for mcs51,but not for xstack, only the regular stack.
It does so by injecting the stack pointer check in the prologue of each function and assumes that the conditional branch is normally not taken if the stack check passes.
This is not perfect of course. It doesn't catch wraparound of the stack pointer and also doesn't catch a stack overflow after allocating the stack frame inside of the function (because the check is done before that). But it's better than nothing at all and has proven useful for me.
One issue I don't know how to deal with is how to extend the device lib set with the permutation for the option '--stack-probe'. The idea is to have stack probing also enabled for rt / c std device libs (printf can overflow the stack easily for example) when it's specified in the user application.
@spth do you have any suggestion?
I'd really appreciate some feedback where we are with this one.
If @maartenbrock doesn't find time to look into this again in the next few weeks or months, I'll try to do so. After all I'm planning to work on mcs51 a bit more in the future, so I need to get a bit familiar with the mcs51 port it anyway.
I can look into this later this week.