UPDATE Assuming my latest theory is correct, I've run into an odd error building binutils when targeting android-21 headers and libs. It is odd because the undefined symbols referenced in the build errors below are not referenced in the files mentioned. depends.c has no code referencing __swbuf or __sputc input-file.c has no code referencing __srget. /usr/bash/bin/bash ./libtool --tag=CC --mode=link gcc --sysroot=/opt21/arm21-sysroot -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -fPIE -fPIC -march=armv7-a -mandroid -mbionic -DNO_LOCALE -static-libstdc++ -static-libgcc -Wl,-E -Wl,--dynamic-linker=/system/bin/linker -fPIE -pie -o as-new app.o as.o atof-generic.o compress-debug.o cond.o depend.o dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o flonum-konst.o flonum-mult.o frags.o hash.o input-file.o input-scrub.o listing.o literal.o macro.o messages.o output-file.o read.o remap.o sb.o stabs.o subsegs.o symbols.o write.o tc-arm.o obj-elf.o atof-ieee.o ../opcodes/libopcodes.la ../bfd/libbfd.la ../libiberty/libiberty.a -lz -lc -ldl -lm libtool: link: gcc --sysroot=/opt21/arm21-sysroot -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -fPIE -fPIC -march=armv7-a -mandroid -mbionic -DNO_LOCALE -static-libstdc++ -static-libgcc -Wl,-E -Wl,--dynamic-linker=/system/bin/linker -fPIE -pie -o .libs/as-new app.o as.o atof-generic.o compress-debug.o cond.o depend.o dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o flonum-konst.o flonum-mult.o frags.o hash.o input-file.o input-scrub.o listing.o literal.o macro.o messages.o output-file.o read.o remap.o sb.o stabs.o subsegs.o symbols.o write.o tc-arm.o obj-elf.o atof-ieee.o ../opcodes/.libs/libopcodes.so -L/bld/gcc/build-bin/opcodes/../libiberty/pic ../bfd/.libs/libbfd.so -L/bld/gcc/build-bin/bfd/../libiberty/pic -liberty ../libiberty/libiberty.a -lz -ldl -lm -Wl,-rpath -Wl,/tmp21/lib depend.o: In function `__sputc': depend.c:(.text+0x90): undefined reference to `__swbuf' input-file.o: In function `input_file_open': input-file.c:(.text+0x2c4): undefined reference to `__srget' input-file.c:(.text+0x424): undefined reference to `__srget' messages.o: In function `__sputc': messages.c:(.text+0x90): undefined reference to `__swbuf' collect2: error: ld returned 1 exit status make[4]: *** [as-new] Error 1 make[4]: Leaving directory `/bld/gcc/build-bin/gas' make[3]: *** [all-recursive] Error 1 make[3]: Leaving directory `/bld/gcc/build-bin/gas' make[2]: *** [all] Error 2 make[2]: Leaving directory `/bld/gcc/build-bin/gas' make[1]: *** [all-gas] Error 2 make[1]: Leaving directory `/bld/gcc/build-bin' make: *** [all] Error 2 This is confusing...why is the build erroring out? Or should this go to the binutils mailing list? On June 19, 2015 12:23:58 PM CDT, Cyd Haselton <chaselton@xxxxxxxxx> wrote: >While researching how to cross-compile for PIE, I discovered my theory >was based on a faulty premise: that PIE binaries will only run on >Android 5.0. > >Therefore (again while I;m waiting for more knowledgeable people to >respond to my original email) I;m ditching the cross-compile for native >building and I've downloaded the Android 5.0 libs and headers to use. > >On June 19, 2015 6:26:16 AM CDT, Cyd Haselton <chaselton@xxxxxxxxx> >wrote: >>ADDITIONAL NOTE: >>I have a theory as to what I did wrong, so while i'm waiting for >>responses I'll test it by trying to re-building binutils and gcc as >>cross-compiles >> >>On June 19, 2015 6:13:09 AM CDT, Cyd Haselton <chaselton@xxxxxxxxx> >>wrote: >>>As suggested by the responses to my previous email (building GCC AS >>>PIE) I went ahead and configured/built binutils with -fPIE and >started >>>to build GCC with the same: >>> >>>../gcc-4.9.2/configure --prefix=/usr/gcc-49-pie >>>--build=arm-linux-androideabi --host=arm-linux-androideabi >>>--target=arm-linux-androideabi --disable-ld >>>--with-as=/usr/gcc-49-pie/bin/as --with-ld=/usr/gcc-49-pie/bin/ld >>>--enable-shared --enable-languages=c,c++ --disable-bootstrap >>>--disable-sjlj-exceptions --disable-nls --disable-gold >>>--disable-fortran --disable-libssp --disable-lto >--disable-libquadmath >>>--disable-libquadmath-support --disable-libada --disable-werror >>>--disable-multilib --disable-libgomp --disable-cloog >>>--with-build-time-tools=/usr/gcc-4.9.2/bin LIBCXXFLAGS='-O2 -mandroid >>>-mbionic -fno-implicit-templates -frtti' LIBS='-lc -ldl -lgcc -lm >>>-lsupc++ -lgnustl_shared' --with-build-sysroot=/sysroot >>>--disable-libsanitizer >>> >>> >>>Unfortunately, about midway through the build, I get the following >>>error (warning, long): >>> >>> >>>bld/gcc/build-gcc49/./gcc/xgcc -B/bld/gcc/build-gcc49/./gcc/ >>>-B/usr/gcc-49-pie/arm-linux-androideabi/bin/ >>>-B/usr/gcc-49-pie/arm-linux-androideabi/lib/ -isystem >>>/usr/gcc-49-pie/arm-linux-androideabi/include -isystem >>>/usr/gcc-49-pie/arm-linux-androideabi/sys-include --sysroot=/sysroot > >>>-g -O2 -fPIE -fPIC -march=armv7-a -mandroid -mbionic -DNO-LOCALE -O2 >>>-g -O2 -fPIE -fPIC -march=armv7-a -mandroid -mbionic -DNO-LOCALE >>>-DIN_GCC -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual >>>-Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition >>>-isystem ./include -fPIC -fno-inline -g -DIN_LIBGCC2 >>>-fbuilding-libgcc -fno-stack-protector -fPIC -fno-inline -I. -I. >>>-I../.././gcc -I../../../gcc-4.9.2/libgcc >>-I../../../gcc-4.9.2/libgcc/. >>>-I../../../gcc-4.9.2/libgcc/../gcc >>>-I../../../gcc-4.9.2/libgcc/../include -o _arm_cmpdf2_s.o -MT >>>_arm_cmpdf2_s.o -MD -MP -MF _arm_cmpdf2_s.dep -DSHARED -DL_arm_cmpdf2 >>>-xassembler-with-cpp -c >>>../../../gcc-4.9.2/libgcc/config/arm/lib1funcs.S >>><command-line>:0:3: warning: missing whitespace after the macro name >>><command-line>:0:3: warning: missing whitespace after the macro name >>>../../../gcc-4.9.2/libgcc/config/arm/ieee754-df.S: Assembler >messages: >>>../../../gcc-4.9.2/libgcc/config/arm/ieee754-df.S:1158: Error: cannot >>>represent BFD_RELOC_CTOR relocation in this object file format >>>../../../gcc-4.9.2/libgcc/config/arm/ieee754-df.S:1174: Error: cannot >>>represent BFD_RELOC_CTOR relocation in this object file format >>>../../../gcc-4.9.2/libgcc/config/arm/ieee754-df.S:1185: Error: cannot >>>represent BFD_RELOC_CTOR relocation in this object file format >>>../../../gcc-4.9.2/libgcc/config/arm/ieee754-df.S:1196: Error: cannot >>>represent BFD_RELOC_CTOR relocation in this object file format >>>../../../gcc-4.9.2/libgcc/config/arm/ieee754-df.S:1207: Error: cannot >>>represent BFD_RELOC_CTOR relocation in this object file format >>>../../../gcc-4.9.2/libgcc/config/arm/ieee754-df.S:1218: Error: cannot >>>represent BFD_RELOC_CTOR relocation in this object file format >>>make[2]: *** [_arm_cmpdf2_s.o] Error 1 >>>make[2]: Leaving directory >>>`/bld/gcc/build-gcc49/arm-linux-androideabi/libgcc' >>>make[1]: *** [all-target-libgcc] Error 2 >>>make[1]: Leaving directory `/bld/gcc/build-gcc49' >>>make: *** [all] Error 2 >>> >>>Google is not helpful when searching for the specific error...any >>>ideas?