Is stack protection being forced on always?

Hi all,

In the process of catching up with Swift 5.11, I've rebased our compiler fork on top of modern swift and finally started running our unit test suite for our compiler IDE. Lots of our local tests are failing due to the missing symbol __stack_chk_guard. I'm new to stack protection and only just now noticed Erik's implementation. I can just add a global into all our programs for this but this feels like overhead we don't want on our platform possibly? Plus if it fails... we don't really have a concept of programs "trapping on safety exceptions" in our small embedded world.


I tried adding -Xfrontend -disable-stack-protector into our swift command line but I'm still getting the missing symbol. It might be I need to go back and add that into the compile of all our hardware libraries too.

I suppose I'm just looking for answers to these questions if anyone (@Erik_Eckstein?) can shed some light.

  1. am I understanding it right that over the last year, Swift has basically added stack protection on all normal (not inline) functions, at a brief glance this is implemented by asking llvm to add it to the function prolog/epilog?

  2. if I decide that we shouldn't have that on our platform, is the above flag "safe to use" and correct? Or will it have unintended consequences I haven't realised (apart from a lack of stack protection)?

  3. am I being over protective and we would be better to just "take the hit everywhere" and allow it? Our platform is super sensitive to code bloat, so the thought of adding anything to stack frames across all functions makes me feel a little queasy, but I might be over sensitive!

Thanks for any advice and help anyone can give.

Cheers,
Carl

2 Likes