summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/i386
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/dietlibc/i386')
-rw-r--r--mdk-stage1/dietlibc/i386/Makefile.add7
-rw-r--r--mdk-stage1/dietlibc/i386/__longjmp.S1
-rw-r--r--mdk-stage1/dietlibc/i386/__testandset.S1
-rw-r--r--mdk-stage1/dietlibc/i386/clone.S29
-rw-r--r--mdk-stage1/dietlibc/i386/setjmp.S55
-rw-r--r--mdk-stage1/dietlibc/i386/start.S69
-rw-r--r--mdk-stage1/dietlibc/i386/unified.S35
7 files changed, 113 insertions, 84 deletions
diff --git a/mdk-stage1/dietlibc/i386/Makefile.add b/mdk-stage1/dietlibc/i386/Makefile.add
index b685cc360..83b18ae29 100644
--- a/mdk-stage1/dietlibc/i386/Makefile.add
+++ b/mdk-stage1/dietlibc/i386/Makefile.add
@@ -1,3 +1,8 @@
-CFLAGS+=-march=i386 -mcpu=i386 -Os -fomit-frame-pointer
+M:=$(shell ./findcflags.sh $(CC))
+LIBOBJ+=$(OBJDIR)/__ten.o $(OBJDIR)/md5asm.o $(OBJDIR)/mmap64.o
+LIBMATH+=acos.o asin.o atan.o atan2.o ceil.o cos.o exp.o exp10.o exp2.o expm1.o fabs.o floor.o hypot.o log.o log10.o log2.o sin.o sqrt.o tan.o copysign.o sincos.o __half.o ldexp.o pow.o ilogb.o cbrt.o log1p.o sqrtl.o fmod.o libm2.o
+#CFLAGS+=-march=i386 -Os -fomit-frame-pointer -malign-functions=0 -malign-jumps=0 -malign-loops=0 -mpreferred-stack-boundary=2
+CFLAGS+=$(M)
VPATH:=i386:syscalls.s:$(VPATH)
+LIBGMON_OBJS+=$(OBJDIR)/mcount.o
diff --git a/mdk-stage1/dietlibc/i386/__longjmp.S b/mdk-stage1/dietlibc/i386/__longjmp.S
index 098275037..a09191f0b 100644
--- a/mdk-stage1/dietlibc/i386/__longjmp.S
+++ b/mdk-stage1/dietlibc/i386/__longjmp.S
@@ -2,6 +2,7 @@
.text
.global __longjmp
+.type __longjmp,@function
__longjmp:
movl 4(%esp), %ecx /* User's jmp_buf in %ecx. */
movl 8(%esp), %eax /* Second argument is return value. */
diff --git a/mdk-stage1/dietlibc/i386/__testandset.S b/mdk-stage1/dietlibc/i386/__testandset.S
index af7b4d5a0..29b02d57a 100644
--- a/mdk-stage1/dietlibc/i386/__testandset.S
+++ b/mdk-stage1/dietlibc/i386/__testandset.S
@@ -1,5 +1,6 @@
.text
.global __testandset
+.type __testandset,@function
__testandset:
xorl %eax, %eax
movl 0x4(%esp),%edx
diff --git a/mdk-stage1/dietlibc/i386/clone.S b/mdk-stage1/dietlibc/i386/clone.S
index ac02eb468..ea43bc2e2 100644
--- a/mdk-stage1/dietlibc/i386/clone.S
+++ b/mdk-stage1/dietlibc/i386/clone.S
@@ -1,17 +1,21 @@
-#include <asm/unistd.h>
+#include "syscalls.h"
+#include <errno.h>
+#include "PIC.h"
.text
+.type clone,@function
.weak clone
clone:
+.type __clone,@function
.global __clone
__clone:
+ mov $-EINVAL, %eax
+
movl 4(%esp), %ecx /* have non null thread_funcion */
- testl %ecx, %ecx
- je .Lclone_error
+ jecxz .Lclone_error
movl 8(%esp), %ecx /* have non null child_stack pointer */
- testl %ecx, %ecx
- je .Lclone_error
+ jecxz .Lclone_error
/* put the parameter on thread stack */
subl $8, %ecx
@@ -31,9 +35,7 @@ __clone:
testl %eax, %eax
jl .Lclone_error
- je .Lstart_thread
- ret
-
+ jne .Lreturn
.Lstart_thread:
xorl %ebp,%ebp
call *%ebx
@@ -43,9 +45,16 @@ __clone:
.Lclone_error:
negl %eax
pushl %eax
+#ifdef PIC
+ pushl %ebx
+ PIC_INIT
+ call __errno_location@PLT
+ popl %ebx
+#else
call __errno_location
+#endif
popl %ecx
movl %ecx, (%eax)
- xorl %eax, %eax
- decl %eax
+ orl $-1, %eax
+.Lreturn:
ret
diff --git a/mdk-stage1/dietlibc/i386/setjmp.S b/mdk-stage1/dietlibc/i386/setjmp.S
index 9bfecf565..09b266c61 100644
--- a/mdk-stage1/dietlibc/i386/setjmp.S
+++ b/mdk-stage1/dietlibc/i386/setjmp.S
@@ -1,61 +1,40 @@
#include <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
+.type setjmp,@function
setjmp:
.globl __setjmp
+.type __setjmp,@function
__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. */
+ popl %eax
+ popl %ecx
+ pushl $0
+ pushl %ecx
+ pushl %eax
.globl __sigsetjmp
+.type __sigsetjmp,@function
__sigsetjmp:
- movl 4(%esp), %eax /* User's jmp_buf in %eax. */
+ movl 4(%esp), %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)
+ leal 4(%esp), %edx /* Save SP as it will be after we return. */
movl 0(%esp), %ecx /* Save PC we are returning to now. */
+ movl %edx, (JB_SP*4)(%eax)
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
+ call 1f
+ addl $_GLOBAL_OFFSET_TABLE_, %ecx
+ jmp *__sigjmp_save@GOT(%ecx)
+1: movl (%esp), %ecx
+ ret
#else
jmp __sigjmp_save
#endif
diff --git a/mdk-stage1/dietlibc/i386/start.S b/mdk-stage1/dietlibc/i386/start.S
index 167bb779c..1a825fc2a 100644
--- a/mdk-stage1/dietlibc/i386/start.S
+++ b/mdk-stage1/dietlibc/i386/start.S
@@ -1,42 +1,51 @@
-#include "start.h"
+#include "dietfeatures.h"
+#include "PIC.h"
-#ifdef __i386__
.text
-.globl _start
+.global _start
_start:
-#if 0
- popl %ecx
- movl %esp, %esi
- leal 4(%esp,%ecx,4),%eax
+#if 1
+ popl %ecx /* %ecx = argc */
+ movl %esp,%esi /* %esi = argv */
+ pushl %ecx
#else
- movl (%esp),%ecx /* %ecx = argc */
- leal 4(%esp),%esi /* %esi = argv */
-
- leal 4(%esi,%ecx,4),%eax /* eax = 4*ecx+4 = envp */
+ movl (%esp),%ecx /* %ecx = argc */
+ leal 4(%esp),%esi /* %esi = argv */
#endif
- pushl %eax
- pushl %esi
- pushl %ecx
- movl %eax,environ
+ leal 4(%esi,%ecx,4),%eax /* %eax = envp = (4*ecx)+%esi+4 */
#ifdef WANT_DYNAMIC
-/* in %edx we have the dynamic _fini ( register this if non null ) */
- test %edx, %edx
- je .Linit
+/* in %edx we have the ld.so dynamic _fini ( register this if non null ) */
push %edx
- call atexit
- pop %edx
-.Linit:
- call _init
- push $_fini
- call atexit
- pop %edx
#endif
- call main
- pushl %eax
- call exit
-.Lfefe:
- .size _start,.Lfefe-_start
+ pushl %eax
+ pushl %esi
+ pushl %ecx
+ PIC_INIT /* non-PIC: this is an empty line */
+ PUT_VAR %eax, environ, %ecx /* non-PIC: movl %eax,environ */
+
+#ifdef PROFILING
+ pushl $_etext
+ pushl $.text
+ call monitor
+ addl $0x8, %esp
+#endif
+
+#ifdef WANT_DYNAMIC
+ call _dyn_start
+#else
+ call main
+#endif
+
+#ifdef PROFILING
+ pushl %eax
+ call _stop_monitor
+ popl %eax
#endif
+ pushl %eax
+ call exit
+ hlt /* die now ! will ya ... */
+.Lstart:
+ .size _start,.Lstart-_start
diff --git a/mdk-stage1/dietlibc/i386/unified.S b/mdk-stage1/dietlibc/i386/unified.S
index f182bdb4b..989bf37b5 100644
--- a/mdk-stage1/dietlibc/i386/unified.S
+++ b/mdk-stage1/dietlibc/i386/unified.S
@@ -1,13 +1,33 @@
+
#include <dietfeatures.h>
.text
+.global __unified_syscall_256
+.type __unified_syscall_256,@function
+__unified_syscall_256:
+ movzwl %ax,%eax
+ jmp .L1
+.L2:
+.size __unified_syscall_256,.L2-__unified_syscall_256
+.weak exit
+exit:
+.global _exit
+.type _exit,@function
+_exit:
+ movb $1,%al
.global __unified_syscall
+.type __unified_syscall,@function
__unified_syscall:
+.size _exit,__unified_syscall-_exit
movzbl %al, %eax
+.L1:
push %edi
push %esi
push %ebx
movl %esp,%edi
+ /* we use movl instead of pop because otherwise a signal would
+ destroy the stack frame and crash the program, although it
+ would save a few bytes. */
movl 0x10(%edi),%ebx
movl 0x14(%edi),%ecx
movl 0x18(%edi),%edx
@@ -16,19 +36,24 @@ __unified_syscall:
int $0x80
cmp $-124,%eax
jbe .Lnoerror
-#ifdef WANT_THREAD_SAVE
+ neg %eax
+#ifdef WANT_THREAD_SAFE
movl %eax,%ebx
call __errno_location
- neg %ebx
movl %ebx,(%eax)
+ orl $-1,%eax
#else
- neg %eax
mov %eax,errno
+ sbb %eax,%eax # eax = eax - eax - CY = -1
#endif
- xor %eax,%eax
- dec %eax
.Lnoerror:
pop %ebx
pop %esi
pop %edi
+
+/* here we go and "reuse" the return for weak-void functions */
+#include "dietuglyweaks.h"
+
ret
+.L3:
+.size __unified_syscall,.L3-__unified_syscall