|When do I need PIC? firstname.lastname@example.org (joshc) (2006-07-28)|
|Re: When do I need PIC? email@example.com (Vincent Zweije) (2006-07-29)|
|Re: When do I need PIC? firstname.lastname@example.org (joshc) (2006-07-31)|
|Re: When do I need PIC? email@example.com (russell kym horsell) (2006-08-03)|
|Re: When do I need PIC? firstname.lastname@example.org (joshc) (2006-08-04)|
|Re: When do I need PIC? email@example.com (glen herrmannsfeldt) (2006-08-09)|
|Date:||28 Jul 2006 18:49:13 -0400|
|Keywords:||code, question, comment|
So I'm pretty sure there's probably no standard that dictates this,
but with regards to the majority of compilers when does one need to
compile a function to be PIC? What I'm interested in is having the
ability to relocate functions from the address they were linked to and
executing these functions from their new locations. I know this
probably depends a lot on processor architecture and compiler, but
what sort of things would dictate whether or not I need to compile
this function to be PIC?
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.
2) Whether or not the function calls any other functions because again
the branches could be relative vs absolute.
Are the above two points correct, and what else do I need to worry
about? As you can probably tell this is in the context of an embedded
[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]
Return to the
Search the comp.compilers archives again.