Subject: Re: refusal to run static binaries
To: Rian Hunter <rian@thelaststop.cjb.net>
From: Bill Studenmund <wrstuden@netbsd.org>
List: port-macppc
Date: 08/30/2004 12:31:29
--5QAgd0e35j3NYeGe
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Thu, Aug 26, 2004 at 03:00:32AM -0400, Rian Hunter wrote:
> Hi,
>=20
> I'm trying to get this very tiny static binary to run, but for some
> reason NetBSD refuses to run it with a error from bash saying "failure
> to execute binary file" or something similar to that. The source goes as
As always, the exact error message is helpful.
> follows:
>=20
>=20
> /// write.S
> .section ".text"
> .align 2
>=20
> .global _start
> _start:
> li 3, 1
> lis 4, msg@ha
> addi 4, 4, msg@l
> li 5, 6
>=20
> // write
> li 0, 4
> sc
>=20
> // _exit
> li 0, 1
> sc
>=20
> .section ".data"
> msg: .string "hello\n"
> /// end
>=20
> it is compiled with "gcc -nostdlib write.S". When I compile the program,
That's not static compiling. "-static" turns on static compiling.
> renaming _start as main and linking with the C library the program runs
> fine. Does the NetBSD loader refuse to run executables that are not
> dynamically linked with libc? thanks
No. NetBSD certainly supports static linking.
I'm not sure what problem you're encountering, but I'd expect that it's=20
that libc also includes the runtime setup code. Or you're building what=20
looks like a dynamic-link program but not including the bits the runtime=20
linker needs.
Why are you trying to do this?
Take care,
Bill
--5QAgd0e35j3NYeGe
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)
iD8DBQFBM4CRWz+3JHUci9cRAguWAJ4mE7UzqbM9EVbGCLem3kUkGiyjfQCfWlDe
G3kaDkwMoeuswL2Bj/wCfDs=
=v15D
-----END PGP SIGNATURE-----
--5QAgd0e35j3NYeGe--