Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: John Max Skaller <skaller@ozemail.com.au>
To: fabrice.le_fessant@inria.fr
Cc: Vitaly Lugovsky <vsl@ontil.ihep.su>, caml-list@inria.fr
Subject: Re: Dynamic loading. Again.
Date: Sat, 02 Dec 2000 03:49:07 +1100	[thread overview]
Message-ID: <3A27D683.5C34212E@ozemail.com.au> (raw)
In-Reply-To: <14887.46228.317525.40290@cremant.inria.fr>

Fabrice Le Fessant wrote:

> >   The per process data lives at the same address for
> > every process, but the underlying memory is swapped for
> > every task switch (at least, on the 486 this is done).
> 
> What about libraries mapped at the same address, 

	They can't be.

> or on overlapping
> segments ? They could be loaded first by different processes, 

	Only one library can be loaded at a time.
The loader must block while it is loading a library.
[At least, it must block while allocating the address space]

>then another one would want to use both of them and would not be able to
> map both of them !!! You MUST have position independent code if you
> really want your code to be SHARED.

	Suppose I load library X. It gets mapped to

	0xFF00-0000

Now suppose YOU load library X. It is already in memory.
The loader knows that. It gets mapped to

	0xFF00-0000

The same address for both of us.  Now I load Y, and you load Z.
Y loads first, under X. Then Z loads, under Y.
Or the other way around: the order doesn't matter, but the 
address space used had better be the same. We all share
the same physical memory at the same address (for the shared
libraries).

Perhaps there is a confusion here: ALL the code is built to
run at address zero. ALL the code is patched to the actual
load address. The address space for each library is allocated
so it cannot overlap, at the first load attempt. Subsequent
attempts to load the library simply refer to it at the 
address at which it is already loaded. Everyone maps the code
to the same address it is actually loaded at! This means
your code address space will consist of 'chunks' (with holes
for the loaded libraries you are not using).

In some sense, the library image is position independent, because
it can be loaded at any address. But this is a loader function,
not a property of the addressing modes of instructions used.

In the old days, I used to write assembler for code that was
loaded directly into memory straight off disk. This code
has to be position independent in the sense that there
was NO 'loader' to patch anything: the disk image was a
a memory image of the code, ready to run. So absolute
addressing was used only for reference to things like ROM
in fixed positions.

The problem is always the data, not the code. Relative jumps
and calls are easy. Its not so easy to do 'relative' data,
if there are many processes each requiring its own copy
of writable store: that required indirection through a register.
But these days, that indirection is provided by system level
hardware like VM, rather than an application register.

The reason is probably that application code cannot
EVER use real absolute addresses. Only the OS is allowed
to do that.  Instead, absolute addresses are translated
using an invisible 'register', there being no good reason
to waste an application register for the job. Why waste
bits specifying the register in the instruction set?
[I cite this argument without believing it :-]

-- 
John (Max) Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net



  reply	other threads:[~2000-12-03 22:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-26  0:09 Vitaly Lugovsky
2000-11-28  1:27 ` John Max Skaller
2000-11-29 16:42 ` Fabrice Le Fessant
2000-11-30  7:02   ` John Max Skaller
2000-11-30 16:08     ` Fabrice Le Fessant
2000-12-01 12:59       ` John Max Skaller
2000-12-01 14:24         ` Fabrice Le Fessant
2000-12-01 16:49           ` John Max Skaller [this message]
2000-12-04 21:06             ` Gerd Stolpmann
2000-11-30 18:00     ` Chris Hecker
2000-12-01 13:34       ` John Max Skaller
2000-11-30 20:55     ` Gerd Stolpmann
2000-11-28 11:14 Ken Wakita

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3A27D683.5C34212E@ozemail.com.au \
    --to=skaller@ozemail.com.au \
    --cc=caml-list@inria.fr \
    --cc=fabrice.le_fessant@inria.fr \
    --cc=vsl@ontil.ihep.su \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox