ELF branding / magic numbers

2004-02-05 Thread Philip Reynolds

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.
[EMAIL PROTECTED]  | +353 (0)1 8832063
http://people.rfc-networks.ie/~phil/ | www.rfc-networks.ie
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: ELF branding / magic numbers

2004-02-05 Thread Ruslan Ermilov
On Thu, Feb 05, 2004 at 08:39:45AM +, Philip Reynolds wrote:
[...]
 Does the magic number not then support multiple ABI's per system
 architecture, or is there some part of the puzzle I'm missing?
 
There's an EI_ABIVERSION byte following the EI_OSABI byte, which
is both documented in the elf(5) manpage, and is shown in the
``readelf -h'' output.


Cheers,
-- 
Ruslan Ermilov
FreeBSD committer
[EMAIL PROTECTED]


pgp0.pgp
Description: PGP signature


Re: ELF branding / magic numbers

2004-02-05 Thread Philip Reynolds
Ruslan Ermilov [EMAIL PROTECTED] 35 lines of wisdom included:
 On Thu, Feb 05, 2004 at 08:39:45AM +, Philip Reynolds wrote:
 [...]
  Does the magic number not then support multiple ABI's per system
  architecture, or is there some part of the puzzle I'm missing?
  
 There's an EI_ABIVERSION byte following the EI_OSABI byte, which
 is both documented in the elf(5) manpage, and is shown in the
 ``readelf -h'' output.

You misunderstood me. 

My question was why is there a need for a PT_NOTE section (which is
a more convaluted way of branding and reading a brand of an elf
binary) if the above sections exist?

-- 
Philip Reynolds  | RFC Networks Ltd.
[EMAIL PROTECTED]  | +353 (0)1 8832063
http://people.rfc-networks.ie/~phil/ | www.rfc-networks.ie
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: My new fdisk(8) program.

2004-02-05 Thread epi bug
 Oh, just curious, why are you opposed to the use of structs?  Does it make
 the code less portable due to alignment restrictions or something?
 
 Fred

to quote him:
structures are not portable

-- 
epibug - EPIT{A,ECH} *BSD User Group
  l'asso des codeurs qui aiment les systemes BSD :)
http://assos.epita.fr/~epibug
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: ELF branding / magic numbers

2004-02-05 Thread M. Warner Losh
In message: [EMAIL PROTECTED]
Philip Reynolds [EMAIL PROTECTED] writes:
: Ruslan Ermilov [EMAIL PROTECTED] 35 lines of wisdom included:
:  On Thu, Feb 05, 2004 at 08:39:45AM +, Philip Reynolds wrote:
:  [...]
:   Does the magic number not then support multiple ABI's per system
:   architecture, or is there some part of the puzzle I'm missing?
:   
:  There's an EI_ABIVERSION byte following the EI_OSABI byte, which
:  is both documented in the elf(5) manpage, and is shown in the
:  ``readelf -h'' output.
: 
: You misunderstood me. 
: 
: My question was why is there a need for a PT_NOTE section (which is
: a more convaluted way of branding and reading a brand of an elf
: binary) if the above sections exist?

Because PT_NOTE is more portable and flexible.

Warner
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]