When do I need PIC?

"joshc" <josh.curtz@gmail.com>
28 Jul 2006 18:49:13 -0400

          From comp.compilers

Related articles
When do I need PIC? josh.curtz@gmail.com (joshc) (2006-07-28)
Re: When do I need PIC? vzweije@sense.net (Vincent Zweije) (2006-07-29)
Re: When do I need PIC? josh.curtz@gmail.com (joshc) (2006-07-31)
Re: When do I need PIC? kym@otaku.freeshell.org (russell kym horsell) (2006-08-03)
Re: When do I need PIC? josh.curtz@gmail.com (joshc) (2006-08-04)
Re: When do I need PIC? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2006-08-09)
| List of all articles for this month |
From: "joshc" <josh.curtz@gmail.com>
Newsgroups: comp.compilers
Date: 28 Jul 2006 18:49:13 -0400
Organization: http://groups.google.com
Keywords: code, question, comment
Posted-Date: 28 Jul 2006 18:49:13 EDT

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
system.


Thanks.
[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]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.