1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-26 14:04:03 +03:00

[PATCH] update klibc to version 0.181

This commit is contained in:
greg@kroah.com 2004-10-05 18:32:12 -07:00 committed by Greg KH
parent 9e8a3a095d
commit a062277768
288 changed files with 3415 additions and 6722 deletions

View File

@ -3,22 +3,29 @@
# Makefile configuration, without explicit rules
#
# Eventually support separate compilation, but we don't have it yet...
OBJROOT = $(SRCROOT)
ARCH = $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
CROSS =
CC = $(CROSS)gcc
LD = $(CROSS)ld
KLIBSRC = $(SRCROOT)/klibc
REQFLAGS = $(ARCHREQFLAGS) -nostdinc -iwithprefix include -I$(KLIBSRC) \
-I$(KLIBSRC)/arch/$(ARCH)/include \
-I$(KLIBSRC)/include/bits$(BITSIZE) \
-D__KLIBC__ -DBITSIZE=$(BITSIZE) -I$(KLIBSRC)/include \
-I$(KERNEL_DIR)/include
KLIBOBJ = $(OBJROOT)/klibc
REQFLAGS = $(ARCHREQFLAGS) -nostdinc -iwithprefix include \
-D__KLIBC__ -DBITSIZE=$(BITSIZE) \
-I$(SRCROOT)/include/arch/$(ARCH) \
-I$(SRCROOT)/include/bits$(BITSIZE) \
-I$(SRCROOT)/include \
-I$(SRCROOT)/linux/include -I$(SRCROOT)/linux/include2
LDFLAGS =
AR = $(CROSS)ar
RANLIB = $(CROSS)ranlib
NM = $(CROSS)nm
PERL = perl
STRIP = $(CROSS)strip --strip-all -R .comment -R .note
OBJCOPY = $(CROSS)objcopy
HOST_CC = gcc
HOST_CFLAGS = -g -O
@ -26,13 +33,13 @@ HOST_LDFLAGS =
HOST_LIBS =
# Static library paths
CRT0 = $(KLIBSRC)/crt0.o
KLIBC = $(KLIBSRC)/libc.a
CRT0 = $(KLIBOBJ)/crt0.o
KLIBC = $(KLIBOBJ)/libc.a
LIBGCC = $(shell $(CC) --print-libgcc)
# Shared library paths
CRTSHARED = $(KLIBSRC)/interp.o
LIBSHARED = $(KLIBSRC)/libc.so
CRTSHARED = $(KLIBOBJ)/interp.o
LIBSHARED = $(KLIBOBJ)/libc.so
#
# This indicates the location of the final version of the shared library.
@ -41,7 +48,15 @@ LIBSHARED = $(KLIBSRC)/libc.so
#
SHLIBDIR = /lib
# Enable this to make perror/strerror return real error messages
# This makes klibc.so and any static binary which uses these functions
# about 4K bigger.
ERRLIST = 1
#
# Include arch-specific rule fragments
#
include $(KLIBSRC)/arch/$(ARCH)/MCONFIG
# How to tell the linker main() is the entrypoint
EMAIN ?= -e main

View File

@ -10,7 +10,7 @@ klibc.spec: klibc.spec.in version
.PHONY: rpm
rpm: klibc.spec
+$(rpmbuild) -bb klibc.spec
+$(rpmbuild) -bb klibc.spec --target=$(ARCH)
%:
@set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done

View File

@ -1,4 +1,5 @@
Please see klibc/README for build instructions.
Please see klibc/README for build instructions and for the status of
various platforms.

157
klibc/klibc.spec Normal file
View File

@ -0,0 +1,157 @@
Summary: A minimal libc subset for use with initramfs.
Name: klibc
Version: 0.181
Release: 1
License: BSD/GPL
Group: Development/Libraries
URL: http://www.zytor.com/mailman/listinfo/klibc
Source: http://www.kernel.org/pub/linux/libs/klibc-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildRequires: kernel-source >= 2.6.0
Packager: H. Peter Anvin <hpa@zytor.com>
Prefix: /usr
Vendor: Starving Linux Artists
%description
%{name} is intended to be a minimalistic libc subset for use with
initramfs. It is deliberately written for small size, minimal
entanglement, and portability, not speed. It is definitely a work in
progress, and a lot of things are still missing.
%package kernheaders
Summary: Kernel headers used during the build of klibc.
Group: Development/Libraries
%description kernheaders
This package contains the set of kernel headers that were required to
build %{name} and the utilities that ship with it. This may or may
not be a complete enough set to build other programs that link against
%{name}. If in doubt, use real kernel headers instead.
%package utils
Summary: Small statically-linked utilities built with klibc.
Group: Utilities/System
%description utils
This package contains a collection of programs that are statically
linked against klibc. These duplicate some of the functionality of a
regular Linux toolset, but are typically much smaller than their
full-function counterparts. They are intended for inclusion in
initramfs images and embedded systems.
%prep
%setup -q
cp -as /usr/src/linux-`rpm -q kernel-source | tail -1 | cut -d- -f3-` ./linux
make -C linux defconfig ARCH=%{_target_cpu}
make -C linux prepare ARCH=%{_target_cpu}
# Deal with braindamage in RedHat's kernel-source RPM
rm -f linux/include/linux/config.h
cat <<EOF > linux/include/linux/config.h
#ifndef _LINUX_CONFIG_H
#define _LINUX_CONFIG_H
#include <linux/autoconf.h>
#endif
EOF
mkdir -p %{buildroot}
%build
make ARCH=%{_target_cpu}
%install
rm -rf %{buildroot}
dest=%{buildroot}/%{prefix}
lib=$dest/%{_lib}/klibc
inc=$dest/include/klibc
exe=$dest/libexec/klibc
doc=$dest/share/doc/%{name}-%{version}
udoc=$dest/share/doc/%{name}-utils-%{version}
# First, the library.
install -dD -m 755 $lib $inc/kernel $exe $doc $udoc
install -m 755 klibc/klibc.so $lib
install -m 644 klibc/libc.a $lib
install -m 644 klibc/crt0.o $lib
install -m 644 klibc/libc.so.hash $lib
ln $lib/klibc.so $lib/libc.so
ln $lib/klibc.so $lib/klibc-$(cat $lib/libc.so.hash).so
# Next, the generated binaries.
# These are currently static binaries, should we go for shared?
install -m 755 ash/sh $exe
install -m 755 gzip/gzip $exe
ln $exe/gzip $exe/gunzip
ln $exe/gzip $exe/zcat
install -m 755 ipconfig/ipconfig $exe
install -m 755 kinit/kinit $exe
install -m 755 nfsmount/nfsmount $exe
install -m 755 utils/static/* $exe
# The docs.
install -m 444 README $doc
install -m 444 klibc/README $doc/README.klibc
install -m 444 klibc/arch/README $doc/README.klibc.arch
install -m 444 gzip/COPYING $udoc/COPYING.gzip
install -m 444 gzip/README $udoc/README.gzip
install -m 444 ipconfig/README $udoc/README.ipconfig
install -m 444 kinit/README $udoc/README.kinit
# Finally, the include files.
bitsize=$(make --no-print-directory -C klibc bitsize ARCH=%{_target_cpu})
cp --parents $(find klibc/include \( -name CVS -o -name SCCS \) -prune \
-o -name '*.h' -print) $inc
mv $inc/klibc $inc/klibc.$$
mv $inc/klibc.$$/include/* $inc
mv $inc/bits$bitsize/bitsize $inc
rm -rf $inc/klibc.$$ $inc/bits[0-9]*
pushd klibc/arch/%{_arch}/include
cp --parents -f $(find . \( -name CVS -o -name SCCS \) -prune \
-o -name '*.h' -print) $inc
popd
# Yeugh. Find the transitive closure over all kernel headers included
# by klibc, and copy them into place.
find . -name '.*.d' | xargs -r sed -e 's,[ \t][ \t]*,\n,g' | sed -n -e 's,^\.\./linux/include/,,p' | sort | uniq | (cd linux/include && xargs -ri cp --parents '{}' $inc/kernel)
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
%docdir %{prefix}/share/doc/%{name}-%{version}
%{prefix}/%{_lib}/klibc
%dir %{prefix}/include/klibc
%{prefix}/include/klibc/*.h
%{prefix}/include/klibc/arpa
%{prefix}/include/klibc/bitsize
%{prefix}/include/klibc/klibc
%{prefix}/include/klibc/net
%{prefix}/include/klibc/netinet
%{prefix}/include/klibc/sys
%{prefix}/share/doc/%{name}-%{version}
%files kernheaders
%defattr(-,root,root,-)
%{prefix}/include/klibc/kernel
%files utils
%defattr(-,root,root,-)
%{prefix}/libexec/klibc
%docdir %{prefix}/share/doc/%{name}-utils-%{version}
%{prefix}/share/doc/%{name}-utils-%{version}
%changelog
* Tue Jul 6 2004 H. Peter Anvin <hpa@zytor.com>
- Update to use kernel-source RPM for the kernel symlink.
* Sat Nov 29 2003 Bryan O'Sullivan <bos@serpentine.com> -
- Initial build.

View File

@ -1,16 +1,14 @@
%define _rpmdir rpms
%define _builddir .
Summary: A minimal libc subset for use with initramfs.
Name: klibc
Version: 0.89
Version: @@VERSION@@
Release: 1
License: BSD/GPL
Group: Development/Libraries
URL: http://www.zytor.com/klibc
Source: /dev/null
URL: http://www.zytor.com/mailman/listinfo/klibc
Source: http://www.kernel.org/pub/linux/libs/klibc-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
Packager: Bryan O'Sullivan <bos@serpentine.com>
BuildRequires: kernel-source >= 2.6.0
Packager: H. Peter Anvin <hpa@zytor.com>
Prefix: /usr
Vendor: Starving Linux Artists
@ -43,18 +41,24 @@ full-function counterparts. They are intended for inclusion in
initramfs images and embedded systems.
%prep
if [ ! -L linux ]; then
echo "*** You must have a symlink named linux to build klibc" 1>&2
exit 1
fi
if [ ! -f linux/include/asm/page.h ]; then
echo "*** You need to 'make prepare' in the linux tree before building klibc" 1>&2
exit 1
fi
mkdir -p %{buildroot} %{_rpmdir}
%setup -q
cp -as /usr/src/linux-`rpm -q kernel-source | tail -1 | cut -d- -f3-` ./linux
make -C linux defconfig ARCH=%{_target_cpu}
make -C linux prepare ARCH=%{_target_cpu}
# Deal with braindamage in RedHat's kernel-source RPM
rm -f linux/include/linux/config.h
cat <<EOF > linux/include/linux/config.h
#ifndef _LINUX_CONFIG_H
#define _LINUX_CONFIG_H
#include <linux/autoconf.h>
#endif
EOF
mkdir -p %{buildroot}
%build
make
make ARCH=%{_target_cpu}
%install
rm -rf %{buildroot}
@ -77,6 +81,7 @@ ln $lib/klibc.so $lib/libc.so
ln $lib/klibc.so $lib/klibc-$(cat $lib/libc.so.hash).so
# Next, the generated binaries.
# These are currently static binaries, should we go for shared?
install -m 755 ash/sh $exe
install -m 755 gzip/gzip $exe
@ -85,9 +90,7 @@ ln $exe/gzip $exe/zcat
install -m 755 ipconfig/ipconfig $exe
install -m 755 kinit/kinit $exe
install -m 755 nfsmount/nfsmount $exe
for i in chroot dd fstype mkdir mkfifo mount umount; do
install -m 755 utils/$i $exe
done
install -m 755 utils/static/* $exe
# The docs.
@ -102,7 +105,7 @@ install -m 444 kinit/README $udoc/README.kinit
# Finally, the include files.
bitsize=$(make --no-print-directory -C klibc bitsize)
bitsize=$(make --no-print-directory -C klibc bitsize ARCH=%{_target_cpu})
cp --parents $(find klibc/include \( -name CVS -o -name SCCS \) -prune \
-o -name '*.h' -print) $inc
mv $inc/klibc $inc/klibc.$$
@ -147,5 +150,8 @@ rm -rf $RPM_BUILD_ROOT
%{prefix}/share/doc/%{name}-utils-%{version}
%changelog
* Tue Jul 6 2004 H. Peter Anvin <hpa@zytor.com>
- Update to use kernel-source RPM for the kernel symlink.
* Sat Nov 29 2003 Bryan O'Sullivan <bos@serpentine.com> -
- Initial build.

View File

@ -8,6 +8,11 @@ include ../MCONFIG
include ../MRULES
WARNFLAGS = -W -Wall -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline
ifeq ($(ERRLIST),1)
REQFLAGS += -DWITH_ERRLIST
endif
CFLAGS = -Wp,-MD,$(dir $*).$(notdir $*).d $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS)
SOFLAGS = -fPIC

View File

@ -10,6 +10,7 @@ include MCONFIG
TESTS = $(patsubst %.c,%,$(wildcard tests/*.c)) \
$(patsubst %.c,%.shared,$(wildcard tests/*.c))
LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \
asprintf.o vasprintf.o \
vsscanf.o sscanf.o ctypes.o \
strntoumax.o strntoimax.o \
atoi.o atol.o atoll.o \
@ -18,41 +19,51 @@ LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \
globals.o exitc.o atexit.o onexit.o \
execl.o execle.o execv.o execvpe.o execvp.o execlp.o execlpe.o \
fork.o wait.o wait3.o waitpid.o system.o setpgrp.o getpgrp.o \
open.o \
daemon.o \
printf.o vprintf.o fprintf.o vfprintf.o perror.o \
fopen.o fread.o fread2.o fgetc.o fgets.o \
fwrite.o fwrite2.o fputc.o fputs.o puts.o \
sleep.o usleep.o raise.o abort.o assert.o alarm.o pause.o \
statfs.o fstatfs.o umount.o \
open.o fopen.o fread.o fread2.o fgetc.o fgets.o \
fwrite.o fwrite2.o fputc.o fputs.o puts.o putchar.o \
sleep.o usleep.o strtotimespec.o strtotimeval.o \
raise.o abort.o assert.o alarm.o pause.o \
__signal.o sysv_signal.o bsd_signal.o siglist.o siglongjmp.o \
sigaction.o sigpending.o sigprocmask.o sigsuspend.o \
brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o getpagesize.o \
brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o \
memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \
memmove.o \
memmove.o memchr.o \
strcasecmp.o strncasecmp.o strndup.o strerror.o \
strcat.o strchr.o strcmp.o strcpy.o strdup.o strlen.o \
strncat.o strstr.o strncmp.o strncpy.o strrchr.o strspn.o \
strcat.o strchr.o strcmp.o strcpy.o strdup.o strlen.o strnlen.o \
strncat.o strlcpy.o strlcat.o \
strstr.o strncmp.o strncpy.o strrchr.o strspn.o \
strsep.o strtok.o \
gethostname.o getdomainname.o getcwd.o \
seteuid.o setegid.o setresuid.o setresgid.o \
seteuid.o setegid.o \
getenv.o setenv.o putenv.o __put_env.o unsetenv.o \
getopt.o readdir.o \
syslog.o closelog.o pty.o getpt.o isatty.o reboot.o \
time.o utime.o fdatasync.o llseek.o select.o nice.o getpriority.o \
qsort.o lrand48.o srand48.o seed48.o \
time.o utime.o llseek.o nice.o getpriority.o \
qsort.o \
lrand48.o jrand48.o mrand48.o nrand48.o srand48.o seed48.o \
inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o \
inet/inet_ntop.o inet/inet_pton.o inet/bindresvport.o \
send.o recv.o
ifeq ($(ERRLIST),1)
LIBOBJS += errlist.o
endif
SOLIB = libc.so
SOHASH = klibc.so
CRT0 = crt0.o
LIB = libc.a
#all: tests $(CRT0) $(LIB) $(SOLIB) klibc.so
all: $(CRT0) $(LIB) $(SOLIB) klibc.so
INTERP_O = interp.o
all: tests $(CRT0) $(LIB) $(SOLIB) klibc.so
# Add any architecture-specific rules
include arch/$(ARCH)/Makefile.inc
EMAIN ?= -e main
tests: $(TESTS)
@ -71,19 +82,20 @@ tests/% : tests/%.o $(LIB) $(CRT0)
$(STRIP) $@.stripped
tests/%.shared : tests/%.o interp.o $(SOLIB)
$(LD) $(LDFLAGS) -o $@ -e main interp.o tests/$*.o -R $(SOLIB) $(LIBGCC)
$(LD) $(LDFLAGS) -o $@ $(EMAIN) interp.o tests/$*.o -R $(SOLIB) $(LIBGCC)
cp $@ $@.stripped
$(STRIP) $@.stripped
$(LIB): __static_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/static.obj socketcalls/static.obj
rm -f $(LIB)
$(AR) cq $(LIB) __static_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/*.o socketcalls/*.o
$(AR) cq $(LIB) __static_init.o $(LIBOBJS) $(ARCHOBJS) \
$(wildcard syscalls/*.o) $(wildcard socketcalls/*.o)
$(RANLIB) $(LIB)
$(SOLIB): $(CRT0) __shared_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/static.obj socketcalls/static.obj
$(LD) $(LDFLAGS) $(SHAREDFLAGS) -o $@ \
$(CRT0) __shared_init.o $(LIBOBJS) $(ARCHOBJS) \
syscalls/*.o socketcalls/*.o \
$(wildcard syscalls/*.o) $(wildcard socketcalls/*.o) \
$(LIBGCC)
sha1hash: sha1hash.c
@ -99,7 +111,7 @@ $(SOHASH): $(SOLIB) $(SOLIB).hash
rm -f klibc-??????????????????????.so
ln -f $@ klibc-`cat $(SOLIB).hash`.so
interp.o: interp.S $(SOLIB).hash
$(INTERP_O): interp.S $(SOLIB).hash
$(CC) $(CFLAGS) -D__ASSEMBLY__ -DLIBDIR=\"$(SHLIBDIR)\" \
-DSOHASH=\"`cat $(SOLIB).hash`\" \
-c -o $@ $<
@ -107,16 +119,29 @@ interp.o: interp.S $(SOLIB).hash
crt0.o: arch/$(ARCH)/crt0.o
cp arch/$(ARCH)/crt0.o .
syscalls.dir: SYSCALLS syscalls.pl syscommon.h
errlist.c:
$(PERL) makeerrlist.pl -errlist > $@ || rm -f $@
# We pass -ansi to keep cpp from define e.g. "i386" as well as "__i386__"
SYSCALLS.i: SYSCALLS.def
$(CC) $(CFLAGS) -D__ASSEMBLY__ -ansi -x assembler-with-cpp -E -o $@ $<
syscalls.nrs: ../include/sys/syscall.h ../include/arch/$(ARCH)/klibc/archsys.h ../linux/include/asm/unistd.h
$(CC) $(CFLAGS) -Wp,-dM -x c -E -o $@ ../include/sys/syscall.h
syscalls.dir: SYSCALLS.i syscalls.pl arch/$(ARCH)/sysstub.ph syscommon.h syscalls.nrs
rm -rf syscalls
mkdir syscalls
$(PERL) syscalls.pl $(ARCH) SYSCALLS
$(PERL) syscalls.pl SYSCALLS.i $(ARCH) $(BITSIZE) syscalls.nrs ../include/klibc/havesyscall.h
touch $@
socketcalls.dir: SOCKETCALLS socketcalls.pl socketcommon.h
../include/klibc/havesyscall.h: syscalls.dir
: Generated by side effect
socketcalls.dir: SOCKETCALLS.def socketcalls.pl socketcommon.h
rm -rf socketcalls
mkdir socketcalls
$(PERL) socketcalls.pl $(ARCH) SOCKETCALLS
$(PERL) socketcalls.pl SOCKETCALLS.def $(ARCH)
touch $@
%/static.obj: %.dir
@ -133,9 +158,10 @@ clean: archclean
rm -f $(TESTS) tests/*.stripped
rm -rf syscalls syscalls.dir
rm -rf socketcalls socketcalls.dir
rm -f sha1hash
rm -f sha1hash errlist.c
spotless: clean
rm -f ../include/klibc/havesyscall.h syscalls.nrs
find . \( -name \*~ -o -name '.*.d' \) -not -type d -print0 | \
xargs -0rt rm -f

View File

@ -1,6 +1,6 @@
This is klibc, what is intended to be a minimalistic libc subset for
use with initramfs. It is deliberately written for small size,
minimal entaglement and portability, not speed. It is definitely a
minimal entaglement, and portability, not speed. It is definitely a
work in progress, and a lot of things are still missing.
@ -34,20 +34,38 @@ b) If you're cross-compiling, change ARCH in the main MCONFIG file to
The following is the last known status of various architectures:
Known to work: alpha arm ia64 i386 ppc s390 s390x sparc
sparc64 x86_64*
Works static, not shared: mips* arm-thumb sh* parisc
Might work: ppc64
Need porting work: cris m68k mips64 v850
alpha: Working static, shared untested
arm-thumb: Untested
arm26: Not yet ported
arm: Working
cris: Untested
h8300: Not yet ported
i386: Working
ia64: Working
m68k: Not yet ported
mips64: Not yet ported
mips: Working
parisc: Untested
ppc64: Working
ppc: Working
s390: Working static, shared untested
s390x: Working
sh: Untested
sparc64: sigaction() fails in ash for unknown reason
sparc: Working
v850: Not yet ported
x86-64: Working
Shared library support requires recent binutils on many
architectures.
x86_64: requires a kernel header patch (to be created)
mips, sh: linker problem; might work with fixed linker
"Need sysstub.ph" means the architectural changes first implemented
in klibc-0.117 has not yet been implemented; klibc-0.116 did,
however, work. "Not yet ported" means no porting work has been
done on this architecture.
Shared library support requires binutils 2.13.90.0.4 or later on
many architectures.
Note that even the "known to work" ones likely have bugs. Please
report them if you run into them.
Note that even the "working" ones likely have bugs. Please report
them if you run into them.
c) Type "make" and pray...

View File

@ -1,21 +0,0 @@
# -*- fundamental -*-
#
# These are calls that are invoked via the socketcall mechanism
#
int socket(int, int, int)
int bind(int, struct sockaddr *, int)
int connect(int, struct sockaddr *, socklen_t)
int listen(int, int)
int accept(int, struct sockaddr *, socklen_t *)
int getsockname(int, struct sockaddr *, socklen_t *)
int getpeername(int, struct sockaddr *, socklen_t *)
int socketpair(int, int, int, int *)
# int send(int, const void *, size_t, unsigned int)
int sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t)
# int recv(int, void *, size_t, unsigned int)
int recvfrom(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *)
int shutdown(int, int)
int setsockopt(int, int, int, const void *, socklen_t)
int getsockopt(int, int, int, void *, socklen_t *)
int sendmsg(int, const struct msghdr *, unsigned int)
int recvmsg(int, struct msghdr *, unsigned int)

View File

@ -0,0 +1,21 @@
; -*- fundamental -*-
;
; These are calls that are invoked via the socketcall mechanism
; Note that on most architectures this is simply #included into
; SYSCALLS.def.
;
<?> int socket(int, int, int)
<?> int bind(int, struct sockaddr *, int)
<?> int connect(int, struct sockaddr *, socklen_t)
<?> int listen(int, int)
<?> int accept(int, struct sockaddr *, socklen_t *)
<?> int getsockname(int, struct sockaddr *, socklen_t *)
<?> int getpeername(int, struct sockaddr *, socklen_t *)
<?> int socketpair(int, int, int, int *)
<?> int sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t)
<?> int recvfrom(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *)
<?> int shutdown(int, int)
<?> int setsockopt(int, int, int, const void *, socklen_t)
<?> int getsockopt(int, int, int, void *, socklen_t *)
<?> int sendmsg(int, const struct msghdr *, unsigned int)
<?> int recvmsg(int, struct msghdr *, unsigned int)

View File

@ -1,153 +0,0 @@
# -*- fundamental -*-
#
# This is a list of system calls we invoke "directly". These
# are generated into syscall stubs in their own C files, so the
# linker can do its job properly.
#
# The full description of a line is:
# [<[!]arch,...>] type sysname[@systype][::funcname](args)
#
#
# Process-related syscalls
#
<!mips,mips64,sparc,ia64> pid_t vfork()
<sparc> pid_t vfork@forkish()
<!alpha> pid_t getpid()
<alpha> pid_t getxpid@dual0::getpid()
int setpgid(pid_t, pid_t)
pid_t getpgid(pid_t)
<!alpha> pid_t getppid()
<alpha> pid_t getxpid@dual1::getppid()
pid_t setsid()
pid_t getsid(pid_t)
pid_t wait4(pid_t, int *, int, struct rusage *)
int execve(const char *, char * const *, char * const *)
int setpriority(int, int, int)
int sched_setscheduler(pid_t, int, const struct sched_param *)
int sched_yield()
#
# User and group IDs
#
int setuid(uid_t)
int setgid(gid_t)
<!alpha> uid_t getuid()
<alpha> uid_t getxuid@dual0::getuid()
<!alpha> gid_t getgid()
<alpha> gid_t getxgid@dual0::getgid()
<!alpha> uid_t geteuid()
<alpha> uid_t getxuid@dual1::geteuid()
<!alpha> gid_t getegid()
<alpha> uid_t getxgid@dual1::getegid()
int getgroups(int, gid_t *)
int setgroups(size_t, const gid_t *)
int setreuid(uid_t, uid_t)
int setregid(gid_t, gid_t)
int setfsuid(uid_t)
int setfsgid(gid_t)
#
# Filesystem-related system calls
#
int mount(const char *, const char *, const char *, unsigned long, const void *)
<!alpha,ia64> int umount2(const char *, int)
<alpha,ia64> int umount::umount2(const char *, int)
<!m68k> int pivot_root(const char *, const char *)
int sync()
int statfs(const char *, struct statfs *)
int fstatfs(int, struct statfs *)
int swapon(const char *, int)
int swapoff(const char *)
#
# Inode-related system calls
#
int access(const char *, int)
int link(const char *, const char *)
int unlink(const char *)
int chdir(const char *)
int rename(const char *, const char *)
int mknod(const char *, mode_t, dev_t)
int chmod(const char *, mode_t)
int fchmod(int, mode_t)
int mkdir(const char *, mode_t)
int rmdir(const char *)
<!alpha,ia64,mips,mips64> int pipe(int *)
mode_t umask(mode_t)
int chroot(const char *)
int symlink(const char *, const char *)
int readlink(const char *, char *, size_t)
int stat(const char *, struct stat *)
int lstat(const char *, struct stat *)
int fstat(int, struct stat *)
int getdents(unsigned int, struct dirent *, unsigned int)
int chown(const char *, uid_t, gid_t)
int fchown(int, uid_t, gid_t)
int lchown(const char *, uid_t, gid_t)
#
# I/O operations
#
ssize_t read(int, void *, size_t)
ssize_t write(int, const void *, size_t)
int close(int)
off_t lseek(int, off_t, int)
int dup(int)
int dup2(int, int)
int fcntl(int, int, long)
int ioctl(int, int, void *)
int flock(int, int)
int poll(struct pollfd *, nfds_t, long)
int fsync(int)
int readv(int, const struct iovec *, int)
int writev(int, const struct iovec *, int)
int ftruncate(int, off_t)
#
# Signal operations
#
int kill(pid_t, int)
int rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t)
int rt_sigsuspend(const sigset_t *, size_t)
int rt_sigpending(sigset_t *, size_t)
int rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t)
int getitimer(int, struct itimerval *)
int setitimer(int, const struct itimerval *, struct itimerval *)
#
# Time-related system calls
#
clock_t times(struct tms *)
int gettimeofday(struct timeval *, struct timezone *)
int settimeofday(const struct timeval *, const struct timezone *)
int nanosleep(const struct timespec *, struct timespec *)
#
# Memory
#
void * brk::__brk(void *)
int munmap(void *, size_t)
void * mremap(void *, size_t, size_t, unsigned long)
int msync(const void *, size_t, int)
int mprotect(const void *, size_t, int)
#
# System stuff
#
int uname(struct utsname *)
int setdomainname(const char *, size_t)
int sethostname(const char *, size_t)
long init_module(void *, unsigned long, const char *)
long delete_module(const char *, unsigned int)
<!ia64> int query_module(const char *, int, void *, size_t, size_t)
int reboot::__reboot(int, int, int, void *)
int syslog::klogctl(int, char *, int)
int sysinfo(struct sysinfo *)
#
# Low-level I/O (generally architecture-specific)
#
<i386,x86_64> int iopl(int)
<i386,x86_64> int ioperm(unsigned long, unsigned long, int)
<i386> int vm86(struct vm86_struct *)

207
klibc/klibc/SYSCALLS.def Normal file
View File

@ -0,0 +1,207 @@
; -*- fundamental -*-
;
; This is a list of system calls we invoke "directly". These
; are generated into syscall stubs in their own files, so the
; linker can do its job properly.
;
; The full description of a line is:
; [<[?][!]arch,...>] type [sysname,...][@systype][::funcname](args)
;
; ? means only instantiate this system call if present in asm/unistd.h
;
#include <asm/unistd.h>
;
; Process-related syscalls
;
<?!ia64> pid_t clone::__clone(unsigned long, void *)
<?ia64> pid_t clone::__clone2(unsigned long, void *, void *)
<?!sparc> pid_t fork()
<sparc> pid_t fork@forkish()
<!mips,mips64,sparc,ia64> pid_t vfork()
<sparc> pid_t vfork@forkish()
<!alpha> pid_t getpid()
<alpha> pid_t getxpid@dual0::getpid()
int setpgid(pid_t, pid_t)
pid_t getpgid(pid_t)
<!alpha> pid_t getppid()
<alpha> pid_t getxpid@dual1::getppid()
pid_t setsid()
pid_t getsid(pid_t)
pid_t wait4(pid_t, int *, int, struct rusage *)
int execve(const char *, char * const *, char * const *)
<?> int nice(int)
<alpha,ia64> int getpriority(int, int)
<!alpha,ia64> int getpriority::__getpriority(int, int)
int setpriority(int, int, int)
int sched_setscheduler(pid_t, int, const struct sched_param *)
int sched_yield()
;
; User and group IDs
;
int setuid32,setuid::setuid(uid_t)
int setgid32,setgid::setgid(gid_t)
<!alpha> uid_t getuid32,getuid::getuid()
<alpha> uid_t getxuid@dual0::getuid()
<!alpha> gid_t getgid32,getgid::getgid()
<alpha> gid_t getxgid@dual0::getgid()
<!alpha> uid_t geteuid32,geteuid::geteuid()
<alpha> uid_t getxuid@dual1::geteuid()
<!alpha> gid_t getegid32,getegid::getegid()
<alpha> gid_t getxgid@dual1::getegid()
int getgroups32,getgroups::getgroups(int, gid_t *)
int setgroups32,setgroups::setgroups(size_t, const gid_t *)
int setreuid32,setreuid::setreuid(uid_t, uid_t)
int setregid32,setregid::setregid(gid_t, gid_t)
int setfsuid32,setfsuid::setfsuid(uid_t)
int setfsgid32,setfsgid::setfsgid(gid_t)
int setresuid32,setresuid::setresuid(int, uid_t, uid, uid_t)
;
; Filesystem-related system calls
;
int mount(const char *, const char *, const char *, unsigned long, const void *)
<!alpha,ia64> int umount2(const char *, int)
<alpha,ia64> int umount::umount2(const char *, int)
<!m68k> int pivot_root(const char *, const char *)
int sync()
#ifdef __NR_statfs64
int statfs64::__statfs64(const char *, size_t, struct statfs *)
#else
int statfs(const char *, struct statfs *)
#endif
#ifdef __NR_fstatfs64
int fstatfs64::__fstatfs64(int, size_t, struct statfs *)
#else
int fstatfs(int, struct statfs *)
#endif
int swapon(const char *, int)
int swapoff(const char *)
;
; Inode-related system calls
;
int access(const char *, int)
int link(const char *, const char *)
int unlink(const char *)
int chdir(const char *)
int fchdir(int)
int rename(const char *, const char *)
int mknod(const char *, mode_t, dev_t)
int chmod(const char *, mode_t)
int fchmod(int, mode_t)
int mkdir(const char *, mode_t)
int rmdir(const char *)
<!alpha,ia64,mips,mips64> int pipe(int *)
mode_t umask(mode_t)
int chroot(const char *)
int symlink(const char *, const char *)
int readlink(const char *, char *, size_t)
int stat64,stat::stat(const char *, struct stat *)
int lstat64,lstat::lstat(const char *, struct stat *)
int fstat64,fstat::fstat(int, struct stat *)
int getdents64,getdents::getdents(unsigned int, struct dirent *, unsigned int)
int chown32,chown::chown(const char *, uid_t, gid_t)
int fchown32,fchown::fchown(int, uid_t, gid_t)
int lchown32,lchown::lchown(const char *, uid_t, gid_t)
int getcwd::__getcwd(char *, size_t)
<?> int utime(const char *, const struct utimbuf *)
<?> int utimes(const char *, const struct timeval *)
;
; I/O operations
;
<!i386,64> int open::__open(const char *, int, mode_t)
<64> int open(const char *, int, mode_t)
ssize_t read(int, void *, size_t)
ssize_t write(int, const void *, size_t)
int close(int)
<64> off_t lseek(int, off_t, int)
<32> int _llseek::__llseek(int, unsigned long, unsigned long, off_t *, int)
int dup(int)
int dup2(int, int)
<i386> int fcntl64@varadic::fcntl(int, int, unsigned long)
<!i386> int fcntl64,fcntl::fcntl(int, int, unsigned long)
int ioctl(int, int, void *)
int flock(int, int)
int _newselect,select::select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
int poll(struct pollfd *, nfds_t, long)
int fsync(int)
int fdatasync,fsync::fdatasync(int)
int readv(int, const struct iovec *, int)
int writev(int, const struct iovec *, int)
int ftruncate64,ftruncate::ftruncate(int, off_t)
ssize_t pread64,pread::pread(int, void *, size_t, off_t)
ssize_t pwrite64,pwrite::pwrite(int, void *, size_t, off_t)
;
; Signal operations
;
int kill(pid_t, int)
<?> int sigaction(int, const struct sigaction *, struct sigaction *)
int rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t)
<?> int sigsuspend(const sigset_t *)
int rt_sigsuspend(const sigset_t *, size_t)
<?> int sigpending(sigset_t)
int rt_sigpending(sigset_t *, size_t)
<?> int sigprocmask(int, const sigset_t *, sigset_t *)
int rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t)
<?> unsigned int alarm(unsigned int)
int getitimer(int, struct itimerval *)
int setitimer(int, const struct itimerval *, struct itimerval *)
;
; Time-related system calls
;
<?> time_t time(time_t *)
clock_t times(struct tms *)
int gettimeofday(struct timeval *, struct timezone *)
int settimeofday(const struct timeval *, const struct timezone *)
int nanosleep(const struct timespec *, struct timespec *)
<?> int pause()
;
; Memory
;
void * brk::__brk(void *)
int munmap(void *, size_t)
void * mremap(void *, size_t, size_t, unsigned long)
int msync(const void *, size_t, int)
int mprotect(const void *, size_t, int)
#if (BITSIZE == 32 && defined(__NR_mmap2)) || (BITSIZE == 64 && !defined(__NR_mmap))
<!s390> void * mmap2::__mmap2(void *, size_t, int, int, int, long)
#else
<!s390x> void * mmap(void *, size_t, int, int, int, long)
#endif
int mlockall(int)
int munlockall()
int mlock(const void *, size_t)
int munlock(const void *, size_t)
;
; System stuff
;
int uname(struct utsname *)
int setdomainname(const char *, size_t)
int sethostname(const char *, size_t)
long init_module(void *, unsigned long, const char *)
long delete_module(const char *, unsigned int)
int reboot::__reboot(int, int, int, void *)
int syslog::klogctl(int, char *, int)
int sysinfo(struct sysinfo *)
;
; Low-level I/O (generally architecture-specific)
;
<i386,x86_64> int iopl(int)
<i386,x86_64> int ioperm(unsigned long, unsigned long, int)
<i386> int vm86(struct vm86_struct *)
;
; Most architectures have the socket interfaces using regular
; system calls.
;
<?!i386> long socketcall::__socketcall(int, const unsigned long *)
#include "SOCKETCALLS.def"

View File

@ -1,56 +1,2 @@
/*
* __shared_init.c
*
* This function takes the raw data block set up by the ELF loader
* in the kernel and parses it. It is invoked by crt0.S which makes
* any necessary adjustments and passes calls this function using
* the standard C calling convention.
*
* The arguments are:
* uintptr_t *elfdata -- The ELF loader data block; usually from the stack.
* Basically a pointer to argc.
* void (*onexit)(void) -- Function to install into onexit
*/
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
#include <klibc/compiler.h>
#include <elf.h>
char **environ;
__noreturn __libc_init(uintptr_t *elfdata, void (*onexit)(void))
{
int argc;
char **argv, **envp, **envend;
struct auxentry {
uintptr_t type;
uintptr_t v;
} *auxentry;
typedef int (*main_t)(int, char **, char **);
main_t main_ptr = NULL;
(void)onexit; /* For now, we ignore this... */
argc = (int)*elfdata++;
argv = (char **)elfdata;
envp = argv+(argc+1);
/* The auxillary entry vector is after all the environment vars */
for ( envend = envp ; *envend ; envend++ );
auxentry = (struct auxentry *)(envend+1);
while ( auxentry->type ) {
if ( auxentry->type == AT_ENTRY ) {
main_ptr = (main_t)(auxentry->v);
break;
}
auxentry++;
}
environ = envp;
exit(main_ptr(argc, argv, envp));
}
#define SHARED 1
#include "libc_init.c"

View File

@ -1,38 +1,2 @@
/*
* __static_init.c
*
* This function takes the raw data block set up by the ELF loader
* in the kernel and parses it. It is invoked by crt0.S which makes
* any necessary adjustments and passes calls this function using
* the standard C calling convention.
*
* The arguments are:
* uintptr_t *elfdata -- The ELF loader data block; usually from the stack.
* Basically a pointer to argc.
* void (*onexit)(void) -- Function to install into onexit
*/
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
#include <klibc/compiler.h>
#include <elf.h>
char **environ;
extern int main(int, char **, char **);
__noreturn __libc_init(uintptr_t *elfdata, void (*onexit)(void))
{
int argc;
char **argv, **envp;
(void)onexit; /* For now, we ignore this... */
argc = (int)*elfdata++;
argv = (char **)elfdata;
envp = argv+(argc+1);
environ = envp;
exit(main(argc, argv, envp));
}
#define SHARED 0
#include "libc_init.c"

View File

@ -5,11 +5,7 @@
#include <sys/time.h>
#include <sys/syscall.h>
#ifdef __NR_alarm
_syscall1(unsigned int,alarm,unsigned int,seconds);
#else
#ifndef __NR_alarm
/* Emulate alarm() via setitimer() */

View File

@ -11,7 +11,7 @@
DIVCFLAGS = $(REQFLAGS) \
-O3 -fomit-frame-pointer -fcall-saved-1 -fcall-saved-2 \
-fcall-saved-3 -fcall-saved-4 -fcall-saved-5 -fcall-saved-6 \
-fcall-saved-7 -fcall-saved-8 -fcall-saved-15 -fcall-saved-16 \
-fcall-saved-7 -fcall-saved-8 -ffixed-15 -fcall-saved-16 \
-fcall-saved-17 -fcall-saved-18 -fcall-saved-19 -fcall-saved-20 \
-fcall-saved-21 -fcall-saved-22 -ffixed-23 -fcall-saved-24 \
-ffixed-25 -ffixed-27
@ -26,7 +26,9 @@ ARCHOBJS = \
arch/$(ARCH)/__divl.o \
arch/$(ARCH)/__reml.o \
arch/$(ARCH)/pipe.o \
arch/$(ARCH)/setjmp.o
arch/$(ARCH)/setjmp.o \
arch/$(ARCH)/syscall.o \
arch/$(ARCH)/sysdual.o
ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))

View File

@ -3,10 +3,10 @@
#
.text
.type __start,@function
.ent __start, 0
.globl __start
__start:
.type _start,@function
.ent _start, 0
.globl _start
_start:
.frame $30, 0, $26, 0
mov $31, $15
br $29, 1f
@ -18,4 +18,5 @@ __start:
jsr $26, __libc_init
.size __start,.-__start
.size _start,.-_start
.end _start

View File

@ -1,33 +0,0 @@
/*
* arch/alpha/include/klibc/archsetjmp.h
*/
#ifndef _KLIBC_ARCHSETJMP_H
#define _KLIBC_ARCHSETJMP_H
struct __jmp_buf {
unsigned long __s0;
unsigned long __s1;
unsigned long __s2;
unsigned long __s3;
unsigned long __s4;
unsigned long __s5;
unsigned long __fp;
unsigned long __ra;
unsigned long __gp;
unsigned long __sp;
unsigned long __f2;
unsigned long __f3;
unsigned long __f4;
unsigned long __f5;
unsigned long __f6;
unsigned long __f7;
unsigned long __f8;
unsigned long __f9;
};
/* Must be an array so it will decay to a pointer when a function is called */
typedef struct __jmp_buf jmp_buf[1];
#endif /* _KLIBC_ARCHSETJMP_H */

View File

@ -1,13 +0,0 @@
/*
* arch/alpha/include/klibc/archsignal.h
*
* Architecture-specific signal definitions
*
*/
#ifndef _KLIBC_ARCHSIGNAL_H
#define _KLIBC_ARCHSIGNAL_H
/* No special stuff for this architecture */
#endif

View File

@ -1,53 +0,0 @@
/*
* arch/alpha/include/klibc/archsys.h
*
* Architecture-specific syscall definitions
*/
#ifndef _KLIBC_ARCHSYS_H
#define _KLIBC_ARCHSYS_H
/* Alpha has some bizarre Tru64-derived system calls which return two
different values in $0 and $20(!), respectively. The standard
macros can't deal with these; even the ones that give the right
return value have the wrong clobbers. */
#define _syscall0_dual0(type, name) \
type name(void) \
{ \
long _sc_ret, _sc_err; \
{ \
register long _sc_0 __asm__("$0"); \
register long _sc_19 __asm__("$19"); \
register long _sc_20 __asm__("$20"); \
\
_sc_0 = __NR_##name; \
__asm__("callsys" \
: "=r"(_sc_0), "=r"(_sc_19), "=r" (_sc_20) \
: "0"(_sc_0) \
: _syscall_clobbers); \
_sc_ret = _sc_0, _sc_err = _sc_19; (void)(_sc_20); \
} \
_syscall_return(type); \
}
#define _syscall0_dual1(type, name) \
type name(void) \
{ \
long _sc_ret, _sc_err; \
{ \
register long _sc_0 __asm__("$0"); \
register long _sc_19 __asm__("$19"); \
register long _sc_20 __asm__("$20"); \
\
_sc_0 = __NR_##name; \
__asm__("callsys" \
: "=r"(_sc_0), "=r"(_sc_19), "=r" (_sc_20) \
: "0"(_sc_0) \
: _syscall_clobbers); \
_sc_ret = _sc_20, _sc_err = _sc_19; (void)(_sc_0); \
} \
_syscall_return(type); \
}
#endif /* _KLIBC_ARCHSYS_H */

View File

@ -1,44 +0,0 @@
/*
* machine/asm.h
*/
#ifndef _MACHINE_ASM_H
#define _MACHINE_ASM_H
/* Standard aliases for Alpha register names */
#define v0 $0
#define t0 $1
#define t1 $2
#define t2 $3
#define t3 $4
#define t4 $5
#define t5 $6
#define t6 $7
#define t7 $8
#define s0 $9
#define s1 $10
#define s2 $11
#define s3 $12
#define s4 $13
#define s5 $14
#define fp $15
#define a0 $16
#define a1 $17
#define a2 $18
#define a3 $19
#define a4 $20
#define a5 $21
#define t8 $22
#define t9 $23
#define t10 $24
#define t11 $25
#define ra $26
#define t12 $27 /* t12 and pv are both used for $27 */
#define pv $27 /* t12 and pv are both used for $27 */
#define at $28
#define gp $29
#define sp $30
#define zero $31
#endif /* _MACHINE_ASM_H */

View File

@ -31,14 +31,14 @@ setjmp:
stq ra, 56(a0)
stq gp, 64(a0)
stq sp, 72(a0)
stt f2, 80(a0)
stt f3, 88(a0)
stt f4, 96(a0)
stt f5, 104(a0)
stt f6, 112(a0)
stt f7, 120(a0)
stt f8, 128(a0)
stt f9, 136(a0)
stt $f2, 80(a0)
stt $f3, 88(a0)
stt $f4, 96(a0)
stt $f5, 104(a0)
stt $f6, 112(a0)
stt $f7, 120(a0)
stt $f8, 128(a0)
stt $f9, 136(a0)
ret zero,(ra),1
.size setjmp,.-setjmp
@ -59,14 +59,14 @@ longjmp:
ldq ra, 56(a0)
ldq gp, 64(a0)
ldq sp, 72(a0)
ldt f2, 80(a0)
ldt f3, 88(a0)
ldt f4, 96(a0)
ldt f5, 104(a0)
ldt f6, 112(a0)
ldt f7, 120(a0)
ldt f8, 128(a0)
ldt f9, 136(a0)
ldt $f2, 80(a0)
ldt $f3, 88(a0)
ldt $f4, 96(a0)
ldt $f5, 104(a0)
ldt $f6, 112(a0)
ldt $f7, 120(a0)
ldt $f8, 128(a0)
ldt $f9, 136(a0)
/* We're bound to get a mispredict here, but at least give us
a chance to get the return stack back in sync... */
ret zero,(ra),1

View File

@ -0,0 +1,26 @@
#
# arch/alpha/syscall.S
#
#include <machine/asm.h>
.text
.align 3
.type __syscall_common,@function
.ent __syscall_common, 0
.globl __syscall_common
__syscall_common:
.frame sp,0,ra,0
callsys
beq a3, 1f
br pv, 2f # pv <- pc
2:
ldgp gp, 0(pv)
lda a1, errno
lda v0, -1(zero)
stl a3, 0(a1)
1:
ret zero,(ra),1
.size __syscall_common,.-__syscall_common
.end __syscall_common

View File

@ -0,0 +1,33 @@
#
# arch/alpha/sysdual.S
#
#
# Some system calls have an alternate return value in r20 (a4).
# This system call stub is for system calls where that is
# the "real" return value.
#
#include <machine/asm.h>
.text
.align 3
.type __syscall_dual1,@function
.ent __syscall_dual1, 0
.globl __syscall_dual1
__syscall_dual1:
.frame sp,0,ra,0
callsys
mov v0, a4
beq a3, 1f
br pv, 2f # pv <- pc
2:
ldgp gp, 0(pv)
lda a1, errno
lda v0, -1(zero)
stl a3, 0(a1)
1:
ret zero,(ra),1
.size __syscall_dual1,.-__syscall_dual1
.end __syscall_dual1

View File

@ -0,0 +1,37 @@
# -*- perl -*-
#
# arch/alpha/sysstub.ph
#
# Script to generate system call stubs
#
# On Alpha, most system calls follow the standard convention, with the
# system call number in r0 (v0), return an error value in r19 (a3) as
# well as the return value in r0 (v0).
#
# A few system calls are dual-return with the second return value in
# r20 (a4).
sub make_sysstub($$$$@) {
my($fname, $type, $sname, $stype, @args) = @_;
$stype = $stype || 'common';
$stype = 'common' if ( $stype eq 'dual0' );
open(OUT, '>', "syscalls/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "#include <machine/asm.h>\n";
print OUT "\n";
print OUT "\t.text\n";
print OUT "\t.type ${fname},\@function\n";
print OUT "\t.ent\t${fname}, 0\n"; # What is this?
print OUT "\t.globl ${fname}\n";
print OUT "${fname}:\n";
print OUT "\tlda\tv0, __NR_${sname}(zero)\n";
print OUT "\tbr __syscall_${stype}\n";
print OUT "\t.size\t${fname},.-${fname}\n";
print OUT "\t.end\t${fname}\n";
close(OUT);
}
1;

View File

@ -17,7 +17,8 @@ ARCHOBJS = \
libgcc/__moddi3.o \
libgcc/__udivdi3.o \
libgcc/__umoddi3.o \
libgcc/__udivmoddi4.o
libgcc/__udivmoddi4.o \
arch/arm/syscall.o
ifeq ($(THUMB),y)
ARCHOBJS += arch/arm/setjmp-thumb.o
@ -26,6 +27,17 @@ else
ARCHOBJS += arch/arm/setjmp-arm.o
endif
arch/arm/sysstubs.a: arch/arm/sysstubs.pl
mkdir -p arch/arm/sysstubs
$(PERL) $< arch/arm/sysstubs
$(MAKE) $(patsubst %.S,%.o,$(wildcard arch/arm/sysstubs/*.S))
-rm -f $@
$(AR) cq $@ arch/arm/sysstubs/*.o
$(RANLIB) $@
ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
archclean:
-rm -rf arch/arm/sysstubs
-rm -f arch/arm/sysstubs.a

View File

@ -3,10 +3,8 @@
#
# void _start(void)
# {
# /* Divine up argc, argv, and envp */
# environ = envp;
# exit(main(argc, argv, envp));
# }
# __libc_init(elf_structure, atexit_ptr);
# }
#
.text

View File

@ -1,14 +0,0 @@
/*
* arch/i386/include/klibc/archsetjmp.h
*/
#ifndef _KLIBC_ARCHSETJMP_H
#define _KLIBC_ARCHSETJMP_H
struct __jmp_buf {
unsigned int regs[10];
};
typedef struct __jmp_buf jmp_buf[1];
#endif /* _SETJMP_H */

View File

@ -1,13 +0,0 @@
/*
* arch/arm/include/klibc/archsignal.h
*
* Architecture-specific signal definitions
*
*/
#ifndef _KLIBC_ARCHSIGNAL_H
#define _KLIBC_ARCHSIGNAL_H
/* No special stuff for this architecture */
#endif

View File

@ -1,12 +0,0 @@
/*
* arch/arm/include/klibc/archsys.h
*
* Architecture-specific syscall definitions
*/
#ifndef _KLIBC_ARCHSYS_H
#define _KLIBC_ARCHSYS_H
/* No special syscall definitions for this architecture */
#endif /* _KLIBC_ARCHSYS_H */

View File

@ -34,7 +34,6 @@ setjmp:
.type longjmp, #function
longjmp:
ldmia r0, {r4, r5, r6, r7, r8, r9, r10, fp, sp, lr}
movs r0, r1
moveq r0, #1
mov r0, r1
mov pc, lr
.size longjmp,.-longjmp

View File

@ -0,0 +1,50 @@
/*
* arch/arm/syscall.S
*
* System call common handling
*/
.type __syscall_common,#function
.globl __syscall_common
#ifndef __thumb__
/* ARM version - this is executed after the swi */
.align 4
__syscall_common:
cmn r0, #4096
rsbcs r2, r0, #0
ldrcs r3, 1f
mvncs r0, #0
strcs r2, [r3]
ldmfd sp!,{r4,r5,pc}
.align 4
1:
.word errno
#else
/* Thumb version - must still load r4 and r5 and run swi */
.thumb_func
.align 2
__syscall_common:
ldr r4, [sp #12]
ldr r5, [sp #16]
swi 0
ldr r1, 2f
cmp r0, r1
bcc 1f
ldr r1, 3f
neg r2, r0
mvn r0, #0
str r2, [r1]
1:
pop {r4,r5,r7,pc}
.align 4
2:
.word #-4095
3:
.word errno
#endif

View File

@ -0,0 +1,44 @@
# -*- perl -*-
#
# arch/arm/sysstub.ph
#
# Script to generate system call stubs
#
sub make_sysstub($$$$@) {
my($fname, $type, $sname, $stype, @args) = @_;
open(OUT, '>', "syscalls/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\t.text\n";
print OUT "\t.type\t${fname}, #function\n";
print OUT "\t.globl ${fname}\n";
print OUT "\t.align\t4\n";
print OUT "#ifndef __thumb__\n";
# ARM version first
print OUT "${fname}:\n";
print OUT "\tstmfd\tsp!,{r4,r5,lr}\n";
print OUT "\tldr\tr4,[sp,#12]\n";
print OUT "\tldr\tr5,[sp,#16]\n";
print OUT "\tswi\t# __NR_${sname}\n";
print OUT "\tb\t__syscall_common\n";
print OUT "#else\n";
# Thumb version
print OUT "\t.thumb_func\n";
print OUT "${fname}:\n";
print OUT "\tpush\t{r4,r5,r7,pc}\n";
print OUT "\tmov\tr7, # __NR_${sname}\n";
print OUT "\tb\t__syscall_common\n";
print OUT "#endif\n";
print OUT "\t.size\t__syscall${i},.-__syscall${i}\n";
}
1;

View File

@ -9,3 +9,18 @@
OPTFLAGS = -Os -fomit-frame-pointer
BITSIZE = 32
# Extra linkflags when building the shared version of the library
# This address needs to be reachable using normal inter-module
# calls, and work on the memory models for this architecture
# 224 MB - normal binaries start at 0
# (lib?)gcc on cris seems to insist on producing .init and .fini sections
SHAREDFLAGS = --section-start .init=0x0e000100
# The CRIS compiler needs an -iprefix to find libgcc includes when
# nostdinc is used. It also needs -mlinux to compile linux applications.
INCLUDE_PREFIX = $(shell $(CC) -print-libgcc-file-name | sed -e s/libgcc.a//)
ARCHREQFLAGS = -iprefix $(INCLUDE_PREFIX) -mlinux
# Special flags needed for linking
LDFLAGS += -mcrislinux

View File

@ -7,4 +7,27 @@
# accordingly.
#
ARCHOBJS = \
arch/$(ARCH)/__Umod.o \
arch/$(ARCH)/__Udiv.o \
arch/$(ARCH)/__Mod.o \
arch/$(ARCH)/__Div.o \
arch/$(ARCH)/__negdi2.o \
arch/$(ARCH)/setjmp.o \
arch/$(ARCH)/syscall.o \
libgcc/__divdi3.o \
libgcc/__moddi3.o \
libgcc/__udivdi3.o \
libgcc/__umoddi3.o \
libgcc/__udivmoddi4.o
arch/$(ARCH)/__Umod.o: arch/$(ARCH)/divide.c
$(CC) $(CFLAGS) -DSIGNED=0 -DREM=1 -DBITS=32 -DNAME=__Umod -c -o $@ $<
arch/$(ARCH)/__Udiv.o: arch/$(ARCH)/divide.c
$(CC) $(CFLAGS) -DSIGNED=0 -DREM=0 -DBITS=32 -DNAME=__Udiv -c -o $@ $<
arch/$(ARCH)/__Mod.o: arch/$(ARCH)/divide.c
$(CC) $(CFLAGS) -DSIGNED=1 -DREM=1 -DBITS=32 -DNAME=__Mod -c -o $@ $<
arch/$(ARCH)/__Div.o: arch/$(ARCH)/divide.c
$(CC) $(CFLAGS) -DSIGNED=1 -DREM=0 -DBITS=32 -DNAME=__Div -c -o $@ $<
archclean:

View File

@ -0,0 +1,25 @@
/*
* arch/cris/__negdi2.c
*/
/*
* In 2's complement arithmetric, -x == (~x + 1), so
* -{h,l} = (~{h,l} + {0,1)
* -{h,l} = {~h,~l} + {0,1}
* -{h,l} = {~h + cy, ~l + 1}
* ... where cy = (l == 0)
* -{h,l} = {~h + cy, -l}
*/
.text
.balign 4
.type __negdi2,@function
.globl __negdi2
__negdi2:
neg.d $r10,$r10
seq $r12
not $r11
ret
add.d $r12,$r11
.size __negdi2, .-__negdi2

View File

@ -0,0 +1,28 @@
#
# arch/cris/crt0.S
#
# Does arch-specific initialization and invokes __libc_init
# with the appropriate arguments.
#
# See __static_init.c or __shared_init.c for the expected
# arguments.
#
.text
.balign 4
.type _start,@function
.globl _start
_start:
/* Save the address of the ELF argument array */
move.d $sp,$r10 /* Address of ELF arguments */
/* atexit() function (assume null) */
moveq 0,$r11
/* Set up a dummy stack frame to keep gcc from getting confused */
push $r11
push $r11
jump __libc_init
.size _start, .-_start

View File

@ -0,0 +1,92 @@
#include <stdint.h>
#include <signal.h>
#if BITS == 64
typedef uint64_t unum;
typedef int64_t snum;
#else
typedef uint32_t unum;
typedef int32_t snum;
#endif
#ifdef SIGNED
typedef snum xnum;
#else
typedef unum xnum;
#endif
#ifdef __cris__
static inline unum __attribute__((const)) dstep(unum rs, unum rd) {
asm("dstep %1,%0" : "+r" (rd) : "r" (rs));
return rd;
}
static inline unum __attribute__((const)) lz(unum rs) {
unum rd;
asm("lz %1,%0" : "=r" (rd) : "r" (rs));
return rd;
}
#else
/* For testing */
static inline unum __attribute__ ((const)) dstep(unum rs, unum rd) {
rd <<= 1;
if ( rd >= rs )
rd -= rs;
return rd;
}
static inline unum __attribute__((const)) lz(unum rs) {
unum rd = 0;
while ( rs >= 0x7fffffff ) {
rd++;
rs <<= 1;
}
return rd;
}
#endif
xnum NAME (unum num, unum den)
{
unum quot = 0, qbit = 1;
int minus = 0;
xnum v;
if ( den == 0 ) {
raise(SIGFPE);
return 0; /* If signal ignored... */
}
if (den == 1) return (xnum)(REM ? 0 : num);
#if SIGNED
if ( (snum)(num^den) < 0 )
minus = 1;
if ( (snum)num < 0 ) num = -num;
if ( (snum)den < 0 ) den = -den;
#endif
den--;
/* Left-justify denominator and count shift */
while ( (snum)den >= 0 ) {
den <<= 1;
qbit <<= 1;
}
while ( qbit ) {
if ( den <= num ) {
num -= den;
quot += qbit;
}
den >>= 1;
qbit >>= 1;
}
v = (xnum)(REM ? num : quot);
if ( minus ) v = -v;
return v;
}

View File

@ -1,13 +0,0 @@
/*
* arch/cris/include/klibc/archsignal.h
*
* Architecture-specific signal definitions
*
*/
#ifndef _KLIBC_ARCHSIGNAL_H
#define _KLIBC_ARCHSIGNAL_H
/* No special stuff for this architecture */
#endif

View File

@ -1,12 +0,0 @@
/*
* arch/cris/include/klibc/archsys.h
*
* Architecture-specific syscall definitions
*/
#ifndef _KLIBC_ARCHSYS_H
#define _KLIBC_ARCHSYS_H
/* No special syscall definitions for this architecture */
#endif /* _KLIBC_ARCHSYS_H */

View File

@ -0,0 +1,37 @@
#
# arch/cris/setjmp.S
#
# setjmp/longjmp for the cris architecture
#
#
# The jmp_buf is assumed to contain the following, in order:
# $r8..$r0 (in that order)
# $sp ($r14)
# return address
#
.text
.balign 4
.globl setjmp
.type setjmp, @function
setjmp:
movem $r8,[$r10+] /* Save $r8..$r0 at $r10... */
move.d $sp,[$r10+]
move $srp,[$r10]
ret
moveq 0,$r10
.size setjmp,.-setjmp
.text
.balign 4
.globl longjmp
.type longjmp, @function
longjmp:
movem [$r10+],$r8 /* Load $r8..$r0 from $r10... */
move.d [$r10+],$sp
jump [$r10]
move.d $r11,$r10
.size longjmp,.-longjmp

View File

@ -0,0 +1,30 @@
/*
* arch/cris/syscall.S
*
* On cris, r9 contains the syscall number (set by generated stub);
* r10..r13 contain arguments 0-3 per the standard calling convention,
* and arguments 4-5 are passed in $mof and $srp; however, we have
* to save $srp around the system call.
*/
.section ".text","ax"
.balign 4
.globl __syscall_common
.type __syscall_common,@function
__syscall_common:
push $srp
move [$sp+4],$mof
move [$sp+8],$srp
break 13
cmps.w -4096,$r10
blo 1f
neg.d $r10,$r11
move.d $r11,[errno]
moveq -1,$r10
1:
pop $srp
ret
nop
.size __syscall_common,.-__syscall_common

View File

@ -0,0 +1,29 @@
# -*- perl -*-
#
# arch/cris/sysstub.ph
#
# Script to generate system call stubs
#
sub make_sysstub($$$$@) {
my($fname, $type, $sname, $stype, @args) = @_;
open(OUT, '>', "syscalls/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.text\n";
print OUT "\t.type\t${fname},\@function\n";
print OUT "\t.globl\t${fname}\n";
print OUT "\t.balign\t4\n";
print OUT "${fname}:\n";
print OUT "#if __NR_${sname} <= 31\n";
print OUT "\t moveq\t__NR_${sname}, \$r9\n";
print OUT "#else\n";
print OUT "\t move.d\t__NR_${sname}, \$r9\n";
print OUT "#endif\n";
print OUT "\tjump\t__syscall_common\n";
print OUT "\t.size ${fname},.-${fname}\n";
close(OUT);
}
1;

View File

@ -9,11 +9,11 @@
# Enable this to compile with register parameters; only safe for
# gcc > 3
REGPARM_OPT := -mregparm=3 -DREGPARM
REGPARM_OPT := -mregparm=3 -DREGPARM=3
gcc_major := $(shell $(CC) -v 2>&1 | awk '/gcc version/{print int($$3)}')
gcc_major := $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1)
OPTFLAGS = $(REGPARM) -march=i386 -Os
OPTFLAGS = $(REGPARM) -march=i386 -Os -g
ifeq ($(gcc_major),3)
REGPARM := $(REGPARM_OPT)

View File

@ -11,6 +11,8 @@ ARCHOBJS = \
arch/$(ARCH)/exits.o \
arch/$(ARCH)/socketcall.o \
arch/$(ARCH)/setjmp.o \
arch/$(ARCH)/syscall.o \
arch/$(ARCH)/open.o \
arch/$(ARCH)/libgcc/__ashldi3.o \
arch/$(ARCH)/libgcc/__ashrdi3.o \
arch/$(ARCH)/libgcc/__lshrdi3.o \
@ -22,6 +24,4 @@ ARCHOBJS = \
libgcc/__umoddi3.o \
libgcc/__udivmoddi4.o
ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
archclean:

View File

@ -1,19 +0,0 @@
/*
* arch/i386/include/klibc/archsetjmp.h
*/
#ifndef _KLIBC_ARCHSETJMP_H
#define _KLIBC_ARCHSETJMP_H
struct __jmp_buf {
unsigned int __ebx;
unsigned int __esp;
unsigned int __ebp;
unsigned int __esi;
unsigned int __edi;
unsigned int __eip;
};
typedef struct __jmp_buf jmp_buf[1];
#endif /* _SETJMP_H */

View File

@ -1,13 +0,0 @@
/*
* arch/i386/include/klibc/archsignal.h
*
* Architecture-specific signal definitions
*
*/
#ifndef _KLIBC_ARCHSIGNAL_H
#define _KLIBC_ARCHSIGNAL_H
/* No special stuff for this architecture */
#endif

View File

@ -1,96 +0,0 @@
/*
* arch/i386/include/klibc/archsys.h
*
* Architecture-specific syscall definitions
*/
#ifndef _KLIBC_ARCHSYS_H
#define _KLIBC_ARCHSYS_H
/*
* If we're compiling i386 in PIC mode, we need to treat %ebx
* specially. Most of these are copied from the equivalent file in
* newlib and were written by Werner Almesberger.
*/
#if defined(__PIC__)
/* _syscall0() is the same as non-PIC */
#undef _syscall1
#define _syscall1(type,name,type1,arg1) \
type name(type1 arg1) \
{ \
long __res; \
__asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
: "=a" (__res) \
: "0" (__NR_##name),"r" ((long)(arg1))); \
__syscall_return(type,__res); \
}
#undef _syscall2
#define _syscall2(type,name,type1,arg1,type2,arg2) \
type name(type1 arg1,type2 arg2) \
{ \
long __res; \
__asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
: "=a" (__res) \
: "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2))); \
__syscall_return(type,__res); \
}
#undef _syscall3
#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
type name(type1 arg1,type2 arg2,type3 arg3) \
{ \
long __res; \
__asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
: "=a" (__res) \
: "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
"d" ((long)(arg3))); \
__syscall_return(type,__res); \
}
#undef _syscall4
#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
{ \
long __res; \
__asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
: "=a" (__res) \
: "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
"d" ((long)(arg3)),"S" ((long)(arg4))); \
__syscall_return(type,__res); \
}
#undef _syscall5
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
type5,arg5) \
type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
{ \
long __res; \
__asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
: "=a" (__res) \
: "0" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \
"d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
__syscall_return(type,__res); \
}
#undef _syscall6
#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
type5,arg5,type6,arg6) \
type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
{ \
long __res; \
__asm__ __volatile__ ("push %%ebx; pushl %%ebp; movl %2,%%ebx; " \
"movl %%eax,%%ebp; movl %1,%%eax; int $0x80; " \
"pop %%ebp ; pop %%ebx" \
: "=a" (__res) \
: "i" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \
"d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)), \
"a" ((long)(arg6))); \
__syscall_return(type,__res); \
}
#endif /* __PIC__ */
#endif /* _KLIBC_ARCHSYS_H */

View File

@ -1,16 +0,0 @@
/*
* arch/i386/include/klibc/diverr.h
*/
#ifndef _KLIBC_DIVERR_H
#define _KLIBC_DIVERR_H
#include <signal.h>
static __inline__ void
__divide_error(void)
{
asm volatile("divl %0" :: "rm" (0) : "eax", "edx");
}
#endif /* _KLIBC_DIVERR_H */

View File

@ -1,126 +0,0 @@
#ident "$Id: io.h,v 1.2 2004/01/25 07:49:39 hpa Exp $"
/* ----------------------------------------------------------------------- *
*
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall
* be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* ----------------------------------------------------------------------- */
/*
* sys/io.h for the i386 architecture
*
* Basic I/O macros
*/
#ifndef _SYS_IO_H
#define _SYS_IO_H 1
/* I/O-related system calls */
int iopl(int);
int ioperm(unsigned long, unsigned long, int);
/* Basic I/O macros */
static __inline__ void
outb(unsigned char __v, unsigned short __p)
{
asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p));
}
static __inline__ void
outw(unsigned short __v, unsigned short __p)
{
asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p));
}
static __inline__ void
outl(unsigned int __v, unsigned short __p)
{
asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p));
}
static __inline__ unsigned char
inb(unsigned short __p)
{
unsigned char __v;
asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p));
return __v;
}
static __inline__ unsigned short
inw(unsigned short __p)
{
unsigned short __v;
asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p));
return __v;
}
static __inline__ unsigned int
inl(unsigned short __p)
{
unsigned int __v;
asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p));
return __v;
}
/* String I/O macros */
static __inline__ void
outsb (unsigned short __p, const void *__d, unsigned long __n)
{
asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p));
}
static __inline__ void
outsw (unsigned short __p, const void *__d, unsigned long __n)
{
asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p));
}
static __inline__ void
outsl (unsigned short __p, const void *__d, unsigned long __n)
{
asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p));
}
static __inline__ void
insb (unsigned short __p, void *__d, unsigned long __n)
{
asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p));
}
static __inline__ void
insw (unsigned short __p, void *__d, unsigned long __n)
{
asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p));
}
static __inline__ void
insl (unsigned short __p, void *__d, unsigned long __n)
{
asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p));
}
#endif /* _SYS_IO_H */

View File

@ -1,41 +0,0 @@
#ident "$Id: vm86.h,v 1.1 2004/01/25 01:34:28 hpa Exp $"
/* ----------------------------------------------------------------------- *
*
* Copyright 2004 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall
* be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* ----------------------------------------------------------------------- */
/*
* sys/vm86.h for i386
*/
#ifndef _SYS_VM86_H
#define _SYS_VM86_H 1
#include <asm/vm86.h>
/* Actual system call */
int vm86(struct vm86_struct *);
#endif

View File

@ -0,0 +1,29 @@
/*
* arch/i386/open.S
*
* Handle the open() system call - oddball due to the varadic
* prototype, which forces the use of the cdecl calling convention,
* and the need for O_LARGEFILE.
*/
#include <asm/unistd.h>
/* <asm/fcntl.h>, despite the name, isn't assembly-safe */
#define O_LARGEFILE 0100000
.globl open
.type open,@function
open:
#ifdef REGPARM
movl 4(%esp),%eax
movl 8(%esp),%edx
movl 12(%esp),%ecx
orl $O_LARGEFILE,%edx
#else
orl $O_LARGEFILE,8(%esp)
#endif
pushl $__NR_open
jmp __syscall_common
.size open,.-open

View File

@ -16,18 +16,22 @@
.type __socketcall_common, @function
__socketcall_common:
pushl %ebx
movzbl %al,%ebx # The socketcall number is passed in in %al
leal 8(%esp),%ecx # Argument pointer
movl $__NR_socketcall, %eax
int $0x80
cmpl $-125,%eax # Error return?
popl %ebx
jb 1f
neg %eax
movl %eax,errno
xorl %eax,%eax
decl %eax # Return = -1
pushl %ebx
movzbl %al,%ebx # The socketcall number is passed in in %al
leal 8(%esp),%ecx # Argument pointer
movl $__NR_socketcall,%eax
int $0x80
cmpl $-4096,%eax # Error return?
popl %ebx
jb 1f
negl %eax
movl %eax,errno
orl $-1,%eax # Return -1
1:
ret

View File

@ -0,0 +1,60 @@
/*
* arch/i386/syscall.S
*
* Common tail-handling code for system calls. Because of __syscalldecl
* we are using the stack even on if we are compiling with regparm.
*
* The arguments are on the stack; the system call number in %eax.
*/
#define ARG(n) (4*n+20)(%esp)
.text
.align 4
.globl __syscall_common
.type __syscall_common,@function
__syscall_common:
#ifdef REGPARM
xchgl %ebx,(%esp)
#else
popl %eax
pushl %ebx
#endif
pushl %esi
pushl %edi
pushl %ebp
#ifdef REGPARM
xchgl %eax,%ebx
xchgl %ecx,%edx
movl ARG(0),%esi
movl ARG(1),%edi
movl ARG(2),%ebp
#else
movl ARG(0),%ebx # Syscall arguments
movl ARG(1),%ecx
movl ARG(2),%edx
movl ARG(3),%esi
movl ARG(4),%edi
movl ARG(5),%ebp
#endif
int $0x80
cmpl $-4096,%eax
popl %ebp
popl %edi
popl %esi
popl %ebx
jb 1f
# Error return, must set errno
negl %eax
movl %eax,errno
orl $-1,%eax # Return -1
1:
ret
.size __syscall_common,.-__syscall_common

View File

@ -0,0 +1,32 @@
# -*- perl -*-
#
# arch/i386/sysstub.ph
#
# Script to generate system call stubs
#
sub make_sysstub($$$$@) {
my($fname, $type, $sname, $stype, @args) = @_;
open(OUT, '>', "syscalls/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.type ${fname},\@function\n";
print OUT "\t.globl ${fname}\n";
print OUT "${fname}:\n";
if ( $stype eq 'varadic' ) {
print OUT "#ifdef REGPARM\n";
print OUT "\tmovl 4(%esp),%eax\n";
print OUT "\tmovl 8(%esp),%edx\n";
print OUT "\tmovl 12(%esp),%ecx\n";
print OUT "#endif\n";
}
print OUT "\tpushl \$__NR_${sname}\n";
print OUT "\tjmp __syscall_common\n";
print OUT "\t.size ${fname},.-${fname}\n";
close(OUT);
}
1;

View File

@ -11,6 +11,7 @@ ARCHOBJS = \
arch/$(ARCH)/vfork.o \
arch/$(ARCH)/setjmp.o \
arch/$(ARCH)/pipe.o \
arch/$(ARCH)/syscall.o \
libgcc/__divdi3.o \
libgcc/__divsi3.o \
libgcc/__udivdi3.o \

View File

@ -1,17 +0,0 @@
/*
* arch/ia64/include/klibc/archsetjmp.h
*
* Code borrowed from the FreeBSD kernel.
*
*/
#ifndef _KLIBC_ARCHSETJMP_H
#define _KLIBC_ARCHSETJMP_H
/* User code must not depend on the internal representation of jmp_buf. */
#define _JBLEN 0x200
/* guaranteed 128-bit alignment! */
typedef char jmp_buf[_JBLEN] __attribute__ ((aligned (16)));
#endif

View File

@ -1,31 +0,0 @@
/*
* arch/ia64/include/klibc/archsignal.h
*
* Architecture-specific signal definitions.
*
*/
#ifndef _KLIBC_ARCHSIGNAL_H
#define _KLIBC_ARCHSIGNAL_H
#define _NSIG 64
#define _NSIG_BPW 64
#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
typedef struct {
unsigned long sig[_NSIG_WORDS];
} sigset_t;
struct sigaction {
union {
__sighandler_t _sa_handler;
void (*_sa_sigaction)(int, struct siginfo *, void *);
} _u;
sigset_t sa_mask;
int sa_flags;
};
#define sa_handler _u._sa_handler
#define sa_sigaction _u._sa_sigaction
#endif

View File

@ -1,218 +0,0 @@
/*
* arch/ia64/include/klibc/archsys.h
*
* Architecture-specific syscall definitions
*/
#ifndef _KLIBC_ARCHSYS_H
#define _KLIBC_ARCHSYS_H
#define __IA64_BREAK "break 0x100000;;\n\t"
#define _syscall0(type,name) \
type \
name (void) \
{ \
register long _r8 asm ("r8"); \
register long _r10 asm ("r10"); \
register long _r15 asm ("r15") = __NR_##name; \
long _retval; \
__asm __volatile (__IA64_BREAK \
: "=r" (_r8), "=r" (_r10), "=r" (_r15) \
: "2" (_r15) ASM_ARGS_0 \
: "memory" ASM_CLOBBERS_0); \
_retval = _r8; \
if (_r10 == -1) { \
errno = (_retval); \
_retval = -1; \
} \
return _retval; \
}
#define _syscall1(type,name,type1,arg1) \
type \
name (type1 arg1) \
{ \
register long _r8 asm ("r8"); \
register long _r10 asm ("r10"); \
register long _r15 asm ("r15") = __NR_##name; \
long _retval; \
LOAD_ARGS_1(arg1); \
__asm __volatile (__IA64_BREAK \
: "=r" (_r8), "=r" (_r10), "=r" (_r15), \
ASM_OUTARGS_1 \
: "2" (_r15) ASM_ARGS_1 \
: "memory" ASM_CLOBBERS_1); \
_retval = _r8; \
if (_r10 == -1) { \
errno = (_retval); \
_retval = -1; \
} \
return _retval; \
}
#define _syscall2(type,name,type1,arg1,type2,arg2) \
type \
name (type1 arg1, type2 arg2) \
{ \
register long _r8 asm ("r8"); \
register long _r10 asm ("r10"); \
register long _r15 asm ("r15") = __NR_##name; \
long _retval; \
LOAD_ARGS_2(arg1, arg2); \
__asm __volatile (__IA64_BREAK \
: "=r" (_r8), "=r" (_r10), "=r" (_r15), \
ASM_OUTARGS_2 \
: "2" (_r15) ASM_ARGS_2 \
: "memory" ASM_CLOBBERS_2); \
_retval = _r8; \
if (_r10 == -1) { \
errno = (_retval); \
_retval = -1; \
} \
return _retval; \
}
#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
type \
name (type1 arg1, type2 arg2, type3 arg3) \
{ \
register long _r8 asm ("r8"); \
register long _r10 asm ("r10"); \
register long _r15 asm ("r15") = __NR_##name; \
long _retval; \
LOAD_ARGS_3(arg1, arg2, arg3); \
__asm __volatile (__IA64_BREAK \
: "=r" (_r8), "=r" (_r10), "=r" (_r15), \
ASM_OUTARGS_3 \
: "2" (_r15) ASM_ARGS_3 \
: "memory" ASM_CLOBBERS_3); \
_retval = _r8; \
if (_r10 == -1) { \
errno = (_retval); \
_retval = -1; \
} \
return _retval; \
}
#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
type \
name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
{ \
register long _r8 asm ("r8"); \
register long _r10 asm ("r10"); \
register long _r15 asm ("r15") = __NR_##name; \
long _retval; \
LOAD_ARGS_4(arg1, arg2, arg3, arg4); \
__asm __volatile (__IA64_BREAK \
: "=r" (_r8), "=r" (_r10), "=r" (_r15), \
ASM_OUTARGS_4 \
: "2" (_r15) ASM_ARGS_4 \
: "memory" ASM_CLOBBERS_4); \
_retval = _r8; \
if (_r10 == -1) { \
errno = (_retval); \
_retval = -1; \
} \
return _retval; \
}
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
type \
name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
{ \
register long _r8 asm ("r8"); \
register long _r10 asm ("r10"); \
register long _r15 asm ("r15") = __NR_##name; \
long _retval; \
LOAD_ARGS_5(arg1, arg2, arg3, arg4, arg5); \
__asm __volatile (__IA64_BREAK \
: "=r" (_r8), "=r" (_r10), "=r" (_r15), \
ASM_OUTARGS_5 \
: "2" (_r15) ASM_ARGS_5 \
: "memory" ASM_CLOBBERS_5); \
_retval = _r8; \
if (_r10 == -1) { \
errno = (_retval); \
_retval = -1; \
} \
return _retval; \
}
#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
type \
name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
{ \
register long _r8 asm ("r8"); \
register long _r10 asm ("r10"); \
register long _r15 asm ("r15") = __NR_##name; \
long _retval; \
LOAD_ARGS_6(arg1, arg2, arg3, arg4, arg5, arg6); \
__asm __volatile (__IA64_BREAK \
: "=r" (_r8), "=r" (_r10), "=r" (_r15), \
ASM_OUTARGS_6 \
: "2" (_r15) ASM_ARGS_6 \
: "memory" ASM_CLOBBERS_6); \
_retval = _r8; \
if (_r10 == -1) { \
errno = (_retval); \
_retval = -1; \
} \
return _retval; \
}
#define LOAD_ARGS_0() do { } while (0)
#define LOAD_ARGS_1(out0) \
register long _out0 asm ("out0") = (long) (out0); \
LOAD_ARGS_0 ()
#define LOAD_ARGS_2(out0, out1) \
register long _out1 asm ("out1") = (long) (out1); \
LOAD_ARGS_1 (out0)
#define LOAD_ARGS_3(out0, out1, out2) \
register long _out2 asm ("out2") = (long) (out2); \
LOAD_ARGS_2 (out0, out1)
#define LOAD_ARGS_4(out0, out1, out2, out3) \
register long _out3 asm ("out3") = (long) (out3); \
LOAD_ARGS_3 (out0, out1, out2)
#define LOAD_ARGS_5(out0, out1, out2, out3, out4) \
register long _out4 asm ("out4") = (long) (out4); \
LOAD_ARGS_4 (out0, out1, out2, out3)
#define LOAD_ARGS_6(out0, out1, out2, out3, out4, out5) \
register long _out5 asm ("out5") = (long) (out5); \
LOAD_ARGS_5 (out0, out1, out2, out3, out4)
#define ASM_OUTARGS_1 "=r" (_out0)
#define ASM_OUTARGS_2 ASM_OUTARGS_1, "=r" (_out1)
#define ASM_OUTARGS_3 ASM_OUTARGS_2, "=r" (_out2)
#define ASM_OUTARGS_4 ASM_OUTARGS_3, "=r" (_out3)
#define ASM_OUTARGS_5 ASM_OUTARGS_4, "=r" (_out4)
#define ASM_OUTARGS_6 ASM_OUTARGS_5, "=r" (_out5)
#define ASM_ARGS_0
#define ASM_ARGS_1 ASM_ARGS_0, "3" (_out0)
#define ASM_ARGS_2 ASM_ARGS_1, "4" (_out1)
#define ASM_ARGS_3 ASM_ARGS_2, "5" (_out2)
#define ASM_ARGS_4 ASM_ARGS_3, "6" (_out3)
#define ASM_ARGS_5 ASM_ARGS_4, "7" (_out4)
#define ASM_ARGS_6 ASM_ARGS_5, "8" (_out5)
#define ASM_CLOBBERS_0 ASM_CLOBBERS_1, "out0"
#define ASM_CLOBBERS_1 ASM_CLOBBERS_2, "out1"
#define ASM_CLOBBERS_2 ASM_CLOBBERS_3, "out2"
#define ASM_CLOBBERS_3 ASM_CLOBBERS_4, "out3"
#define ASM_CLOBBERS_4 ASM_CLOBBERS_5, "out4"
#define ASM_CLOBBERS_5 ASM_CLOBBERS_6, "out5"
#define ASM_CLOBBERS_6 , "out6", "out7", \
/* Non-stacked integer registers, minus r8, r10, r15. */ \
"r2", "r3", "r9", "r11", "r12", "r13", "r14", "r16", "r17", "r18", \
"r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", \
"r28", "r29", "r30", "r31", \
/* Predicate registers. */ \
"p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
/* Non-rotating fp registers. */ \
"f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
/* Branch registers. */ \
"b6", "b7"
#endif /* _KLIBC_ARCHSYS_H */

View File

@ -27,7 +27,7 @@ int pipe(int *filedes)
long _retval;
__asm __volatile (__IA64_BREAK
: "=r" (_r8), "=r" (_r10), "=r" (_r15),
"=r" (_out0)
"=r" (_out0), "=r" (_r9)
: "2" (_r15), "3" (_out0)
: "memory" ASM_CLOBBERS);
if (_r10 == -1) {

View File

@ -0,0 +1,20 @@
#
# arch/ia64/syscall.S
#
#include <asm/unistd.h>
.text
.align 32
.proc __syscall_error
.globl __syscall_error
__syscall_error:
addl r2 = @ltoffx(errno),gp
;;
ld8.mov r3 = [r2],errno
;;
st4 [r3] = r8
mov r8 = -1
br.ret.sptk.many b0
.size __syscall_error, .-__syscall_error
.endp __syscall_error

View File

@ -0,0 +1,29 @@
# -*- perl -*-
#
# arch/ia64/sysstub.ph
#
# Script to generate system call stubs
#
sub make_sysstub($$$$@) {
my($fname, $type, $sname, $stype, @args) = @_;
open(OUT, '>', "syscalls/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.text\n";
print OUT "\t.align 32\n";
print OUT "\t.proc ${fname}\n";
print OUT "\t.globl ${fname}\n";
print OUT "${fname}:\n";
print OUT "\tmov\tr15 = __NR_${sname}\n";
print OUT "\tbreak __BREAK_SYSCALL\n";
print OUT "\tcmp.eq p6,p0 = -1,r10\n";
print OUT "(p6)\tbr.few __syscall_error\n";
print OUT "\tbr.ret.sptk.many b0\n";
print OUT "\t.size\t${fname},.-${fname}\n";
print OUT "\t.endp\t${fname}\n";
close(OUT);
}
1;

View File

@ -27,8 +27,8 @@ vfork:
mov out0=CLONE_VM|CLONE_VFORK|SIGCHLD
mov out1=0
;;
__IA64_BREAK // Do the syscall
break 0x100000 // Do the syscall
;;
addl r15=0,r1
cmp.eq p7,p6 = -1,r10
;;

View File

@ -1,13 +0,0 @@
/*
* arch/m68k/include/klibc/archsignal.h
*
* Architecture-specific signal definitions
*
*/
#ifndef _KLIBC_ARCHSIGNAL_H
#define _KLIBC_ARCHSIGNAL_H
/* No special stuff for this architecture */
#endif

View File

@ -1,12 +0,0 @@
/*
* arch/m68k/include/klibc/archsys.h
*
* Architecture-specific syscall definitions
*/
#ifndef _KLIBC_ARCHSYS_H
#define _KLIBC_ARCHSYS_H
/* No special syscall definitions for this architecture */
#endif /* _KLIBC_ARCHSYS_H */

View File

@ -7,12 +7,9 @@
# accordingly.
#
ARCHREQFLAGS = -fno-pic -mno-abicalls
ARCHREQFLAGS = -fno-pic -mno-abicalls -G 0
OPTFLAGS = -Os -fomit-frame-pointer
BITSIZE = 32
# Extra linkflags when building the shared version of the library
# This address needs to be reachable using normal inter-module
# calls, and work on the memory models for this architecture
# 2 MB -- the normal starting point for text is 4 MB.
SHAREDFLAGS = -Ttext 0x00200200
SHAREDFLAGS = -T arch/$(ARCH)/klibc.ld

View File

@ -11,6 +11,7 @@ ARCHOBJS = \
arch/$(ARCH)/pipe.o \
arch/$(ARCH)/vfork.o \
arch/$(ARCH)/setjmp.o \
arch/$(ARCH)/syscall.o \
libgcc/__divdi3.o \
libgcc/__moddi3.o \
libgcc/__udivdi3.o \

View File

@ -1,39 +0,0 @@
/*
* arch/mips/include/klibc/archsetjmp.h
*/
#ifndef _KLIBC_ARCHSETJMP_H
#define _KLIBC_ARCHSETJMP_H
struct __jmp_buf {
unsigned long __s0;
unsigned long __s1;
unsigned long __s2;
unsigned long __s3;
unsigned long __s4;
unsigned long __s5;
unsigned long __s6;
unsigned long __s7;
unsigned long __gp;
unsigned long __sp;
unsigned long __s8;
unsigned long __ra;
unsigned long __f20;
unsigned long __f21;
unsigned long __f22;
unsigned long __f23;
unsigned long __f24;
unsigned long __f25;
unsigned long __f26;
unsigned long __f27;
unsigned long __f28;
unsigned long __f29;
unsigned long __f30;
unsigned long __f31;
unsigned long __fcr31;
unsigned long __unused;
} __attribute__((aligned(8)));
typedef struct __jmp_buf jmp_buf[1];
#endif /* _KLIBC_ARCHSETJMP_H */

View File

@ -1,13 +0,0 @@
/*
* arch/mips/include/klibc/archsignal.h
*
* Architecture-specific signal definitions
*
*/
#ifndef _KLIBC_ARCHSIGNAL_H
#define _KLIBC_ARCHSIGNAL_H
/* No special stuff for this architecture */
#endif

View File

@ -1,12 +0,0 @@
/*
* arch/mips/include/klibc/archsys.h
*
* Architecture-specific syscall definitions
*/
#ifndef _KLIBC_ARCHSYS_H
#define _KLIBC_ARCHSYS_H
/* No special syscall definitions for this architecture */
#endif /* _KLIBC_ARCHSYS_H */

View File

@ -1,11 +0,0 @@
/*
* arch/mips/include/machine/asm.h
*/
#ifndef _MACHINE_ASM_H
#define _MACHINE_ASM_H
#include <asm/regdef.h>
#include <asm/asm.h>
#endif /* _MACHINE_ASM_H */

View File

@ -1,20 +0,0 @@
/*
* arch/mips/include/sgidefs.h
*/
/* Some ABI constants */
#ifndef _SGIDEFS_H
#define _SGIDEFS_H
#define _MIPS_ISA_MIPS1 1
#define _MIPS_ISA_MIPS2 2
#define _MIPS_ISA_MIPS3 3
#define _MIPS_ISA_MIPS4 4
#define _MIPS_ISA_MIPS5 5
#define _MIPS_SIM_ABI32 1
#define _MIPS_SIM_NABI32 2
#define _MIPS_SIM_ABI64 3
#endif /* _SGIDEFS_H */

View File

@ -0,0 +1,217 @@
/* Linker script for klibc.so, needed because of the the damned
GNU ld script headers problem */
OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips",
"elf32-tradlittlemips")
OUTPUT_ARCH(mips)
ENTRY(__start)
SECTIONS
{
/* Read-only sections, merged into text segment: */
/* This address needs to be reachable using normal inter-module
calls, and work on the memory models for this architecture */
/* 2 MB -- the normal starting point for text is 4 MB */
. = 0x00200400;
.interp : { *(.interp) }
.reginfo : { *(.reginfo) }
.dynamic : { *(.dynamic) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.dyn :
{
*(.rel.init)
*(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
*(.rel.fini)
*(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
*(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
*(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
*(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
*(.rel.ctors)
*(.rel.dtors)
*(.rel.got)
*(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*)
*(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*)
*(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*)
*(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*)
*(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
}
.rela.dyn :
{
*(.rela.init)
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
*(.rela.fini)
*(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
*(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
*(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
*(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
*(.rela.ctors)
*(.rela.dtors)
*(.rela.got)
*(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
*(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
*(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
*(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
*(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
}
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.init :
{
KEEP (*(.init))
} =0
.plt : { *(.plt) }
.text :
{
_ftext = . ;
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.mips16.fn.*) *(.mips16.call.*)
} =0
.fini :
{
KEEP (*(.fini))
} =0
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.sdata2 : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) }
.sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
.eh_frame_hdr : { *(.eh_frame_hdr) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = ALIGN(8192);
/* Ensure the __preinit_array_start label is properly aligned. We
could instead move the label definition inside the section, but
the linker would then create the section even if it turns out to
be empty, which isn't pretty. */
. = ALIGN(32 / 8);
PROVIDE (__preinit_array_start = .);
.preinit_array : { *(.preinit_array) }
PROVIDE (__preinit_array_end = .);
PROVIDE (__init_array_start = .);
.init_array : { *(.init_array) }
PROVIDE (__init_array_end = .);
PROVIDE (__fini_array_start = .);
.fini_array : { *(.fini_array) }
PROVIDE (__fini_array_end = .);
.data :
{
_fdata = . ;
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.eh_frame : { KEEP (*(.eh_frame)) }
.gcc_except_table : { *(.gcc_except_table) }
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin*.o(.ctors))
/* We don't want to include the .ctor section from
from the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin*.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
_gp = ALIGN(16) + 0x7ff0;
.got : { *(.got.plt) *(.got) }
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */
.sdata :
{
*(.sdata .sdata.* .gnu.linkonce.s.*)
}
.lit8 : { *(.lit8) }
.lit4 : { *(.lit4) }
_edata = .;
PROVIDE (edata = .);
__bss_start = .;
_fbss = .;
.sbss :
{
PROVIDE (__sbss_start = .);
PROVIDE (___sbss_start = .);
*(.dynsbss)
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon)
PROVIDE (__sbss_end = .);
PROVIDE (___sbss_end = .);
}
.bss :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections. */
. = ALIGN(32 / 8);
}
. = ALIGN(32 / 8);
_end = .;
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
.gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
.gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
/DISCARD/ : { *(.note.GNU-stack) }
}

View File

@ -0,0 +1,15 @@
#include <asm/asm.h>
#include <asm/regdef.h>
#include <asm/unistd.h>
.set noreorder
LEAF(__syscall_common)
syscall
beqz a3, 1f
# sw is actually two instructions; the first one goes
# in the branch delay slot
sw v0, errno
li v0, -1
1: jr ra
END(__syscall_common)

View File

@ -0,0 +1,30 @@
# -*- perl -*-
#
# arch/mips/sysstub.ph
#
# Script to generate system call stubs
#
# On MIPS, most system calls follow the standard convention, with the
# system call number in r0 (v0), return an error value in r19 (a3) as
# well as the return value in r0 (v0).
sub make_sysstub($$$$@) {
my($fname, $type, $sname, $stype, @args) = @_;
$stype = $stype || 'common';
open(OUT, '>', "syscalls/${fname}.S");
print OUT "#include <asm/asm.h>\n";
print OUT "#include <asm/regdef.h>\n";
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.set noreorder\n";
print OUT "\n";
print OUT "LEAF(${fname})\n";
print OUT "\tj\t__syscall_${stype}\n";
print OUT "\t li\tv0, __NR_${sname}\n";
print OUT "\tEND(${fname})\n";
close(OUT);
}
1;

View File

@ -6,14 +6,11 @@
#define CLONE_VFORK 0x00004000
#define SIGCHLD 18
.set noreorder
LEAF(vfork)
li a0, CLONE_VFORK | CLONE_VM | SIGCHLD
li a1, 0
li v0, __NR_clone
syscall
bnez a3, 1f
b 2f
1: sw v0, errno
li v0, -1
2: jr ra
j __syscall_common
li v0, __NR_clone
END(vfork)

View File

@ -1,13 +0,0 @@
/*
* arch/mips64/include/klibc/archsignal.h
*
* Architecture-specific signal definitions
*
*/
#ifndef _KLIBC_ARCHSIGNAL_H
#define _KLIBC_ARCHSIGNAL_H
/* No special stuff for this architecture */
#endif

View File

@ -1,12 +0,0 @@
/*
* arch/mips64/include/klibc/archsys.h
*
* Architecture-specific syscall definitions
*/
#ifndef _KLIBC_ARCHSYS_H
#define _KLIBC_ARCHSYS_H
/* No special syscall definitions for this architecture */
#endif /* _KLIBC_ARCHSYS_H */

View File

@ -8,8 +8,12 @@
#
ARCHOBJS = \
arch/$(ARCH)/setjmp.o
arch/$(ARCH)/setjmp.o \
arch/$(ARCH)/syscall.o
ARCHOOBJS = $(patsubst %o,%.lo,%(ARCHOBJS))
archclean:
arch/$(ARCH)/syscall.o: arch/$(ARCH)/syscall.c
$(CC) $(CFLAGS) -ffixed-r20 -c -o $@ $<

View File

@ -1,24 +0,0 @@
/*
* arch/parisc/include/klibc/archsignal.h
*
* Architecture-specific signal definitions
*
*/
#ifndef _KLIBC_ARCHSIGNAL_H
#define _KLIBC_ARCHSIGNAL_H
#define _NSIG 64
#define _NSIG_SZ (_NSIG / LONG_BIT)
typedef struct {
unsigned long sig[_NSIG_SZ];
} sigset_t;
struct sigaction {
__sighandler_t sa_handler;
unsigned long sa_flags;
sigset_t sa_mask;
};
#endif

View File

@ -1,12 +0,0 @@
/*
* arch/parisc/include/klibc/archsys.h
*
* Architecture-specific syscall definitions
*/
#ifndef _KLIBC_ARCHSYS_H
#define _KLIBC_ARCHSYS_H
/* No special syscall definitions for this architecture */
#endif /* _KLIBC_ARCHSYS_H */

View File

@ -0,0 +1,29 @@
/*
* arch/parisc/syscall.c
*
* This function is called from a stub with %r20 already set up.
* Compile this function with -ffixed-r20 so that it doesn't clobber
* this register by mistake.
*/
#include <klibc/compiler.h>
#include <errno.h>
long __syscall_common(long a0, long a1, long a2, long a3, long a4, long a5)
{
register unsigned long rv asm ("r28");
asm volatile("\tble 0x100(%%sr2, %%r0)\n"
: "=r" (rv)
: "r" (a0), "r" (a1), "r" (a2), "r" (a3), "r" (a4), "r" (a5)
: "%r1", "%r2", "%r29", "%r31");
if ( __unlikely(rv >= -4095UL) ) {
errno = -rv;
return -1L;
} else {
return (long)rv;
}
}

View File

@ -0,0 +1,29 @@
# -*- perl -*-
#
# arch/parisc/sysstub.ph
#
# Script to generate system call stubs
#
sub make_sysstub($$$$@) {
my($fname, $type, $sname, $stype, @args) = @_;
open(OUT, '>', "syscalls/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.text\n";
print OUT "\t.align 4\n";
print OUT "\t.import __syscall_common, code\n";
print OUT "\t.global ${fname}\n";
print OUT "\t.export ${fname}, code\n";
print OUT "\t.type ${fname}, @function\n";
print OUT "\t.proc\n";
print OUT "\.callinfo\n";
print OUT "${fname}:\n";
print OUT "\tb\t__syscall_common\n";
print OUT "\t ldo\t__NR_${sname}(%r0),%r20\n";
print OUT "\t.procend\n";
close(OUT);
}
1;

View File

@ -9,3 +9,10 @@
OPTFLAGS = -Os -fomit-frame-pointer
BITSIZE = 32
# Extra linkflags when building the shared version of the library
# This address needs to be reachable using normal inter-module
# calls, and work on the memory models for this architecture
# 256-16 MB - normal binaries start at 256 MB, and jumps are limited
# to +/- 16 MB
SHAREDFLAGS = -Ttext 0x0f000200

View File

@ -9,6 +9,7 @@
ARCHOBJS = \
arch/$(ARCH)/setjmp.o \
arch/$(ARCH)/syscall.o \
libgcc/__divdi3.o \
libgcc/__moddi3.o \
libgcc/__udivdi3.o \

View File

@ -1,36 +0,0 @@
/*
* arch/ppc/include/klibc/archsetjmp.h
*/
#ifndef _KLIBC_ARCHSETJMP_H
#define _KLIBC_ARCHSETJMP_H
struct __jmp_buf {
unsigned long __r2;
unsigned long __sp;
unsigned long __lr;
unsigned long __cr;
unsigned long __r13;
unsigned long __r14;
unsigned long __r15;
unsigned long __r16;
unsigned long __r17;
unsigned long __r18;
unsigned long __r19;
unsigned long __r20;
unsigned long __r21;
unsigned long __r22;
unsigned long __r23;
unsigned long __r24;
unsigned long __r25;
unsigned long __r26;
unsigned long __r27;
unsigned long __r28;
unsigned long __r29;
unsigned long __r30;
unsigned long __r31;
};
typedef struct __jmp_buf jmp_buf[1];
#endif /* _SETJMP_H */

View File

@ -1,13 +0,0 @@
/*
* arch/ppc/include/klibc/archsignal.h
*
* Architecture-specific signal definitions
*
*/
#ifndef _KLIBC_ARCHSIGNAL_H
#define _KLIBC_ARCHSIGNAL_H
/* No special stuff for this architecture */
#endif

View File

@ -1,61 +0,0 @@
/*
* arch/ppc/include/klibc/archsys.h
*
* Architecture-specific syscall definitions
*/
#ifndef _KLIBC_ARCHSYS_H
#define _KLIBC_ARCHSYS_H
/* PowerPC seems to lack _syscall6() in its headers */
/* This seems to work on both 32- and 64-bit ppc */
#ifndef _syscall6
#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
type5,arg5,type6,arg6) \
type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
{ \
unsigned long __sc_ret, __sc_err; \
{ \
register unsigned long __sc_0 __asm__ ("r0"); \
register unsigned long __sc_3 __asm__ ("r3"); \
register unsigned long __sc_4 __asm__ ("r4"); \
register unsigned long __sc_5 __asm__ ("r5"); \
register unsigned long __sc_6 __asm__ ("r6"); \
register unsigned long __sc_7 __asm__ ("r7"); \
register unsigned long __sc_8 __asm__ ("r8"); \
\
__sc_3 = (unsigned long) (arg1); \
__sc_4 = (unsigned long) (arg2); \
__sc_5 = (unsigned long) (arg3); \
__sc_6 = (unsigned long) (arg4); \
__sc_7 = (unsigned long) (arg5); \
__sc_8 = (unsigned long) (arg6); \
__sc_0 = __NR_##name; \
__asm__ __volatile__ \
("sc \n\t" \
"mfcr %1 " \
: "+r" (__sc_3), \
"+r" (__sc_0), \
"+r" (__sc_4), \
"+r" (__sc_5), \
"+r" (__sc_6), \
"+r" (__sc_7), \
"+r" (__sc_8) \
: : "cr0", "ctr", "memory", \
"r9", "r10", "r11", "r12"); \
__sc_ret = __sc_3; \
__sc_err = __sc_0; \
} \
if (__sc_err & 0x10000000) \
{ \
errno = (int)__sc_ret; \
__sc_ret = -1; \
} \
return (type)__sc_ret; \
}
#endif /* _syscall6() missing */
#endif /* _KLIBC_ARCHSYS_H */

View File

@ -0,0 +1,16 @@
/*
* arch/ppc/syscall.S
*
* Common error-handling path for system calls.
*/
.text
.align 2
.globl __syscall_error
.type __syscall_error,@function
__syscall_error:
lis 9,errno@ha
stw 3,errno@l(9)
li 3,-1
blr
.size __syscall_error,.-__syscall_error

View File

@ -0,0 +1,25 @@
# -*- perl -*-
#
# arch/ppc/sysstub.ph
#
# Script to generate system call stubs
#
sub make_sysstub($$$$@) {
my($fname, $type, $sname, $stype, @args) = @_;
open(OUT, '>', "syscalls/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.type ${fname},\@function\n";
print OUT "\t.globl ${fname}\n";
print OUT "${fname}:\n";
print OUT "\tli 0,__NR_${sname}\n";
print OUT "\tsc\n";
print OUT "\tbnslr\n";
print OUT "\tb __syscall_error\n";
print OUT "\t.size ${fname},.-${fname}\n";
close(OUT);
}
1;

View File

@ -9,3 +9,10 @@
OPTFLAGS = -Os -fomit-frame-pointer
BITSIZE = 64
# Extra linkflags when building the shared version of the library
# This address needs to be reachable using normal inter-module
# calls, and work on the memory models for this architecture
# 256-16 MB - normal binaries start at 256 MB, and jumps are limited
# to +/- 16 MB
SHAREDFLAGS = -Ttext 0x0f000200

View File

@ -8,8 +8,18 @@
#
ARCHOBJS = \
arch/$(ARCH)/setjmp.o
arch/$(ARCH)/setjmp.o \
arch/$(ARCH)/syscall.o
ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
INTERP_O = interp1.o
interp.o: interp1.o klibc.got
$(LD) $(LDFLAGS) -r -o $@ interp1.o klibc.got
klibc.got: $(SOHASH)
$(OBJCOPY) -j.got $< $@
archclean:
rm -f klibc.got

View File

@ -1,36 +0,0 @@
/*
* arch/ppc64/include/klibc/archsetjmp.h
*/
#ifndef _KLIBC_ARCHSETJMP_H
#define _KLIBC_ARCHSETJMP_H
struct __jmp_buf {
unsigned long __r2;
unsigned long __sp;
unsigned long __lr;
unsigned long __cr;
unsigned long __r13;
unsigned long __r14;
unsigned long __r15;
unsigned long __r16;
unsigned long __r17;
unsigned long __r18;
unsigned long __r19;
unsigned long __r20;
unsigned long __r21;
unsigned long __r22;
unsigned long __r23;
unsigned long __r24;
unsigned long __r25;
unsigned long __r26;
unsigned long __r27;
unsigned long __r28;
unsigned long __r29;
unsigned long __r30;
unsigned long __r31;
};
typedef struct __jmp_buf jmp_buf[1];
#endif /* _SETJMP_H */

View File

@ -1,13 +0,0 @@
/*
* arch/ppc64/include/klibc/archsignal.h
*
* Architecture-specific signal definitions
*
*/
#ifndef _KLIBC_ARCHSIGNAL_H
#define _KLIBC_ARCHSIGNAL_H
/* No special stuff for this architecture */
#endif

View File

@ -1,52 +0,0 @@
/*
* arch/ppc64/include/klibc/archsys.h
*
* Architecture-specific syscall definitions
*/
#ifndef _KLIBC_ARCHSYS_H
#define _KLIBC_ARCHSYS_H
#ifndef _syscall6
#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
type5,arg5,type6,arg6) \
type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
{ \
unsigned long __sc_ret, __sc_err; \
{ \
register unsigned long __sc_0 __asm__ ("r0"); \
register unsigned long __sc_3 __asm__ ("r3"); \
register unsigned long __sc_4 __asm__ ("r4"); \
register unsigned long __sc_5 __asm__ ("r5"); \
register unsigned long __sc_6 __asm__ ("r6"); \
register unsigned long __sc_7 __asm__ ("r7"); \
register unsigned long __sc_8 __asm__ ("r8"); \
\
__sc_3 = (unsigned long) (arg1); \
__sc_4 = (unsigned long) (arg2); \
__sc_5 = (unsigned long) (arg3); \
__sc_6 = (unsigned long) (arg4); \
__sc_7 = (unsigned long) (arg5); \
__sc_8 = (unsigned long) (arg6); \
__sc_0 = __NR_##name; \
__asm__ __volatile__ \
("sc \n\t" \
"mfcr %1 " \
: "=&r" (__sc_3), "=&r" (__sc_0) \
: "0" (__sc_3), "1" (__sc_0), \
"r" (__sc_4), \
"r" (__sc_5), \
"r" (__sc_6), \
"r" (__sc_7), \
"r" (__sc_8) \
: __syscall_clobbers); \
__sc_ret = __sc_3; \
__sc_err = __sc_0; \
} \
__syscall_return (type); \
}
#endif /* _syscall6() missing */
#endif /* _KLIBC_ARCHSYS_H */

View File

@ -2,7 +2,6 @@
# arch/ppc64/setjmp.S
#
# Basic setjmp/longjmp implementation
# This file was derived from the equivalent file in NetBSD
#
.text
@ -17,13 +16,33 @@ setjmp:
.globl setjmp
.globl .setjmp
.setjmp:
mflr %r11 /* save return address */
mfcr %r12 /* save condition register */
mr %r10,%r1 /* save stack pointer */
mr %r9,%r2 /* save GPR2 (not needed) */
stmw %r9,0(%r3) /* save r9..r31 */
li %r3,0 /* indicate success */
blr /* return */
mflr %r11 /* save return address */
mfcr %r12 /* save condition register */
std %r2,0(%r3) /* save TOC pointer (not needed) */
stdu %r1,8(%r3) /* save stack pointer */
stdu %r11,8(%r3)
stdu %r12,8(%r3)
stdu %r13,8(%r3) /* save caller saved regs */
stdu %r14,8(%r3)
stdu %r15,8(%r3)
stdu %r16,8(%r3)
stdu %r17,8(%r3)
stdu %r18,8(%r3)
stdu %r19,8(%r3)
stdu %r20,8(%r3)
stdu %r21,8(%r3)
stdu %r22,8(%r3)
stdu %r23,8(%r3)
stdu %r24,8(%r3)
stdu %r25,8(%r3)
stdu %r26,8(%r3)
stdu %r27,8(%r3)
stdu %r28,8(%r3)
stdu %r29,8(%r3)
stdu %r30,8(%r3)
std %r31,8(%r3)
li %r3,0 /* indicate success */
blr /* return */
.size .setjmp,.-.setjmp
.section ".opd","aw"
@ -35,12 +54,32 @@ longjmp:
.globl longjmp
.globl .longjmp
.longjmp:
lmw %r9,0(%r3) /* save r9..r31 */
mtlr %r11 /* restore LR */
mtcr %r12 /* restore CR */
mr %r2,%r9 /* restore GPR2 (not needed) */
mr %r1,%r10 /* restore stack */
mr %r3,%r4 /* get return value */
blr /* return */
ld %r2,0(%r3) /* restore TOC pointer (not needed) */
ldu %r1,8(%r3) /* restore stack */
ldu %r11,8(%r3)
ldu %r12,8(%r3)
ldu %r13,8(%r3) /* restore caller saved regs */
ldu %r14,8(%r3)
ldu %r15,8(%r3)
ldu %r16,8(%r3)
ldu %r17,8(%r3)
ldu %r18,8(%r3)
ldu %r19,8(%r3)
ldu %r20,8(%r3)
ldu %r21,8(%r3)
ldu %r22,8(%r3)
ldu %r23,8(%r3)
ldu %r24,8(%r3)
ldu %r25,8(%r3)
ldu %r26,8(%r3)
ldu %r27,8(%r3)
ldu %r28,8(%r3)
ldu %r29,8(%r3)
ldu %r30,8(%r3)
ld %r31,8(%r3)
mtlr %r11 /* restore LR */
mtcr %r12 /* restore CR */
mr %r3,%r4 /* get return value */
blr /* return */
.size .longjmp,.-.longjmp

View File

@ -0,0 +1,14 @@
/*
* arch/ppc64/syscall.c
*
* Common error-handling path for system calls.
* The return value from __syscall_error becomes the
* return value from the system call.
*/
#include <errno.h>
long int __syscall_error(long int err)
{
errno = err;
return -1;
}

View File

@ -0,0 +1,34 @@
# -*- perl -*-
#
# arch/ppc64/sysstub.ph
#
# Script to generate system call stubs
#
sub make_sysstub($$$$@) {
my($fname, $type, $sname, $stype, @args) = @_;
open(OUT, '>', "syscalls/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.globl ${fname}\n";
print OUT "\t.section \".opd\",\"aw\"\n";
print OUT "\t.align 3\n";
print OUT "${fname}:\n";
print OUT "\t.quad .${fname},.TOC.\@tocbase,0\n";
print OUT "\t.size ${fname},24\n";
print OUT "\t.text\n";
print OUT "\t.type .${fname},\@function\n";
print OUT "\t.globl .${fname}\n";
print OUT ".${fname}:\n";
print OUT "\tli 0,__NR_${sname}\n";
print OUT "\tsc\n";
print OUT "\tmfcr 0\n";
print OUT "\trldicl. 9,0,36,63\n";
print OUT "\tbeqlr- 0\n";
print OUT "\tb .__syscall_error\n";
print OUT "\t.size .${fname},.-.${fname}\n";
close(OUT);
}
1;

View File

@ -9,6 +9,8 @@
ARCHOBJS = \
arch/$(ARCH)/setjmp.o \
arch/$(ARCH)/mmap.o \
arch/$(ARCH)/syscall.o \
libgcc/__divdi3.o \
libgcc/__moddi3.o \
libgcc/__udivdi3.o \

View File

@ -1,15 +0,0 @@
/*
* arch/s390/include/klibc/archsetjmp.h
*/
#ifndef _KLIBC_ARCHSETJMP_H
#define _KLIBC_ARCHSETJMP_H
struct __jmp_buf {
uint32_t __gregs[10]; /* general registers r6-r15 */
uint64_t __fpregs[2]; /* fp registers f4 and f6 */
};
typedef struct __jmp_buf jmp_buf[1];
#endif /* _SETJMP_H */

Some files were not shown because too many files have changed in this diff Show More