Re: ELF branding / magic numbers
On Thu, Feb 05, 2004 at 10:31:54AM +, Philip Reynolds wrote: 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? Yes. It is used on other systems, like NetBSD and Linux. Having the note section allows those system to correctly recognize FreeBSD binaries. (The people developing binutils apparently don't agree with the use of EI_OSABI.) Unfortunately, FreeBSD doesn't check for it in the kernel. Doing it as a fall-back would permit detecting statically linked Linux binaries, without needing to run brandelf on them. I've been considering working on a patch for that, but haven't had time. ---Nathan ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
ELF branding / magic numbers
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
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
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: ELF branding / magic numbers
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]