Menu

#462 mcs51: implement stack probing

open
nobody
None
5
5 hours ago
2023-07-01
Oleg Endo
No

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?

1 Attachments

Discussion

<< < 1 2 (Page 2 of 2)
  • Oleg Endo

    Oleg Endo - 2023-11-12

    I'd really appreciate some feedback where we are with this one.

     
    • Philipp Klaus Krause

      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.

       
      • Maarten Brock

        Maarten Brock - 5 hours ago

        I can look into this later this week.

         
<< < 1 2 (Page 2 of 2)

Log in to post a comment.