I came to here after I read the wiki entry on "porting newlib" [1] and I have been searching these forums and the rest of the web without much succes (which I find strange!). Perhaps I am just plain stupid
Background
I do porting of stuff to the Plan9 operating system [0] as a hobby project [2] and one thing I am now trying to do is to update an old GCC-based toolchain that was ported back in 2002 (binaries of the original gcc port can be found at [3] or if Bell labs is down a mirror at [4]). The status of updating the GCC stuff can be read on the wiki [5]. I have updated the old APE (ansi- posix environment) libc from the old (3rd edition?) variant to a recent one and it can compile stuff. I am not entirely sure however if the new APE libc port to GCC is entirely safe and functional since I notice some crashes in some binaries compiled with it. I am thus considering whether I should switch the default libc for GCC to newlib since this is a better tested libc and a Plan9 port of it could also make it easier to make a cross-compiler for the i386-Plan9 target on other hosts.
Problem
- In the "porting newlib" wiki, 17 syscalls are mentioned that they need to be implemented in newlib for a port. It does however not mention where those syscalls should be implemented.
I have been browsing through the source and I did not find anything (yet again, it could simply be because I am stupid).
The Plan9 (i386) kernel intercepts syscalls at exception vector 40 (0x64) [6] and these are the syscalls:
Code: Select all
cat /sys/src/libc/9syscall/sys.h
#define SYSR1 0
#define _ERRSTR 1
#define BIND 2
#define CHDIR 3
#define CLOSE 4
#define DUP 5
#define ALARM 6
#define EXEC 7
#define EXITS 8
#define _FSESSION 9
#define FAUTH 10
#define _FSTAT 11
#define SEGBRK 12
#define _MOUNT 13
#define OPEN 14
#define _READ 15
#define OSEEK 16
#define SLEEP 17
#define _STAT 18
#define RFORK 19
#define _WRITE 20
#define PIPE 21
#define CREATE 22
#define FD2PATH 23
#define BRK_ 24
#define REMOVE 25
#define _WSTAT 26
#define _FWSTAT 27
#define NOTIFY 28
#define NOTED 29
#define SEGATTACH 30
#define SEGDETACH 31
#define SEGFREE 32
#define SEGFLUSH 33
#define RENDEZVOUS 34
#define UNMOUNT 35
#define _WAIT 36
#define SEMACQUIRE 37
#define SEMRELEASE 38
#define SEEK 39
#define FVERSION 40
#define ERRSTR 41
#define STAT 42
#define FSTAT 43
#define WSTAT 44
#define FWSTAT 45
#define MOUNT 46
#define AWAIT 47
#define PREAD 50
#define PWRITE 51
Since I already have a native (old) binutils/gcc (including Crt0), most of the stuff are basically in place already as soon as I get this "syscall glue" in place.
References
[0] http://en.wikipedia.org/wiki/Plan_9_from_Bell_Labs
[1] http://wiki.osdev.org/Porting_Newlib
[2] http://code.google.com/p/ports2plan9/
[3] http://plan9.bell-labs.com/sources/extra/gcc/gnubin.tgz
[4] http://code.google.com/p/ports2plan9/do ... gnubin.tgz
[5] http://code.google.com/p/ports2plan9/wiki/GNUonPlan9
[6] http://www.glendix.org/docs/glendix_report.pdf