Subject: Fat binaries
To: None <current-users@NetBSD.ORG>
From: der Mouse <mouse@Collatz.McRCIM.McGill.EDU>
Date: 04/11/1995 12:35:16
> How about an architectural independent format for multi-platform
> distrubution. It won't give you the speed of native binaries, but at
> least it will give portablity.
> Two candiates that come to mind are: RTL (this is abit of a problem,
> if two versons of NetBSD differ significantly, although it could be
> argued that if an application is platform specific then it should be
> native anyway), and the Java virtual machine.
> The Java virtual machine (start at http://java.sun.com - I think), of
> which I am currently reading, seems to be a better platform, although
> I wonder if it is workable.
I would be inclined to doubt it. I know little about Java, only what
I've seen when I spent a few hours browsing their web pages...but the
Java machine seems to have too much security cruft to be usable as a
general-purpose machine language. I suppose you could add lots of new
primitives (corresponding to C-coded stuff in a traditional Java
implementation), but then what's the difference between just inventing
a new p-code language from scratch?
Of course, this p-code would not be usable for things like the kernel
and init; it would be useful only for distributing application-level
software. And we already have a good application-level language for
the purpose; it's called C.
> Another idea that was muted many moons ago was to get the exec call
> to recognise the AR format files. It would look in the archive for a
> file that was named like the CPU. Ie. "ix86", "m68k-nfpu", etc. and
> then load that file. This fits the classical idea of a fat file.
Yes. Unless the archive is very carefully constructed, though, it
would have to treat the file like an OMAGIC (or is it NMAGIC?) file,
since page boundaries in the executable won't in general be aligned on
page boundaries on disk. Perhaps such a situation should just impose a
performance penalty; perhaps it should produce ENOEXEC.
Or perhaps something else should be done. Maybe an attempt to exec() a
directory that's mode 4000 (ie, --S------) should search it for a file
named after the machine architecture and attempt to execute that
instead. Or is there some present use for mode 4000 directories?
Overloading directory mode bits like that is _really_ ugly, tho....
How about the following as a fat binary? (Obviously the btoa data
sections are not for real. :-)
case `arch` in
sun4) atob << \EOF
xbtoa End N 384 180 E 54 S c262 R 6c84e301
sun3) atob << \EOF
xbtoa End N 384 180 E 55 S c443 R cc4a45be
*) echo 'No support for '`arch`' in this binary.' 1>&2
esac > $fn
if [ -s $fn ]; then
chmod 700 $fn
case $# in
0) exec $fn ;;
*) exec $fn "$@" ;;