All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [parisc-linux] PIC code generation in gcc/binutils
@ 2000-07-24 23:58 Cary Coutant
  2000-07-25  0:05 ` Ulrich Drepper
  2000-07-25  0:23 ` David Huggins-Daines
  0 siblings, 2 replies; 9+ messages in thread
From: Cary Coutant @ 2000-07-24 23:58 UTC (permalink / raw)
  To: David Huggins-Daines; +Cc: parisc-linux

>I was hoping to write up a preliminary ABI specification based on the
>64-bit ELF implementation on HP/UX, so I've been trying to find
>detailed specifications on how the ELF64 ABI actually works but so far
>have not come up with much information from HP's documentation.  The
>64-bit runtime architecture document has some useful information, but
>I suspect I'll have to look at the actual implementation to nail down
>the details.

As the HP-UX Runtime Architect, I'll be happy to answer any questions you 
may have on the runtime architecture. I realize that the 64-bit runtime 
architecture is weak in the dynamic loading area, but I'll try to make up 
for that by answering questions in this forum.


>One thing I am sure of is that if we try to follow the HP/UX ELF64
>specification for dynamic linking on 32-bit Linux we are going to be
>substantially different from other Linux/ELF platforms.  In
>particular, the handling of inter-module calls and function pointers,
>and the management of the GP, are done in a totally different way from
>all the other platforms I've encountered (i386, m68k, alpha).
>(i.e. inter-module calls are handled by another set of stubs, and GP
>management is done by the caller via the function descriptors, rather
>than by the callee with GPDISP and similar relocations)

The model used for PA-RISC is a a consequence of the segmented 
architecture, where the text and data segments are not adjacent. Since 
the PA-RISC sharing model is based on global virtual addresses, the text 
and data segment are loaded in separate quadrants of the address space so 
that the text can be shared and the data can be process-private. As a 
result, a procedure cannot materialize its own gp, since there is no 
fixed pc-relative offset between the text and data. This means that the 
caller must materialize the gp prior to the call, or as part of the call.

By the way, this model is also being used for IA-64. You may be able to 
leverage some of the work being done for ld.so on that platform.

It shouldn't really complicate the dynamic loader that much, though. A 
function pointer is still essentially a function pointer, and behaves the 
same as in the other model, even though it points to a 128-bit descriptor 
rather than an actual function. The linker needs to allocate a GOT entry 
for each import stub (aka "proxy") it creates, and attach a dynamic FPTR 
relocation to that GOT entry. The dynamic loader needs to create the 
function descriptor when it processes the FPTR relocation.

Lazy binding requires a bit of cleverness. We do it by dynamically 
creating lazy-binding stubs that load a module id and a PLT index into 
registers, then branch to a common bind-on-reference routine.


Cary Coutant
HP-UX Runtime Architect

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: [parisc-linux] PIC code generation in gcc/binutils
@ 2000-07-25 17:21 Cary Coutant
  0 siblings, 0 replies; 9+ messages in thread
From: Cary Coutant @ 2000-07-25 17:21 UTC (permalink / raw)
  To: Cary Coutant, David Huggins-Daines; +Cc: parisc-linux

>I realize that the 64-bit runtime 
>architecture is weak in the dynamic loading area, ...

By the way, I meant the documentation, not the runtime architecture 
itself!

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: [parisc-linux] PIC code generation in gcc/binutils
@ 2000-07-25 17:20 Cary Coutant
  0 siblings, 0 replies; 9+ messages in thread
From: Cary Coutant @ 2000-07-25 17:20 UTC (permalink / raw)
  To: David Huggins-Daines; +Cc: parisc-linux

>I can see some advantages in this even with a non-segmented runtime
>architecture - theoretically, having the GP be managed by the caller
>rather than the callee should make intramodule calls in
>position-independent code more efficient.  (I think so at least)

Yes, it does have that advantage, and we take advantage of it when we can 
determine at compile time that the callee is in the same load module.

>One thing I have not figured out is how the GP is "bootstrapped" in
>the startup code for the dynamic linker itself - how does ELF64 on
>HP/UX deal with this problem?

The kernel loader passes a "load info" record to the dynamic loader as 
the fourth parameter (after argc, argv, and envp). This record contains, 
among other things, the load addresses of the dynamic loader's text and 
data segments. The dynamic loader's startup code materializes its own gp 
based on the base address of its data segment.

-cary

^ permalink raw reply	[flat|nested] 9+ messages in thread
* [parisc-linux] PIC code generation in gcc/binutils
@ 2000-07-18 17:58 David Huggins-Daines
  0 siblings, 0 replies; 9+ messages in thread
From: David Huggins-Daines @ 2000-07-18 17:58 UTC (permalink / raw)
  To: Alan Modra; +Cc: parisc-linux

Hi Alan, other porters,

I'm at the point now (userland mostly works for me as does the 64-bit
toolchain) where I'd like to start working on the implementation of
ELF dynamic linking for hppa-linux.  Obviously the precondition for
this is a working PIC code model in GCC and binutils.

I was hoping to write up a preliminary ABI specification based on the
64-bit ELF implementation on HP/UX, so I've been trying to find
detailed specifications on how the ELF64 ABI actually works but so far
have not come up with much information from HP's documentation.  The
64-bit runtime architecture document has some useful information, but
I suspect I'll have to look at the actual implementation to nail down
the details.

One thing I am sure of is that if we try to follow the HP/UX ELF64
specification for dynamic linking on 32-bit Linux we are going to be
substantially different from other Linux/ELF platforms.  In
particular, the handling of inter-module calls and function pointers,
and the management of the GP, are done in a totally different way from
all the other platforms I've encountered (i386, m68k, alpha).
(i.e. inter-module calls are handled by another set of stubs, and GP
management is done by the caller via the function descriptors, rather
than by the callee with GPDISP and similar relocations)

This will potentially make implementing ld.so more difficult, and thus
I'm not sure how desireable it is to follow the 64-bit example; we
will never have to actually link and load HP/UX ELF binaries with our
native toolchain and dynamic linker, even when we do have support for
64-bit userland.

On the other hand following the ELF64 example *will* allow us to reuse
code (though the ELF64 PIC implementation in BFD appears to be still
somewhat incomplete) in binutils, so it looks like kind of a
binutils/ld.so tradeoff.

Thus I am playing a bit with adapting the ELF64 code to produce a
preliminary PIC-generating toolchain.  I don't, however, want to get
too far into this before knowing (a) what other people are working on,
and (b) what the implementation is going to look like.

Thoughts?

-- 
dhd@linuxcare.com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2000-07-25 17:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-07-24 23:58 [parisc-linux] PIC code generation in gcc/binutils Cary Coutant
2000-07-25  0:05 ` Ulrich Drepper
2000-07-25  0:23 ` David Huggins-Daines
2000-07-25  1:12   ` Alan Modra
2000-07-25 14:36     ` Matthew Wilcox
2000-07-25 15:16     ` Matthew Wilcox
  -- strict thread matches above, loose matches on Subject: below --
2000-07-25 17:21 Cary Coutant
2000-07-25 17:20 Cary Coutant
2000-07-18 17:58 David Huggins-Daines

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.