The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: paul.winalski@gmail.com (Paul Winalski)
Subject: [TUHS] shared objects in Unix
Date: Fri, 30 Mar 2018 19:29:03 -0400	[thread overview]
Message-ID: <CABH=_VRNbkVvMduP4L5m3+BCi=uf3qLnXkRo2f3k59un7qWqJw@mail.gmail.com> (raw)
In-Reply-To: <CAC20D2P3FXPeC-Vy+rpuNh9j9vcNfca=ASDLYMK2HM4k+vSn-g@mail.gmail.com>

Regarding the various object/program image formats on Unix:

a.out ZMAGIC had three sections (.text, .data, BSS) and .text was
read-only and therefore shareable between processes running the same
image.  And if .text and .data started on a page boundary, you could
do demand paging of them from the a.out file on disk (you'd of course
need to do copy-on-write of .data to space in a page file).  I can see
how, with mmap, one could map multiple ZMAGIC images to the same
address space, thus implementing shared objects, but there isn't
anything in ZMAGIC to direct the runtime loader as to which images
need to be so mapped or where to map them.

MACH-O was a big advance over a.out in that it was extensible--you
could have up to 16 sections.  MacOS-X indeed uses some of the extra
sections to implement its shared memory scheme.

COFF was another step forward.  One now had a lot more sections to
play with.  But a lot of the meta-data needed by the runtime loader to
do shared image binding was in auxiliary data structures outside such
as the optional header (which in practice is anything but optional).
And, as Clem pointed out, it suffered from a dialect problem.
Microsoft adopted COFF as the object and image format for Windows NT.
But as MS does so often, they took a "embrace and extend" approach to
it.  When I had to implement object file writing support in DEC's GEM
back end for Microsoft PECOFF, I found it significantly different from
Tru64 Unix's COFF.  I found myself putting so many "if (is_pecoff)"
conditionals in the code that I gave up on that and wrote a separate
module for PECOFF (just as the VMS OBJ support had its own module).
The two COFF-based shared object designs I'm familiar with (Tru64 Unix
and Windows NT) both hung the data structures for shared object
loading off of the optional header.

ELF is the cleanest and the easiest to work with, from a compiler
writer's point of view.  Everything is a section.  The one mistake
they made was using a 16-bit field for the section number, thus
limiting each file to 64K sections.  The grouped communal sections for
C++ can blow through that limit quite easily.  A hack was later added
to ELF to support 32-bit section numbers.  It's not as clean as it
would have been if section numbers had been 32 bits from the get-go,
but it does mean that only modules that need a grossly large number of
sections incur the file bloat from the larger section numbers.  ELF is
nice enough that when VMS did their port to Itanium, they decided to
use ELF rather than try to add Itanium's extensive set of relocations
to the OBJ format in use on Alpha.

-Paul W.


  reply	other threads:[~2018-03-30 23:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-29 21:37 Paul Winalski
2018-03-29 22:01 ` Henry Bent
2018-03-29 22:26 ` Warner Losh
2018-03-29 23:11 ` Dave Horsfall
2018-03-29 23:22   ` Warner Losh
2018-03-29 23:24   ` Larry McVoy
2018-03-30  0:22     ` Clem Cole
2018-03-30  1:46       ` Larry McVoy
2018-03-30  4:28         ` Clem cole
2018-03-30 20:52           ` Jon Forrest
2018-03-30 22:42             ` Clem Cole
2018-03-30 23:29               ` Paul Winalski [this message]
2018-04-03 15:49               ` Derek Fawcus
2018-03-30  1:20   ` Lyndon Nerenberg
2018-03-30  0:40 ` Clem Cole
2018-03-30  1:35   ` Charles H. Sauer
2018-03-30  2:10     ` Larry McVoy
2018-03-30  2:34       ` Charles H. Sauer
2018-03-30  3:04         ` Warner Losh
2018-03-30 20:33         ` Charles H Sauer
2018-03-30  3:00   ` Ron Natalie
2018-03-30 21:53   ` Steve Johnson

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='CABH=_VRNbkVvMduP4L5m3+BCi=uf3qLnXkRo2f3k59un7qWqJw@mail.gmail.com' \
    --to=paul.winalski@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).