Swift and Stack smashing protection

前端 未结 3 1194
灰色年华
灰色年华 2021-01-04 07:20

How to enable Stack Smashing Protection in pure swift application?

I did try to put \"-fstack-protector-all\" flag to Other C++ Flags under project build settings t

3条回答
  •  [愿得一人]
    2021-01-04 07:52

    A bit late to the party but as it might be helpful for other's seeking advice: Joe's answer is not correct. -fstack-protector-all is a flag on the GCC compiler. (Documentation here: https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html)

    For swift applications, the GCC compiler is not involved here. Instead it's the swiftc compiler with different options and settings. Alas, I don't know of comparable options for the latter one.

    Adding an objective-c class to the project as @btype suggests, is not helping your swift sourcecode, as it only affects the Obj-C and C code. But if you use 3rd party libraries written in Obj-C it's still a valuable setting. But make sure, you set this flag on the right target, if 3rd party libraries are embedded as separate targets.

    Cheers, Chris

提交回复
热议问题