Re: [AD] proposed patch for nicer asm symbols exports |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Thu, Aug 19, 2004, Eric Botcazou wrote:
> Is it not the case that the text segment of a shared library can't contain
> any (dynamic) relocation in order to be sharable? Do you think
This is right.
> movl %eax, my_global
>
> can be resolved at static link time in a shared object? So is there not a
> contradiction?
If you do that, the text segment will simply not be shared but
duplicated. We still call it a shared object because it's shared at
least on the filesystem, but then the text area will not be shared
across program instances.
> > It's better if it's PIC code, because the dynamic loader has fewer
> > relocations to do, but on x86 it's not mandatory.
>
> Why on Earth are all shared libraries compiled with -fPIC on x86 then?
> Contrary to what happens for RISC cpus, -fPIC is really a performance
> killer on x86 because it steals 1 register out of 6 and prevents direct
> addressing from being used.
Well, it's the CPU/memory tradeoff. There is a CPU hit when using
-fPIC but not using it uses more memory when several programs use the
shared object. So it's definitely not worth using it in the libc for
instance, but admittedly you will seldom run several binaries using
liballegro at the same time.
However, I have not benchmarked Allegro with or without -fPIC, but I
wouldn't expect an important performance hit. And remember that %ebx is
not completely lost to the GOT handler: if you are in a critical routine
that does not do any function calls, just push %ebx on the stack and pop
it later, it's safe.
Also, there are x86 systems where -fPIC is mandatory. BeOS is one of
them (actually on BeOS you cannot even clobber %ebx in the executable).
Hopefully x86_32 on the desktop will die soon.
Cheers,
--
Sam.