[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shared Libs



Hi Chris,

> >Sure, most library modules will want to use some static variables(*),
> >which must be allocated in different data sections for different pro-
> >cesses. So the trap code should pass the proper base address of a mo-
> >dules' data section before jumping to a function within that module.
> 
> Unless the shared library manages the data sections itself, in which
> case we'd avoid using up another register.

Since the modules text segment is only loaded once, while the
modules data segment must use different storage space for each
process, a function must refer to its static variables via some
variable base address. It doesn't matter who manages the data
segments (be it the start-up code in the apllication, the trap
code loading the functions, or the functions themselves), the
base adress of a modules data segment for some process will
always remain variable (fixed addresses are a no-no for any
shared text).

It's exactly the same situation as with base relative binaries,
they too use a base register (gcc uses a5; latice-c leaves the
choice to the user, but in practice the choice is limited to
a5, because static libs and applications must use the same
base register).

Allthough you `loose' a register, the resulting code is often
faster (`movl a5@(foo),d0' is faster than `movl foo:l,d0').


Waldi