|Info on PIC code email@example.com (Doug Wyatt) (1997-06-10)|
|Re: Info on PIC code firstname.lastname@example.org (Ian Lance Taylor) (1997-06-13)|
|From:||Ian Lance Taylor <email@example.com>|
|Date:||13 Jun 1997 22:01:44 -0400|
In comp.compilers Doug Wyatt <firstname.lastname@example.org> writes:
>Are there any good references on the specifics on PIC code
>implementations? In particular, I'm interested in PIC from gcc in x86
>machines. I need info such as persistency of the PIC register,
>when/where PIC register values are calculated, offset formulas for
>symbols at runtime, etc.
The version of PIC implemented on ELF based systems (such as
GNU/Linux) is documented in two books: System V Application Binary
Interface and System V Application Binary Interface Intel386 Processor
The %ebx register holds the address of the global offset table. It is
normally calculated in the prologue of each function; this makes it
possible to easily call a function in another object via a function
pointer. I don't know what you mean by offset formulas.
>I am currently trying to build some shared libraries for an OS we are
>developing and need to know what sort of register manipulations are
>legal and where. I tried to munge through the source to gcc but that
>was getting me nowhere.
gcc will only give you 1/3 of the story. You must also understand
what the assembler and linker do.
>[A quick look at the code suggests that it uses a procedure lookup table
>and global offset table like the ones that Sun's shared libraries do, and
>that %bx is reserved to hold the address of the PLT. I also note that on
>my BSD/OS 2.1 box, the assembler can't assemble the compiler's output when
>you tell it to generate PIC. -John]
The ELF PIC system was based on the SunOS system. It has the
advantage of being thoroughly documented. I've never seen any
technical documentation on SunOS shared libraries; I implemented it in
the GNU linker by reading the ELF specs and reverse engineering.
I don't know what BSD/OS does.
[Oops, those two SysV books happen to be on a shelf about three feet
from my desk. BSD/OS doesn't use PIC, since their shared library
scheme doesn't use dynamic linking. -John]
Return to the
Search the comp.compilers archives again.