jfmoy/android-dropbear

Doesn't build PIE version correctly?

bigwave opened this issue · 4 comments

Hi,

First of all, a really useful docker container as all I needed was a PIE ssh client and I've never compiled NDK stuff before.

However the PIE output (at least for the ARM ssh client) wasn't actually a PIE executable.

It seemed that the final linking(?) command didn't have the PIE flags, so I brute forced a solution by adding -pie -fPIE to the end of the COMPILER=${TOOLCHAIN}/bin/arm-linux-androideabi-gcc line

Which worked, but I'm pretty sure this isn't the correct way to fix this.

Cheers,
Ian

I'm having this same issue. Did you ever find a more proper solution?

Afraid not, once I had a PIE enabled executable I didn't need to look into this any more.

That's fine! Thanks anyways!

The answer is that the -pie flag have to be set on LDFLAGS for executables.

@@ -75,6 +75,7 @@ for ARCH_NAME in mips arm x86; do

         if [ $BIN_TYPE == "pie" ]; then
             export CFLAGS="-g -O2 -pie -fPIE"
+            export LDFLAGS="-pie"
             # Use the default platform target for pie binaries 
             unset GOOGLE_PLATFORM
         else