https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64237
--- Comment #4 from Markus Trippelsdorf <trippels at gcc dot gnu.org> --- (In reply to H.J. Lu from comment #3) > (In reply to Markus Trippelsdorf from comment #0) > > trippels@gcc20 nscd % cat nscd.i > > extern int program_invocation_name; > > extern void fn2(int, int); > > void > > fn1() { fn2(0, program_invocation_name); } > > > > trippels@gcc20 nscd % gcc -shared nscd.i -fpie > > /home/trippels/bin/ld: /home/trippels/tmp/ccoI5Lbg.o: relocation > > R_X86_64_PC32 against undefined symbol > > `program_invocation_name@@GLIBC_2.2.5' can not be used when making a shared > > object; recompile with -fPIC > > /home/trippels/bin/ld: final link failed: Bad value > > collect2: error: ld returned 1 exit status > > If you use -fpie, you should use -pie. > If you use -shared, you should use -fpic. -shared was used for demonstration purpose only. Same issue with -pie: % gcc -O2 -pie nscd.i -fPIE /usr/lib/x86_64-linux-gnu/Scrt1.o: In function `_start': (.text+0x20): undefined reference to `main' /home/trippels/bin/ld: /home/trippels/tmp/ccZF5sOU.o: relocation R_X86_64_PC32 against undefined symbol `program_invocation_name@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC