Enable stack canaries in ios swift

5.9k views Asked by At

I was looking for a way to enable stack canaries for my ios application in swift but then i found that recent version of xcodes have the flag required to enable stack canaries is enabled by default. So then i was looking for a way to ensure the stack canaries are enabled and as the other sites say i tried with the otool command in terminal($ otool -Iv appName |grep stack_chk) to ensure it and expecting it to return 'stack_chk_guard and stack_chk_fail' flags but it did not return any value/flags. So I then tried setting manually the flag '-fstack-protector-all' under 'other C flags', still I could see no flags with otool command.

enter image description here

What am I missing here ? or am I misinterpreting something ? how can I assure myself that stack canaries are enabled for my application ?

1

There are 1 answers

6
Alexey Kozhevnikov On

Looks like you are doing everything correctly. Please double check:

  1. You are setting -fstack-protector-all flag for main target "Other C Flags". Or you are setting it for project settings and has $(inherited) in target build settings.
  2. Build your application and in build log (in report navigator, cmd+8) check where is AppName.app package
  3. cd path-to-package/AppName.app
  4. use otool on binary file: otool -Iv AppName| grep stack