solar@coral 2 test001 $ gcc -v ; ld -v Reading specs from /usr/lib/gcc-lib/armv4l-unknown-linux-gnu/3.3.3/specs Configured with: /var/tmp/portage/gcc-3.3.3-r5/work/gcc-3.3.3/configure --prefix=/usr --bindir=/usr/armv4l-unknown-linux-gnu/gcc-bin/3.3 --includedir=/usr/lib/gcc-lib/armv4l-unknown-linux-gnu/3.3.3/include --datadir=/usr/share/gcc-data/armv4l-unknown-linux-gnu/3.3 --mandir=/usr/share/gcc-data/armv4l-unknown-linux-gnu/3.3/man --infodir=/usr/share/gcc-data/armv4l-unknown-linux-gnu/3.3/info --enable-shared --host=armv4l-unknown-linux-gnu --target=armv4l-unknown-linux-gnu --with-system-zlib --enable-languages=c,c++ --enable-threads=posix --enable-long-long --disable-checking --disable-libunwind-exceptions --enable-cstdio=stdio --enable-version-specific-runtime-libs --with-gxx-include-dir=/usr/lib/gcc-lib/armv4l-unknown-linux-gnu/3.3.3/include/g++-v3 --with-local-prefix=/usr/local --enable-shared --enable-nls --without-included-gettext --disable-multilib --enable-__cxa_atexit --enable-clocale=generic Thread model: posix gcc version 3.3.3 20040412 (Gentoo Linux 3.3.3-r5, ssp-3.3-7, pie-8.7.5.3) GNU ld version 2.15.90.0.3 20040415 --------------------------------------------------------- solar@coral 2 test001 $ emerge -pv gcc binutils glibc These are the packages that I would merge, in order: Calculating dependencies ...done! [ebuild R ] sys-devel/gcc-3.3.3-r5 +X -bootstrap -build -debug -debug -f77 -gcj -hardened -(java) -multilib +nls -objc -static -uclibc 23,201 kB [ebuild R ] sys-devel/binutils-2.15.90.0.3-r3 -bootstrap -build -multitarget +nls 10,527 kB [ebuild R ] sys-libs/glibc-2.3.2-r10 -build -debug +nls -nptl -pic 14,946 kB Total size of downloads: 48,675 kB --------------------------------------------------------- solar@coral 2 test001 $ ./test_pie_pic_shared_relation.sh pappy little hack0 script for toolchain resilience testing compiling as PIC linking as PIE with gcc pie and linker pie /usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x50): In function `__libc_csu_init': : undefined reference to `__init_array_start' /usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x54): In function `__libc_csu_init': : undefined reference to `__init_array_end' /usr/lib/libc_nonshared.a(elf-init.oS)(.text+0xa4): In function `__libc_csu_fini': : undefined reference to `__fini_array_start' /usr/lib/libc_nonshared.a(elf-init.oS)(.text+0xa8): In function `__libc_csu_fini': : undefined reference to `__fini_array_end' collect2: ld returned 1 exit status starting ./test_pie_pic_shared_relation.sh: line 21: ./hello_pie: No such file or directory linking as PIE without gcc pie but with linker pie - look at the used startfiles/crtbegin/end/etc. Reading specs from /usr/lib/gcc-lib/armv4l-unknown-linux-gnu/3.3.3/specs Configured with: /var/tmp/portage/gcc-3.3.3-r5/work/gcc-3.3.3/configure --prefix=/usr --bindir=/usr/armv4l-unknown-linux-gnu/gcc-bin/3.3 --includedir=/usr/lib/gcc-lib/armv4l-unknown-linux-gnu/3.3.3/include --datadir=/usr/share/gcc-data/armv4l-unknown-linux-gnu/3.3 --mandir=/usr/share/gcc-data/armv4l-unknown-linux-gnu/3.3/man --infodir=/usr/share/gcc-data/armv4l-unknown-linux-gnu/3.3/info --enable-shared --host=armv4l-unknown-linux-gnu --target=armv4l-unknown-linux-gnu --with-system-zlib --enable-languages=c,c++ --enable-threads=posix --enable-long-long --disable-checking --disable-libunwind-exceptions --enable-cstdio=stdio --enable-version-specific-runtime-libs --with-gxx-include-dir=/usr/lib/gcc-lib/armv4l-unknown-linux-gnu/3.3.3/include/g++-v3 --with-local-prefix=/usr/local --enable-shared --enable-nls --without-included-gettext --disable-multilib --enable-__cxa_atexit --enable-clocale=generic Thread model: posix gcc version 3.3.3 20040412 (Gentoo Linux 3.3.3-r5, ssp-3.3-7, pie-8.7.5.3) /usr/lib/gcc-lib/armv4l-unknown-linux-gnu/3.3.3/collect2 -dynamic-linker /lib/ld-linux.so.2 -X -m armelf_linux -p -o hello_pie /usr/lib/gcc-lib/armv4l-unknown-linux-gnu/3.3.3/../../../crt1.o /usr/lib/gcc-lib/armv4l-unknown-linux-gnu/3.3.3/../../../crti.o /usr/lib/gcc-lib/armv4l-unknown-linux-gnu/3.3.3/crtbegin.o -L/usr/lib/gcc-lib/armv4l-unknown-linux-gnu/3.3.3 -L/usr/lib/gcc-lib/armv4l-unknown-linux-gnu/3.3.3/../../.. -pie hello_pie.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/lib/gcc-lib/armv4l-unknown-linux-gnu/3.3.3/crtend.o /usr/lib/gcc-lib/armv4l-unknown-linux-gnu/3.3.3/../../../crtn.o /usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x50): In function `__libc_csu_init': : undefined reference to `__init_array_start' /usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x54): In function `__libc_csu_init': : undefined reference to `__init_array_end' /usr/lib/libc_nonshared.a(elf-init.oS)(.text+0xa4): In function `__libc_csu_fini': : undefined reference to `__fini_array_start' /usr/lib/libc_nonshared.a(elf-init.oS)(.text+0xa8): In function `__libc_csu_fini': : undefined reference to `__fini_array_end' collect2: ld returned 1 exit status starting ./test_pie_pic_shared_relation.sh: line 26: ./hello_pie: No such file or directory compiling as PIC linking with nostdlib and nostartfiles as PIC starting with dynamic loader hello pic -------------------------------------------------- solar@coral 2 test001 $ file * hello_pic: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.1, dynamically linked (uses shared libs), not stripped hello_pic.c: ASCII C program text hello_pic.o: ELF 32-bit LSB relocatable, ARM, version 1 (ARM), not stripped hello_pie.c: ASCII C program text hello_pie.o: ELF 32-bit LSB relocatable, ARM, version 1 (ARM), not stripped