|When do I need PIC? email@example.com (joshc) (2006-07-28)|
|Re: When do I need PIC? firstname.lastname@example.org (Vincent Zweije) (2006-07-29)|
|Re: When do I need PIC? email@example.com (joshc) (2006-07-31)|
|Re: When do I need PIC? firstname.lastname@example.org (russell kym horsell) (2006-08-03)|
|Re: When do I need PIC? email@example.com (joshc) (2006-08-04)|
|Re: When do I need PIC? firstname.lastname@example.org (glen herrmannsfeldt) (2006-08-09)|
|From:||glen herrmannsfeldt <email@example.com>|
|Date:||9 Aug 2006 00:00:18 -0400|
|Posted-Date:||09 Aug 2006 00:00:18 EDT|
> Some things that I think would dictate when I need PIC:
> 1) Whether or not the function references any global data because the
> variables might be accessed relative to the program counter.
I would expect only constant data to be referenced relative to the
program counter. There should be faster ways to reference other data,
at least on most machines around.
> 2) Whether or not the function calls any other functions because again
> the branches could be relative vs absolute.
As long as you move them together, it should be fine. I don't know if
any do that, though. If they do, the relocation information should be
> [The whole point of PIC is so you can move code from one place to
> another without having to modify it. If you want to be able to
> relocate the code, use PIC, if you don't, don't. -John]
I remember from the SunOS 4.x days, the DLL for the C library,
libc.so.? as supplied by sun didn't include routines to query a
nameserver. DLL's required PIC, but the static C library, libc.a,
didn't use PIC because it was slower. Sun then supplied a separate C
library that was PIC. One extracts all the entries as .o files,
replaces the desired files, and then creates a new libc.so from the
On most machines PIC is bigger and slower, and so is not used by
default. For any machine where it wasn't slower, it would probably be
used, to save the relocation time on program load.
Return to the
Search the comp.compilers archives again.