0

How to enable Stack Smashing Protection in the swift application?

I did try to put "-fstack-protector-all" flag to Other C Flags under project build settings tab in xCode, but is seems that, this flag is unused or have no impact on builded application.

To verifie build I'm using otool -Iv AppBinary | grep stack enter image description here

Run the otool command and no presence of stack_chk_guard and stack_chk_fail. I tried for both build App.app file and Development signing file,no working. What additional setting need to add in my Xcode swift app?

Sabai Phoo
  • 358
  • 1
  • 4
  • 20
  • any idea for that? – Sabai Phoo Dec 07 '20 at 10:56
  • I am facing the same issue in my swift project, Have you find any solution? As I know there is no need to enable Stack Smashing Protection in swift project because it is default enabled, only in Objective -C we have to put "-fstack-protector-all" flag to Other C Flags under project build settings tab. – Prema Janoti Dec 29 '20 at 09:34
  • I add "-fstack-protector-all" flag to Other C Flags,but not wrorking – Sabai Phoo Jan 18 '21 at 03:07

1 Answers1

0

Please check this Solution. It worked for me. As per this Solution you have to do below steps-

  1. Add Objective-C Class in you Swift project.
  2. Add "-fstack-protector-all" flag to Other C Flags and Other C++ Flags
  3. Than execute otool -Iv AppBinaryPath | grep stack command on Terminal. it will show result like bello-

___stack_chk_fail

___stack_chk_guard

Prema Janoti
  • 836
  • 5
  • 18