Gentoo Archives: gentoo-amd64

From: Daniel Iliev <danny@××××××××.com>
To: gentoo-amd64@l.g.o
Subject: Re: [gentoo-amd64] First Impressions
Date: Wed, 27 Sep 2006 15:17:39
Message-Id: 451A8E18.7040104@ilievnet.com
In Reply to: Re: [gentoo-amd64] First Impressions by Christoph Mende
1 Christoph Mende wrote:
2 > One thing that I think wasn't mentioned yet, while -fPIC is needed for
3 > libraries, it must be disabled for binaries (don't know if that's true
4 > for prelink), as portage says, it might break things and your binaries
5 > are most likely becoming slower when you compile them with -fPIC.
6 >
7
8 Unfortunately I am not a C programmer and I can't be sure about how
9 exactly PIC and prelink work.
10 As far as I understood the mechanism (please, correct me if I'm wrong)
11 prelink scans the executables to find which libs they load. Then it
12 makes cache and when a program is started it uses already pre-loaded
13 libs. So the program is ready for action faster.
14
15 My only way to judge about the result is to test. Taking this in mind
16 you can understand that the part about "becoming slower" sounds very
17 disturbing to me. ;-)
18 Can you, please, explain how it comes that PIC is good for libs and bad
19 for execs? I'm confused because the gcc man page says:
20 -fpic
21 Generate position-independent code (PIC) --snip--
22 If the GOT size for the linked executable exceeds a
23 machine-specific maximum size, you get an error message
24 from the linker indicating that -fpic does not work; in that
25 case,
26 recompile with -fPIC instead. -snip- *The 386 has no such limit*
27
28 -fPIC
29 If supported for the target machine, emit position-independent
30 code, suitable for dynamic linking and avoiding any limit on the
31 size of the global offset table. *This option makes a
32 difference on
33 the m68k, PowerPC and SPARC.*
34
35 So, both flags let gcc produce PIC for libs and programs and none of
36 them lets gcc produce PIC for libs only? The next flag described in the
37 man page is -fpie, which makes PIC for programs only. Something is wrong
38 and don't know how to find the right explanation.
39
40 --
41 Best regards,
42 Daniel
43
44
45 --
46 gentoo-amd64@g.o mailing list

Replies

Subject Author
Re: [gentoo-amd64] First Impressions Simon Stelling <blubb@g.o>
Re: [gentoo-amd64] First Impressions Barry.SCHWARTZ@×××××××××××××.org