summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/i386
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-01-04 20:04:45 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-01-04 20:04:45 +0000
commit02fec4701cee79f875c1d02b8b4aee09380dbcb8 (patch)
treef4f291aedbb2e60ee58351481858a8cd3ec80b6b /mdk-stage1/dietlibc/i386
parent9887fe04751edf39e8389f2c3ec3f020b5e1c17d (diff)
downloaddrakx-02fec4701cee79f875c1d02b8b4aee09380dbcb8.tar
drakx-02fec4701cee79f875c1d02b8b4aee09380dbcb8.tar.gz
drakx-02fec4701cee79f875c1d02b8b4aee09380dbcb8.tar.bz2
drakx-02fec4701cee79f875c1d02b8b4aee09380dbcb8.tar.xz
drakx-02fec4701cee79f875c1d02b8b4aee09380dbcb8.zip
integrate dietlibc/stdio per default for cdrom and disk only installs
Diffstat (limited to 'mdk-stage1/dietlibc/i386')
-rw-r--r--mdk-stage1/dietlibc/i386/Makefile.add3
-rw-r--r--mdk-stage1/dietlibc/i386/__longjmp.S20
-rw-r--r--mdk-stage1/dietlibc/i386/mmap.c16
-rw-r--r--mdk-stage1/dietlibc/i386/select.S6
-rw-r--r--mdk-stage1/dietlibc/i386/setjmp.S64
-rw-r--r--mdk-stage1/dietlibc/i386/start.S28
-rw-r--r--mdk-stage1/dietlibc/i386/strchr.S47
-rw-r--r--mdk-stage1/dietlibc/i386/unified.S33
8 files changed, 217 insertions, 0 deletions
diff --git a/mdk-stage1/dietlibc/i386/Makefile.add b/mdk-stage1/dietlibc/i386/Makefile.add
new file mode 100644
index 000000000..8d2914e66
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/Makefile.add
@@ -0,0 +1,3 @@
+
+CFLAGS+=-march=i386 -mcpu=i386 -Os -fomit-frame-pointer
+override VPATH=i386:syscalls.s:lib
diff --git a/mdk-stage1/dietlibc/i386/__longjmp.S b/mdk-stage1/dietlibc/i386/__longjmp.S
new file mode 100644
index 000000000..312e01ed1
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/__longjmp.S
@@ -0,0 +1,20 @@
+#define _ASM
+#define _SETJMP_H
+#include <bits/setjmp.h>
+
+.text
+.global __longjmp
+__longjmp:
+ movl 4(%esp), %ecx /* User's jmp_buf in %ecx. */
+ movl 8(%esp), %eax /* Second argument is return value. */
+ /* Save the return address now. */
+ movl (JB_PC*4)(%ecx), %edx
+ /* Restore registers. */
+ movl (JB_BX*4)(%ecx), %ebx
+ movl (JB_SI*4)(%ecx), %esi
+ movl (JB_DI*4)(%ecx), %edi
+ movl (JB_BP*4)(%ecx), %ebp
+ movl (JB_SP*4)(%ecx), %esp
+ /* Jump to saved PC. */
+ jmp *%edx
+.size __longjmp,.-__longjmp;
diff --git a/mdk-stage1/dietlibc/i386/mmap.c b/mdk-stage1/dietlibc/i386/mmap.c
new file mode 100644
index 000000000..26ecb55c0
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/mmap.c
@@ -0,0 +1,16 @@
+#include <linux/types.h>
+#include <linux/unistd.h>
+
+#define __NR__mmap __NR_mmap
+_syscall1(int,_mmap,unsigned long *,buffer)
+
+char *mmap(char *addr, size_t len, int prot, int flags, int fd, unsigned long off) {
+ unsigned long buffer[6];
+ buffer[0] = (unsigned long)addr;
+ buffer[1] = (unsigned long)len;
+ buffer[2] = (unsigned long)prot;
+ buffer[3] = (unsigned long)flags;
+ buffer[4] = (unsigned long)fd;
+ buffer[5] = (unsigned long)off;
+ return (char*) _mmap(buffer);
+}
diff --git a/mdk-stage1/dietlibc/i386/select.S b/mdk-stage1/dietlibc/i386/select.S
new file mode 100644
index 000000000..6e9fce8e3
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/select.S
@@ -0,0 +1,6 @@
+#include "syscalls.h"
+
+.text
+.weak select
+select:
+syscall(_newselect,select)
diff --git a/mdk-stage1/dietlibc/i386/setjmp.S b/mdk-stage1/dietlibc/i386/setjmp.S
new file mode 100644
index 000000000..d7898e58f
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/setjmp.S
@@ -0,0 +1,64 @@
+#define _ASM
+#define _SETJMP_H
+#include <bits/setjmp.h>
+
+/* setjmp for i386.
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+.section .rodata
+.text
+.weak setjmp
+setjmp:
+.globl __setjmp
+__setjmp:
+ popl %eax /* Pop return address. */
+ popl %ecx /* Pop jmp_buf. */
+ pushl $0 /* Push zero argument. */
+ pushl %ecx /* Push jmp_buf. */
+ pushl %eax /* Push back return address. */
+
+.globl __sigsetjmp
+__sigsetjmp:
+ movl 4(%esp), %eax /* User's jmp_buf in %eax. */
+ /* Save registers. */
+ movl %ebx, (JB_BX*4)(%eax)
+ movl %esi, (JB_SI*4)(%eax)
+ movl %edi, (JB_DI*4)(%eax)
+ movl %ebp, (JB_BP*4)(%eax)
+ leal 4(%esp), %ecx /* Save SP as it will be after we return. */
+ movl %ecx, (JB_SP*4)(%eax)
+ movl 0(%esp), %ecx /* Save PC we are returning to now. */
+ movl %ecx, (JB_PC*4)(%eax)
+
+ /* Make a tail call to __sigjmp_save; it takes the same args. */
+#ifdef PIC
+ /* We cannot use the PLT, because it requires that %ebx be set, but
+ we can't save and restore our caller's value. Instead, we do an
+ indirect jump through the GOT, using for the temporary register
+ %ecx, which is call-clobbered. */
+ call L(here)
+L(here):
+ popl %ecx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-L(here)], %ecx
+ movl C_SYMBOL_NAME(__sigjmp_save@GOT)(%ecx), %ecx
+ jmp *%ecx
+#else
+ jmp __sigjmp_save
+#endif
+.size __sigsetjmp,.-__sigsetjmp;
diff --git a/mdk-stage1/dietlibc/i386/start.S b/mdk-stage1/dietlibc/i386/start.S
new file mode 100644
index 000000000..8a2ba7e38
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/start.S
@@ -0,0 +1,28 @@
+#include "start.h"
+
+#ifdef __i386__
+.text
+.globl _start
+_start:
+#if 0
+ popl %ecx
+ movl %esp, %edx
+ leal 4(%esp,%ecx,4),%eax
+#else
+ movl (%esp),%ecx /* %ecx = argc */
+ leal 4(%esp),%edx /* %edx = argv */
+
+ leal 4(%edx,%ecx,4),%eax /* eax = 4*ecx+4 = envp */
+#endif
+ pushl %eax
+ pushl %edx
+ pushl %ecx
+ movl %eax,environ
+
+ call main
+ pushl %eax
+ call exit
+.Lfefe:
+ .size _start,.Lfefe-_start
+#endif
+
diff --git a/mdk-stage1/dietlibc/i386/strchr.S b/mdk-stage1/dietlibc/i386/strchr.S
new file mode 100644
index 000000000..0a2a5aa52
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/strchr.S
@@ -0,0 +1,47 @@
+#define NEW
+
+.text
+.global strchr
+strchr:
+ mov %esi,%edx
+ mov 0x4(%esp,1),%esi
+ mov 0x8(%esp,1),%cl
+ cld
+.L1:
+ lods (%esi),%eax
+ cmp %al,%cl
+ jz .Lafound
+ test %al,%al
+ jz .Lnotfound
+
+ cmp %ah,%cl
+ jz .Lbfound
+ test %ah,%ah
+ jz .Lnotfound
+
+ shr $16,%eax
+ cmp %al,%cl
+ jz .Lcfound
+ test %al,%al
+ jz .Lnotfound
+
+ cmp %ah,%cl
+ jz .Ldfound
+ test %ah,%ah
+
+ jnz .L1
+.Lnotfound:
+ sub %eax,%eax
+ mov %edx,%esi
+ ret
+.Lafound:
+ dec %esi
+.Lbfound:
+ dec %esi
+.Lcfound:
+ dec %esi
+.Ldfound:
+ mov %esi,%eax
+ mov %edx,%esi
+ dec %eax
+ ret
diff --git a/mdk-stage1/dietlibc/i386/unified.S b/mdk-stage1/dietlibc/i386/unified.S
new file mode 100644
index 000000000..c3cd11001
--- /dev/null
+++ b/mdk-stage1/dietlibc/i386/unified.S
@@ -0,0 +1,33 @@
+#include <dietfeatures.h>
+
+.text
+.global __unified_syscall
+__unified_syscall:
+ and $0xff,%eax
+ push %edi
+ push %esi
+ push %ebx
+ movl 0x10(%esp),%ebx
+ movl 0x14(%esp),%ecx
+ movl 0x18(%esp),%edx
+ movl 0x1c(%esp),%edi
+ movl 0x20(%esp),%esi
+ int $0x80
+ cmp $-124,%eax
+ jbe .Lnoerror
+#ifdef WANT_THREAD_SAVE
+ movl %eax,%ebx
+ call __errno_location
+ neg %ebx
+ movl %ebx,(%eax)
+#else
+ neg %eax
+ mov %eax,errno
+#endif
+ xor %eax,%eax
+ dec %eax
+.Lnoerror:
+ pop %ebx
+ pop %esi
+ pop %edi
+ ret