leleliu008 / ndk-pkg-formula-repository-official-core

the formula repository for ndk-pkg
Apache License 2.0
13 stars 6 forks source link

Bash isn't complied as a Position Independent Executable, rendering the binary unlaunchable on android 5.0 and above. #5

Closed ghost closed 2 years ago

ghost commented 2 years ago

Just adding 'package set ccflags "-fPIE"' doesn't really work.

leleliu008 commented 2 years ago

try 'package set ldflags "-fPIE"'

-fPIE flag is used by linker.

ghost commented 2 years ago

I test out my target shell script with a toybox shell. Thanks for looking into it. I believe it has worked out for me in the end.

leleliu008 commented 2 years ago

Bash use system-wide profile /etc/profile, I don't change these config. I will look into this problem when have time.

ghost commented 2 years ago

"I believe it has worked out for me in the end."(the toybox shell solution).

The gcc man page says -fPIE is a Code Generation feature flag, doesn't occur anywhere else as a feature flag. An "-fpic" flag gets set by something else. I thought for awhile since that comes first, then "-fPIE" doesn't override the "fpic" flag.

leleliu008 commented 2 years ago

yes, you are right, I removed the -fpic flags from CFLAGS and add -pie -fPIE, it works now.