Closed emaste closed 9 years ago
Curious, does LDFLAGS="-s -Wl,-e_start" make runtest
work as well? Do the *BSDs setup the stack/registers the same way as Linux upon loading an ELF image into memory?
-Wl,-e_start
doesn't help, but forcing the undefined reference with -Wl,-u_start
does. I tried -Wl,--whole-archive
since the C startup routines are traditionally linked explicitly as .o
s on the command line.
Anyhow, t/test.exe does work too. The notable difference is the way errors are returned from system calls: Linux returns negative errno, BSD sets the carry flag and returns errno. Fortunately the sample code here doesn't really care about errno :)
Awesome. Thanks for the feedback. I'll add this change to the Makefile
. Eventually, I'll need to setup a FreeBSD VM. I've only ever really played with NetBSD but that was on an old Dreamcast and as a stripped down router.
Building on FreeBSD I get:
Nothing references _start to bring 00_start.o in.
Explicitly adding the --whole-archive flag forces the four objects to be linked into the binary: