This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: What different between PIC code and non-PIC code?


> From: pschen@mmpp5.iie.ncku.edu.tw
> Date: Tue, 24 Aug 1999 10:36:18 +0800 (CST)

>     PIC is position independent code.

Yes.

>     If the program is PIC, then that program can be relocated
>     at run-time.

This is imprecise, but yes.

>     I dont compile a program using -fPIC option normally.  The
>     program also can be relocated at run-time.

If by relocated, you mean moved without running relocs, then no, it
cannot be.  If by relocated, you mean moved, and running relocs, then
yes.  Most people use the first meaning.

>     That is no different between using -fPIC and no-using.

Ok, maybe, depends upon what you mean.

>     But I see the compiler output asemble-files between them, it is
>     different.  That is confused me. How to explain it?

when

	org 0x100
	jump A
A:

is turned into

   C3 01 03	jump	0x103

then we say that is not PIC code.  When it is turned into

   10 80 00 00	jump	.+4

we say it is PIC code.  The first code cannot be run at any address
other than 100, the second can run at any address.  The difference is
that one is PC relative addressing mode (the later one).  When you see
code gen differences, it is to use PC relative addressing modes.  That
_is_ the difference.

>     There is SYMBLE "_GLOBAL_OFFSET_TABLE" in the assemble-file from
>     gcc by using -fPIC option. What is _GLOBAL_OFFSET_TABLE?

I am sorry, this is way beyond the scope of this list.  Please consult
your OS documentation.  Most people probably don't have the time to
answer questions like this around here.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]