*BSD News Article 38033


Return to BSD News archive

Xref: sserve comp.os.386bsd.questions:14524 comp.os.linux.misc:29954
Newsgroups: comp.os.386bsd.questions,comp.os.linux.misc
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!msuinfo!uwm.edu!news.alpha.net!news.mathworks.com!uhog.mit.edu!bloom-beacon.mit.edu!cambridge-news.cygnus.com!news.cygnus.com!kithrup.com!sef
From: sef@kithrup.com (Sean Eric Fagan)
Subject: Re: ELF and dynamic loading (Re: 386BSD vs Linux)
Organization: Kithrup Enterprises, Ltd.
Message-ID: <CzG93E.C5o@kithrup.com>
References: <39tu2u$o8r@styx.uwa.edu.au> <3a4a2o$d7m@j51.com> <3ag7cn$lba@pdq.coe.montana.edu> <1994Nov18.021141.29144@kf8nh.wariat.org>
Date: Fri, 18 Nov 1994 06:09:14 GMT
Lines: 36

In article <1994Nov18.021141.29144@kf8nh.wariat.org>,
Brandon S. Allbery <bsa@kf8nh.wariat.org> wrote:
>Also sprach nate@bsd.coe.montana.edu (Nate Williams) (<3ag7cn$lba@pdq.coe.montana.edu>):
>| >ELF is better than a.out. That is the point.
>| What basis do you use for this statement?
>Global constructors and destructors will do for a first point.

To be precise:

ELF, like COFF, has multiple sections; also like COFF, they can be loaded at
an arbitrary address, and have a length.  a.out doesn't quite have this, and
it's annoying.  ELF is quite nice for loading executables (I know:  I've
written ELF, COFF, and a.out loaders for FreeBSD and 386BSD).  ELF is more
easily able to support shared libraries, but not in a terribly important
fashion; what is much nicer is the ability to specify the linker to be used,
so the kernel can load it as part of the normal loading process (as opposed
to specifying it in the startup routine for the process, which then mmap's
or read's it in and executes it).  Also nice is the ability to have multiple
sections -- .init, .ctors, .text, .fini, .dtors, .const, .data, .bss are all
popular ones.

ELF, like a.out, does not have a defined debug format.  COFF does, and it
kills it:  the COFF debug symbols were defined for C and FORTRAN only, and
just die on C++.  (You can do *most* things using the COFF debug symbols,
but you do lose some things, and it's painful.)  There are two versions of
DWARF, which is "the" debugging format for ELF, but stabs-in-ELF are also
popular, and currently supported by gcc and company.  stabs-in-COFF are also
done, but are more painful.

The original COFF format had some really stupid limitations, like having
shorts for some fields which have since been outgrown.  ELF was obviously
designed to easily extend that; the header bits which say *which* ELF
version it is are much more usable and extendable than COFF's, and a.out is
largely lacking in them.  (Take a look at what was done, for both NetBSD and
FreeBSD, to the header when dynamic linking was added... yech.)