* [Qemu-devel] [PATCH] reduce magic numbers length to 16 bytes (qemu-binfmt-conf.sh)
@ 2006-03-11 2:58 Anderson Lizardo
2006-03-11 14:23 ` Paul Brook
2006-03-11 14:51 ` Andreas Schwab
0 siblings, 2 replies; 6+ messages in thread
From: Anderson Lizardo @ 2006-03-11 2:58 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 600 bytes --]
Hi,
Any reason why the magic numbers from qemu-binfmt-conf.sh are not just
16 bytes long as those reported by "readelf --file-header"? For
example:
$ readelf --file-header /bin/true | grep Magic:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Using only the first 16 bytes avoids the need to have separate entries
for i386 and i486, given that they are emulated by the same program
(qemu-i386). The others still need separate entries because of
endianess.
Regards,
--
Anderson Lizardo
Embedded Linux Lab - 10LE
Nokia Institute of Technology - INdT
Manaus - Brazil
[-- Attachment #2: qemu-binfmt-conf-16bytes-magic.patch --]
[-- Type: text/x-patch, Size: 3719 bytes --]
--- qemu-binfmt-conf.sh.orig 2005-12-19 18:51:53.000000000 -0400
+++ qemu-binfmt-conf.sh 2006-03-10 22:51:01.000000000 -0400
@@ -20,20 +20,19 @@
# register the interpreter for each cpu except for the native one
if [ $cpu != "i386" ] ; then
- echo ':i386:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register
- echo ':i486:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register
+ echo ':i386:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff:/usr/local/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "arm" ] ; then
- echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-arm:' > /proc/sys/fs/binfmt_misc/register
- echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-armeb:' > /proc/sys/fs/binfmt_misc/register
+ echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff:/usr/local/bin/qemu-arm:' > /proc/sys/fs/binfmt_misc/register
+ echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff:/usr/local/bin/qemu-armeb:' > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "sparc" ] ; then
- echo ':sparc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-sparc:' > /proc/sys/fs/binfmt_misc/register
+ echo ':sparc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff:/usr/local/bin/qemu-sparc:' > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "ppc" ] ; then
- echo ':ppc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-ppc:' > /proc/sys/fs/binfmt_misc/register
+ echo ':ppc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff:/usr/local/bin/qemu-ppc:' > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "mips" ] ; then
- echo ':mips:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-mips:' > /proc/sys/fs/binfmt_misc/register
- echo ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-mipsel:' > /proc/sys/fs/binfmt_misc/register
+ echo ':mips:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff:/usr/local/bin/qemu-mips:' > /proc/sys/fs/binfmt_misc/register
+ echo ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff:/usr/local/bin/qemu-mipsel:' > /proc/sys/fs/binfmt_misc/register
fi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] reduce magic numbers length to 16 bytes (qemu-binfmt-conf.sh)
2006-03-11 2:58 [Qemu-devel] [PATCH] reduce magic numbers length to 16 bytes (qemu-binfmt-conf.sh) Anderson Lizardo
@ 2006-03-11 14:23 ` Paul Brook
2006-03-11 14:51 ` Andreas Schwab
1 sibling, 0 replies; 6+ messages in thread
From: Paul Brook @ 2006-03-11 14:23 UTC (permalink / raw)
To: qemu-devel
On Saturday 11 March 2006 02:58, Anderson Lizardo wrote:
> Hi,
>
> Any reason why the magic numbers from qemu-binfmt-conf.sh are not just
> 16 bytes long as those reported by "readelf --file-header"?
The first 16 bytes only tell you it's an ELF executable. ie. you've just
removed the bits that tell you whether it's e.g an arm or a ppc executable.
You'll notice that after your patch all the be/le pattern matches are
identical, which is obviously not going to work.
Paul
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] reduce magic numbers length to 16 bytes (qemu-binfmt-conf.sh)
2006-03-11 2:58 [Qemu-devel] [PATCH] reduce magic numbers length to 16 bytes (qemu-binfmt-conf.sh) Anderson Lizardo
2006-03-11 14:23 ` Paul Brook
@ 2006-03-11 14:51 ` Andreas Schwab
2006-03-11 15:37 ` Anderson Lizardo
1 sibling, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2006-03-11 14:51 UTC (permalink / raw)
To: qemu-devel
"Anderson Lizardo" <anderson.lizardo@gmail.com> writes:
> Any reason why the magic numbers from qemu-binfmt-conf.sh are not just
> 16 bytes long as those reported by "readelf --file-header"? For
> example:
>
> $ readelf --file-header /bin/true | grep Magic:
> Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
>
> Using only the first 16 bytes avoids the need to have separate entries
> for i386 and i486, given that they are emulated by the same program
> (qemu-i386).
How would you distinguish it from an arm or mipsel binary?
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] reduce magic numbers length to 16 bytes (qemu-binfmt-conf.sh)
2006-03-11 14:51 ` Andreas Schwab
@ 2006-03-11 15:37 ` Anderson Lizardo
2006-03-11 15:45 ` Paul Brook
0 siblings, 1 reply; 6+ messages in thread
From: Anderson Lizardo @ 2006-03-11 15:37 UTC (permalink / raw)
To: qemu-devel
On 3/11/06, Andreas Schwab <schwab@suse.de> wrote:
> "Anderson Lizardo" <anderson.lizardo@gmail.com> writes:
>
> > Any reason why the magic numbers from qemu-binfmt-conf.sh are not just
> > 16 bytes long as those reported by "readelf --file-header"? For
> > example:
> >
> > $ readelf --file-header /bin/true | grep Magic:
> > Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
> >
> > Using only the first 16 bytes avoids the need to have separate entries
> > for i386 and i486, given that they are emulated by the same program
> > (qemu-i386).
>
> How would you distinguish it from an arm or mipsel binary?
Now I realize my mistake, sorry for the noise :/
To not make this thread completely useless: I find
/usr/share/misc/file/magic very useful to get machine patterns (as
detected by "file"). Search there for "magic for ELF executables" and
you will find a fairly complete list of machine magic numbers.
Regards,
--
Anderson Lizardo
Embedded Linux Lab - 10LE
Nokia Institute of Technology - INdT
Manaus - Brazil
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] reduce magic numbers length to 16 bytes (qemu-binfmt-conf.sh)
2006-03-11 15:37 ` Anderson Lizardo
@ 2006-03-11 15:45 ` Paul Brook
2006-03-12 19:43 ` Johannes Schindelin
0 siblings, 1 reply; 6+ messages in thread
From: Paul Brook @ 2006-03-11 15:45 UTC (permalink / raw)
To: qemu-devel
> To not make this thread completely useless: I find
> /usr/share/misc/file/magic very useful to get machine patterns (as
> detected by "file"). Search there for "magic for ELF executables" and
> you will find a fairly complete list of machine magic numbers.
Or you could just use the official list in the gABI spec:
http://www.thescogroup.com/developers/gabi/latest/ch4.eheader.html
Paul
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] reduce magic numbers length to 16 bytes (qemu-binfmt-conf.sh)
2006-03-11 15:45 ` Paul Brook
@ 2006-03-12 19:43 ` Johannes Schindelin
0 siblings, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2006-03-12 19:43 UTC (permalink / raw)
To: qemu-devel
Hi,
On Sat, 11 Mar 2006, Paul Brook wrote:
> > To not make this thread completely useless: I find
> > /usr/share/misc/file/magic very useful to get machine patterns (as
> > detected by "file"). Search there for "magic for ELF executables" and
> > you will find a fairly complete list of machine magic numbers.
>
> Or you could just use the official list in the gABI spec:
>
> http://www.thescogroup.com/developers/gabi/latest/ch4.eheader.html
... but be aware they might sue you for using it ;-)
Ciao,
Dscho
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-03-12 19:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-11 2:58 [Qemu-devel] [PATCH] reduce magic numbers length to 16 bytes (qemu-binfmt-conf.sh) Anderson Lizardo
2006-03-11 14:23 ` Paul Brook
2006-03-11 14:51 ` Andreas Schwab
2006-03-11 15:37 ` Anderson Lizardo
2006-03-11 15:45 ` Paul Brook
2006-03-12 19:43 ` Johannes Schindelin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.