On Mon, May 08, 2017 at 08:46:54AM +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?
It's a feature, not a bug. <G> There's a news item being worked on in the Gentoo dev list. I'd normally just link to a mail archive, but it's too new to have been archived yet. Here's a copy of the proposed news item. Note the example error message about relocation against .rodata ####################################################################### Title: GCC 6 defaults to USE="pie ssp" Author: Matthias Maier <tam...@gentoo.org> Content-Type: text/plain Posted: 2017-05-07 Revision: 1 News-Item-Format: 1.0 Display-If-Installed: >=sys-devel/gcc-6.3.0 Display-If-Keyword: amd64 In Gentoo, several GCC features can be default disabled or enabled via use-flags of sys-devel/gcc. Starting with gcc-4.8.3 we have already enabled default SSP [1]. Since the PIE patchset for default position independent executable support was integrated upstream [2,3], starting with gcc-6.3 we are also enabling PIE by default (via a default-enabled use-flag pie) in regular (non-hardened) profiles. [Additionally, following Gentoo policies, the default-off use-flags nopie (only present in Hardened) and nossp are replaced starting with gcc-6 by default-on use-flags pie and ssp.] Be advised that switching from an older version to GCC 6 will enable the PIE feature by default. This should not cause many problems, but it may be necessary to recompile parts of your userland. An indicator are linker errors of the form [4] relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC [1] https://www.gentoo.org/support/news-items/2014-06-15-gcc48_ssp.html [2] https://gcc.gnu.org/gcc-6/changes.html [3] A big thanks to all developers and members of the Gentoo community that made upstreaming the pie patchset and other hardening options possible! [4] https://bugs.gentoo.org/617698 ####################################################################### -- Walter Dnes <waltd...@waltdnes.org> I don't run "desktop environments"; I run useful applications