Subject: Toolchain for netbsd on FreeBSD
To: None <tech-toolchain@NetBSD.org>
From: Srinivasa Kanduru <ksraghavan@yahoo.com>
List: tech-toolchain
Date: 11/16/2003 13:13:12
Hi,

I was trying to cross-compile netbsd 1.6.1 on FreeBSD. I was having some
problems in making it self-sufficient in the sense building it without using
any of the host libraries. I tried it on i386 architecture.

Some of the toolchain binaries used netbsd-specific system calls like __glob13,
__[lf]stat13, __sigprocmask14 etc which doesn't exist on the host system.

I worked around it by using the host libraries to compile it and make it run on
the host system. I had to fix some of the header files.

While compiling for the target image the libraries which worked were the pic
version rather than the regular .a version, so I had to change the Makefiles
for a lot of binaries to use the pic versions. The functions referenced were
missing in the regular .a versions.

Finally in the libc library I have a doubht if the system call failure case was
returning error code properly or not.

The system call in general stores the error number in $eax and calls cerror
which in turn calls errno to store the errno in that variable. But the code
didn't suggest to work in that way as the err number from system calls were
just ignored. I made the following change and wondering if this is the right
thing to do.

diff -u cerror.S.orig cerror.S
--- cerror.S.orig       Sun Nov 16 02:51:03 2003
+++ cerror.S    Sun Nov 16 02:53:05 2003
@@ -49,6 +49,8 @@
             
_ENTRY(CERROR)
     pushl   %eax
+    pushl   %ecx
+    movl    %eax,%ecx
     #ifdef PIC
     PIC_PROLOGUE
     call    PIC_PLT(_C_LABEL(__errno))
@@ -56,6 +58,8 @@
     #else
     call    _C_LABEL(__errno)
     #endif /* PIC */
+    movl    %ecx,(%eax)
+    popl    %ecx
     popl    (%eax)
     movl    $-1,%eax
     movl    $-1,%edx


It may be that I took the distribution from the wrong place or I am doing
something wrong. Can somebody throw some light on it ? This is the first  mail
that I am posting to NetBSD and I am first time user, so please let me know if
this is not the right mailing list to send this email.

Thanks,
Srini.

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree