It worked fine with a simple binary.
But when I tried to build a Shared Library for Android it did not accept the -Z flag and stack-protector attribute.
I used cargo-ndk to build a shared library for android. So what could be the possible solution to enable stack canary for an android so when we build with Cargo.
As I worked further I did not find a way to pass the stack-protector flag to cargo-ndk. However, I found a way to build the Android shared library by configuring the ndk toolchain manually. The below article helped me in building an 'so' without cargo-ndk