Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Feb 2004 08:39:45 +0000
From:      Philip Reynolds <philip.reynolds@rfc-networks.ie>
To:        freebsd-hackers@freebsd.org
Subject:   ELF branding / magic numbers
Message-ID:  <20040205083945.GB96509@rfc-networks.ie>

next in thread | raw e-mail | index | archive | help

Hi,

At the moment, on both OpenBSD and FreeBSD (you're going to have to
excuse my lack of familiarity with NetBSD but I presume this
situation is similar) ELF files are branded via the CSU library,
inside a PT_NOTE section.

I've looked through as much documentation and list archives that I
could manage at the moment and this seems to be due to the fact that
"ELF was designed with the assumption that there would be only one
system ABI".

At the moment, ELF files still contain a magic number, rather like
a.out(5). Readelf quickly shows this using ``-h''

$ readelf -h /bin/ls
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 09 00 00 00 00 00 00 00 00

If we break the hexidecimal values up, the first four denote the
first four bytes of the magic number, which basically say it's an
ELF binary. The next three are the class, data and version
respectively and the eighth bit would seem to denote the ABI (elf(5)
and /usr/include/sys/elf_common.h seem to agree with me).

Does the magic number not then support multiple ABI's per system
architecture, or is there some part of the puzzle I'm missing?
OpenBSD, curiously, enough doesn't set the ABI within the magic
number at all (it only supports the one type of branded elf as far
as I'm aware anyways) which just leads me to believe it's only set
for legacy reasons in FreeBSD?

Any insight into the matter will be greatly appreciated. It's not
something I'm questioning, more curious about, as reading the
PT_NOTE section (e.g. from file(1)) is certainly more convaluted
than looking at the mgaic number. There's obviously a good reason
for that.

-- 
Philip Reynolds                      | RFC Networks Ltd.
philip.reynolds@rfc-networks.ie      | +353 (0)1 8832063
http://people.rfc-networks.ie/~phil/ | www.rfc-networks.ie



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040205083945.GB96509>