On Mon, 8 May 2017 08:46:54 +1000 Adam Carter wrote:
> Since an update to the default USE flags on gcc 6 turned on PIE and SSP,
> i'm getting these errors;
> 
> /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
> atof-generic.o: relocation R_X86_64_32 against `.rodata' can not be used
> when making a shared object; recompile with -fPIC
> /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
> dw2gencfi.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be
> used when making a shared object; recompile with -fPIC
> /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
> frags.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used
> when making a shared object; recompile with -fPIC
> /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
> messages.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used
> when making a shared object; recompile with -fPIC
> /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
> subsegs.o: relocation R_X86_64_32 against `.rodata' can not be used when
> making a shared object; recompile with -fPIC
> /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
> symbols.o: relocation R_X86_64_32S against symbol `_sch_toupper' can not be
> used when making a shared object; recompile with -fPIC
> /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
> atof-ieee.o: relocation R_X86_64_32S against `.rodata' can not be used when
> making a shared object; recompile with -fPIC
> /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
> symbols.o: warning: relocation against `strlen@@GLIBC_2.2.5' in readonly
> section `.text'
> /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
> final link failed: Nonrepresentable section on output
> collect2: error: ld returned 1 exit status
> 
> If I add -fPIC to CFLAGS it will compile. Interestingly some packages (eg
> PHP) will compile without the -fPIC. Also the man page says; "This option
> makes a difference on AArch64, m68k, PowerPC and SPARC:, whereas i'm
> running amd64.
> 
> What's going on here?

Shared objects often need -fPIC for proper relocations when
linking, just add it when you're told to. It allows COW strategy
for DLOs but at the cost of extra CPU register and some slowdown.

Best regards,
Andrew Savchenko

Attachment: pgp_7cjU5i50K.pgp
Description: PGP signature

Reply via email to