From 167217bec15c9c7aa70ba2a3dc9c689b3cd91872 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Mon, 14 May 2001 14:19:32 +0000 Subject: import new version of dietlibc --- mdk-stage1/dietlibc/i386/Makefile.add | 2 +- mdk-stage1/dietlibc/i386/__longjmp.S | 4 +-- mdk-stage1/dietlibc/i386/__testandset.S | 8 ++++++ mdk-stage1/dietlibc/i386/clone.S | 51 +++++++++++++++++++++++++++++++++ mdk-stage1/dietlibc/i386/select.S | 5 +--- mdk-stage1/dietlibc/i386/setjmp.S | 4 +-- mdk-stage1/dietlibc/i386/start.S | 22 +++++++++++--- mdk-stage1/dietlibc/i386/strchr.S | 47 ------------------------------ mdk-stage1/dietlibc/i386/unified.S | 13 +++++---- 9 files changed, 88 insertions(+), 68 deletions(-) create mode 100644 mdk-stage1/dietlibc/i386/__testandset.S create mode 100644 mdk-stage1/dietlibc/i386/clone.S delete mode 100644 mdk-stage1/dietlibc/i386/strchr.S (limited to 'mdk-stage1/dietlibc/i386') diff --git a/mdk-stage1/dietlibc/i386/Makefile.add b/mdk-stage1/dietlibc/i386/Makefile.add index 8d2914e66..b685cc360 100644 --- a/mdk-stage1/dietlibc/i386/Makefile.add +++ b/mdk-stage1/dietlibc/i386/Makefile.add @@ -1,3 +1,3 @@ CFLAGS+=-march=i386 -mcpu=i386 -Os -fomit-frame-pointer -override VPATH=i386:syscalls.s:lib +VPATH:=i386:syscalls.s:$(VPATH) diff --git a/mdk-stage1/dietlibc/i386/__longjmp.S b/mdk-stage1/dietlibc/i386/__longjmp.S index 312e01ed1..098275037 100644 --- a/mdk-stage1/dietlibc/i386/__longjmp.S +++ b/mdk-stage1/dietlibc/i386/__longjmp.S @@ -1,6 +1,4 @@ -#define _ASM -#define _SETJMP_H -#include +#include .text .global __longjmp diff --git a/mdk-stage1/dietlibc/i386/__testandset.S b/mdk-stage1/dietlibc/i386/__testandset.S new file mode 100644 index 000000000..af7b4d5a0 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/__testandset.S @@ -0,0 +1,8 @@ +.text +.global __testandset +__testandset: + xorl %eax, %eax + movl 0x4(%esp),%edx + incl %eax + xchgl %eax,(%edx) + ret diff --git a/mdk-stage1/dietlibc/i386/clone.S b/mdk-stage1/dietlibc/i386/clone.S new file mode 100644 index 000000000..ac02eb468 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/clone.S @@ -0,0 +1,51 @@ +#include + +.text +.weak clone +clone: +.global __clone +__clone: + movl 4(%esp), %ecx /* have non null thread_funcion */ + testl %ecx, %ecx + je .Lclone_error + + movl 8(%esp), %ecx /* have non null child_stack pointer */ + testl %ecx, %ecx + je .Lclone_error + + /* put the parameter on thread stack */ + subl $8, %ecx + + movl 16(%esp), %eax /* arg */ + movl %eax, 4(%ecx) + + movl 4(%esp), %eax /* thread_func */ + movl %eax, 0(%ecx) + + /* the syscall */ + pushl %ebx + movl 16(%esp), %ebx /* flags */ + movl $__NR_clone, %eax + int $0x80 + popl %ebx + + testl %eax, %eax + jl .Lclone_error + je .Lstart_thread + ret + +.Lstart_thread: + xorl %ebp,%ebp + call *%ebx + pushl %eax + call _exit + +.Lclone_error: + negl %eax + pushl %eax + call __errno_location + popl %ecx + movl %ecx, (%eax) + xorl %eax, %eax + decl %eax + ret diff --git a/mdk-stage1/dietlibc/i386/select.S b/mdk-stage1/dietlibc/i386/select.S index 6e9fce8e3..9e7066eae 100644 --- a/mdk-stage1/dietlibc/i386/select.S +++ b/mdk-stage1/dietlibc/i386/select.S @@ -1,6 +1,3 @@ #include "syscalls.h" -.text -.weak select -select: -syscall(_newselect,select) +syscall_weak(_newselect,select,__libc_select) diff --git a/mdk-stage1/dietlibc/i386/setjmp.S b/mdk-stage1/dietlibc/i386/setjmp.S index d7898e58f..9bfecf565 100644 --- a/mdk-stage1/dietlibc/i386/setjmp.S +++ b/mdk-stage1/dietlibc/i386/setjmp.S @@ -1,6 +1,4 @@ -#define _ASM -#define _SETJMP_H -#include +#include /* setjmp for i386. Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. diff --git a/mdk-stage1/dietlibc/i386/start.S b/mdk-stage1/dietlibc/i386/start.S index 8a2ba7e38..167bb779c 100644 --- a/mdk-stage1/dietlibc/i386/start.S +++ b/mdk-stage1/dietlibc/i386/start.S @@ -6,19 +6,33 @@ _start: #if 0 popl %ecx - movl %esp, %edx + movl %esp, %esi leal 4(%esp,%ecx,4),%eax #else movl (%esp),%ecx /* %ecx = argc */ - leal 4(%esp),%edx /* %edx = argv */ + leal 4(%esp),%esi /* %esi = argv */ - leal 4(%edx,%ecx,4),%eax /* eax = 4*ecx+4 = envp */ + leal 4(%esi,%ecx,4),%eax /* eax = 4*ecx+4 = envp */ #endif pushl %eax - pushl %edx + pushl %esi pushl %ecx movl %eax,environ +#ifdef WANT_DYNAMIC +/* in %edx we have the dynamic _fini ( register this if non null ) */ + test %edx, %edx + je .Linit + push %edx + call atexit + pop %edx +.Linit: + call _init + push $_fini + call atexit + pop %edx +#endif + call main pushl %eax call exit diff --git a/mdk-stage1/dietlibc/i386/strchr.S b/mdk-stage1/dietlibc/i386/strchr.S deleted file mode 100644 index 0a2a5aa52..000000000 --- a/mdk-stage1/dietlibc/i386/strchr.S +++ /dev/null @@ -1,47 +0,0 @@ -#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 index 740cb0ecc..f182bdb4b 100644 --- a/mdk-stage1/dietlibc/i386/unified.S +++ b/mdk-stage1/dietlibc/i386/unified.S @@ -3,15 +3,16 @@ .text .global __unified_syscall __unified_syscall: - and $0xff,%eax + movzbl %al, %eax push %edi push %esi push %ebx - movl 0x10(%esp),%ebx - movl 0x14(%esp),%ecx - movl 0x18(%esp),%edx - movl 0x1c(%esp),%esi - movl 0x20(%esp),%edi + movl %esp,%edi + movl 0x10(%edi),%ebx + movl 0x14(%edi),%ecx + movl 0x18(%edi),%edx + movl 0x1c(%edi),%esi + movl 0x20(%edi),%edi int $0x80 cmp $-124,%eax jbe .Lnoerror -- cgit v1.2.1