diff options
Diffstat (limited to 'libc')
59 files changed, 568 insertions, 1371 deletions
diff --git a/libc/sysdeps/linux/alpha/Makefile b/libc/sysdeps/linux/alpha/Makefile index 5c7310b38..c37858380 100644 --- a/libc/sysdeps/linux/alpha/Makefile +++ b/libc/sysdeps/linux/alpha/Makefile @@ -19,8 +19,8 @@ TOPDIR=../../../../ include $(TOPDIR)Rules.mak -CRT0_SRC = crt0.S -CRT0_OBJ = crt0.o crt1.o +CRT_SRC = crt1.S +CRT_OBJ = crt1.o CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o SSRC=__longjmp.S brk.S bsd-_setjmp.S bsd-setjmp.S clone.S \ @@ -36,12 +36,12 @@ OBJ_LIST=../../../obj.sysdeps.$(TARGET_ARCH) all: $(OBJ_LIST) -$(OBJ_LIST): $(OBJS) $(CRT0_OBJ) $(CTOR_TARGETS) +$(OBJ_LIST): $(OBJS) $(CRT_OBJ) $(CTOR_TARGETS) echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $(OBJ_LIST) $(INSTALL) -d $(TOPDIR)lib/ - cp $(CRT0_OBJ) $(TOPDIR)lib/ + cp $(CRT_OBJ) $(TOPDIR)lib/ -$(CRT0_OBJ): $(CRT0_SRC) +$(CRT_OBJ): $(CRT_SRC) $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o $(STRIPTOOL) -x -R .note -R .comment $*.o diff --git a/libc/sysdeps/linux/alpha/bits/siginfo.h b/libc/sysdeps/linux/alpha/bits/siginfo.h index a2aacc04b..2cc92babb 100644 --- a/libc/sysdeps/linux/alpha/bits/siginfo.h +++ b/libc/sysdeps/linux/alpha/bits/siginfo.h @@ -1,5 +1,5 @@ /* siginfo_t, sigevent and constants. Linux/Alpha version. - Copyright (C) 1997-2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000, 2001 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 @@ -22,6 +22,8 @@ # error "Never include this file directly. Use <signal.h> instead" #endif +#include <bits/wordsize.h> + #if (!defined __have_sigval_t \ && (defined _SIGNAL_H || defined __need_siginfo_t \ || defined __need_sigevent_t)) @@ -40,7 +42,11 @@ typedef union sigval # define __have_siginfo_t 1 # define __SI_MAX_SIZE 128 -# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 4) +# if __WORDSIZE == 64 +# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 4) +# else +# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3) +# endif typedef struct siginfo { @@ -63,9 +69,8 @@ typedef struct siginfo /* POSIX.1b timers. */ struct { - int si_tid; /* Timer ID. */ - int si_overrun; /* Overrun count. */ - sigval_t si_sigval; /* Signal value. */ + unsigned int _timer1; + unsigned int _timer2; } _timer; /* POSIX.1b signals. */ @@ -105,8 +110,8 @@ typedef struct siginfo /* X/Open requires some more fields with fixed names. */ # define si_pid _sifields._kill.si_pid # define si_uid _sifields._kill.si_uid -# define si_timerid _sifields._timer.si_tid -# define si_overrun _sifields._timer.si_overrun +# define si_timer1 _sifields._timer._timer1 +# define si_timer2 _sifields._timer._timer2 # define si_status _sifields._sigchld.si_status # define si_utime _sifields._sigchld.si_utime # define si_stime _sifields._sigchld.si_stime @@ -122,10 +127,8 @@ typedef struct siginfo signals. */ enum { - SI_ASYNCNL = -60, /* Sent by asynch name lookup completion. */ + SI_ASYNCNL = -6, /* Sent by asynch name lookup completion. */ # define SI_ASYNCNL SI_ASYNCNL - SI_TKILL = -6, /* Sent by tkill. */ -# define SI_TKILL SI_TKILL SI_SIGIO, /* Sent by queued SIGIO. */ # define SI_SIGIO SI_SIGIO SI_ASYNCIO, /* Sent by AIO completion. */ @@ -258,7 +261,14 @@ enum /* Structure to transport application-defined values with signals. */ # define __SIGEV_MAX_SIZE 64 -# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4) +# if __WORDSIZE == 64 +# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4) +# else +# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3) +# endif + +/* Forward declaration of the `pthread_attr_t' type. */ +struct __pthread_attr_s; typedef struct sigevent { @@ -270,14 +280,10 @@ typedef struct sigevent { int _pad[__SIGEV_PAD_SIZE]; - /* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the - thread to receive the signal. */ - __pid_t _tid; - struct { - void (*_function) (sigval_t); /* Function to start. */ - void *_attribute; /* Really pthread_attr_t. */ + void (*_function) (sigval_t); /* Function to start. */ + struct __pthread_attr_s *_attribute; /* Really pthread_attr_t. */ } _sigev_thread; } _sigev_un; } sigevent_t; @@ -293,11 +299,8 @@ enum # define SIGEV_SIGNAL SIGEV_SIGNAL SIGEV_NONE, /* Other notification: meaningless. */ # define SIGEV_NONE SIGEV_NONE - SIGEV_THREAD, /* Deliver via thread creation. */ + SIGEV_THREAD /* Deliver via thread creation. */ # define SIGEV_THREAD SIGEV_THREAD - - SIGEV_THREAD_ID = 4 /* Send signal to specific thread. */ -#define SIGEV_THREAD_ID SIGEV_THREAD_ID }; #endif /* have _SIGNAL_H. */ diff --git a/libc/sysdeps/linux/alpha/clone.S b/libc/sysdeps/linux/alpha/clone.S index 396816184..b326925d7 100644 --- a/libc/sysdeps/linux/alpha/clone.S +++ b/libc/sysdeps/linux/alpha/clone.S @@ -23,21 +23,12 @@ #include <features.h> #define _ERRNO_H 1 #include <bits/errno.h> +#include <sys/syscall.h> +#include <asm/regdef.h> /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg) */ -#define a0 $16 -#define a1 $17 -#define a2 $18 -#define a3 $19 -#define v0 $0 -#define fp $15 -#define gp $29 -#define ra $26 -#define pv $27 -#define zero $31 - - .text +.text .globl __clone; .align 3; .ent __clone , 0; diff --git a/libc/sysdeps/linux/alpha/crt0.S b/libc/sysdeps/linux/alpha/crt0.S deleted file mode 100644 index 2e2941042..000000000 --- a/libc/sysdeps/linux/alpha/crt0.S +++ /dev/null @@ -1,84 +0,0 @@ -/* Startup code for Alpha/ELF. - Copyright (C) 1993,1995,1996,1997,1998,2000,2001 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Richard Henderson <rth@tamu.edu> - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#define a0 $16 /* argument registers (caller-saved) */ -#define a1 $17 -#define a2 $18 -#define a3 $19 -#define a4 $20 -#define a5 $21 -#define ra $26 /* return address register */ - -#define s6 $15 -#define fp s6 /* frame-pointer (s6 in frame-less procedures) */ -#define gp $29 /* global pointer */ -#define sp $30 /* stack pointer */ -#define zero $31 /* reads as zero, writes are noops */ - - .text - .align 3 - .globl _start - .ent _start, 0 - .type _start,@function -#if defined L_crt0 || ! defined __UCLIBC_CTOR_DTOR__ - .type __uClibc_main,@function -#else - .weak _init - .weak _fini - .type __uClibc_start_main,@function -#endif -/* Stick in a dummy reference to main(), so that if an application - * is linking when the main() function is in a static library (.a) - * we can be sure that main() actually gets linked in */ - .type main,@function - -_start: - .frame fp, 0, zero - mov zero, fp - br gp, 1f -1: ldgp gp, 0(gp) - subq sp, 16, sp - .prologue 0 - - ldl a0, 16(sp) /* get argc */ - lda a1, 24(sp) /* get argv */ - addq a0, 1, a2 - s8addq a2, a1, a2 /* Calculate environ */ - - /* Call the user's main function, and exit with its value. - But let the libc call main. */ - jsr ra, __uClibc_main - - /* Die very horribly if exit returns. Call_pal hlt is callable from - kernel mode only; this will result in an illegal instruction trap. */ - call_pal 0 - .end _start - -/* For ECOFF backwards compatibility. */ -.weak __start; - __start = _start - -/* Define a symbol for the first piece of initialized data. */ - .data - .globl __data_start -__data_start: - .long 0 - .weak data_start - data_start = __data_start diff --git a/libc/sysdeps/linux/arm/Makefile b/libc/sysdeps/linux/arm/Makefile index 94929304e..77245307a 100644 --- a/libc/sysdeps/linux/arm/Makefile +++ b/libc/sysdeps/linux/arm/Makefile @@ -19,33 +19,37 @@ TOPDIR=../../../../ include $(TOPDIR)Rules.mak -CRT0_SRC = crt0.S -CRT0_OBJ = crt0.o crt1.o -CRT0_DEPS=gmon-start.S +CRT_SRC = crt1.S +CRT_OBJ = crt1.o +SCRT_OBJ = $(patsubst %,S%, $(CRT_OBJ)) CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o SSRC=__longjmp.S vfork.S clone.S setjmp.S bsd-setjmp.S \ bsd-_setjmp.S sigrestorer.S mmap64.S SOBJS=$(patsubst %.S,%.o, $(SSRC)) -CSRC=brk.c syscall.c ioperm.c sigaction.c +CSRC=brk.c syscall.c ioperm.c sigaction.c __syscall_error.c COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(SOBJS) $(MOBJ) $(COBJS) +OBJS=$(SOBJS) $(COBJS) OBJ_LIST=../../../obj.sysdeps.$(TARGET_ARCH) all: $(OBJ_LIST) -$(OBJ_LIST): $(OBJS) $(CRT0_OBJ) $(CTOR_TARGETS) +$(OBJ_LIST): $(OBJS) $(CRT_OBJ) $(SCRT_OBJ) $(CTOR_TARGETS) echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $(OBJ_LIST) $(INSTALL) -d $(TOPDIR)lib/ - cp $(CRT0_OBJ) $(TOPDIR)lib/ + cp $(CRT_OBJ) $(SCRT_OBJ) $(TOPDIR)lib/ -$(CRT0_OBJ): $(CRT0_SRC) +$(CRT_OBJ): $(CRT_SRC) $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o $(STRIPTOOL) -x -R .note -R .comment $*.o +$(SCRT_OBJ): $(CRT_SRC) + $(CC) $(ASFLAGS) $(PIEFLAG) -DL_$* $< -c -o $*.o + $(STRIPTOOL) -x -R .note -R .comment $*.o + $(SOBJS): %.o : %.S $(CC) $(ASFLAGS) -c $< -o $@ $(STRIPTOOL) -x -R .note -R .comment $*.o @@ -83,4 +87,3 @@ headers: clean: $(RM) *.[oa] *~ core $(RM) bits/sysnum.h - $(RM) gmon-start.S diff --git a/libc/sysdeps/linux/arm/__longjmp.S b/libc/sysdeps/linux/arm/__longjmp.S index e280d842d..44837911b 100644 --- a/libc/sysdeps/linux/arm/__longjmp.S +++ b/libc/sysdeps/linux/arm/__longjmp.S @@ -23,9 +23,9 @@ #include <bits/setjmp.h> -.globl __longjmp; +.global __longjmp .type __longjmp,%function -.align 4; +.align 4 __longjmp: mov ip, r0 /* save jmp_buf pointer */ @@ -39,4 +39,5 @@ __longjmp: #endif ldmia ip , {v1-v6, sl, fp, sp, pc} -.size __longjmp,.-__longjmp; + +.size __longjmp,.-__longjmp diff --git a/libc/sysdeps/linux/arm/bits/kernel_stat.h b/libc/sysdeps/linux/arm/bits/kernel_stat.h index bfef64cea..70d268c19 100644 --- a/libc/sysdeps/linux/arm/bits/kernel_stat.h +++ b/libc/sysdeps/linux/arm/bits/kernel_stat.h @@ -6,51 +6,68 @@ * different opinion on the subject... */ struct kernel_stat { +#if defined(__ARMEB__) unsigned short st_dev; unsigned short __pad1; +#else + unsigned long st_dev; +#endif unsigned long st_ino; unsigned short st_mode; unsigned short st_nlink; unsigned short st_uid; unsigned short st_gid; +#if defined(__ARMEB__) unsigned short st_rdev; unsigned short __pad2; +#else + unsigned long st_rdev; +#endif unsigned long st_size; unsigned long st_blksize; unsigned long st_blocks; unsigned long st_atime; - unsigned long __unused1; + unsigned long st_atime_nsec; unsigned long st_mtime; - unsigned long __unused2; + unsigned long st_mtime_nsec; unsigned long st_ctime; - unsigned long __unused3; + unsigned long st_ctime_nsec; unsigned long __unused4; unsigned long __unused5; }; +/* see the notes in common/xstatconv.c about why we have these + * funky funk unions here ... i blame the schools */ struct kernel_stat64 { - unsigned short st_dev; - unsigned char __pad0[10]; + unsigned long long st_dev; + unsigned char __pad0[4]; + #define _HAVE_STAT64___ST_INO - unsigned long __st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned long st_uid; - unsigned long st_gid; - unsigned short st_rdev; - unsigned char __pad3[10]; - long long st_size; - unsigned long st_blksize; - unsigned long st_blocks; /* Number 512-byte blocks allocated. */ - unsigned long __pad4; /* future possible st_blocks high bits */ - unsigned long st_atime; - unsigned long __pad5; - unsigned long st_mtime; - unsigned long __pad6; - unsigned long st_ctime; - unsigned long __pad7; /* will be high 32 bits of ctime someday */ - unsigned long long st_ino; -}; + unsigned long __st_ino; + unsigned int st_mode; + unsigned int st_nlink; + unsigned long st_uid; + unsigned long st_gid; -#endif /* _BITS_STAT_STRUCT_H */ + unsigned long long st_rdev; + unsigned char __pad3[4]; + long long st_size; + unsigned long st_blksize; +#if defined(__ARMEB__) + unsigned long __pad4; /* future possible st_blocks high bits */ + unsigned long st_blocks; /* Number 512-byte blocks allocated. */ +#else + unsigned long st_blocks; /* Number 512-byte blocks allocated. */ + unsigned long __pad4; /* future possible st_blocks high bits */ +#endif + unsigned long st_atime; + unsigned long st_atime_nsec; + unsigned long st_mtime; + unsigned long st_mtime_nsec; + unsigned long st_ctime; + unsigned long st_ctime_nsec; + unsigned long long st_ino; +} __attribute__((packed)); + +#endif /* _BITS_STAT_STRUCT_H */ diff --git a/libc/sysdeps/linux/arm/bsd-_setjmp.S b/libc/sysdeps/linux/arm/bsd-_setjmp.S index 7f092c18b..3f3a986b3 100644 --- a/libc/sysdeps/linux/arm/bsd-_setjmp.S +++ b/libc/sysdeps/linux/arm/bsd-_setjmp.S @@ -25,10 +25,15 @@ #define _ASM #include <bits/setjmp.h> -.globl _setjmp; +.global _setjmp .type _setjmp,%function -.align 4; +.align 4 _setjmp: mov r1, #0 - b __sigsetjmp (PLT) -.size _setjmp,.-_setjmp; +#ifdef __PIC__ + b __sigsetjmp(PLT) +#else + b __sigsetjmp +#endif + +.size _setjmp,.-_setjmp diff --git a/libc/sysdeps/linux/arm/bsd-setjmp.S b/libc/sysdeps/linux/arm/bsd-setjmp.S index 16f077a79..3e5ff59fa 100644 --- a/libc/sysdeps/linux/arm/bsd-setjmp.S +++ b/libc/sysdeps/linux/arm/bsd-setjmp.S @@ -25,10 +25,15 @@ #define _ASM #include <bits/setjmp.h> -.globl setjmp; +.global setjmp .type setjmp,%function -.align 4; +.align 4 setjmp: mov r1, #1 - b __sigsetjmp (PLT) -.size setjmp,.-setjmp; +#ifdef __PIC__ + b __sigsetjmp(PLT) +#else + b __sigsetjmp +#endif + +.size setjmp,.-setjmp diff --git a/libc/sysdeps/linux/arm/clone.S b/libc/sysdeps/linux/arm/clone.S index f417be07f..a4d5f99bd 100644 --- a/libc/sysdeps/linux/arm/clone.S +++ b/libc/sysdeps/linux/arm/clone.S @@ -20,21 +20,23 @@ /* clone() is even more special than fork() as it mucks with stacks and invokes a function in the right context after its all over. */ -#include <asm/errno.h> +#define _ERRNO_H +#include <bits/errno.h> #include <sys/syscall.h> +#ifdef __NR_clone /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */ .text -.globl __clone; +.global __clone .type __clone,%function -.align 4; +.align 4 __clone: @ sanity check args cmp r0, #0 cmpne r1, #0 moveq r0, #-EINVAL - beq __syscall_error (PLT) + beq __error @ insert the args onto the new stack sub r1, r1, #8 @@ -48,7 +50,7 @@ __clone: @ new sp is already in r1 swi __NR_clone movs a1, a1 - blt __syscall_error (PLT) + blt __error movne pc, lr @ pick the function arg and call address off the stack and execute @@ -57,25 +59,18 @@ __clone: ldr pc, [sp] @ and we are done, passing the return value through r0 - b _exit (PLT) +#ifdef __PIC__ + b _exit(PLT) +#else + b _exit +#endif -__syscall_error: - /* Looks like the syscall choked -- set errno */ - ldr r3, .L4 - /* Calculate the - of the syscall result, in case we need it */ - rsb r2, r0, $0 +__error: + b __syscall_error - /* errno = -result */ - str r2, [r9,r3] +.size __clone,.-__clone - /* return -1 */ - mvn r0, $0 - mov pc, lr -.size __clone,.-__clone; - -.L4: .word errno - - -.globl clone; - clone = __clone +.weak clone + clone = __clone +#endif diff --git a/libc/sysdeps/linux/arm/crt0.S b/libc/sysdeps/linux/arm/crt0.S deleted file mode 100644 index f58885d17..000000000 --- a/libc/sysdeps/linux/arm/crt0.S +++ /dev/null @@ -1,150 +0,0 @@ -/* When we enter this piece of code, the program stack looks like this: - argc argument counter (integer) - argv[0] program name (pointer) - argv[1...N] program args (pointers) - argv[argc-1] end of args (integer) - NULL - env[0...N] environment variables (pointers) - NULL - - For uClinux it looks like this: - - argc argument counter (integer) - argv char *argv[] - envp char *envp[] - argv[0] program name (pointer) - argv[1...N] program args (pointers) - argv[argc-1] end of args (integer) - NULL - env[0...N] environment variables (pointers) - NULL - - When we are done here, we want - a1=argc - a2=argv[0] - a3=argv[argc+1] - -ARM register quick reference: - - Name Number ARM Procedure Calling Standard Role - - a1 r0 argument 1 / integer result / scratch register / argc - a2 r1 argument 2 / scratch register / argv - a3 r2 argument 3 / scratch register / envp - a4 r3 argument 4 / scratch register - v1 r4 register variable - v2 r5 register variable - v3 r6 register variable - v4 r7 register variable - v5 r8 register variable - sb/v6 r9 static base / register variable - sl/v7 r10 stack limit / stack chunk handle / reg. variable - fp r11 frame pointer - ip r12 scratch register / new-sb in inter-link-unit calls - sp r13 lower end of current stack frame - lr r14 link address / scratch register - pc r15 program counter -*/ - -#include <features.h> - -.text - .global _start - .type _start,%function -#if defined L_crt0 || ! defined __UCLIBC_CTOR_DTOR__ - .type __uClibc_main,%function -#else - .weak _init - .weak _fini - .type __uClibc_start_main,%function -#endif -/* Stick in a dummy reference to main(), so that if an application - * is linking when the main() function is in a static library (.a) - * we can be sure that main() actually gets linked in */ - .type main,%function - - -.text -_start: - /* clear the frame pointer */ - mov fp, #0 - -#ifdef __ARCH_HAS_MMU__ - /* Load register r0 (argc) from the stack to its final resting place */ - ldr r0, [sp], #4 - - /* Copy argv pointer into r1 -- which its final resting place */ - mov r1, sp - - /* Skip to the end of argv and put a pointer to whatever - we find there (hopefully the environment) in r2 */ - add r2, r1, r0, lsl #2 - add r2, r2, #4 - -#else - /* - * uClinux stacks look a little different from normal - * MMU-full Linux stacks (for no good reason) - */ - /* pull argc, argv and envp off the stack */ - ldr r0,[sp, #0] - ldr r1,[sp, #4] - ldr r2,[sp, #8] -#endif - -#if (defined L_crt1 ) && defined __UCLIBC_CTOR_DTOR__ -#ifdef __PIC__ - /* Store the address of _init in r3 as an argument to main() */ - adr r5, .L_init - ldr r3, .L_init - add r3, r3, r5 - - /* Push _fini onto the stack as the final argument to main() */ - ldr r4, .L_init + 4 - add r4, r4, r5 -#else - /* Store the address of _init in r3 as an argument to main() */ - ldr r3, =_init - - /* Push _fini onto the stack as the final argument to main() */ - ldr r4, =_fini -#endif - stmfd sp!, {r4} - - /* Ok, now run uClibc's main() -- shouldn't return */ - bl __uClibc_start_main -#else - bl __uClibc_main -#endif - - /* Crash if somehow `exit' returns anyways. */ - bl abort - -#if (defined L_crt1 ) && defined __UCLIBC_CTOR_DTOR__ && defined __PIC__ -.L_init: - .word _init - .L_init - .word _fini - .L_init -#endif - -/* We need this stuff to make gdb behave itself, otherwise - gdb will chokes with SIGILL when trying to debug apps. -*/ - .section ".note.ABI-tag", "a" - .align 4 - .long 1f - 0f - .long 3f - 2f - .long 1 -0: .asciz "GNU" -1: .align 4 -2: .long 0 - .long 2,0,0 -3: .align 4 - -/* Define a symbol for the first piece of initialized data. */ - .data - .globl __data_start -__data_start: - .long 0 - .weak data_start - data_start = __data_start - diff --git a/libc/sysdeps/linux/arm/mmap64.S b/libc/sysdeps/linux/arm/mmap64.S index 0da4afbb0..63b02f9df 100644 --- a/libc/sysdeps/linux/arm/mmap64.S +++ b/libc/sysdeps/linux/arm/mmap64.S @@ -16,20 +16,18 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#define _ERRNO_H 1 #include <features.h> +#define _ERRNO_H #include <bits/errno.h> #include <sys/syscall.h> #if defined __UCLIBC_HAS_LFS__ && defined __NR_mmap2 - - /* The mmap2 system call takes six arguments, all in registers. */ - .text - .global mmap64; - .type mmap64,%function - .align 4; - +/* The mmap2 system call takes six arguments, all in registers. */ +.text +.global mmap64 +.type mmap64,%function +.align 4 mmap64: stmfd sp!, {r4, r5, lr} ldr r5, [sp, $16] @@ -47,33 +45,26 @@ mmap64: ldmccfd sp!, {r4, r5, pc} cmn r0, $ENOSYS ldmnefd sp!, {r4, r5, lr} - bne __syscall_error (PLT) + bne __error /* The current kernel does not support mmap2. Fall back to plain mmap if the offset is small enough. */ ldr r5, [sp, $20] mov r0, ip @ first arg was clobbered teq r5, $0 ldmeqfd sp!, {r4, r5, lr} - beq mmap (PLT) +#ifdef __PIC__ + beq mmap(PLT) +#else + beq mmap +#endif .Linval: mov r0, $-EINVAL ldmfd sp!, {r4, r5, lr} - b __syscall_error (PLT) - -__syscall_error: - /* Looks like the syscall choked -- set errno */ - ldr r3, .L4 - /* Calculate the - of the syscall result, in case we need it */ - rsb r2, r0, $0 - - /* errno = -result */ - str r2, [r9,r3] + b __error - /* return -1 */ - mvn r0, $0 - mov pc, lr -.size mmap64,.-mmap64; +__error: + b __syscall_error -.L4: .word errno +.size mmap64,.-mmap64 #endif diff --git a/libc/sysdeps/linux/arm/setjmp.S b/libc/sysdeps/linux/arm/setjmp.S index 402a66422..62d038cc5 100644 --- a/libc/sysdeps/linux/arm/setjmp.S +++ b/libc/sysdeps/linux/arm/setjmp.S @@ -22,9 +22,9 @@ #define _ASM #include <bits/setjmp.h> -.globl __sigsetjmp; +.global __sigsetjmp .type __sigsetjmp,%function -.align 4; +.align 4 __sigsetjmp: /* Save registers */ #if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__ @@ -38,5 +38,10 @@ __sigsetjmp: sub r0, r0, #48 /* Make a tail call to __sigjmp_save; it takes the same args. */ - B __sigjmp_save (PLT) -.size __sigsetjmp,.-__sigsetjmp; +#ifdef __PIC__ + B __sigjmp_save(PLT) +#else + B __sigjmp_save +#endif + +.size __sigsetjmp,.-__sigsetjmp diff --git a/libc/sysdeps/linux/arm/sigrestorer.S b/libc/sysdeps/linux/arm/sigrestorer.S index a90881eb0..b4e17326b 100644 --- a/libc/sysdeps/linux/arm/sigrestorer.S +++ b/libc/sysdeps/linux/arm/sigrestorer.S @@ -22,18 +22,18 @@ one of these. This avoids the need for the kernel to synthesise a return instruction on the stack, which would involve expensive cache flushes. */ -.globl __default_sa_restorer; +.global __default_sa_restorer .type __default_sa_restorer,%function -.align 4; +.align 4 __default_sa_restorer: swi __NR_sigreturn #ifdef __NR_rt_sigreturn -.globl __default_rt_sa_restorer; +.global __default_rt_sa_restorer .type __default_rt_sa_restorer,%function -.align 4; +.align 4 __default_rt_sa_restorer: swi __NR_rt_sigreturn diff --git a/libc/sysdeps/linux/arm/vfork.S b/libc/sysdeps/linux/arm/vfork.S index 9d18945d1..cf9d3d8d6 100644 --- a/libc/sysdeps/linux/arm/vfork.S +++ b/libc/sysdeps/linux/arm/vfork.S @@ -20,52 +20,37 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <asm/errno.h> +#define _ERRNO_H +#include <bits/errno.h> #include <sys/syscall.h> - - - .text - .global vfork; - .type vfork,%function - .align 4; \ - - - +#ifdef __NR_fork +.text +.global vfork +.type vfork,%function +.align 4 vfork: #ifdef __NR_vfork - swi __NR_vfork - cmn r0, #4096 - movcc pc, lr - - /* Check if vfork even exists. */ - ldr r1, =-ENOSYS - teq r0, r1 - bne __syscall_error + swi __NR_vfork + cmn r0, #4096 + movcc pc, lr + + /* Check if vfork even exists. */ + ldr r1, =-ENOSYS + teq r0, r1 + bne __error #endif - /* If we don't have vfork, use fork. */ - swi __NR_fork - cmn r0, #4096 + /* If we don't have vfork, use fork. */ + swi __NR_fork + cmn r0, #4096 - /* Syscal worked. Return to child/parent */ - movcc pc, lr - -__syscall_error: - - /* Looks like the syscall choked -- set errno */ - ldr r3, .L4 - /* Calculate the - of the syscall result, in case we need it */ - rsb r2, r0, $0 - - /* errno = -result */ - str r2, [r9,r3] - - /* return -1 */ - mvn r0, $0 - mov pc, lr - -.L4: .word errno + /* Syscal worked. Return to child/parent */ + movcc pc, lr +__error: + b __syscall_error +.size vfork,.-vfork +#endif diff --git a/libc/sysdeps/linux/i386/Makefile b/libc/sysdeps/linux/i386/Makefile index d9bf0239a..fc13e6f45 100644 --- a/libc/sysdeps/linux/i386/Makefile +++ b/libc/sysdeps/linux/i386/Makefile @@ -19,17 +19,16 @@ TOPDIR=../../../../ include $(TOPDIR)Rules.mak -CRT0_SRC = crt0.S -CRT0_OBJ = crt0.o crt1.o -SCRT0_OBJ = $(patsubst %,S%, $(CRT0_OBJ)) -CRT0_DEPS=gmon-start.S +CRT_SRC = crt1.S +CRT_OBJ = crt1.o +SCRT_OBJ = $(patsubst %,S%, $(CRT_OBJ)) CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o SSRC=__longjmp.S vfork.S clone.S setjmp.S bsd-setjmp.S \ bsd-_setjmp.S syscall.S mmap64.S SOBJS=$(patsubst %.S,%.o, $(SSRC)) -CSRC=brk.c sigaction.c +CSRC=brk.c sigaction.c __syscall_error.c COBJS=$(patsubst %.c,%.o, $(CSRC)) OBJS=$(SOBJS) $(COBJS) @@ -38,21 +37,16 @@ OBJ_LIST=../../../obj.sysdeps.$(TARGET_ARCH) all: $(OBJ_LIST) -$(OBJ_LIST): $(OBJS) $(CRT0_OBJ) $(SCRT0_OBJ) $(CTOR_TARGETS) +$(OBJ_LIST): $(OBJS) $(CRT_OBJ) $(SCRT_OBJ) $(CTOR_TARGETS) echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $(OBJ_LIST) $(INSTALL) -d $(TOPDIR)lib/ - cp $(CRT0_OBJ) $(SCRT0_OBJ) $(TOPDIR)lib/ -ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) - $(RM) $(TOPDIR)lib/Scrt0.o -else - mv $(TOPDIR)lib/Scrt0.o $(TOPDIR)lib/Scrt1.o -endif + cp $(CRT_OBJ) $(SCRT_OBJ) $(TOPDIR)lib/ -$(CRT0_OBJ): $(CRT0_SRC) +$(CRT_OBJ): $(CRT_SRC) $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o $(STRIPTOOL) -x -R .note -R .comment $*.o -$(SCRT0_OBJ): $(CRT0_SRC) +$(SCRT_OBJ): $(CRT_SRC) $(CC) $(ASFLAGS) $(PIEFLAG) -DL_$* $< -c -o $*.o $(STRIPTOOL) -x -R .note -R .comment $*.o @@ -94,4 +88,3 @@ clean: $(RM) *.[oa] *~ core $(RM) bits/sysnum.h $(RM) $(TOPDIR)/include/fpu_control.h - $(RM) gmon-start.S diff --git a/libc/sysdeps/linux/i386/__longjmp.S b/libc/sysdeps/linux/i386/__longjmp.S index 484a564c3..52f53bb68 100644 --- a/libc/sysdeps/linux/i386/__longjmp.S +++ b/libc/sysdeps/linux/i386/__longjmp.S @@ -21,20 +21,20 @@ #define _SETJMP_H #include <bits/setjmp.h> -.globl __longjmp; -.type __longjmp,@function -.align 4; \ +.global __longjmp +.type __longjmp,%function +.align 4 __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. */ + /* 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; + jmp *%edx +.size __longjmp,.-__longjmp diff --git a/libc/sysdeps/linux/i386/bsd-_setjmp.S b/libc/sysdeps/linux/i386/bsd-_setjmp.S index 73d90eb4e..ac2c8930d 100644 --- a/libc/sysdeps/linux/i386/bsd-_setjmp.S +++ b/libc/sysdeps/linux/i386/bsd-_setjmp.S @@ -25,27 +25,23 @@ #define _SETJMP_H #include <bits/setjmp.h> - -.globl _setjmp; -.type _setjmp,@function -.align 4; - +.global _setjmp +.type _setjmp,%function +.align 4 _setjmp: xorl %eax, %eax movl 4 (%esp), %edx - /* Save registers. */ + /* Save registers. */ movl %ebx, (JB_BX*4)(%edx) movl %esi, (JB_SI*4)(%edx) movl %edi, (JB_DI*4)(%edx) leal 4 (%esp), %ecx /* Save SP as it will be after we return. */ - movl %ecx, (JB_SP*4)(%edx) + movl %ecx, (JB_SP*4)(%edx) movl 0 (%esp), %ecx /* Save PC we are returning to now. */ - movl %ecx, (JB_PC*4)(%edx) + movl %ecx, (JB_PC*4)(%edx) movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer. */ movl %eax, JB_SIZE(%edx) /* No signal mask set. */ ret -.size _setjmp,.-_setjmp; - - +.size _setjmp,.-_setjmp diff --git a/libc/sysdeps/linux/i386/bsd-setjmp.S b/libc/sysdeps/linux/i386/bsd-setjmp.S index c075bada0..532dfa1bd 100644 --- a/libc/sysdeps/linux/i386/bsd-setjmp.S +++ b/libc/sysdeps/linux/i386/bsd-setjmp.S @@ -21,32 +21,32 @@ #define _SETJMP_H #include <bits/setjmp.h> -.globl setjmp; -.type setjmp,@function -.align 4; +.global setjmp +.type setjmp,%function +.align 4 setjmp: - movl 4 (%esp), %eax + movl 4 (%esp), %eax /* Save registers. */ - movl %ebx, (0 *4)(%eax) - movl %esi, (1 *4)(%eax) - movl %edi, (2 *4)(%eax) + movl %ebx, (0 *4)(%eax) + movl %esi, (1 *4)(%eax) + movl %edi, (2 *4)(%eax) /* Save SP as it will be after we return. */ - leal 4 (%esp), %ecx - movl %ecx, (4 *4)(%eax) + leal 4 (%esp), %ecx + movl %ecx, (4 *4)(%eax) /* Save PC we are returning to now. */ - movl 0 (%esp), %ecx - movl %ecx, (5 *4)(%eax) + movl 0 (%esp), %ecx + movl %ecx, (5 *4)(%eax) /* Save caller's frame pointer. */ - movl %ebp, (3 *4)(%eax) + movl %ebp, (3 *4)(%eax) /* Call __sigjmp_save. */ pushl $1 pushl 8(%esp) #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. */ + 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 here2 here2: popl %ecx addl $_GLOBAL_OFFSET_TABLE_+[.-here2], %ecx @@ -58,4 +58,4 @@ here2: popl %ecx popl %ecx popl %edx ret -.size setjmp,.-setjmp; +.size setjmp,.-setjmp diff --git a/libc/sysdeps/linux/i386/clone.S b/libc/sysdeps/linux/i386/clone.S index 1ba3bcc48..fbbb7d4cf 100644 --- a/libc/sysdeps/linux/i386/clone.S +++ b/libc/sysdeps/linux/i386/clone.S @@ -1,4 +1,4 @@ -/* Copyright (C) 1996,1997,98,99,2000,02,03 Free Software Foundation, Inc. +/* Copyright (C) 1996-2000,02,03,04,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Richard Henderson (rth@tamu.edu) @@ -24,8 +24,8 @@ */ #define _ERRNO_H 1 -#include <features.h> #include <bits/errno.h> +#include <sys/syscall.h> /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg, pid_t *ptid, struct user_desc *tls, pid_t *ctid); */ @@ -41,32 +41,35 @@ #define TLS PTID+PTR_SIZE #define CTID TLS+PTR_SIZE -#define __NR_clone 120 -#define __NR_exit 1 - .text -.type clone,@function; -.weak clone ; clone = __clone - -.type __clone,@function; -.globl __clone; - +.global __clone +.type __clone,%function __clone: /* Sanity check arguments. */ movl $-EINVAL,%eax /* no NULL function pointers */ movl FUNC(%esp),%ecx - jecxz .Lclone_error +#ifdef __PIC__ + jecxz __error +#else + testl %ecx,%ecx + jz __error +#endif /* no NULL stack pointers */ movl STACK(%esp),%ecx - jecxz .Lclone_error +#ifdef __PIC__ + jecxz __error +#else + testl %ecx,%ecx + jz __error +#endif /* Insert the argument onto the new stack. Make sure the new thread is started with an alignment of (mod 16). */ andl $0xfffffff0, %ecx - subl $24,%ecx + subl $28,%ecx movl ARG(%esp),%eax /* no negative argument counts */ movl %eax,12(%ecx) @@ -93,14 +96,13 @@ __clone: popl %ebx test %eax,%eax - jl .Lclone_error + jl __error jz .Lthread_start - -.Lpseudo_end: ret .Lthread_start: - subl %ebp,%ebp /* terminate the stack frame */ + /* Note: %esi is zero. */ + movl %esi,%ebp /* terminate the stack frame */ call *%ebx #ifdef __PIC__ call .Lhere @@ -112,38 +114,10 @@ __clone: movl $__NR_exit, %eax int $0x80 -#ifdef __PIC__ - -.Lthere: - movl (%esp), %ebx - ret - -.Lclone_error: - pushl %ebx - call .Lthere - addl $_GLOBAL_OFFSET_TABLE_, %ebx - xorl %edx, %edx - subl %eax, %edx - pushl %edx - call __errno_location@PLT - popl %ecx - popl %ebx - movl %ecx, (%eax) - orl $-1, %eax - jmp .Lpseudo_end - -#else /* __PIC__ */ - -.Lclone_error: - negl %eax - pushl %eax - call __errno_location - popl %ecx - movl %ecx, (%eax) - xorl %eax, %eax - decl %eax - -#endif +__error: + jmp __syscall_error .size __clone,.-__clone +.weak clone + clone = __clone diff --git a/libc/sysdeps/linux/i386/crt0.S b/libc/sysdeps/linux/i386/crt0.S deleted file mode 100644 index 735d5167f..000000000 --- a/libc/sysdeps/linux/i386/crt0.S +++ /dev/null @@ -1,132 +0,0 @@ -/* Copyright (C) 1991, 1992 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., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - - -/* Based on the code from GNU libc, but hacked up by John Beppu and Erik Andersen */ -/* adapted by PaX Team for ET_DYN/PIE binaries */ - -/* - When we enter this piece of code, the program stack looks like this: - argc argument counter (integer) - argv[0] program name (pointer) - argv[1...N] program args (pointers) - argv[argc-1] end of args (integer) - NULL - env[0...N] environment variables (pointers) - NULL -*/ - -#include <features.h> - -.text - .align 4 - - .global _start - .type _start,%function -#if defined L_crt0 || defined L_Scrt0 || ! defined __UCLIBC_CTOR_DTOR__ - .type __uClibc_main,%function -#else - .weak _init - .weak _fini - .type __uClibc_start_main,%function -#endif -/* Stick in a dummy reference to main(), so that if an application - * is linking when the main() function is in a static library (.a) - * we can be sure that main() actually gets linked in */ - .type main,%function - -_start: - /* locate the start of the environment variables */ - popl %ecx /* Store argc into %ecx */ - movl %esp,%ebx /* Store argv into ebx */ - movl %esp,%eax /* Store argv into eax as well*/ - movl %edx,%esi /* Store edx(FINI ptr) in %esi */ - movl %ecx,%edx /* Stick argc into %edx so we can do some math in a sec */ - leal 4(%eax,%edx,4),%eax - - /* [ register layout ] - - sizeof(char*) == 4 - %ecx = argc ; 0(esp) - %ebx = argv ; 4(esp) - %eax = env ; argv + (argc * 4) + 4 - */ - - /* Set up an invalid (NULL return address, NULL frame pointer) - callers stack frame so anybody unrolling the stack knows where - to stop */ - xorl %ebp,%ebp /* NULL */ - pushl %ebp /* callers %cs */ - pushl %ebp /* callers %eip (return address) */ - pushl %ebp /* callers %ebp (frame pointer) */ - movl %esp,%ebp /* mark callers stack frame as invalid */ - -#if defined L_Scrt0 || defined L_Scrt1 - call .L0 -.L0: - pop %edx - addl $_GLOBAL_OFFSET_TABLE_+[.-.L0],%edx -#endif - pushl %esi /* Push FINI pointer */ -#if (defined L_crt1 || defined L_Scrt1) && defined __UCLIBC_CTOR_DTOR__ - /* Push .init and .fini arguments to __uClibc_start_main() on the stack */ -#ifdef L_Scrt1 - pushl _fini@GOT(%edx) - pushl _init@GOT(%edx) -#else - pushl $_fini - pushl $_init -#endif - - /* Push envp, argc, and argc arguments to __uClibc_start_main() on the stack */ - pushl %eax /* Environment pointer */ - pushl %ebx /* Argument pointer */ - pushl %ecx /* And the argument count */ - - /* Ok, now run uClibc's main() -- shouldn't return */ -#ifdef L_Scrt1 - call *__uClibc_start_main@GOT(%edx) -#else - call __uClibc_start_main -#endif -#else - /* Push envp, argc, and argc arguments to __uClibc_start_main() on the stack */ - pushl %eax /* Environment pointer */ - pushl %ebx /* Argument pointer */ - pushl %ecx /* And the argument count */ - -#ifdef L_Scrt0 - call *__uClibc_main@GOT(%edx) -#else - call __uClibc_main -#endif -#endif - - /* Crash if somehow `exit' returns anyways. */ - hlt -.size _start,.-_start - - -/* Define a symbol for the first piece of initialized data. */ - .data - .globl __data_start -__data_start: - .long 0 - .weak data_start - data_start = __data_start - diff --git a/libc/sysdeps/linux/i386/crti.S b/libc/sysdeps/linux/i386/crti.S index cd0194975..7dbaaadcb 100644 --- a/libc/sysdeps/linux/i386/crti.S +++ b/libc/sysdeps/linux/i386/crti.S @@ -1,6 +1,6 @@ - .section .init -.globl _init - .type _init, @function +.section .init +.global _init +.type _init,%function _init: pushl %ebp movl %esp, %ebp @@ -10,10 +10,9 @@ _init: - - .section .fini -.globl _fini - .type _fini, @function +.section .fini +.global _fini +.type _fini,%function _fini: pushl %ebp movl %esp, %ebp @@ -23,10 +22,10 @@ _fini: - .section .gnu.linkonce.t.__get_pc_thunk_bx,"ax",@progbits -.globl __get_pc_thunk_bx - .hidden __get_pc_thunk_bx - .type __get_pc_thunk_bx, @function +.section .gnu.linkonce.t.__get_pc_thunk_bx,"ax",@progbits +.global __get_pc_thunk_bx +.hidden __get_pc_thunk_bx +.type __get_pc_thunk_bx,%function __get_pc_thunk_bx: movl (%esp), %ebx ret diff --git a/libc/sysdeps/linux/i386/crtn.S b/libc/sysdeps/linux/i386/crtn.S index 8554b9b2e..191250487 100644 --- a/libc/sysdeps/linux/i386/crtn.S +++ b/libc/sysdeps/linux/i386/crtn.S @@ -1,27 +1,29 @@ - .file "initfini.c" - .section .init -.globl _init - .type _init, @function +.file "initfini.c" + +.section .init +.global _init +.type _init,%function popl %ebx popl %ebp ret - .size _init, .-_init +.size _init,.-_init + - .section .fini -.globl _fini - .type _fini, @function +.section .fini +.global _fini +.type _fini,%function popl %ebx popl %ebp ret - .size _fini, .-_fini +.size _fini,.-_fini - .section .gnu.linkonce.t.__get_pc_thunk_bx,"ax",@progbits -.globl __get_pc_thunk_bx - .hidden __get_pc_thunk_bx - .type __get_pc_thunk_bx, @function +.section .gnu.linkonce.t.__get_pc_thunk_bx,"ax",@progbits +.global __get_pc_thunk_bx +.hidden __get_pc_thunk_bx +.type __get_pc_thunk_bx,%function __get_pc_thunk_bx: movl (%esp), %ebx ret diff --git a/libc/sysdeps/linux/i386/mmap64.S b/libc/sysdeps/linux/i386/mmap64.S index 141b839eb..34cee1640 100644 --- a/libc/sysdeps/linux/i386/mmap64.S +++ b/libc/sysdeps/linux/i386/mmap64.S @@ -37,10 +37,10 @@ #define OFFLO FD+4 #define OFFHI OFFLO+4 - .text - .globl mmap64; - .type mmap64,@function; - .align 1<<4; +.text +.global mmap64 +.type mmap64,%function +.align 1<<4 mmap64: /* Save registers. */ @@ -65,6 +65,7 @@ mmap64: movl FD(%esp), %edi movl $__NR_mmap2, %eax /* System call number in %eax. */ + /* Do the system call trap. */ int $0x80 /* Restore registers. */ @@ -75,7 +76,8 @@ mmap64: /* If 0 > %eax > -4096 there was an error. */ cmpl $-4095,%eax - jae __syscall_error + ja __error + /* Successful; return the syscall's value. */ ret /* This means the offset value is too large. */ @@ -85,28 +87,11 @@ L_einval: popl %ebx popl %ebp movl $-EINVAL, %eax - jmp __syscall_error - - -__syscall_error: - negl %eax - pushl %eax -#ifdef __PIC__ - call .Lthere -.Lthere: - popl %ebx - addl $_GLOBAL_OFFSET_TABLE_+[.- .Lthere ], %ebx - call __errno_location@PLT -#else - call __errno_location -#endif - popl %ecx - movl %ecx, (%eax) - xorl %eax, %eax - decl %eax + jmp __error -.Lsize: - .size mmap64,.Lsize-mmap64 +__error: + jmp __syscall_error -#endif +.size mmap64,.-mmap64 +#endif diff --git a/libc/sysdeps/linux/i386/setjmp.S b/libc/sysdeps/linux/i386/setjmp.S index ef9deebd6..917ee283b 100644 --- a/libc/sysdeps/linux/i386/setjmp.S +++ b/libc/sysdeps/linux/i386/setjmp.S @@ -22,9 +22,9 @@ #include <bits/setjmp.h> -.globl __sigsetjmp; -.type __sigsetjmp,@function -.align 4; +.global __sigsetjmp +.type __sigsetjmp,%function +.align 4 __sigsetjmp: movl 4 (%esp), %eax @@ -56,4 +56,4 @@ __sigsetjmp: #else jmp __sigjmp_save #endif -.size __sigsetjmp,.-__sigsetjmp; +.size __sigsetjmp,.-__sigsetjmp diff --git a/libc/sysdeps/linux/i386/syscall.S b/libc/sysdeps/linux/i386/syscall.S index 69cafd4fe..44eb00f49 100644 --- a/libc/sysdeps/linux/i386/syscall.S +++ b/libc/sysdeps/linux/i386/syscall.S @@ -19,58 +19,36 @@ * syscall(__NR_exit, 42); * and things will just work. */ - + .text - .align 4 -.globl syscall - .type syscall,@function +.global syscall +.type syscall,%function +.align 4 syscall: + pushl %ebp pushl %edi pushl %esi pushl %ebx - movl 36(%esp),%edi; /* Load the 5 syscall argument registers */ - movl 32(%esp),%esi; - movl 28(%esp),%edx; - movl 24(%esp),%ecx; - movl 20(%esp),%ebx; - movl 16(%esp),%eax /* Load syscall number into %eax. */ -#APP - int $0x80 -#NO_APP - cmpl $-4095,%eax - jbe .Ldone - -#ifdef __PIC__ - call Lhere -Lhere: - popl %ebx - addl $_GLOBAL_OFFSET_TABLE_+[.-Lhere],%ebx - negl %eax - movl %eax,%ecx -#ifdef __UCLIBC_HAS_THREADS__ - call __errno_location@PLT -#else - movl errno@GOT(%ebx),%eax -#endif /* __UCLIBC_HAS_THREADS__ */ - movl %ecx,(%eax) -#else - negl %eax -#ifdef __UCLIBC_HAS_THREADS__ - movl %eax,%ecx - call __errno_location - movl %ecx,(%eax) -#else - movl %eax,errno -#endif /* __UCLIBC_HAS_THREADS__ */ -#endif /* __PIC__ */ + movl 44(%esp),%ebp /* Load the 6 syscall argument registers */ + movl 40(%esp),%edi + movl 36(%esp),%esi + movl 32(%esp),%edx + movl 28(%esp),%ecx + movl 24(%esp),%ebx + movl 20(%esp),%eax /* Load syscall number into %eax. */ + int $0x80 - movl $-1,%eax - .p2align 4,,7 -.Ldone: popl %ebx popl %esi popl %edi - ret -.Lsize: - .size syscall,.Lsize-syscall + popl %ebp + + cmpl $-4095,%eax + jae __error + ret /* Return to caller. */ + +__error: + jmp __syscall_error + +.size syscall,.-syscall diff --git a/libc/sysdeps/linux/i386/vfork.S b/libc/sysdeps/linux/i386/vfork.S index d340a983d..19c1210cb 100644 --- a/libc/sysdeps/linux/i386/vfork.S +++ b/libc/sysdeps/linux/i386/vfork.S @@ -3,8 +3,6 @@ * */ -#define _ERRNO_H 1 -#include <bits/errno.h> #include <sys/syscall.h> #ifndef __NR_vfork @@ -14,39 +12,24 @@ #else - .text - .globl __vfork; - .type __vfork,@function; - .align 1<<4; - +.text +.global __vfork +.type __vfork,%function +.align 1<<4 + __vfork: popl %ecx movl $__NR_vfork,%eax int $0x80 pushl %ecx cmpl $-4095,%eax - jae __syscall_error + jae __error ret -__syscall_error: - negl %eax - pushl %eax -#ifdef __PIC__ - call .Lthere -.Lthere: - popl %ebx - addl $_GLOBAL_OFFSET_TABLE_+[.- .Lthere ], %ebx - call __errno_location@PLT -#else - call __errno_location -#endif - popl %ecx - movl %ecx, (%eax) - xorl %eax, %eax - decl %eax +__error: + jmp __syscall_error -.Lsize: - .size __vfork,.Lsize-__vfork +.size __vfork,.-__vfork .weak vfork ; vfork = __vfork diff --git a/libc/sysdeps/linux/powerpc/Makefile b/libc/sysdeps/linux/powerpc/Makefile index 25cb7047d..eb212bac0 100644 --- a/libc/sysdeps/linux/powerpc/Makefile +++ b/libc/sysdeps/linux/powerpc/Makefile @@ -19,10 +19,9 @@ TOPDIR=../../../../ include $(TOPDIR)Rules.mak -CRT0_SRC = crt0.S -CRT0_OBJ = crt0.o crt1.o -SCRT0_OBJ = $(patsubst %,S%, $(CRT0_OBJ)) -CRT0_DEPS=gmon-start.S +CRT_SRC = crt1.S +CRT_OBJ = crt1.o +SCRT_OBJ = $(patsubst %,S%, $(CRT_OBJ)) CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o SSRC=__longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S brk.S \ @@ -38,21 +37,16 @@ OBJ_LIST=../../../obj.sysdeps.$(TARGET_ARCH) all: $(OBJ_LIST) -$(OBJ_LIST): $(OBJS) $(CRT0_OBJ) $(SCRT0_OBJ) $(CTOR_TARGETS) +$(OBJ_LIST): $(OBJS) $(CRT_OBJ) $(SCRT_OBJ) $(CTOR_TARGETS) echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $(OBJ_LIST) $(INSTALL) -d $(TOPDIR)lib/ - cp $(CRT0_OBJ) $(SCRT0_OBJ) $(TOPDIR)lib/ -ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) - $(RM) $(TOPDIR)lib/Scrt0.o -else - mv $(TOPDIR)lib/Scrt0.o $(TOPDIR)lib/Scrt1.o -endif + cp $(CRT_OBJ) $(SCRT_OBJ) $(TOPDIR)lib/ -$(CRT0_OBJ): $(CRT0_SRC) +$(CRT_OBJ): $(CRT_SRC) $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o $(STRIPTOOL) -x -R .note -R .comment $*.o -$(SCRT0_OBJ): $(CRT0_SRC) +$(SCRT_OBJ): $(CRT_SRC) $(CC) $(ASFLAGS) $(PIEFLAG) -DL_$* $< -c -o $*.o $(STRIPTOOL) -x -R .note -R .comment $*.o @@ -94,4 +88,3 @@ headers: clean: $(RM) *.[oa] *~ core $(RM) bits/sysnum.h - $(RM) gmon-start.S diff --git a/libc/sysdeps/linux/powerpc/__syscall_error.c b/libc/sysdeps/linux/powerpc/__syscall_error.c index 9ab65ed79..de65a1f39 100644 --- a/libc/sysdeps/linux/powerpc/__syscall_error.c +++ b/libc/sysdeps/linux/powerpc/__syscall_error.c @@ -1,4 +1,4 @@ -/* Wrapper around clone system call. +/* Wrapper for setting errno. Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -18,12 +18,12 @@ 02111-1307 USA. */ #include <errno.h> +#include <features.h> /* This routine is jumped to by all the syscall handlers, to stash * an error number into errno. */ -int __syscall_error (int err_no) +int attribute_hidden __syscall_error(int err_no) { - __set_errno (err_no); + __set_errno(err_no); return -1; } - diff --git a/libc/sysdeps/linux/powerpc/__uClibc_syscall.S b/libc/sysdeps/linux/powerpc/__uClibc_syscall.S index 09bfb89cc..5a14c948c 100644 --- a/libc/sysdeps/linux/powerpc/__uClibc_syscall.S +++ b/libc/sysdeps/linux/powerpc/__uClibc_syscall.S @@ -1,14 +1,12 @@ -.section ".text" + .text .align 2 -.globl __uClibc_syscall + .globl __uClibc_syscall .type __uClibc_syscall,@function __uClibc_syscall: .Lsize: sc bnslr -#ifdef __PIC__ - b __syscall_error@plt -#else + b __syscall_error -#endif + .size __uClibc_syscall,.Lsize-__uClibc_syscall diff --git a/libc/sysdeps/linux/powerpc/bits/syscalls.h b/libc/sysdeps/linux/powerpc/bits/syscalls.h index ac7395097..6168f3906 100644 --- a/libc/sysdeps/linux/powerpc/bits/syscalls.h +++ b/libc/sysdeps/linux/powerpc/bits/syscalls.h @@ -27,10 +27,9 @@ ".align 2\n\t" \ ".globl " __STRINGIFY(name) "\n\t" \ ".type " __STRINGIFY(name) ",@function\n\t" \ - #name":\n\tli 0," __STRINGIFY(__NR_##name) "\n\t" \ + #name":\tli 0," __STRINGIFY(__NR_##name) "\n\t" \ "b " __MAKE_SYSCALL "\n\t" \ - ".Lfe1" __STRINGIFY(name) ":\n\t" \ - ".size\t" __STRINGIFY(name) ",.Lfe1" __STRINGIFY(name) "-" __STRINGIFY(name) "\n" \ + ".size\t" __STRINGIFY(name) ",.""-" __STRINGIFY(name) "\n" \ ) #undef _syscall0 diff --git a/libc/sysdeps/linux/powerpc/brk.S b/libc/sysdeps/linux/powerpc/brk.S index b914ce814..c0b436d96 100644 --- a/libc/sysdeps/linux/powerpc/brk.S +++ b/libc/sysdeps/linux/powerpc/brk.S @@ -24,10 +24,10 @@ #ifdef __NR_brk .comm __curbrk,4,4 - .section ".text" -.globl __brk; -.type __brk, @function; -.align 2; + .text + .globl __brk + .type __brk,@function + .align 2 __brk: stwu r1,-16(r1) @@ -51,13 +51,11 @@ __brk: li r3,0 blelr+ li r3,ENOMEM -#ifdef __PIC__ - b __syscall_error@plt -#else + b __syscall_error -#endif -.size __brk,.-__brk -.weak brk; -brk=__brk + .size __brk,.-__brk + + .weak brk + brk=__brk #endif diff --git a/libc/sysdeps/linux/powerpc/clone.S b/libc/sysdeps/linux/powerpc/clone.S index edce8d569..f7c6bd18e 100644 --- a/libc/sysdeps/linux/powerpc/clone.S +++ b/libc/sysdeps/linux/powerpc/clone.S @@ -30,10 +30,9 @@ int flags [r5], void *arg [r6]); */ #ifdef __NR_clone -.globl __clone; -.type __clone, @function; -.align 2; - + .globl __clone + .type __clone,@function + .align 2 __clone: /* Check for child_stack == NULL || fn == NULL. */ @@ -90,21 +89,15 @@ __clone: lmw r29,16(r1) addi r1,r1,32 bnslr+ -#ifdef __PIC__ - b __syscall_error@plt -#else + b __syscall_error -#endif .Lbadargs: li r3,EINVAL -#ifdef __PIC__ - b __syscall_error@plt -#else + b __syscall_error -#endif -.size __clone,.-__clone -.weak clone; -clone=__clone + .size __clone,.-__clone + .weak clone + clone=__clone #endif diff --git a/libc/sysdeps/linux/powerpc/crt0.S b/libc/sysdeps/linux/powerpc/crt0.S deleted file mode 100644 index d2808a7c1..000000000 --- a/libc/sysdeps/linux/powerpc/crt0.S +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2003 by Erik Andersen - * - * This program 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. - * - * This program 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 this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* Integer registers. */ -#define r0 0 -#define r1 1 -#define r2 2 -#define r3 3 -#define r4 4 -#define r5 5 -#define r6 6 -#define r7 7 -#define r8 8 -#define r9 9 -#define r13 13 -#define r31 31 - -#include <features.h> - - .section ".text" - .globl _start - .type _start,@function -#if defined L_crt0 || defined L_Scrt0 || ! defined __UCLIBC_CTOR_DTOR__ - .type __uClibc_main,%function -#else - .weak _init - .weak _fini - .type __uClibc_start_main,%function -#endif -/* Stick in a dummy reference to main(), so that if an application - * is linking when the main() function is in a static library (.a) - * we can be sure that main() actually gets linked in */ - .type main,%function - -_start: - /* Save the stack pointer, in case we're statically linked under Linux. */ - mr r9,r1 -#if defined L_Scrt0 || defined L_Scrt1 - bl _GLOBAL_OFFSET_TABLE_-4@local - mflr r31 -#endif - /* Set up an initial stack frame, and clear the LR. */ - clrrwi r1,r1,4 - li r0,0 - stwu r1,-16(r1) - mtlr r0 - stw r0,0(r1) - - /* find argc from the stack pointer */ - lwz r3,0(r9) - /* find argv one word offset from the stack pointer */ - addi r4,r9,4 - /* find environment pointer (argv+argc+1) */ - lwz r5,0(r9) - addi r5,r5,1 - rlwinm r5,r5,2,0,29 - add r5,r5,r4 - mr r8,r7 /* Pass _dl_fini from ldso */ - /* Ok, now run uClibc's main() -- shouldn't return */ -#if (defined L_crt1 || defined L_Scrt1) && defined __UCLIBC_CTOR_DTOR__ -# ifdef L_Scrt1 - lwz r6,_init@got(r31) - lwz r7,_fini@got(r31) - b __uClibc_start_main@plt -# else - lis r6,_init@ha # load top 16 bits - addi r6,r6,_init@l # load bottom 16 bits - lis r7,_fini@ha # load top 16 bits of &msg - addi r7,r7,_fini@l # load bottom 16 bits - b __uClibc_start_main -# endif -#else -# ifdef L_Scrt0 - b __uClibc_main@plt -# else - b __uClibc_main -# endif -#endif -.size _start,.-_start - -/* Define a symbol for the first piece of initialized data. */ - .data - .globl __data_start -__data_start: - .long 0 - .weak data_start - data_start = __data_start - diff --git a/libc/sysdeps/linux/powerpc/syscall.S b/libc/sysdeps/linux/powerpc/syscall.S index 71f711931..b85398416 100644 --- a/libc/sysdeps/linux/powerpc/syscall.S +++ b/libc/sysdeps/linux/powerpc/syscall.S @@ -18,14 +18,10 @@ #include <features.h> - .section ".text" - .globl syscall; - .type syscall,@function; - .align 2; - -.globl syscall; -.type syscall,@function; -.align 2; + .text + .globl syscall + .type syscall,@function + .align 2 syscall: mr 0,3 @@ -36,10 +32,7 @@ syscall: mr 7,8 sc bnslr; -#ifdef __PIC__ - b __syscall_error@plt -#else + b __syscall_error -#endif -.size syscall,.-syscall + .size syscall,.-syscall diff --git a/libc/sysdeps/linux/sh/__longjmp.S b/libc/sysdeps/linux/sh/__longjmp.S index 1bab16c94..9e310a283 100644 --- a/libc/sysdeps/linux/sh/__longjmp.S +++ b/libc/sysdeps/linux/sh/__longjmp.S @@ -20,6 +20,7 @@ #define _SETJMP_H #define _ASM #include <bits/setjmp.h> +#include <features.h> /* __longjmp(jmpbuf, val) */ diff --git a/libc/sysdeps/linux/sparc/Makefile b/libc/sysdeps/linux/sparc/Makefile index 0e9ede2f5..8a2549cb2 100644 --- a/libc/sysdeps/linux/sparc/Makefile +++ b/libc/sysdeps/linux/sparc/Makefile @@ -19,15 +19,15 @@ TOPDIR=../../../../ include $(TOPDIR)Rules.mak -CRT0_SRC = crt0.c -CRT0_OBJ = crt0.o crt1.o +CRT_SRC = crt1.S +CRT_OBJ = crt1.o CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o SSRC=__longjmp.S fork.S vfork.S clone.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \ urem.S udiv.S umul.S sdiv.S rem.S SOBJS=$(patsubst %.S,%.o, $(SSRC)) -CSRC=brk.c +CSRC=brk.c __syscall_error.c COBJS=$(patsubst %.c,%.o, $(CSRC)) OBJS=$(SOBJS) $(MOBJ) $(COBJS) @@ -36,12 +36,12 @@ OBJ_LIST=../../../obj.sysdeps.$(TARGET_ARCH) all: $(OBJ_LIST) -$(OBJ_LIST): $(OBJS) $(CRT0_OBJ) $(CTOR_TARGETS) +$(OBJ_LIST): $(OBJS) $(CRT_OBJ) $(CTOR_TARGETS) echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $(OBJ_LIST) $(INSTALL) -d $(TOPDIR)lib/ - cp $(CRT0_OBJ) $(TOPDIR)lib/ + cp $(CRT_OBJ) $(TOPDIR)lib/ -$(CRT0_OBJ): $(CRT0_SRC) +$(CRT_OBJ): $(CRT_SRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(STRIPTOOL) -x -R .note -R .comment $*.o diff --git a/libc/sysdeps/linux/sparc/__longjmp.S b/libc/sysdeps/linux/sparc/__longjmp.S index d6e04bd1e..06828e61e 100644 --- a/libc/sysdeps/linux/sparc/__longjmp.S +++ b/libc/sysdeps/linux/sparc/__longjmp.S @@ -25,29 +25,29 @@ #define ST_FLUSH_WINDOWS 3 #define RW_FP [%fp + 0x48] -.global __longjmp; -.align 4; -__longjmp: ; -.type __longjmp ,@function; +.global __longjmp +.type __longjmp,%function +.align 4 +__longjmp: /* Store our arguments in global registers so we can still - use them while unwinding frames and their register windows. */ + * use them while unwinding frames and their register windows. */ ld ENV(o0,JB_FP), %g3 /* Cache target FP in register %g3. */ mov %o0, %g1 /* ENV in %g1 */ - orcc %o1, %g0, %g2 /* VAL in %g2 */ - be,a 0f /* Branch if zero; else skip delay slot. */ - mov 1, %g2 /* Delay slot only hit if zero: VAL = 1. */ + orcc %o1, %g0, %g2 /* VAL in %g2 */ + be,a 0f /* Branch if zero; else skip delay slot. */ + mov 1, %g2 /* Delay slot only hit if zero: VAL = 1. */ 0: xor %fp, %g3, %o0 add %fp, 512, %o1 andncc %o0, 4095, %o0 bne .Lthread - cmp %o1, %g3 + cmp %o1, %g3 bl .Lthread /* Now we will loop, unwinding the register windows up the stack - until the restored %fp value matches the target value in %g3. */ + * until the restored %fp value matches the target value in %g3. */ .Lloop: cmp %fp, %g3 /* Have we reached the target frame? */ @@ -71,7 +71,7 @@ __longjmp: ; sub %fp, 64, %sp /* Allocate a register frame. */ st %g3, RW_FP /* Set saved FP on restore below. */ retl - restore %g2, 0, %o0 /* Restore values from above register frame. */ + restore %g2, 0, %o0 /* Restore values from above register frame. */ .Lfound: /* We have unwound register windows so %fp matches the target. */ @@ -82,4 +82,4 @@ __longjmp: ; jmp %o0 + 8 /* Return there. */ mov %g2, %o0 /* Delay slot: set return value. */ -.size __longjmp , . - __longjmp +.size __longjmp,.-__longjmp diff --git a/libc/sysdeps/linux/sparc/bits/siginfo.h b/libc/sysdeps/linux/sparc/bits/siginfo.h index 7ff1971c2..da2aed678 100644 --- a/libc/sysdeps/linux/sparc/bits/siginfo.h +++ b/libc/sysdeps/linux/sparc/bits/siginfo.h @@ -1,5 +1,5 @@ /* siginfo_t, sigevent and constants. Linux/SPARC version. - Copyright (C) 1997-2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000, 2001 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 @@ -69,9 +69,8 @@ typedef struct siginfo /* POSIX.1b timers. */ struct { - int si_tid; /* Timer ID. */ - int si_overrun; /* Overrun count. */ - sigval_t si_sigval; /* Signal value. */ + unsigned int _timer1; + unsigned int _timer2; } _timer; /* POSIX.1b signals. */ @@ -112,8 +111,8 @@ typedef struct siginfo /* X/Open requires some more fields with fixed names. */ # define si_pid _sifields._kill.si_pid # define si_uid _sifields._kill.si_uid -# define si_timerid _sifields._timer.si_tid -# define si_overrun _sifields._timer.si_overrun +# define si_timer1 _sifields._timer._timer1 +# define si_timer2 _sifields._timer._timer2 # define si_status _sifields._sigchld.si_status # define si_utime _sifields._sigchld.si_utime # define si_stime _sifields._sigchld.si_stime @@ -130,10 +129,8 @@ typedef struct siginfo signals. */ enum { - SI_ASYNCNL = -60, /* Sent by asynch name lookup completion. */ + SI_ASYNCNL = -6, /* Sent by asynch name lookup completion. */ # define SI_ASYNCNL SI_ASYNCNL - SI_TKILL = -6, /* Sent by tkill. */ -# define SI_TKILL SI_TKILL SI_SIGIO, /* Sent by queued SIGIO. */ # define SI_SIGIO SI_SIGIO SI_ASYNCIO, /* Sent by AIO completion. */ @@ -279,6 +276,9 @@ enum # define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3) # endif +/* Forward declaration of the `pthread_attr_t' type. */ +struct __pthread_attr_s; + typedef struct sigevent { sigval_t sigev_value; @@ -291,8 +291,8 @@ typedef struct sigevent struct { - void (*_function) (sigval_t); /* Function to start. */ - void *_attribute; /* Really pthread_attr_t. */ + void (*_function) (sigval_t); /* Function to start. */ + struct __pthread_attr_s *_attribute; /* Really pthread_attr_t. */ } _sigev_thread; } _sigev_un; } sigevent_t; @@ -308,11 +308,8 @@ enum # define SIGEV_SIGNAL SIGEV_SIGNAL SIGEV_NONE, /* Other notification: meaningless. */ # define SIGEV_NONE SIGEV_NONE - SIGEV_THREAD, /* Deliver via thread creation. */ + SIGEV_THREAD /* Deliver via thread creation. */ # define SIGEV_THREAD SIGEV_THREAD - - SIGEV_THREAD_ID = 4 /* Send signal to specific thread. */ -#define SIGEV_THREAD_ID SIGEV_THREAD_ID }; #endif /* have _SIGNAL_H. */ diff --git a/libc/sysdeps/linux/sparc/clone.S b/libc/sysdeps/linux/sparc/clone.S index 9af88688c..7421ef672 100644 --- a/libc/sysdeps/linux/sparc/clone.S +++ b/libc/sysdeps/linux/sparc/clone.S @@ -20,53 +20,49 @@ /* clone() is even more special than fork() as it mucks with stacks and invokes a function in the right context after its all over. */ -#include <asm/errno.h> #include <asm/unistd.h> /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */ - .text - .align 4 - .globl __clone - .type __clone,@function +.text +.global __clone +.type __clone,%function +.align 4 __clone: save %sp,-96,%sp /* sanity check arguments */ tst %i0 - be .Lerror - orcc %i1,%g0,%o1 - be .Lerror - mov %i2,%o0 + be __error + orcc %i1,%g0,%o1 + be __error + mov %i2,%o0 /* Do the system call */ set __NR_clone,%g1 ta 0x10 - bcs .Lerror - tst %o1 + bcs __error + tst %o1 bne __thread_start - nop + nop ret - restore %o0,%g0,%o0 + restore %o0,%g0,%o0 -.Lerror: - call __errno_location - or %g0,EINVAL,%i0 - st %i0,[%o0] - ret - restore %g0,-1,%o0 +__error: + jmp __syscall_error - .size __clone, .-__clone +.size __clone,.-__clone - .type __thread_start,@function +.type __thread_start,%function __thread_start: call %i0 - mov %i3,%o0 + mov %i3,%o0 call _exit,0 - nop + nop - .size __thread_start, .-__thread_start +.size __thread_start,.-__thread_start -.weak clone ; clone = __clone +.weak clone + clone = __clone diff --git a/libc/sysdeps/linux/sparc/crt0.c b/libc/sysdeps/linux/sparc/crt0.c deleted file mode 100644 index 81caf1eed..000000000 --- a/libc/sysdeps/linux/sparc/crt0.c +++ /dev/null @@ -1,44 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* uClibc/sysdeps/linux/i386/crt0.S - * Pull stuff off the stack and get uClibc moving. - * - * Copyright (C) 2000,2001 by Erik Andersen <andersen@uclibc.org> - * - * This program 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. - * - * This program 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 this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* Stick in a dummy reference to main(), so that if an application - * is linking when the main() function is in a static library (.a) - * we can be sure that main() actually gets linked in */ -extern void main(int argc,void *argv,void *envp); -void (*mainp)(int argc,void *argv,void *envp) = main; - -extern void __uClibc_main(int argc,void *argv,void *envp); - - -void _start(void) -{ - unsigned int argc; - char **argv, **envp; - unsigned long *stack; - - stack = ((unsigned long*)__builtin_frame_address(0))+16; - argc = *stack; - argv = (char **)stack + 1; - envp = (char **)stack + argc + 2; - - __uClibc_main(argc, argv, envp); -} - diff --git a/libc/sysdeps/linux/sparc/crti.S b/libc/sysdeps/linux/sparc/crti.S index 9dff14858..6dfc6c61e 100644 --- a/libc/sysdeps/linux/sparc/crti.S +++ b/libc/sysdeps/linux/sparc/crti.S @@ -3,7 +3,7 @@ .section .init .align 4 .global _init - .type _init, #function + .type _init, %function .proc 020 _init: !#PROLOGUE# 0 @@ -15,12 +15,9 @@ _init: .section .fini .align 4 .global _fini - .type _fini, #function + .type _fini, %function .proc 020 _fini: !#PROLOGUE# 0 save %sp, -104, %sp .align 4 - - - .ident "GCC: (GNU) 3.3.2" diff --git a/libc/sysdeps/linux/sparc/crtn.S b/libc/sysdeps/linux/sparc/crtn.S index 345638f67..24b4bf43c 100644 --- a/libc/sysdeps/linux/sparc/crtn.S +++ b/libc/sysdeps/linux/sparc/crtn.S @@ -3,7 +3,7 @@ .section .init .align 4 .global _init - .type _init, #function + .type _init, %function .proc 020 ret restore @@ -12,10 +12,8 @@ .section .fini .align 4 .global _fini - .type _fini, #function + .type _fini, %function .proc 020 ret restore .size _fini, .-_fini - - .ident "GCC: (GNU) 3.3.2" diff --git a/libc/sysdeps/linux/sparc/fork.S b/libc/sysdeps/linux/sparc/fork.S index 1b271060b..c382f4b4e 100644 --- a/libc/sysdeps/linux/sparc/fork.S +++ b/libc/sysdeps/linux/sparc/fork.S @@ -21,10 +21,10 @@ #include <sys/syscall.h> -.text; -.global __libc_fork; -.align 4; -.type __libc_fork,@function; +.text +.global __libc_fork +.type __libc_fork,%function +.align 4 __libc_fork: mov __NR_fork, %g1 @@ -43,6 +43,7 @@ __libc_fork: retl and %o0, %o1, %o0 -.size __libc_fork,.-__libc_fork; -.weak fork; fork = __libc_fork +.size __libc_fork,.-__libc_fork +.weak fork + fork = __libc_fork diff --git a/libc/sysdeps/linux/sparc/setjmp.S b/libc/sysdeps/linux/sparc/setjmp.S index e01e73b04..796abc763 100644 --- a/libc/sysdeps/linux/sparc/setjmp.S +++ b/libc/sysdeps/linux/sparc/setjmp.S @@ -23,35 +23,32 @@ #include <bits/setjmp.h> #define ST_FLUSH_WINDOWS 3 -.global _setjmp; -.align 4; -.type _setjmp ,@function; - +.global _setjmp +.type _setjmp,%function +.align 4 _setjmp: b 1f - set 0, %o1 -.size _setjmp,.-_setjmp; - - + set 0, %o1 +.size _setjmp,.-_setjmp -.global setjmp; -.align 4; -.type setjmp ,@function; +.global setjmp +.type setjmp,%function +.align 4 setjmp: set 1, %o1 -.size setjmp,.-setjmp; +.size setjmp,.-setjmp -.global __sigsetjmp; -.align 4; -.type __sigsetjmp ,@function; +.global __sigsetjmp +.type __sigsetjmp,%function +.align 4 __sigsetjmp: 1: /* Save our PC, SP and FP. Save the signal mask if requested with @@ -64,10 +61,10 @@ __sigsetjmp: mov %o7, %g1 call __sigjmp_save - mov %g1, %o7 -.size __sigsetjmp,.-__sigsetjmp; + mov %g1, %o7 +.size __sigsetjmp,.-__sigsetjmp -.weak _setjmp -.weak setjmp +.weak _setjmp +.weak setjmp diff --git a/libc/sysdeps/linux/sparc/vfork.S b/libc/sysdeps/linux/sparc/vfork.S index 0df960d65..854b66182 100644 --- a/libc/sysdeps/linux/sparc/vfork.S +++ b/libc/sysdeps/linux/sparc/vfork.S @@ -22,16 +22,18 @@ #include <sys/syscall.h> #ifndef __NR_vfork -/* uClinux-2.0 only has fork which is really vfork */ -#define __NR_vfork __NR_fork -#endif +/* No vfork so use fork instead */ +.weak vfork + vfork = __libc_fork -.text; -.global vfork; -.align 4; -.type vfork,@function; +#else -vfork: +.text +.global vfork +.type vfork,%function +.align 4 + +__vfork: mov __NR_vfork, %g1 ta 0x10 bcc,a 9000f @@ -48,5 +50,9 @@ vfork: retl and %o0, %o1, %o0 -.size vfork,.-vfork; +.size __vfork,.-__vfork + +.weak vfork + vfork = __vfork +#endif /* __NR_vfork */ diff --git a/libc/sysdeps/linux/x86_64/Makefile b/libc/sysdeps/linux/x86_64/Makefile index 2ec4b540c..3c48d9e0b 100644 --- a/libc/sysdeps/linux/x86_64/Makefile +++ b/libc/sysdeps/linux/x86_64/Makefile @@ -19,16 +19,15 @@ TOPDIR=../../../../ include $(TOPDIR)Rules.mak -CRT0_SRC = crt0.S -CRT0_OBJ = crt0.o crt1.o -SCRT0_OBJ = $(patsubst %,S%, $(CRT0_OBJ)) +CRT_SRC = crt1.S +CRT_OBJ = crt1.o +SCRT_OBJ = $(patsubst %,S%, $(CRT_OBJ)) CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o -SSRC=__longjmp.S vfork.S setjmp.S syscall.S bsd-setjmp.S bsd-_setjmp.S -#clone.S +SSRC=__longjmp.S vfork.S setjmp.S syscall.S bsd-setjmp.S bsd-_setjmp.S clone.S SOBJS=$(patsubst %.S,%.o, $(SSRC)) -CSRC=brk.c sigaction.c +CSRC=brk.c sigaction.c __syscall_error.c mmap.c COBJS=$(patsubst %.c,%.o, $(CSRC)) OBJS=$(SOBJS) $(COBJS) @@ -37,21 +36,16 @@ OBJ_LIST=../../../obj.sysdeps.$(TARGET_ARCH) all: $(OBJ_LIST) -$(OBJ_LIST): $(OBJS) $(CRT0_OBJ) $(SCRT0_OBJ) $(CTOR_TARGETS) +$(OBJ_LIST): $(OBJS) $(CRT_OBJ) $(SCRT_OBJ) $(CTOR_TARGETS) echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $(OBJ_LIST) $(INSTALL) -d $(TOPDIR)lib/ - cp $(CRT0_OBJ) $(SCRT0_OBJ) $(TOPDIR)lib/ -ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) - $(RM) $(TOPDIR)lib/Scrt0.o -else - mv $(TOPDIR)lib/Scrt0.o $(TOPDIR)lib/Scrt1.o -endif + cp $(CRT_OBJ) $(SCRT_OBJ) $(TOPDIR)lib/ -$(CRT0_OBJ): $(CRT0_SRC) +$(CRT_OBJ): $(CRT_SRC) $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o $(STRIPTOOL) -x -R .note -R .comment $*.o -$(SCRT0_OBJ): $(CRT0_SRC) +$(SCRT_OBJ): $(CRT_SRC) $(CC) $(ASFLAGS) $(PIEFLAG) -DL_$* $< -c -o $*.o $(STRIPTOOL) -x -R .note -R .comment $*.o diff --git a/libc/sysdeps/linux/x86_64/__longjmp.S b/libc/sysdeps/linux/x86_64/__longjmp.S index 40e459e27..aa47b7233 100644 --- a/libc/sysdeps/linux/x86_64/__longjmp.S +++ b/libc/sysdeps/linux/x86_64/__longjmp.S @@ -23,9 +23,9 @@ /* Jump to the position specified by ENV, causing the setjmp call there to return VAL, or 1 if VAL is 0. void __longjmp (__jmp_buf env, int val). */ -.globl __longjmp; -.type __longjmp,@function; -.align 16; +.global __longjmp +.type __longjmp,%function +.align 16 __longjmp: /* Restore registers. */ movq (JB_RBX*8)(%rdi),%rbx @@ -42,4 +42,4 @@ __longjmp: movq (JB_PC*8)(%rdi),%rdx movq (JB_RSP*8)(%rdi),%rsp jmpq *%rdx -.size __longjmp,.-__longjmp; +.size __longjmp,.-__longjmp diff --git a/libc/sysdeps/linux/x86_64/bits/kernel_stat.h b/libc/sysdeps/linux/x86_64/bits/kernel_stat.h index 74658db49..84125b917 100644 --- a/libc/sysdeps/linux/x86_64/bits/kernel_stat.h +++ b/libc/sysdeps/linux/x86_64/bits/kernel_stat.h @@ -7,26 +7,26 @@ #define STAT_HAVE_NSEC 1 struct kernel_stat { - unsigned long st_dev; - unsigned long st_ino; - unsigned long st_nlink; - - unsigned int st_mode; - unsigned int st_uid; - unsigned int st_gid; - unsigned int __pad0; - unsigned long st_rdev; - long st_size; - long st_blksize; - long st_blocks; /* Number 512-byte blocks allocated. */ - - unsigned long st_atime; - unsigned long st_atime_nsec; - unsigned long st_mtime; - unsigned long st_mtime_nsec; - unsigned long st_ctime; - unsigned long st_ctime_nsec; - long __unused[3]; + unsigned long st_dev; + unsigned long st_ino; + unsigned long st_nlink; + + unsigned int st_mode; + unsigned int st_uid; + unsigned int st_gid; + unsigned int __pad0; + unsigned long st_rdev; + long st_size; + long st_blksize; + long st_blocks; /* Number 512-byte blocks allocated. */ + + unsigned long st_atime; + unsigned long st_atime_nsec; + unsigned long st_mtime; + unsigned long st_mtime_nsec; + unsigned long st_ctime; + unsigned long st_ctime_nsec; + long __unused[3]; }; /* For 32bit emulation */ @@ -38,10 +38,13 @@ struct __old_kernel_stat { unsigned short st_uid; unsigned short st_gid; unsigned short st_rdev; - unsigned int st_size; - unsigned int st_atime; - unsigned int st_mtime; - unsigned int st_ctime; + unsigned int st_size; + unsigned int st_atime; + unsigned int st_mtime; + unsigned int st_ctime; }; +/* x86-64 stat64 is same as stat */ +#define kernel_stat64 kernel_stat + #endif diff --git a/libc/sysdeps/linux/x86_64/bsd-_setjmp.S b/libc/sysdeps/linux/x86_64/bsd-_setjmp.S index 89676bf5f..91c587988 100644 --- a/libc/sysdeps/linux/x86_64/bsd-_setjmp.S +++ b/libc/sysdeps/linux/x86_64/bsd-_setjmp.S @@ -25,10 +25,10 @@ #define _SETJMP_H #include <bits/setjmp.h> -.globl _setjmp; -.type _setjmp,@function -.align 16; +.global _setjmp +.type _setjmp,%function +.align 16 _setjmp: xorq %rsi, %rsi - jmp __sigsetjmp -.size _setjmp,.-_setjmp; + jmp __sigsetjmp@PLT +.size _setjmp,.-_setjmp diff --git a/libc/sysdeps/linux/x86_64/bsd-setjmp.S b/libc/sysdeps/linux/x86_64/bsd-setjmp.S index 340d59642..21d0191d0 100644 --- a/libc/sysdeps/linux/x86_64/bsd-setjmp.S +++ b/libc/sysdeps/linux/x86_64/bsd-setjmp.S @@ -21,10 +21,10 @@ #define _SETJMP_H #include <bits/setjmp.h> -.globl setjmp; -.type setjmp,@function -.align 16; +.global setjmp +.type setjmp,%function +.align 16 setjmp: movq $1, %rsi - jmp __sigsetjmp -.size setjmp,.-setjmp; + jmp __sigsetjmp@PLT +.size setjmp,.-setjmp diff --git a/libc/sysdeps/linux/x86_64/clone.S b/libc/sysdeps/linux/x86_64/clone.S index 9d244d018..cb614a5dc 100644 --- a/libc/sysdeps/linux/x86_64/clone.S +++ b/libc/sysdeps/linux/x86_64/clone.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2002, 2003, 2004, 2005 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 @@ -19,8 +19,9 @@ /* clone() is even more special than fork() as it mucks with stacks and invokes a function in the right context after its all over. */ -#define _ERRNO_H 1 +#define _ERRNO_H 1 #include <bits/errno.h> +#include <sys/syscall.h> #define CLONE_VM 0x00000100 #define CLONE_THREAD 0x00010000 @@ -48,17 +49,17 @@ r8: thread pointer */ - .text -.globl __clone; -.type __clone,@function -.align 4; +.text +.global __clone +.type __clone,%function +.align 4 __clone: /* Sanity check arguments. */ movq $-EINVAL,%rax testq %rdi,%rdi /* no NULL function pointers */ - jz __syscall_error + jz __error testq %rsi,%rsi /* no NULL stack pointers */ - jz __syscall_error + jz __error /* Insert the argument onto the new stack. */ subq $16,%rsi @@ -73,21 +74,21 @@ __clone: movq %r8, %rdx movq %r9, %r8 movq 8(%rsp), %r10 - movq $__NR_clone,%rax + movl $__NR_clone,%eax syscall testq %rax,%rax - jl __syscall_error - jz L(thread_start) + jl __error + jz .Lthread_start -L(pseudo_end): +.Lpseudo_end: ret -L(thread_start): +.Lthread_start: /* Clear the frame pointer. The ABI suggests this be done, to mark the outermost frame obviously. */ - xorq %rbp, %rbp + xorl %ebp, %ebp #ifdef RESET_PID testq $CLONE_THREAD, %rdi @@ -95,7 +96,7 @@ L(thread_start): testq $CLONE_VM, %rdi movl $-1, %eax jne 2f - movq __NR_getpid, %rax + movl $__NR_getpid, %eax syscall 2: movl %eax, %fs:PID movl %eax, %fs:TID @@ -108,9 +109,12 @@ L(thread_start): call *%rax /* Call exit with return value from function call. */ movq %rax, %rdi - call HIDDEN_JUMPTARGET (_exit) + call _exit@PLT //HIDDEN_JUMPTARGET (_exit) - cfi_startproc; -PSEUDO_END (BP_SYM (__clone)) +__error: + jmp __syscall_error -weak_alias (BP_SYM (__clone), BP_SYM (clone)) +.size __clone,.-__clone + +.weak clone + clone = __clone diff --git a/libc/sysdeps/linux/x86_64/crt0.S b/libc/sysdeps/linux/x86_64/crt0.S deleted file mode 100644 index fa08278d9..000000000 --- a/libc/sysdeps/linux/x86_64/crt0.S +++ /dev/null @@ -1,182 +0,0 @@ -/* Startup code compliant to the ELF x86-64 ABI. - Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Andreas Jaeger <aj@suse.de>, 2001. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - - 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -/* Originally based on glibc's sysdeps/x86_64/elf/start.S */ - -/* This is the canonical entry point, usually the first thing in the text - segment. The SVR4/i386 ABI (pages 3-31, 3-32) says that when the entry - point runs, most registers' values are unspecified, except for: - - %rdx Contains a function pointer to be registered with `atexit'. - This is how the dynamic linker arranges to have DT_FINI - functions called for shared libraries that have been loaded - before this code runs. - - %rsp The stack contains the arguments and environment: - 0(%rsp) argc - 8(%rsp) argv[0] - ... - (8*argc)(%rsp) NULL - (8*(argc+1))(%rsp) envp[0] - ... - NULL -*/ - -#include <features.h> - -.text - .global _start - .type _start,%function -#if defined L_crt0 || defined L_Scrt0 || ! defined __UCLIBC_CTOR_DTOR__ - .type __uClibc_main,%function -#else - .weak _init - .weak _fini - .type __uClibc_start_main,%function -#endif -/* Stick in a dummy reference to main(), so that if an application - * is linking when the main() function is in a static library (.a) - * we can be sure that main() actually gets linked in */ - .type main,%function - -_start: - /* Clear the frame pointer. The ABI suggests this be done, to mark - the outermost frame obviously. */ - xorq %rbp, %rbp - - /* Extract the arguments as encoded on the stack and set up - the arguments for __libc_start_main (int (*main) (int, char **, char **), - int argc, char *argv, - void (*init) (void), void (*fini) (void), - void (*rtld_fini) (void), void *stack_end). - The arguments are passed via registers and on the stack: - main: %rdi - argc: %rsi - argv: %rdx - init: %rcx - fini: %r8 - rtld_fini: %r9 - stack_end: stack. */ - -#if 0 - /* glibc */ - movq %rdx, %r9 /* Address of the shared library termination function. */ - popq %rsi /* Pop the argument count. */ - movq %rsp, %rdx /* argv starts just at the current stack top. */ - movq %rsi, %rbx /* now we calc envp ... envp = argc */ - addq $8, %rbx - shl $0x3, %rbx /* envp *= 8 */ - addq %rdx, %rbx /* envp += argv */ -#else - /* uclibc */ - movq %rdx, %r9 /* Address of the shared library termination function. */ - popq %rdi /* Pop the argument count. */ - movq %rsp, %rsi /* argv starts just at the current stack top. */ - movq %rdi, %rdx /* now we calc envp ... envp = argc */ - addq $8, %rdx - shl $0x3, %rdx /* envp *= 8 */ - addq %rsi, %rdx /* envp += argv */ -#endif - /* Align the stack to a 16 byte boundary to follow the ABI. */ - andq $~15, %rsp - - pushq %rax /* Push garbage because we push 8 more bytes. */ - - /* Provide the highest stack address to the user code (for stacks - which grow downwards). */ - pushq %rsp - -/************** - * START TODO */ -#if defined L_Scrt0 || defined L_Scrt1 - call .L0 -.L0: - popq %rbx - addq $_GLOBAL_OFFSET_TABLE_+[.-.L0],%rbx -#endif - -#if (defined L_crt1 || defined L_Scrt1) && defined __UCLIBC_CTOR_DTOR__ - /* Push .init and .fini arguments to __uClibc_start_main() on the stack */ -#ifdef L_Scrt1 - pushl _fini@GOT(%rip) - pushl _init@GOT(%rip) -#else - pushl $_fini - pushl $_init -#endif - - /* Push envp, argc, and argc arguments to __uClibc_start_main() on the stack */ -#if 0 - pushq %rdx /* Environment pointer */ - pushq %rsi /* Argument pointer */ - pushq %rdi /* And the argument count */ -#endif - - /* Ok, now run uClibc's main() -- shouldn't return */ -#ifdef L_Scrt1 - call *__uClibc_start_main@GOT(%rip) -#else - call __uClibc_start_main -#endif -#else - - /* Push envp, argc, and argc arguments to __uClibc_start_main() on the stack */ -#if 0 - pushq %rdx /* Environment pointer */ - pushq %rsi /* Argument pointer */ - pushq %rdi /* And the argument count */ -#endif - -#ifdef L_Scrt0 - call *__uClibc_main@GOT(%rip) -#else - call __uClibc_main -#endif -#endif -/* END TODO * - ************/ - - hlt /* Crash if somehow `exit' does return. */ -.size _start,.-_start - -/* Define a symbol for the first piece of initialized data. */ - .data - .globl __data_start -__data_start: - .long 0 - .weak data_start - data_start = __data_start diff --git a/libc/sysdeps/linux/x86_64/crti.S b/libc/sysdeps/linux/x86_64/crti.S index 6a29f2bc0..11491db4d 100644 --- a/libc/sysdeps/linux/x86_64/crti.S +++ b/libc/sysdeps/linux/x86_64/crti.S @@ -1,14 +1,16 @@ /* glibc's sysdeps/x86_64/elf/initfini.c used for reference [PROLOG] */ + + .section .init -.globl _init -.type _init, @function +.global _init +.type _init, %function _init: subq $8, %rsp .section .fini -.globl _fini -.type _fini, @function +.global _fini +.type _fini, %function _fini: subq $8, %rsp diff --git a/libc/sysdeps/linux/x86_64/crtn.S b/libc/sysdeps/linux/x86_64/crtn.S index 292e499a7..5b110d967 100644 --- a/libc/sysdeps/linux/x86_64/crtn.S +++ b/libc/sysdeps/linux/x86_64/crtn.S @@ -2,18 +2,17 @@ .file "initfini.c" - .section .init -.globl _init -.type _init, @function - addq $8, %rsp +.global _init +.type _init, %function + addq $8, %rsp ret -.size _init, .-_init +.size _init,.-_init .section .fini -.globl _fini -.type _fini, @function - addq $8, %rsp +.global _fini +.type _fini, %function + addq $8, %rsp ret -.size _fini, .-_fini +.size _fini, .-_fini diff --git a/libc/sysdeps/linux/x86_64/setjmp.S b/libc/sysdeps/linux/x86_64/setjmp.S index cb560248b..a44f968c5 100644 --- a/libc/sysdeps/linux/x86_64/setjmp.S +++ b/libc/sysdeps/linux/x86_64/setjmp.S @@ -21,9 +21,9 @@ #define _SETJMP_H #include <bits/setjmp.h> -.globl __sigsetjmp; -.type __sigsetjmp,@function -.align 4; +.global __sigsetjmp +.type __sigsetjmp,%function +.align 4 __sigsetjmp: /* Save registers. */ movq %rbx, (JB_RBX*8)(%rdi) @@ -43,4 +43,4 @@ __sigsetjmp: #else jmp __sigjmp_save #endif -.size __sigsetjmp,.-__sigsetjmp; +.size __sigsetjmp,.-__sigsetjmp diff --git a/libc/sysdeps/linux/x86_64/sigaction.c b/libc/sysdeps/linux/x86_64/sigaction.c index 217fd2ae1..75eb46784 100644 --- a/libc/sysdeps/linux/x86_64/sigaction.c +++ b/libc/sysdeps/linux/x86_64/sigaction.c @@ -27,7 +27,7 @@ #if defined __NR_rt_sigaction -#warning "Yes there are two warnings here. Don't worry about it." +#warning Yes there are two warnings here. Don't worry about it. static void restore_rt (void) asm ("__restore_rt"); static void restore (void) asm ("__restore"); diff --git a/libc/sysdeps/linux/x86_64/syscall.S b/libc/sysdeps/linux/x86_64/syscall.S index 0ec272566..f6273b75f 100644 --- a/libc/sysdeps/linux/x86_64/syscall.S +++ b/libc/sysdeps/linux/x86_64/syscall.S @@ -23,9 +23,10 @@ We need to do some arg shifting, the syscall_number will be in rax. */ -.globl syscall; -.type syscall,@function; -.align 16; +.text +.globl syscall +.type syscall,%function +.align 16 syscall: movq %rdi, %rax /* Syscall number -> rax. */ movq %rsi, %rdi /* shift arg1 - arg5. */ @@ -36,10 +37,10 @@ syscall: movq 8(%rsp),%r9 /* arg6 is on the stack. */ syscall /* Do the system call. */ cmpq $-4095, %rax /* Check %rax for error. */ - jae __syscall_error /* Branch forward if it failed. */ + jae __error /* Branch forward if it failed. */ ret /* Return to caller. */ -__syscall_error: - /* TODO: implement this ! :D */ +__error: + jmp __syscall_error -.size syscall,.-syscall; +.size syscall,.-syscall diff --git a/libc/sysdeps/linux/x86_64/vfork.S b/libc/sysdeps/linux/x86_64/vfork.S index 072a3a0a8..dde29e96a 100644 --- a/libc/sysdeps/linux/x86_64/vfork.S +++ b/libc/sysdeps/linux/x86_64/vfork.S @@ -16,17 +16,24 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#define _ERRNO_H 1 -#include <bits/errno.h> +#include <sys/syscall.h> /* Clone the calling process, but without copying the whole address space. The calling process is suspended until the new process exits or is replaced by a call to `execve'. Return -1 for errors, 0 to the new process, and the process ID of the new process to the old process. */ -.globl __vfork; -.type __vfork,@function; -.align 16; +#ifndef __NR_vfork +/* No vfork so use fork instead */ +.weak vfork + vfork = __libc_fork + +#else + +.text +.global __vfork +.type __vfork,%function +.align 16 __vfork: /* Pop the return PC value into RDI. We need a register that @@ -41,13 +48,17 @@ __vfork: pushq %rdi cmpl $-4095, %eax - jae __syscall_error /* Branch forward if it failed. */ + jae __error /* Branch forward if it failed. */ /* Normal return. */ ret -__syscall_error: - /* TODO: implement this ! :D */ +__error: + jmp __syscall_error + +.size __vfork,.-__vfork + +.weak vfork + vfork = __vfork -.size __vfork,.Lsize-__vfork -.weak vfork ; vfork = __vfork +#endif /* __NR_vfork */ |