Gentoo Archives: gentoo-user

From: Andrew Savchenko <bircoph@g.o>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] gcc 6 PIE use flag
Date: Mon, 08 May 2017 11:30:54
Message-Id: 20170508143034.6b9b9e35d79ff08232e91c38@gentoo.org
In Reply to: [gentoo-user] gcc 6 PIE use flag by Adam Carter
1 On Mon, 8 May 2017 08:46:54 +1000 Adam Carter wrote:
2 > Since an update to the default USE flags on gcc 6 turned on PIE and SSP,
3 > i'm getting these errors;
4 >
5 > /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
6 > atof-generic.o: relocation R_X86_64_32 against `.rodata' can not be used
7 > when making a shared object; recompile with -fPIC
8 > /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
9 > dw2gencfi.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be
10 > used when making a shared object; recompile with -fPIC
11 > /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
12 > frags.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used
13 > when making a shared object; recompile with -fPIC
14 > /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
15 > messages.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used
16 > when making a shared object; recompile with -fPIC
17 > /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
18 > subsegs.o: relocation R_X86_64_32 against `.rodata' can not be used when
19 > making a shared object; recompile with -fPIC
20 > /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
21 > symbols.o: relocation R_X86_64_32S against symbol `_sch_toupper' can not be
22 > used when making a shared object; recompile with -fPIC
23 > /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
24 > atof-ieee.o: relocation R_X86_64_32S against `.rodata' can not be used when
25 > making a shared object; recompile with -fPIC
26 > /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
27 > symbols.o: warning: relocation against `strlen@@GLIBC_2.2.5' in readonly
28 > section `.text'
29 > /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
30 > final link failed: Nonrepresentable section on output
31 > collect2: error: ld returned 1 exit status
32 >
33 > If I add -fPIC to CFLAGS it will compile. Interestingly some packages (eg
34 > PHP) will compile without the -fPIC. Also the man page says; "This option
35 > makes a difference on AArch64, m68k, PowerPC and SPARC:, whereas i'm
36 > running amd64.
37 >
38 > What's going on here?
39
40 Shared objects often need -fPIC for proper relocations when
41 linking, just add it when you're told to. It allows COW strategy
42 for DLOs but at the cost of extra CPU register and some slowdown.
43
44 Best regards,
45 Andrew Savchenko

Replies

Subject Author
Re: [gentoo-user] gcc 6 PIE use flag Adam Carter <adamcarter3@×××××.com>