MIPS fixes; move i386-specific and x86-64-specific files into their
respective arch directories.
diff --git a/SYSCALLS b/SYSCALLS
index 7e22ca1..7815050 100644
--- a/SYSCALLS
+++ b/SYSCALLS
@@ -11,7 +11,7 @@
#
# Process-related syscalls
#
-<!mips,mips64> pid_t vfork()
+pid_t vfork()
<!alpha> pid_t getpid()
<alpha> pid_t getxpid@dual0::getpid()
int setpgid(pid_t, pid_t)
@@ -55,7 +55,7 @@
int mount(const char *, const char *, const char *, unsigned long, const void *)
<!alpha,ia64> int umount2(const char *, int)
<alpha,ia64> int umount::umount2(const char *, int)
-<!m68k,mips64> int pivot_root(const char *, const char *)
+<!m68k> int pivot_root(const char *, const char *)
int sync()
int statfs(const char *, struct statfs *)
int fstatfs(int, struct statfs *)
@@ -74,7 +74,7 @@
<!alpha> int utime(const char *, struct utimbuf *)
int mkdir(const char *, mode_t)
int rmdir(const char *)
-int pipe(int *)
+<!mips,mips64> int pipe(int *)
mode_t umask(mode_t)
int chroot(const char *)
int symlink(const char *, const char *)
diff --git a/arch/alpha/Makefile.inc b/arch/alpha/Makefile.inc
index af6dbd5..b8ab8b1 100644
--- a/arch/alpha/Makefile.inc
+++ b/arch/alpha/Makefile.inc
@@ -25,15 +25,8 @@
arch/$(ARCH)/__remlu.o \
arch/$(ARCH)/__divl.o \
arch/$(ARCH)/__reml.o
-ARCHSOOBJS = \
- arch/$(ARCH)/__divqu.lo \
- arch/$(ARCH)/__remqu.lo \
- arch/$(ARCH)/__divq.lo \
- arch/$(ARCH)/__remq.lo \
- arch/$(ARCH)/__divlu.lo \
- arch/$(ARCH)/__remlu.lo \
- arch/$(ARCH)/__divl.lo \
- arch/$(ARCH)/__reml.lo
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
arch/$(ARCH)/%.s: arch/$(ARCH)/%.ss
sed -e 's/\$$0\b/$$27/g' -e 's/\$$24\b/$$99/g' \
diff --git a/arch/i386/Makefile.inc b/arch/i386/Makefile.inc
index 8896a8a..867a6b7 100644
--- a/arch/i386/Makefile.inc
+++ b/arch/i386/Makefile.inc
@@ -7,4 +7,10 @@
# accordingly.
#
+ARCHOBJS = \
+ arch/$(ARCH)/exits.o \
+ arch/$(ARCH)/socketcall.o
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
archclean:
diff --git a/arch/i386/exits.S b/arch/i386/exits.S
new file mode 100644
index 0000000..b6f3227
--- /dev/null
+++ b/arch/i386/exits.S
@@ -0,0 +1,42 @@
+#
+# exit and _exit get included in *every* program, and gcc generates
+# horrible code for them. Yes, this only saves a few bytes, but
+# it does it in every program.
+#
+
+#include <asm/unistd.h>
+
+ .data
+ .align 4
+ .globl __exit_handler
+ .type __exit_handler,@object
+__exit_handler:
+ .long _exit
+ .size __exit_handler,4
+
+ .text
+ .align 4
+ .globl exit
+ .type exit,@function
+exit:
+ jmp *(__exit_handler)
+ .size exit,.-exit
+
+ /* No need to save any registers... we're exiting! */
+ .text
+ .align 4
+ .globl _exit
+ .type _exit,@function
+_exit:
+#if __NR_exit == 1
+ popl %ebx
+ xorl %eax,%eax
+ popl %ebx
+ incl %eax
+#else
+ movl 4(%esp),%ebx
+ movl $__NR_exit,%eax
+#endif
+ int $0x80
+ hlt
+ .size _exit,.-exit
diff --git a/klibc/socketcall.S b/arch/i386/socketcall.S
similarity index 100%
copy from klibc/socketcall.S
copy to arch/i386/socketcall.S
diff --git a/arch/mips/MCONFIG b/arch/mips/MCONFIG
index a487c8f..cfda7a5 100644
--- a/arch/mips/MCONFIG
+++ b/arch/mips/MCONFIG
@@ -7,5 +7,5 @@
# accordingly.
#
-OPTFLAGS = -Os -fomit-frame-pointer
+OPTFLAGS = -Os -fomit-frame-pointer -fno-pic -mno-abicalls
BITSIZE = 32
diff --git a/arch/mips/crt0.S b/arch/mips/crt0.S
new file mode 100644
index 0000000..e070fbe
--- /dev/null
+++ b/arch/mips/crt0.S
@@ -0,0 +1,29 @@
+#
+# arch/mips/crt0.S
+#
+# void _start(void)
+# {
+# /* Divine up argc, argv, and envp */
+# environ = envp;
+# exit(main(argc, argv, envp));
+# }
+#
+
+#include <asm/regdef.h>
+#include <asm/asm.h>
+
+NESTED(__start, 32, 16)
+ subu $29, 32
+ sw zero, 16(sp)
+
+ lw a0, (sp)
+ addiu a1, sp, 4
+ sll a2, a0, 4
+ addiu a2, 4
+ addiu a2, a1
+ sw a2, environ
+ jalr main
+ move a0, v0
+ jalr exit
+
+ END(__start)
diff --git a/arch/x86_64/Makefile.inc b/arch/x86_64/Makefile.inc
index 2801965..ca76253 100644
--- a/arch/x86_64/Makefile.inc
+++ b/arch/x86_64/Makefile.inc
@@ -7,4 +7,9 @@
# accordingly.
#
+ARCHOBJS = \
+ arch/$(ARCH)/exits.o
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
archclean:
diff --git a/arch/x86_64/exits.S b/arch/x86_64/exits.S
new file mode 100644
index 0000000..2d49d75
--- /dev/null
+++ b/arch/x86_64/exits.S
@@ -0,0 +1,35 @@
+#
+# exit and _exit get included in *every* program, and gcc generates
+# horrible code for them. Yes, this only saves a few bytes, but
+# it does it in every program.
+#
+
+#include <asm/unistd.h>
+
+ .data
+ .align 8
+ .globl __exit_handler
+ .type __exit_handler,@object
+__exit_handler:
+ .quad _exit
+ .size __exit_handler,8
+
+ .text
+ .align 8
+ .globl exit
+ .type exit,@function
+exit:
+ jmp *(__exit_handler)
+ .size exit,.-exit
+
+ /* No need to save any registers... we're exiting! */
+ .text
+ .align 4
+ .globl _exit
+ .type _exit,@function
+_exit:
+ movl $__NR_exit,%rax
+ /* The argument is already in %rdi */
+ syscall
+ .size _exit,.-exit
+
diff --git a/klibc/Makefile b/klibc/Makefile
index 2e1ae66..b24a590 100644
--- a/klibc/Makefile
+++ b/klibc/Makefile
@@ -14,7 +14,7 @@
atoi.o atol.o atoll.o \
strtol.o strtoll.o strtoul.o strtoull.o \
strtoimax.o strtoumax.o \
- __main.o globals.o exitc.o exits.o atexit.o onexit.o \
+ __main.o globals.o exitc.o atexit.o onexit.o \
execl.o execle.o execv.o execvpe.o execvp.o execlp.o execlpe.o \
fork.o wait.o wait3.o waitpid.o setpgrp.o \
printf.o vprintf.o fprintf.o vfprintf.o \
@@ -30,7 +30,6 @@
syslog.o closelog.o \
time.o fdatasync.o llseek.o select.o nice.o getpriority.o \
qsort.o lrand48.o srand48.o seed48.o \
- socketcall.o \
inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o \
inet/inet_ntop.o inet/inet_pton.o
LIB = libc.a
diff --git a/klibc/SYSCALLS b/klibc/SYSCALLS
index 7e22ca1..7815050 100644
--- a/klibc/SYSCALLS
+++ b/klibc/SYSCALLS
@@ -11,7 +11,7 @@
#
# Process-related syscalls
#
-<!mips,mips64> pid_t vfork()
+pid_t vfork()
<!alpha> pid_t getpid()
<alpha> pid_t getxpid@dual0::getpid()
int setpgid(pid_t, pid_t)
@@ -55,7 +55,7 @@
int mount(const char *, const char *, const char *, unsigned long, const void *)
<!alpha,ia64> int umount2(const char *, int)
<alpha,ia64> int umount::umount2(const char *, int)
-<!m68k,mips64> int pivot_root(const char *, const char *)
+<!m68k> int pivot_root(const char *, const char *)
int sync()
int statfs(const char *, struct statfs *)
int fstatfs(int, struct statfs *)
@@ -74,7 +74,7 @@
<!alpha> int utime(const char *, struct utimbuf *)
int mkdir(const char *, mode_t)
int rmdir(const char *)
-int pipe(int *)
+<!mips,mips64> int pipe(int *)
mode_t umask(mode_t)
int chroot(const char *)
int symlink(const char *, const char *)
diff --git a/klibc/arch/alpha/Makefile.inc b/klibc/arch/alpha/Makefile.inc
index af6dbd5..b8ab8b1 100644
--- a/klibc/arch/alpha/Makefile.inc
+++ b/klibc/arch/alpha/Makefile.inc
@@ -25,15 +25,8 @@
arch/$(ARCH)/__remlu.o \
arch/$(ARCH)/__divl.o \
arch/$(ARCH)/__reml.o
-ARCHSOOBJS = \
- arch/$(ARCH)/__divqu.lo \
- arch/$(ARCH)/__remqu.lo \
- arch/$(ARCH)/__divq.lo \
- arch/$(ARCH)/__remq.lo \
- arch/$(ARCH)/__divlu.lo \
- arch/$(ARCH)/__remlu.lo \
- arch/$(ARCH)/__divl.lo \
- arch/$(ARCH)/__reml.lo
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
arch/$(ARCH)/%.s: arch/$(ARCH)/%.ss
sed -e 's/\$$0\b/$$27/g' -e 's/\$$24\b/$$99/g' \
diff --git a/klibc/arch/i386/Makefile.inc b/klibc/arch/i386/Makefile.inc
index 8896a8a..867a6b7 100644
--- a/klibc/arch/i386/Makefile.inc
+++ b/klibc/arch/i386/Makefile.inc
@@ -7,4 +7,10 @@
# accordingly.
#
+ARCHOBJS = \
+ arch/$(ARCH)/exits.o \
+ arch/$(ARCH)/socketcall.o
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
archclean:
diff --git a/klibc/arch/i386/exits.S b/klibc/arch/i386/exits.S
new file mode 100644
index 0000000..b6f3227
--- /dev/null
+++ b/klibc/arch/i386/exits.S
@@ -0,0 +1,42 @@
+#
+# exit and _exit get included in *every* program, and gcc generates
+# horrible code for them. Yes, this only saves a few bytes, but
+# it does it in every program.
+#
+
+#include <asm/unistd.h>
+
+ .data
+ .align 4
+ .globl __exit_handler
+ .type __exit_handler,@object
+__exit_handler:
+ .long _exit
+ .size __exit_handler,4
+
+ .text
+ .align 4
+ .globl exit
+ .type exit,@function
+exit:
+ jmp *(__exit_handler)
+ .size exit,.-exit
+
+ /* No need to save any registers... we're exiting! */
+ .text
+ .align 4
+ .globl _exit
+ .type _exit,@function
+_exit:
+#if __NR_exit == 1
+ popl %ebx
+ xorl %eax,%eax
+ popl %ebx
+ incl %eax
+#else
+ movl 4(%esp),%ebx
+ movl $__NR_exit,%eax
+#endif
+ int $0x80
+ hlt
+ .size _exit,.-exit
diff --git a/klibc/socketcall.S b/klibc/arch/i386/socketcall.S
similarity index 100%
rename from klibc/socketcall.S
rename to klibc/arch/i386/socketcall.S
diff --git a/klibc/arch/mips/MCONFIG b/klibc/arch/mips/MCONFIG
index a487c8f..cfda7a5 100644
--- a/klibc/arch/mips/MCONFIG
+++ b/klibc/arch/mips/MCONFIG
@@ -7,5 +7,5 @@
# accordingly.
#
-OPTFLAGS = -Os -fomit-frame-pointer
+OPTFLAGS = -Os -fomit-frame-pointer -fno-pic -mno-abicalls
BITSIZE = 32
diff --git a/klibc/arch/mips/crt0.S b/klibc/arch/mips/crt0.S
new file mode 100644
index 0000000..e070fbe
--- /dev/null
+++ b/klibc/arch/mips/crt0.S
@@ -0,0 +1,29 @@
+#
+# arch/mips/crt0.S
+#
+# void _start(void)
+# {
+# /* Divine up argc, argv, and envp */
+# environ = envp;
+# exit(main(argc, argv, envp));
+# }
+#
+
+#include <asm/regdef.h>
+#include <asm/asm.h>
+
+NESTED(__start, 32, 16)
+ subu $29, 32
+ sw zero, 16(sp)
+
+ lw a0, (sp)
+ addiu a1, sp, 4
+ sll a2, a0, 4
+ addiu a2, 4
+ addiu a2, a1
+ sw a2, environ
+ jalr main
+ move a0, v0
+ jalr exit
+
+ END(__start)
diff --git a/klibc/arch/x86_64/Makefile.inc b/klibc/arch/x86_64/Makefile.inc
index 2801965..ca76253 100644
--- a/klibc/arch/x86_64/Makefile.inc
+++ b/klibc/arch/x86_64/Makefile.inc
@@ -7,4 +7,9 @@
# accordingly.
#
+ARCHOBJS = \
+ arch/$(ARCH)/exits.o
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
archclean:
diff --git a/klibc/arch/x86_64/exits.S b/klibc/arch/x86_64/exits.S
new file mode 100644
index 0000000..2d49d75
--- /dev/null
+++ b/klibc/arch/x86_64/exits.S
@@ -0,0 +1,35 @@
+#
+# exit and _exit get included in *every* program, and gcc generates
+# horrible code for them. Yes, this only saves a few bytes, but
+# it does it in every program.
+#
+
+#include <asm/unistd.h>
+
+ .data
+ .align 8
+ .globl __exit_handler
+ .type __exit_handler,@object
+__exit_handler:
+ .quad _exit
+ .size __exit_handler,8
+
+ .text
+ .align 8
+ .globl exit
+ .type exit,@function
+exit:
+ jmp *(__exit_handler)
+ .size exit,.-exit
+
+ /* No need to save any registers... we're exiting! */
+ .text
+ .align 4
+ .globl _exit
+ .type _exit,@function
+_exit:
+ movl $__NR_exit,%rax
+ /* The argument is already in %rdi */
+ syscall
+ .size _exit,.-exit
+
diff --git a/klibc/exits.S b/klibc/exits.S
deleted file mode 100644
index 128e128..0000000
--- a/klibc/exits.S
+++ /dev/null
@@ -1,75 +0,0 @@
-#
-# exit and _exit get included in *every* program, and gcc generates
-# horrible code for them. Yes, this only saves a few bytes, but
-# it does it in every program.
-#
-
-#include <asm/unistd.h>
-
-#ifdef __i386__
-
- .data
- .align 4
- .globl __exit_handler
- .type __exit_handler,@object
-__exit_handler:
- .long _exit
- .size __exit_handler,4
-
- .text
- .align 4
- .globl exit
- .type exit,@function
-exit:
- jmp *(__exit_handler)
- .size exit,.-exit
-
- /* No need to save any registers... we're exiting! */
- .text
- .align 4
- .globl _exit
- .type _exit,@function
-_exit:
-#if __NR_exit == 1
- popl %ebx
- xorl %eax,%eax
- popl %ebx
- incl %eax
-#else
- movl 4(%esp),%ebx
- movl $__NR_exit,%eax
-#endif
- int $0x80
- hlt
- .size _exit,.-exit
-
-#elif defined(__x86_64__)
-
- .data
- .align 8
- .globl __exit_handler
- .type __exit_handler,@object
-__exit_handler:
- .quad _exit
- .size __exit_handler,8
-
- .text
- .align 8
- .globl exit
- .type exit,@function
-exit:
- jmp *(__exit_handler)
- .size exit,.-exit
-
- /* No need to save any registers... we're exiting! */
- .text
- .align 4
- .globl _exit
- .type _exit,@function
-_exit:
- movl $__NR_exit,%rax
- /* The argument is already in %rdi */
- syscall
- .size _exit,.-exit
-
-#endif