Subject: Re: refusal to run static binaries
To: None <wrstuden@netbsd.org, port-macppc@netbsd.org>
From: None <rian@thelaststop.cjb.net>
List: port-macppc
Date: 08/30/2004 20:41:18
> > it is compiled with "gcc -nostdlib write.S". When I compile the program,
> 
> That's not static compiling. "-static" turns on static compiling.

well, implicitly it is a static binary because it isn't linked with any dynamic libraries, not even libc.
 
> > 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
> that libc also includes the runtime setup code. Or you're building what
> looks like a dynamic-link program but not including the bits the runtime
> linker needs.

actually, the problem was that recent NetBSD kernels require a .note.netbsd.ident section (well after linking it goes in the program header) with a binary signature to be loaded and read by the NetBSD loader. libc includes this section, but if you don't link with libc it won't be included for loading and NetBSD will refuse to run the "arbitrary" ELF binary.
 
> Why are you trying to do this?

for general hackery and fun.

thanks,
-rian