diff -uNr dietlibc-0.23/CHANGES dietlibc-0.24/CHANGES --- dietlibc-0.23/CHANGES Fri Sep 12 14:33:06 2003 +++ dietlibc-0.24/CHANGES Thu Nov 20 23:48:20 2003 @@ -1,3 +1,43 @@ +0.24: + work around incompatible Linux select() modifying the timeout in + librpc (Patch was sent from Mike Waychison from Sun) + the overflow checking in strtou?ll? was broken in some cases. + Unfortunately, correct overflow checking enlarged the routine by 20%. + (reported by Manuel Novoa III) + two stdio bug fixes (also reported by Manuel Novoa III) + remove several warnings (Johannes Stezenbach) + Olaf: fixing tmpfile (missing parameter) and __dtostr (gcc 2.95) + Olaf: add the pthread-semaphore support. + implemented experimental plug-and-play IPv6 DNS + (see dietfeatures.h, see http://www.fefe.de/ipv6pnpdns.html) + typo in parisc setjmp.S (Michael Mueller) + Olaf: fixing the pthread_join function + add IPv6 link-local%eth0 support to getaddrinfo + Olaf: added missing syscalls (cap{g,s}et) and addmntent + Add s390x and ppc64 support (Marian Jancar, SuSE) + Marian also contributed %m support to printf, and fixes for many bugs + Olaf: + - fixing strtok_r (rewrite) + - making the %m support NON DEFAULT as it is NOT SUSv3 or SUSv2 + - make the HUGE_VAL/HUGE_VALF macros arch (endian) independend + - changeing __dtostr so that it returns "inf" for an inf-value not "nan" + - fixing the strrchr bug (reported by Gernot Tenchio) + - fixing the strtoul/strtoull bug (reported by Gernot Tenchio) + - adding the patch to printf (Gernot Tenchio) + - fixing snprintf (Gernot Tenchio) + - fixing memccpy,memcmp,strncmp (reported by Gernot Tenchio) + - fixing strtoXXX (Gernot Tenchio, patch modified) + - fixing the *scanf return behavior (reported by Enrico Scholz) + add printf test + change sys_siglist to char** (removes linker warning) + fix getnameinfo (Arnaldo Carvalho de Melo) + add ar.h (for GNU make) + replace qsort with new quicksort with three-way partitioning + parisc start.S fix (Gerrit Pape) + check fflush return code (Manuel Novoa III) + add el-cheapo strptime and more BSD legacy crap to get more of + e2fsutils, dump and util-linux compiled + 0.23: update sys/soundcard.h various x86_64 fixes (Gwenole Beauchesne) @@ -176,7 +216,7 @@ add libm2.s from contrib to i386 (oops, how long has it been sitting there?) add truncate64 and ftruncate64 and prototype for truncate (only had ftruncate) - Michal Ludvig ported the diet libc to the x86_64 architecture (the + Michal Ludvig (SuSE) ported the diet libc to the x86_64 architecture (the upcoming AMD Hammer chips!). You can't even buy the chips yet and the diet libc already supports it! Amazing ;-) Michal's patch also fixed several of the outstanding warnings. Thanks! diff -uNr dietlibc-0.23/Makefile dietlibc-0.24/Makefile --- dietlibc-0.23/Makefile Tue Aug 19 15:05:31 2003 +++ dietlibc-0.24/Makefile Tue Nov 4 17:59:17 2003 @@ -26,6 +26,9 @@ ifeq ($(MYARCH),ppc) ARCH=ppc else +ifeq ($(MYARCH),ppc64) +ARCH=ppc64 +else ifeq ($(MYARCH),arm) ARCH=arm else @@ -38,6 +41,9 @@ ifeq ($(MYARCH),s390) ARCH=s390 else +ifeq ($(MYARCH),s390x) +ARCH=s390x +else ifeq ($(MYARCH),mipsel) ARCH=mipsel else @@ -68,6 +74,8 @@ endif endif endif +endif +endif # ARCH=$(MYARCH) @@ -339,6 +347,10 @@ powerpc: $(MAKE) ARCH=ppc CROSS=powerpc-linux- all +hppa: + ln -sf bin-parisc bin-hppa + $(MAKE) ARCH=parisc CROSS=hppa-linux- all + CROSS_ARCH=arm sparc ppc alpha i386 mips sparc64 x86_64 s390 parisc cross: $(MAKE) $(subst $(ARCH),,$(CROSS_ARCH)) @@ -366,7 +378,7 @@ $(OBJDIR)/localtime_r.o $(OBJDIR)/strftime.o: dietfeatures.h # these depend on dietfeatures.h for WANT_SMALL_STDIO_BUFS -$(LIBSTDIOOBJ): dietfeatures.h +$(LIBSTDIOOBJ): dietfeatures.h include/stdio.h dietstdio.h # these depend on dietfeatures.h for WANT_FULL_RESOLV_CONF $(OBJDIR)/dnscruft.o $(OBJDIR)/dnscruft2.o: dietfeatures.h @@ -411,6 +423,8 @@ # these depend on dietfeatures.h for WANT_INET_ADDR_DNS $(OBJDIR)/gethostbyname_r.o: dietfeatures.h +$(OBJDIR)/strsignal.o: include/signal.h + $(LIBPTHREAD_OBJS): include/pthread.h # CFLAGS+=-W -Wshadow -Wid-clash-31 -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wwrite-strings diff -uNr dietlibc-0.23/THANKS dietlibc-0.24/THANKS --- dietlibc-0.23/THANKS Sat Aug 31 00:42:45 2002 +++ dietlibc-0.24/THANKS Fri Nov 14 15:00:44 2003 @@ -26,6 +26,15 @@ the OpenBSD libc for inspiration. Michal Ludvig did the porting to x86_64 and Gwenole Beauchesne helped -finish the port. +finish the port. Gwenole also reported many bugs and helped with some +of the more obscure platforms. Johannes Stezenbach improved the MIPS port. + +Marian Jancar added s390x and ppc64 support. + +Gerrit Pape maintains the Debian port and helped immensely by relaying +bug reports and doing testing on platforms I didn't have access to. + +Manuel Novoa III reported many bugs although it really works for the +competition, uClibc ;-) diff -uNr dietlibc-0.23/TODO dietlibc-0.24/TODO --- dietlibc-0.23/TODO Wed Nov 6 17:43:17 2002 +++ dietlibc-0.24/TODO Thu Oct 16 12:03:28 2003 @@ -24,3 +24,7 @@ - regular expressions standards compliance; test suite from AT&T - fgetpwent (needed for cvm) - investigate putting some libgcc symbols in dietlibc.so for gcc<3 + +implement AI_V4MAPPED in getaddrinfo (not in man page, only susv3) + +Also: AF_UNSPEC, AI_ADDRCONFIG diff -uNr dietlibc-0.23/arm/dyn_syscalls.S dietlibc-0.24/arm/dyn_syscalls.S --- dietlibc-0.23/arm/dyn_syscalls.S Fri Sep 12 14:32:48 2003 +++ dietlibc-0.24/arm/dyn_syscalls.S Wed Oct 8 01:44:25 2003 @@ -178,6 +178,8 @@ #include "../syscalls.s/write.S" #include "../syscalls.s/writev.S" #include "../syscalls.s/msync.S" +#include "../syscalls.s/capget.S" +#include "../syscalls.s/capset.S" #include "../syscalls.s/chown32.S" #include "../syscalls.s/fchown32.S" diff -uNr dietlibc-0.23/arm/syscalls.h dietlibc-0.24/arm/syscalls.h --- dietlibc-0.23/arm/syscalls.h Sun Nov 24 16:23:02 2002 +++ dietlibc-0.24/arm/syscalls.h Fri Nov 7 13:49:40 2003 @@ -239,6 +239,26 @@ #define __NR_fremovexattr (__NR_SYSCALL_BASE+237) #define __NR_tkill (__NR_SYSCALL_BASE+238) +#define __NR_sendfile64 (__NR_SYSCALL_BASE+239) +#define __NR_futex (__NR_SYSCALL_BASE+240) +#define __NR_sched_setaffinity (__NR_SYSCALL_BASE+241) +#define __NR_sched_getaffinity (__NR_SYSCALL_BASE+242) +#define __NR_io_setup (__NR_SYSCALL_BASE+243) +#define __NR_io_destroy (__NR_SYSCALL_BASE+244) +#define __NR_io_getevents (__NR_SYSCALL_BASE+245) +#define __NR_io_submit (__NR_SYSCALL_BASE+246) +#define __NR_io_cancel (__NR_SYSCALL_BASE+247) +#define __NR_exit_group (__NR_SYSCALL_BASE+248) +#define __NR_lookup_dcookie (__NR_SYSCALL_BASE+249) +#define __NR_epoll_create (__NR_SYSCALL_BASE+250) +#define __NR_epoll_ctl (__NR_SYSCALL_BASE+251) +#define __NR_epoll_wait (__NR_SYSCALL_BASE+252) +#define __NR_remap_file_pages (__NR_SYSCALL_BASE+253) +#define __NR_set_thread_area (__NR_SYSCALL_BASE+254) +#define __NR_get_thread_area (__NR_SYSCALL_BASE+255) +#define __NR_set_tid_address (__NR_SYSCALL_BASE+256) + + /* ok the next few values are for the optimization of the unified syscalls * on arm. * If the syscall has #arguments @@ -469,6 +489,42 @@ #define __ARGS_madvise 0 #define __ARGS_fcntl64 0 +#define __ARGS_security 0 +#define __ARGS_gettid 0 +#define __ARGS_readahead 0 +#define __ARGS_setxattr 1 +#define __ARGS_lsetxattr 1 +#define __ARGS_fsetxattr 1 +#define __ARGS_getxattr 0 +#define __ARGS_lgetxattr 0 +#define __ARGS_fgetxattr 0 +#define __ARGS_listxattr 0 +#define __ARGS_llistxattr 0 +#define __ARGS_flistxattr 0 +#define __ARGS_removexattr 0 +#define __ARGS_lremovexattr 0 +#define __ARGS_fremovexattr 0 +#define __ARGS_tkill 0 + +#define __ARGS_sendfile64 0 +#define __ARGS_futex 0 +#define __ARGS_sched_setaffinity 0 +#define __ARGS_sched_getaffinity 0 +#define __ARGS_io_setup 0 +#define __ARGS_io_destroy 0 +#define __ARGS_io_getevents 0 +#define __ARGS_io_submit 0 +#define __ARGS_io_cancel 0 +#define __ARGS_exit_group 0 +#define __ARGS_lookup_dcookie 0 +#define __ARGS_epoll_create 0 +#define __ARGS_epoll_ctl 0 +#define __ARGS_epoll_wait 0 +#define __ARGS_remap_file_pages 0 +#define __ARGS_set_thread_area 0 +#define __ARGS_get_thread_area 0 +#define __ARGS_set_tid_address 0 + #ifdef __ASSEMBLER__ #define syscall_weak(name,wsym,sym) __syscall_weak $__NR_##name, wsym, sym, __ARGS_##name .macro __syscall_weak name wsym sym typ diff -uNr dietlibc-0.23/contrib/Makefile dietlibc-0.24/contrib/Makefile --- dietlibc-0.23/contrib/Makefile Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/contrib/Makefile Sat Sep 20 02:06:32 2003 @@ -0,0 +1,2 @@ +pnpdnsd: pnpdnsd.c + diet gcc -g -o $@ $^ diff -uNr dietlibc-0.23/contrib/elftrunc.c dietlibc-0.24/contrib/elftrunc.c --- dietlibc-0.23/contrib/elftrunc.c Tue Oct 9 20:02:10 2001 +++ dietlibc-0.24/contrib/elftrunc.c Sat Nov 1 23:29:37 2003 @@ -54,7 +54,6 @@ len -= n; eh32.e_shoff=0; - eh32.e_shentsize=0; eh32.e_shnum=0; eh32.e_shstrndx=0; @@ -109,7 +108,6 @@ len -= n; eh64.e_shoff=0; - eh64.e_shentsize=0; eh64.e_shnum=0; eh64.e_shstrndx=0; @@ -121,8 +119,8 @@ { if ((n=read(in,buf,sizeof(buf)))>0) { - write(out,buf,(size_t)((len<(size_t)n)?len:n)); - len-=(len<(size_t)n)?len:n; + write(out,buf,(size_t)((len<(size_t)n)?len:(size_t)n)); + len-=(len<(size_t)n)?len:(size_t)n; } else die(2,"read error"); } diff -uNr dietlibc-0.23/contrib/pnpdnsd.c dietlibc-0.24/contrib/pnpdnsd.c --- dietlibc-0.23/contrib/pnpdnsd.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/contrib/pnpdnsd.c Sat Sep 20 20:03:27 2003 @@ -0,0 +1,117 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc,char* argv[]) { + int pnpfd; + struct sockaddr_in6 pnpsa; + struct pollfd pfd; + struct ipv6_mreq opt; + unsigned int interface=0; + unsigned char inpkg[4095]; + + if (argc<2) { + puts("usage: pnpdnsd eth0"); + return 111; + } + interface=if_nametoindex(argv[1]); + if (interface==0) { + puts("pnpdnsd: network interface not found!"); + return 111; + } + pnpfd=socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP); + + /* bind to port 53 */ + memset(&pnpsa,0,sizeof(struct sockaddr_in6)); + pnpsa.sin6_family=AF_INET6; + pnpsa.sin6_port=htons(53); + pnpsa.sin6_scope_id=interface; + if (bind(pnpfd,(struct sockaddr*)&pnpsa,sizeof(pnpsa))) { + perror("bind"); + return 111; + } + + /* join the multicast group */ + memmove(&opt.ipv6mr_multiaddr,"\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00dnspnp",16); + opt.ipv6mr_interface=interface; + if (setsockopt(pnpfd,IPPROTO_IPV6,IPV6_ADD_MEMBERSHIP,&opt,sizeof opt)==-1) { + perror("setsockopt"); + return 111; + } + + { + socklen_t len=sizeof(pnpsa); + if (getsockname(pnpfd,(struct sockaddr*)&pnpsa,&len)==-1) { + perror("getsockname"); + return 111; + } + } + + for (;;) { + int len; + int fromlen; + int qdcount; + struct sockaddr_in6 peersa; + fromlen=sizeof(peersa); + len=recvfrom(pnpfd,inpkg,sizeof(inpkg),0,(struct sockaddr*)&peersa,&fromlen); + if (len==-1) { + perror("recvfrom"); + return 111; + } + + /* is it a recursive query, as libresolv would issue? */ + if (inpkg[2]!=1) continue; + + qdcount=((unsigned long)(inpkg[4])<<8) + inpkg[5]; + + { + int decofs; + char name[257]; + char myname[257]; + struct utsname u; + decofs=dn_expand(inpkg,inpkg+len,inpkg+12,name,sizeof(name)-1); + puts(name); + uname(&u); + if (strlen(u.nodename)>63) u.nodename[63]=0; + if (!strcasecmp(u.nodename,name)) { + char packet[1500]; + char* c; + packet[0]=inpkg[0]; + packet[1]=inpkg[1]; + packet[2]=inpkg[2] | 0x84; + packet[3]=0; + memset(packet+4,0,8); + packet[7]=1; + packet[12]=strlen(u.nodename); + strcpy(packet+13,u.nodename); + c=packet+14+strlen(u.nodename); + if (((long)c)&1) { *c=0; ++c; } + /* int16 type */ + c[0]=0; c[1]=28; /* AAAA */ + /* int16 class */ + c[2]=0; c[3]=1; /* IN */ + /* int32 ttl */ + c[4]=0; c[5]=0; c[6]=0; c[7]=23; /* 23 seconds TTL */ + /* int16 rdlength */ + c[8]=0; c[9]=16; + /* int16 rdata */ + memmove(c+10,&pnpsa.sin6_addr,16); + + if (sendto(pnpfd,packet,c+26-packet,0,(struct sockaddr*)&peersa,fromlen)==-1) + perror("sendto"); + } + } + } +} diff -uNr dietlibc-0.23/diet.c dietlibc-0.24/diet.c --- dietlibc-0.23/diet.c Thu Jun 19 13:23:24 2003 +++ dietlibc-0.24/diet.c Fri Oct 10 15:17:46 2003 @@ -35,7 +35,9 @@ "arm","-Os","-fomit-frame-pointer",0, "mips","-Os","-fomit-frame-pointer","-mno-abicalls","-fno-pic","-G","0",0, "ppc","-Os","-fomit-frame-pointer","-mpowerpc-gpopt","-mpowerpc-gfxopt",0, + "ppc64","-Os","-fomit-frame-pointer","-mpowerpc-gpopt","-mpowerpc-gfxopt",0, "s390","-Os","-fomit-frame-pointer",0, + "s390x","-Os","-fomit-frame-pointer",0, "sh","-Os","-fomit-frame-pointer",0, "ia64","-Os","-fno-omit-frame-pointer",0, "x86_64","-Os","-fstrict-aliasing","-momit-leaf-frame-pointer","-mfance-math-387",0, @@ -125,9 +127,12 @@ shortplatform="sparc"; #endif #endif -#ifdef __powerpc__ +#ifdef powerpc shortplatform="ppc"; #endif +#ifdef __powerpc64__ + shortplatform="ppc64"; +#endif #ifdef __i386__ shortplatform="i386"; #endif @@ -140,9 +145,13 @@ #ifdef __mips__ shortplatform="mips"; #endif +#ifdef __s390x__ + shortplatform="s390x"; +#else #ifdef __s390__ shortplatform="s390"; #endif +#endif #ifdef __sh__ shortplatform="sh"; #endif diff -uNr dietlibc-0.23/dietfeatures.h dietlibc-0.24/dietfeatures.h --- dietlibc-0.23/dietfeatures.h Thu May 1 20:57:02 2003 +++ dietlibc-0.24/dietfeatures.h Wed Oct 15 15:14:41 2003 @@ -7,6 +7,7 @@ #define WANT_FLOATING_POINT_IN_SCANF #define WANT_CHARACTER_CLASSES_IN_SCANF #define WANT_NULL_PRINTF +/* #define WANT_ERROR_PRINTF */ #define WANT_LONGLONG_PRINTF #define WANT_LONGLONG_SCANF @@ -79,6 +80,10 @@ * against glibc fail? This may fail with older binutils. */ #define WANT_SAFEGUARD +/* this enables an experimental DNS hack of mine. + * See http://www.fefe.de/ipv6pnpdns.html */ +// #define WANT_IPV6_PLUGPLAY_DNS + /* dy you want that malloc(0) return a pointer to a "zero-length" object * that is realloc-able; means realloc(..,size) gives a NEW object (like a * call to malloc(size)). diff -uNr dietlibc-0.23/dietstdio.h dietlibc-0.24/dietstdio.h --- dietlibc-0.23/dietstdio.h Wed Dec 4 19:32:33 2002 +++ dietlibc-0.24/dietstdio.h Tue Nov 11 18:35:03 2003 @@ -37,6 +37,8 @@ #define NOBUF 16 #define STATICBUF 32 #define FDPIPE 64 +#define CANREAD 128 +#define CANWRITE 256 #define _IONBF 0 #define _IOLBF 1 @@ -72,6 +74,18 @@ int __fflush_stdout(void); int __fflush_stderr(void); -FILE* __stdio_init_file(int fd,int closeonerror); +FILE* __stdio_init_file(int fd,int closeonerror,int mode); int __stdio_parse_mode(const char *mode); void __stdio_flushall(void); + +#ifndef __THREAD_INTERNAL_H__ +int __libc_close(int fd); +int __libc_open(const char*fn,int flags,...); +int __libc_read(int fd,void*buf,int len); +int __libc_write(int fd,const void*buf,int len); +#endif + +FILE *fopen_unlocked(const char *path, const char *mode) __THROW; +FILE *fdopen_unlocked(int fildes, const char *mode) __THROW; +FILE *freopen_unlocked(const char *path, const char *mode, FILE *stream) __THROW; + diff -uNr dietlibc-0.23/dietuglyweaks.h dietlibc-0.24/dietuglyweaks.h --- dietlibc-0.23/dietuglyweaks.h Mon Aug 19 19:08:56 2002 +++ dietlibc-0.24/dietuglyweaks.h Wed Oct 15 15:14:41 2003 @@ -14,6 +14,8 @@ __fflush_stderr: .weak flockfile flockfile: +.weak ftrylockfile +ftrylockfile: .weak funlockfile funlockfile: .weak __nop diff -uNr dietlibc-0.23/i386/dyn_syscalls.S dietlibc-0.24/i386/dyn_syscalls.S --- dietlibc-0.23/i386/dyn_syscalls.S Fri Sep 12 14:32:48 2003 +++ dietlibc-0.24/i386/dyn_syscalls.S Wed Oct 8 01:44:25 2003 @@ -271,6 +271,8 @@ #include "../syscalls.s/epoll_wait.S" #include "../syscalls.s/sendfile64.S" #include "../syscalls.s/sysfs.S" +#include "../syscalls.s/capget.S" +#include "../syscalls.s/capset.S" #undef __PIC__ #undef __socketcall diff -uNr dietlibc-0.23/i386/fmod.S dietlibc-0.24/i386/fmod.S --- dietlibc-0.23/i386/fmod.S Fri Oct 11 17:31:04 2002 +++ dietlibc-0.24/i386/fmod.S Wed Oct 8 01:44:25 2003 @@ -23,6 +23,7 @@ fstsw %ax sahf jp .Lfmod + fstp %st(1) ret fmodl: diff -uNr dietlibc-0.23/i386/memccpy.S dietlibc-0.24/i386/memccpy.S --- dietlibc-0.23/i386/memccpy.S Thu Sep 26 17:54:54 2002 +++ dietlibc-0.24/i386/memccpy.S Thu Oct 16 12:03:44 2003 @@ -19,9 +19,10 @@ movl %esp, %ecx movl 0x0c(%ecx), %edi movl 0x10(%ecx), %esi - movb 0x14(%ecx), %dl + movl 0x14(%ecx), %edx movl 0x18(%ecx), %ecx cld + jecxz .Lerr .Lloop: lodsb stosb @@ -29,6 +30,7 @@ jz .Lout decl %ecx jnz .Lloop +.Lerr: xorl %edi, %edi .Lout: movl %edi, %eax diff -uNr dietlibc-0.23/i386/memcmp.S dietlibc-0.24/i386/memcmp.S --- dietlibc-0.23/i386/memcmp.S Mon Apr 29 22:18:42 2002 +++ dietlibc-0.24/i386/memcmp.S Thu Oct 16 12:03:44 2003 @@ -1,26 +1,22 @@ .text -.align 0 .global memcmp -.type memcmp,@function +.type memcmp,function memcmp: - xorl %eax,%eax - orl 12(%esp),%eax - jz .Lempty - pushl %esi - pushl %edi - movl 12(%esp),%esi - movl 16(%esp),%edi - movl %eax,%ecx - + pushl %esi + pushl %edi + xorl %eax,%eax + movl %esp,%ecx + movl 12(%ecx),%esi + movl 16(%ecx),%edi + movl 20(%ecx),%ecx + jecxz .Lout + cld rep cmpsb - - decl %esi - decl %edi - lodsb - subb (%edi), %al - movsx %al, %eax - + jz .Lout + sbbl %eax,%eax + orl $1,%eax +.Lout: popl %edi popl %esi -.Lempty: ret +.size memcmp,.-memcmp diff -uNr dietlibc-0.23/i386/strncmp.S dietlibc-0.24/i386/strncmp.S --- dietlibc-0.23/i386/strncmp.S Thu Aug 23 18:53:29 2001 +++ dietlibc-0.24/i386/strncmp.S Thu Oct 16 12:03:44 2003 @@ -1,28 +1,33 @@ .text -.align 0 .global strncmp -.type strncmp,@function +.type strncmp,function strncmp: - push %ebx - movl %esp,%ebx - movl 12(%ebx),%edx - movl 16(%ebx),%ecx - movl 8(%ebx),%ebx + pushl %esi + pushl %edi + movl %esp,%ecx + movl 12(%ecx),%esi + movl 16(%ecx),%edi + movl 20(%ecx),%ecx + jecxz .Lequal .Lloop: - jecxz .Ldone - decl %ecx - movb (%ebx),%al - incl %edx - incl %ebx - movb %al,%ah - subb -1(%edx),%al - jnz .Lnotequal - testb %ah,%ah - jnz .Lloop + movzbl (%esi),%eax + movzbl (%edi),%edx + incl %esi + incl %edi + /* !equal ? */ + subl %edx,%eax + jnz .Lout + /* end of c-string ? */ + test %edx,%edx + jz .Lequal + /* do loop */ + decl %ecx + jnz .Lloop -.Ldone: - xorl %eax,%eax -.Lnotequal: - movsx %al, %eax - popl %ebx +.Lequal: + xorl %eax,%eax +.Lout: + popl %edi + popl %esi ret +.size strncmp,.-strncmp diff -uNr dietlibc-0.23/i386/strrchr.S dietlibc-0.24/i386/strrchr.S --- dietlibc-0.23/i386/strrchr.S Mon Jun 24 17:02:39 2002 +++ dietlibc-0.24/i386/strrchr.S Wed Oct 15 15:14:41 2003 @@ -3,17 +3,17 @@ .type strrchr,@function strrchr: - movl 0x4(%esp), %edx - movb 0x8(%esp), %cl - xorl %eax, %eax - decl %edx + movl 0x4(%esp), %edx + movb 0x8(%esp), %cl + xorl %eax, %eax .Lloop: - incl %edx - cmpb $0x0,(%edx) - jz .Lret - cmpb %cl, (%edx) - jnz .Lloop - movl %edx, %eax - jmp .Lloop + cmpb %cl, (%edx) + jnz .Ltest0 + movl %edx, %eax +.Ltest0: + cmpb $0,(%edx) + jz .Lret + incl %edx + jmp .Lloop .Lret: ret diff -uNr dietlibc-0.23/i386/syscalls.h dietlibc-0.24/i386/syscalls.h --- dietlibc-0.23/i386/syscalls.h Sat Apr 12 15:13:58 2003 +++ dietlibc-0.24/i386/syscalls.h Fri Nov 7 14:15:31 2003 @@ -221,7 +221,7 @@ #define __NR_madvise1 219 /* delete when C lib stub is removed */ #define __NR_getdents64 220 #define __NR_fcntl64 221 -#define __NR_security 223 /* syscall for security modules */ +/* 223 is unused */ #define __NR_gettid 224 #define __NR_readahead 225 #define __NR_setxattr 226 @@ -266,6 +266,12 @@ #define __NR_clock_gettime (__NR_timer_create+6) #define __NR_clock_getres (__NR_timer_create+7) #define __NR_clock_nanosleep (__NR_timer_create+8) +#define __NR_statfs64 268 +#define __NR_fstatfs64 269 +#define __NR_tgkill 270 +#define __NR_utimes 271 +#define __NR_fadvise64_64 272 +#define __NR_vserver 273 #define syscall_weak(name,wsym,sym) \ .text; \ diff -uNr dietlibc-0.23/ia64/fork.S dietlibc-0.24/ia64/fork.S --- dietlibc-0.23/ia64/fork.S Sat Nov 9 18:44:47 2002 +++ dietlibc-0.24/ia64/fork.S Fri Oct 10 15:15:08 2003 @@ -1,8 +1,18 @@ #include "syscalls.h" +#include +#define SIGCLD 17 -.text -.globl fork + .text + .globl fork + .proc fork + .weak __libc_fork + .type fork,@function + .type __libc_fork,@function fork: +__libc_fork: + alloc r2=ar.pfs,0,0,2,0 + mov out0=SIGCLD + mov out1=0 + ;; mov r15 = __NR_clone - mov r32 = 17 br __unified_syscall diff -uNr dietlibc-0.23/ia64/pipe.S dietlibc-0.24/ia64/pipe.S --- dietlibc-0.23/ia64/pipe.S Mon May 13 17:55:50 2002 +++ dietlibc-0.24/ia64/pipe.S Tue Nov 4 17:06:33 2003 @@ -10,8 +10,10 @@ break.i 0x100000 ld8 r2 = [r12] cmp.eq p7,p6=-1,r10 + ;; (p6) st4 [r2] = r8,4 mov r8 = r0 + ;; (p7) br.cond.spnt.few __error_unified_syscall (p6) st4 [r2] = r9 (p6) br.ret.sptk.few b0 diff -uNr dietlibc-0.23/ia64/start.S dietlibc-0.24/ia64/start.S --- dietlibc-0.23/ia64/start.S Sat Nov 9 18:09:30 2002 +++ dietlibc-0.24/ia64/start.S Fri Oct 10 15:15:08 2003 @@ -40,6 +40,6 @@ br.call.sptk.few rp = main /* call main */ ;; mov r32 = r8 /* store return code */ - br _exit /* branch to _exit */ + br exit /* branch to exit */ .endp _start .size _start, . - _start diff -uNr dietlibc-0.23/ia64/syscalls.h dietlibc-0.24/ia64/syscalls.h --- dietlibc-0.23/ia64/syscalls.h Sat Apr 12 15:20:44 2003 +++ dietlibc-0.24/ia64/syscalls.h Fri Oct 10 15:15:08 2003 @@ -247,6 +247,7 @@ wsym: \ .globl sym; \ sym: \ +wsym: ; \ mov r15 = __NR_##name; \ br __unified_syscall; diff -uNr dietlibc-0.23/ia64/waitpid.S dietlibc-0.24/ia64/waitpid.S --- dietlibc-0.23/ia64/waitpid.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/ia64/waitpid.S Fri Oct 10 15:15:08 2003 @@ -0,0 +1,11 @@ +#include + + .text + .weak waitpid +waitpid: + .global __libc_waitpid +__libc_waitpid: + alloc r2=ar.pfs,4,0,0,0 + mov in3=r0 + mov r15=__NR_wait4 + br __unified_syscall diff -uNr dietlibc-0.23/include/ar.h dietlibc-0.24/include/ar.h --- dietlibc-0.23/include/ar.h Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/include/ar.h Sat Nov 1 23:17:00 2003 @@ -0,0 +1,27 @@ +#ifndef _AR_H +#define _AR_H + +/* this header is obsolete, don't rely on it! */ + +#include + +#define ARMAG "!\n" /* String that begins an archive file. */ +#define SARMAG 8 /* Size of that string. */ + +#define ARFMAG "`\n" /* String in ar_fmag at end of each header. */ + +__BEGIN_DECLS + +struct ar_hdr + { + char ar_name[16]; /* Member file name, sometimes / terminated. */ + char ar_date[12]; /* File date, decimal seconds since Epoch. */ + char ar_uid[6], ar_gid[6]; /* User and group IDs, in ASCII decimal. */ + char ar_mode[8]; /* File mode, in ASCII octal. */ + char ar_size[10]; /* File size, in ASCII decimal. */ + char ar_fmag[2]; /* Always contains ARFMAG. */ + }; + +__END_DECLS + +#endif diff -uNr dietlibc-0.23/include/asm/sigcontext.h dietlibc-0.24/include/asm/sigcontext.h --- dietlibc-0.23/include/asm/sigcontext.h Tue Aug 19 23:38:23 2003 +++ dietlibc-0.24/include/asm/sigcontext.h Fri Oct 10 15:17:46 2003 @@ -21,7 +21,7 @@ #include #endif -#ifdef __powerpc__ +#if defined(powerpc) || defined(__powerpc64__) #include #endif diff -uNr dietlibc-0.23/include/byteswap.h dietlibc-0.24/include/byteswap.h --- dietlibc-0.23/include/byteswap.h Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/include/byteswap.h Tue Nov 18 14:14:51 2003 @@ -0,0 +1,18 @@ +#ifndef _BYTESWAP_H +#define _BYTESWAP_H + +#warning "byteswap.h is an unportable GNU extension! Don't use!" + +static inline unsigned short bswap_16(unsigned short x) { + return (x>>8) | (x<<8); +} + +static inline unsigned int bswap_32(unsigned int x) { + return (bswap_16(x&0xffff)<<16) | (bswap_16(x>>16)); +} + +static inline unsigned long long bswap_64(unsigned long long x) { + return (((unsigned long long)bswap_32(x&0xffffffffull))<<32) | (bswap_32(x>>32)); +} + +#endif diff -uNr dietlibc-0.23/include/dietref.h dietlibc-0.24/include/dietref.h --- dietlibc-0.23/include/dietref.h Thu Feb 21 01:33:37 2002 +++ dietlibc-0.24/include/dietref.h Thu Nov 6 13:00:09 2003 @@ -3,20 +3,23 @@ * glibc will fail. */ #ifndef NODIETREF -#include #ifdef __ASSEMBLER__ +#include .section .note +.long 4 +.long 2f-1f +.long 0 +.ascii "diet" +1: #if (__WORDSIZE == 64) .quad __you_tried_to_link_a_dietlibc_object_against_glibc #else .long __you_tried_to_link_a_dietlibc_object_against_glibc #endif +2: .previous #else -#if (__WORDSIZE == 64) -__asm__ (".section .note\n\t.quad __you_tried_to_link_a_dietlibc_object_against_glibc\n\t.previous"); -#else -__asm__ (".section .note\n\t.long __you_tried_to_link_a_dietlibc_object_against_glibc\n\t.previous"); -#endif +#include +__dietref("__you_tried_to_link_a_dietlibc_object_against_glibc"); #endif #endif diff -uNr dietlibc-0.23/include/dietrefdef.h dietlibc-0.24/include/dietrefdef.h --- dietlibc-0.23/include/dietrefdef.h Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/include/dietrefdef.h Thu Nov 6 13:56:25 2003 @@ -0,0 +1,19 @@ +#ifndef __DIETREFDEF_H__ +#include + +#if (__WORDSIZE == 64) +#define __DIETREFDEF_H__ ".quad" +#else +#define __DIETREFDEF_H__ ".long" +#endif + +#define __dietref(name) \ +__asm__(".section .note\n" \ + "\t.long 4\n" \ + "\t.long 2f-1f\n" \ + "\t.long 0\n" \ + "\t.ascii \"diet\"\n" \ + "1:\t" __DIETREFDEF_H__ " " name "\n2:" \ + ".previous"); + +#endif diff -uNr dietlibc-0.23/include/elf.h dietlibc-0.24/include/elf.h --- dietlibc-0.23/include/elf.h Tue Aug 19 18:23:35 2003 +++ dietlibc-0.24/include/elf.h Fri Oct 10 15:39:07 2003 @@ -1,390 +1,1830 @@ #ifndef _ELF_H -#define _ELF_H +#define _ELF_H 1 + +/* Standard ELF types. */ #include __BEGIN_DECLS -/* 32-bit ELF base types. */ -typedef uint32_t Elf32_Addr; -typedef uint16_t Elf32_Half; -typedef uint32_t Elf32_Off; -typedef int32_t Elf32_Sword; -typedef uint32_t Elf32_Word; - -/* 64-bit ELF base types. */ -typedef uint64_t Elf64_Addr; -typedef uint16_t Elf64_Half; -typedef int16_t Elf64_SHalf; -typedef uint64_t Elf64_Off; -typedef int32_t Elf64_Sword; -typedef uint32_t Elf64_Word; -typedef uint64_t Elf64_Xword; -typedef int64_t Elf64_Sxword; - -/* These constants are for the segment types stored in the image headers */ -#define PT_NULL 0 -#define PT_LOAD 1 -#define PT_DYNAMIC 2 -#define PT_INTERP 3 -#define PT_NOTE 4 -#define PT_SHLIB 5 -#define PT_PHDR 6 -#define PT_LOPROC 0x70000000 -#define PT_HIPROC 0x7fffffff -#define PT_MIPS_REGINFO 0x70000000 - -/* Flags in the e_flags field of the header */ -#define EF_MIPS_NOREORDER 0x00000001 -#define EF_MIPS_PIC 0x00000002 -#define EF_MIPS_CPIC 0x00000004 -#define EF_MIPS_ARCH 0xf0000000 - -/* These constants define the different elf file types */ -#define ET_NONE 0 -#define ET_REL 1 -#define ET_EXEC 2 -#define ET_DYN 3 -#define ET_CORE 4 -#define ET_LOPROC 0xff00 -#define ET_HIPROC 0xffff - -/* These constants define the various ELF target machines */ -#define EM_NONE 0 -#define EM_M32 1 -#define EM_SPARC 2 -#define EM_386 3 -#define EM_68K 4 -#define EM_88K 5 -#define EM_486 6 /* Perhaps disused */ -#define EM_860 7 - -#define EM_MIPS 8 /* MIPS R3000 (officially, big-endian only) */ -#define EM_MIPS_RS4_BE 10 /* MIPS R4000 big-endian */ - -#define EM_PARISC 15 /* HPPA */ -#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ -#define EM_PPC 20 /* PowerPC */ -#define EM_S390 22 /* IBM S/390 */ - -#define EM_ARM 40 /* ARM */ -#define EM_SH 42 /* SuperH */ -#define EM_SPARCV9 43 /* SPARC v9 64-bit */ -#define EM_IA_64 50 /* HP/Intel IA-64 */ -#define EM_X86_64 62 /* AMD x86-64 */ -#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ - -/* - * This is an interim value that we will use until the committee comes - * up with a final number. - */ +/* Type for a 16-bit quantity. */ +typedef uint16_t Elf32_Half; +typedef uint16_t Elf64_Half; + +/* Types for signed and unsigned 32-bit quantities. */ +typedef uint32_t Elf32_Word; +typedef int32_t Elf32_Sword; +typedef uint32_t Elf64_Word; +typedef int32_t Elf64_Sword; + +/* Types for signed and unsigned 64-bit quantities. */ +typedef uint64_t Elf32_Xword; +typedef int64_t Elf32_Sxword; +typedef uint64_t Elf64_Xword; +typedef int64_t Elf64_Sxword; + +/* Type of addresses. */ +typedef uint32_t Elf32_Addr; +typedef uint64_t Elf64_Addr; + +/* Type of file offsets. */ +typedef uint32_t Elf32_Off; +typedef uint64_t Elf64_Off; + +/* Type for section indices, which are 16-bit quantities. */ +typedef uint16_t Elf32_Section; +typedef uint16_t Elf64_Section; + +/* Type for version symbol information. */ +typedef Elf32_Half Elf32_Versym; +typedef Elf64_Half Elf64_Versym; + + +/* The ELF file header. This appears at the start of every ELF file. */ + +#define EI_NIDENT (16) + +typedef struct +{ + unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ + Elf32_Half e_type; /* Object file type */ + Elf32_Half e_machine; /* Architecture */ + Elf32_Word e_version; /* Object file version */ + Elf32_Addr e_entry; /* Entry point virtual address */ + Elf32_Off e_phoff; /* Program header table file offset */ + Elf32_Off e_shoff; /* Section header table file offset */ + Elf32_Word e_flags; /* Processor-specific flags */ + Elf32_Half e_ehsize; /* ELF header size in bytes */ + Elf32_Half e_phentsize; /* Program header table entry size */ + Elf32_Half e_phnum; /* Program header table entry count */ + Elf32_Half e_shentsize; /* Section header table entry size */ + Elf32_Half e_shnum; /* Section header table entry count */ + Elf32_Half e_shstrndx; /* Section header string table index */ +} Elf32_Ehdr; + +typedef struct +{ + unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ + Elf64_Half e_type; /* Object file type */ + Elf64_Half e_machine; /* Architecture */ + Elf64_Word e_version; /* Object file version */ + Elf64_Addr e_entry; /* Entry point virtual address */ + Elf64_Off e_phoff; /* Program header table file offset */ + Elf64_Off e_shoff; /* Section header table file offset */ + Elf64_Word e_flags; /* Processor-specific flags */ + Elf64_Half e_ehsize; /* ELF header size in bytes */ + Elf64_Half e_phentsize; /* Program header table entry size */ + Elf64_Half e_phnum; /* Program header table entry count */ + Elf64_Half e_shentsize; /* Section header table entry size */ + Elf64_Half e_shnum; /* Section header table entry count */ + Elf64_Half e_shstrndx; /* Section header string table index */ +} Elf64_Ehdr; + +/* Fields in the e_ident array. The EI_* macros are indices into the + array. The macros under each EI_* macro are the values the byte + may have. */ + +#define EI_MAG0 0 /* File identification byte 0 index */ +#define ELFMAG0 0x7f /* Magic number byte 0 */ + +#define EI_MAG1 1 /* File identification byte 1 index */ +#define ELFMAG1 'E' /* Magic number byte 1 */ + +#define EI_MAG2 2 /* File identification byte 2 index */ +#define ELFMAG2 'L' /* Magic number byte 2 */ + +#define EI_MAG3 3 /* File identification byte 3 index */ +#define ELFMAG3 'F' /* Magic number byte 3 */ + +/* Conglomeration of the identification bytes, for easy testing as a word. */ +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +#define EI_CLASS 4 /* File class byte index */ +#define ELFCLASSNONE 0 /* Invalid class */ +#define ELFCLASS32 1 /* 32-bit objects */ +#define ELFCLASS64 2 /* 64-bit objects */ +#define ELFCLASSNUM 3 + +#define EI_DATA 5 /* Data encoding byte index */ +#define ELFDATANONE 0 /* Invalid data encoding */ +#define ELFDATA2LSB 1 /* 2's complement, little endian */ +#define ELFDATA2MSB 2 /* 2's complement, big endian */ +#define ELFDATANUM 3 + +#define EI_VERSION 6 /* File version byte index */ + /* Value must be EV_CURRENT */ + +#define EI_OSABI 7 /* OS ABI identification */ +#define ELFOSABI_NONE 0 /* UNIX System V ABI */ +#define ELFOSABI_SYSV 0 /* Alias. */ +#define ELFOSABI_HPUX 1 /* HP-UX */ +#define ELFOSABI_NETBSD 2 /* NetBSD. */ +#define ELFOSABI_LINUX 3 /* Linux. */ +#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */ +#define ELFOSABI_AIX 7 /* IBM AIX. */ +#define ELFOSABI_IRIX 8 /* SGI Irix. */ +#define ELFOSABI_FREEBSD 9 /* FreeBSD. */ +#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */ +#define ELFOSABI_MODESTO 11 /* Novell Modesto. */ +#define ELFOSABI_OPENBSD 12 /* OpenBSD. */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +#define EI_ABIVERSION 8 /* ABI version */ + +#define EI_PAD 9 /* Byte index of padding bytes */ + +/* Legal values for e_type (object file type). */ + +#define ET_NONE 0 /* No file type */ +#define ET_REL 1 /* Relocatable file */ +#define ET_EXEC 2 /* Executable file */ +#define ET_DYN 3 /* Shared object file */ +#define ET_CORE 4 /* Core file */ +#define ET_NUM 5 /* Number of defined types */ +#define ET_LOOS 0xfe00 /* OS-specific range start */ +#define ET_HIOS 0xfeff /* OS-specific range end */ +#define ET_LOPROC 0xff00 /* Processor-specific range start */ +#define ET_HIPROC 0xffff /* Processor-specific range end */ + +/* Legal values for e_machine (architecture). */ + +#define EM_NONE 0 /* No machine */ +#define EM_M32 1 /* AT&T WE 32100 */ +#define EM_SPARC 2 /* SUN SPARC */ +#define EM_386 3 /* Intel 80386 */ +#define EM_68K 4 /* Motorola m68k family */ +#define EM_88K 5 /* Motorola m88k family */ +#define EM_860 7 /* Intel 80860 */ +#define EM_MIPS 8 /* MIPS R3000 big-endian */ +#define EM_S370 9 /* IBM System/370 */ +#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */ + +#define EM_PARISC 15 /* HPPA */ +#define EM_VPP500 17 /* Fujitsu VPP500 */ +#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ +#define EM_960 19 /* Intel 80960 */ +#define EM_PPC 20 /* PowerPC */ +#define EM_PPC64 21 /* PowerPC 64-bit */ +#define EM_S390 22 /* IBM S390 */ + +#define EM_V800 36 /* NEC V800 series */ +#define EM_FR20 37 /* Fujitsu FR20 */ +#define EM_RH32 38 /* TRW RH-32 */ +#define EM_RCE 39 /* Motorola RCE */ +#define EM_ARM 40 /* ARM */ +#define EM_FAKE_ALPHA 41 /* Digital Alpha */ +#define EM_SH 42 /* Hitachi SH */ +#define EM_SPARCV9 43 /* SPARC v9 64-bit */ +#define EM_TRICORE 44 /* Siemens Tricore */ +#define EM_ARC 45 /* Argonaut RISC Core */ +#define EM_H8_300 46 /* Hitachi H8/300 */ +#define EM_H8_300H 47 /* Hitachi H8/300H */ +#define EM_H8S 48 /* Hitachi H8S */ +#define EM_H8_500 49 /* Hitachi H8/500 */ +#define EM_IA_64 50 /* Intel Merced */ +#define EM_MIPS_X 51 /* Stanford MIPS-X */ +#define EM_COLDFIRE 52 /* Motorola Coldfire */ +#define EM_68HC12 53 /* Motorola M68HC12 */ +#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/ +#define EM_PCP 55 /* Siemens PCP */ +#define EM_NCPU 56 /* Sony nCPU embeeded RISC */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor */ +#define EM_STARCORE 58 /* Motorola Start*Core processor */ +#define EM_ME16 59 /* Toyota ME16 processor */ +#define EM_ST100 60 /* STMicroelectronic ST100 processor */ +#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/ +#define EM_X86_64 62 /* AMD x86-64 architecture */ +#define EM_PDSP 63 /* Sony DSP Processor */ + +#define EM_FX66 66 /* Siemens FX66 microcontroller */ +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ +#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ +#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ +#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ +#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ +#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ +#define EM_SVX 73 /* Silicon Graphics SVx */ +#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */ +#define EM_VAX 75 /* Digital VAX */ +#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */ +#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ +#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ +#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ +#define EM_HUANY 81 /* Harvard University machine-independent object files */ +#define EM_PRISM 82 /* SiTera Prism */ +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ +#define EM_FR30 84 /* Fujitsu FR30 */ +#define EM_D10V 85 /* Mitsubishi D10V */ +#define EM_D30V 86 /* Mitsubishi D30V */ +#define EM_V850 87 /* NEC v850 */ +#define EM_M32R 88 /* Mitsubishi M32R */ +#define EM_MN10300 89 /* Matsushita MN10300 */ +#define EM_MN10200 90 /* Matsushita MN10200 */ +#define EM_PJ 91 /* picoJava */ +#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ +#define EM_NUM 95 + +/* If it is necessary to assign new unofficial EM_* values, please + pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the + chances of collision with official or non-GNU unofficial values. */ + #define EM_ALPHA 0x9026 -/* - * This is the old interim value for S/390 architecture - */ -#define EM_S390_OLD 0xA390 - -/* This is the info that is needed to parse the dynamic section of the file */ -#define DT_NULL 0 -#define DT_NEEDED 1 -#define DT_PLTRELSZ 2 -#define DT_PLTGOT 3 -#define DT_HASH 4 -#define DT_STRTAB 5 -#define DT_SYMTAB 6 -#define DT_RELA 7 -#define DT_RELASZ 8 -#define DT_RELAENT 9 -#define DT_STRSZ 10 -#define DT_SYMENT 11 -#define DT_INIT 12 -#define DT_FINI 13 -#define DT_SONAME 14 -#define DT_RPATH 15 -#define DT_SYMBOLIC 16 -#define DT_REL 17 -#define DT_RELSZ 18 -#define DT_RELENT 19 -#define DT_PLTREL 20 -#define DT_DEBUG 21 -#define DT_TEXTREL 22 -#define DT_JMPREL 23 -#define DT_NUM 24 -#define DT_LOPROC 0x70000000 -#define DT_HIPROC 0x7fffffff -#define DT_MIPS_RLD_VERSION 0x70000001 -#define DT_MIPS_TIME_STAMP 0x70000002 -#define DT_MIPS_ICHECKSUM 0x70000003 -#define DT_MIPS_IVERSION 0x70000004 -#define DT_MIPS_FLAGS 0x70000005 - #define RHF_NONE 0 - #define RHF_HARDWAY 1 - #define RHF_NOTPOT 2 -#define DT_MIPS_BASE_ADDRESS 0x70000006 -#define DT_MIPS_CONFLICT 0x70000008 -#define DT_MIPS_LIBLIST 0x70000009 -#define DT_MIPS_LOCAL_GOTNO 0x7000000a -#define DT_MIPS_CONFLICTNO 0x7000000b -#define DT_MIPS_LIBLISTNO 0x70000010 -#define DT_MIPS_SYMTABNO 0x70000011 -#define DT_MIPS_UNREFEXTNO 0x70000012 -#define DT_MIPS_GOTSYM 0x70000013 -#define DT_MIPS_HIPAGENO 0x70000014 -#define DT_MIPS_RLD_MAP 0x70000016 - -/* This info is needed when parsing the symbol table */ -#define STB_LOCAL 0 -#define STB_GLOBAL 1 -#define STB_WEAK 2 - -#define STT_NOTYPE 0 -#define STT_OBJECT 1 -#define STT_FUNC 2 -#define STT_SECTION 3 -#define STT_FILE 4 +/* Legal values for e_version (version). */ + +#define EV_NONE 0 /* Invalid ELF version */ +#define EV_CURRENT 1 /* Current version */ +#define EV_NUM 2 + +/* Section header. */ + +typedef struct +{ + Elf32_Word sh_name; /* Section name (string tbl index) */ + Elf32_Word sh_type; /* Section type */ + Elf32_Word sh_flags; /* Section flags */ + Elf32_Addr sh_addr; /* Section virtual addr at execution */ + Elf32_Off sh_offset; /* Section file offset */ + Elf32_Word sh_size; /* Section size in bytes */ + Elf32_Word sh_link; /* Link to another section */ + Elf32_Word sh_info; /* Additional section information */ + Elf32_Word sh_addralign; /* Section alignment */ + Elf32_Word sh_entsize; /* Entry size if section holds table */ +} Elf32_Shdr; + +typedef struct +{ + Elf64_Word sh_name; /* Section name (string tbl index) */ + Elf64_Word sh_type; /* Section type */ + Elf64_Xword sh_flags; /* Section flags */ + Elf64_Addr sh_addr; /* Section virtual addr at execution */ + Elf64_Off sh_offset; /* Section file offset */ + Elf64_Xword sh_size; /* Section size in bytes */ + Elf64_Word sh_link; /* Link to another section */ + Elf64_Word sh_info; /* Additional section information */ + Elf64_Xword sh_addralign; /* Section alignment */ + Elf64_Xword sh_entsize; /* Entry size if section holds table */ +} Elf64_Shdr; + +/* Special section indices. */ + +#define SHN_UNDEF 0 /* Undefined section */ +#define SHN_LORESERVE 0xff00 /* Start of reserved indices */ +#define SHN_LOPROC 0xff00 /* Start of processor-specific */ +#define SHN_HIPROC 0xff1f /* End of processor-specific */ +#define SHN_LOOS 0xff20 /* Start of OS-specific */ +#define SHN_HIOS 0xff3f /* End of OS-specific */ +#define SHN_ABS 0xfff1 /* Associated symbol is absolute */ +#define SHN_COMMON 0xfff2 /* Associated symbol is common */ +#define SHN_XINDEX 0xffff /* Index is in extra table. */ +#define SHN_HIRESERVE 0xffff /* End of reserved indices */ + +/* Legal values for sh_type (section type). */ + +#define SHT_NULL 0 /* Section header table entry unused */ +#define SHT_PROGBITS 1 /* Program data */ +#define SHT_SYMTAB 2 /* Symbol table */ +#define SHT_STRTAB 3 /* String table */ +#define SHT_RELA 4 /* Relocation entries with addends */ +#define SHT_HASH 5 /* Symbol hash table */ +#define SHT_DYNAMIC 6 /* Dynamic linking information */ +#define SHT_NOTE 7 /* Notes */ +#define SHT_NOBITS 8 /* Program space with no data (bss) */ +#define SHT_REL 9 /* Relocation entries, no addends */ +#define SHT_SHLIB 10 /* Reserved */ +#define SHT_DYNSYM 11 /* Dynamic linker symbol table */ +#define SHT_INIT_ARRAY 14 /* Array of constructors */ +#define SHT_FINI_ARRAY 15 /* Array of destructors */ +#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */ +#define SHT_GROUP 17 /* Section group */ +#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */ +#define SHT_NUM 19 /* Number of defined types. */ +#define SHT_LOOS 0x60000000 /* Start OS-specific */ +#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */ +#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */ +#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */ +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_COMDAT 0x6ffffffb +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ +#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ +#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ +#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */ +#define SHT_HIOS 0x6fffffff /* End OS-specific type */ +#define SHT_LOPROC 0x70000000 /* Start of processor-specific */ +#define SHT_HIPROC 0x7fffffff /* End of processor-specific */ +#define SHT_LOUSER 0x80000000 /* Start of application-specific */ +#define SHT_HIUSER 0x8fffffff /* End of application-specific */ + +/* Legal values for sh_flags (section flags). */ + +#define SHF_WRITE (1 << 0) /* Writable */ +#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */ +#define SHF_EXECINSTR (1 << 2) /* Executable */ +#define SHF_MERGE (1 << 4) /* Might be merged */ +#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */ +#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */ +#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */ +#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling + required */ +#define SHF_GROUP (1 << 9) /* Section is member of a group. */ +#define SHF_TLS (1 << 10) /* Section hold thread-local data. */ +#define SHF_MASKOS 0x0ff00000 /* OS-specific. */ +#define SHF_MASKPROC 0xf0000000 /* Processor-specific */ + +/* Section group handling. */ +#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */ + +/* Symbol table entry. */ + +typedef struct +{ + Elf32_Word st_name; /* Symbol name (string tbl index) */ + Elf32_Addr st_value; /* Symbol value */ + Elf32_Word st_size; /* Symbol size */ + unsigned char st_info; /* Symbol type and binding */ + unsigned char st_other; /* Symbol visibility */ + Elf32_Section st_shndx; /* Section index */ +} Elf32_Sym; + +typedef struct +{ + Elf64_Word st_name; /* Symbol name (string tbl index) */ + unsigned char st_info; /* Symbol type and binding */ + unsigned char st_other; /* Symbol visibility */ + Elf64_Section st_shndx; /* Section index */ + Elf64_Addr st_value; /* Symbol value */ + Elf64_Xword st_size; /* Symbol size */ +} Elf64_Sym; -#define ELF32_ST_BIND(x) ((x) >> 4) -#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf) +/* The syminfo section if available contains additional information about + every dynamic symbol. */ +typedef struct +{ + Elf32_Half si_boundto; /* Direct bindings, symbol bound to */ + Elf32_Half si_flags; /* Per symbol flags */ +} Elf32_Syminfo; + +typedef struct +{ + Elf64_Half si_boundto; /* Direct bindings, symbol bound to */ + Elf64_Half si_flags; /* Per symbol flags */ +} Elf64_Syminfo; + +/* Possible values for si_boundto. */ +#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */ +#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */ +#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */ + +/* Possible bitmasks for si_flags. */ +#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */ +#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */ +#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */ +#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy + loaded */ +/* Syminfo version values. */ +#define SYMINFO_NONE 0 +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + + +/* How to extract and insert information held in the st_info field. */ + +#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) +#define ELF32_ST_TYPE(val) ((val) & 0xf) +#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) + +/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */ #define ELF64_ST_BIND(val) ELF32_ST_BIND (val) #define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) +#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type)) + +/* Legal values for ST_BIND subfield of st_info (symbol binding). */ + +#define STB_LOCAL 0 /* Local symbol */ +#define STB_GLOBAL 1 /* Global symbol */ +#define STB_WEAK 2 /* Weak symbol */ +#define STB_NUM 3 /* Number of defined types. */ +#define STB_LOOS 10 /* Start of OS-specific */ +#define STB_HIOS 12 /* End of OS-specific */ +#define STB_LOPROC 13 /* Start of processor-specific */ +#define STB_HIPROC 15 /* End of processor-specific */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_NOTYPE 0 /* Symbol type is unspecified */ +#define STT_OBJECT 1 /* Symbol is a data object */ +#define STT_FUNC 2 /* Symbol is a code object */ +#define STT_SECTION 3 /* Symbol associated with a section */ +#define STT_FILE 4 /* Symbol's name is file name */ +#define STT_COMMON 5 /* Symbol is a common data object */ +#define STT_TLS 6 /* Symbol is thread-local data object*/ +#define STT_NUM 7 /* Number of defined types. */ +#define STT_LOOS 10 /* Start of OS-specific */ +#define STT_HIOS 12 /* End of OS-specific */ +#define STT_LOPROC 13 /* Start of processor-specific */ +#define STT_HIPROC 15 /* End of processor-specific */ + + +/* Symbol table indices are found in the hash buckets and chain table + of a symbol hash table section. This special index value indicates + the end of a chain, meaning no further symbols are found in that bucket. */ + +#define STN_UNDEF 0 /* End of a chain. */ + + +/* How to extract and insert information held in the st_other field. */ + +#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) + +/* For ELF64 the definitions are the same. */ +#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) + +/* Symbol visibility specification encoded in the st_other field. */ +#define STV_DEFAULT 0 /* Default symbol visibility rules */ +#define STV_INTERNAL 1 /* Processor specific hidden class */ +#define STV_HIDDEN 2 /* Sym unavailable in other modules */ +#define STV_PROTECTED 3 /* Not preemptible, not exported */ + + +/* Relocation table entry without addend (in section of type SHT_REL). */ + +typedef struct +{ + Elf32_Addr r_offset; /* Address */ + Elf32_Word r_info; /* Relocation type and symbol index */ +} Elf32_Rel; + +/* I have seen two different definitions of the Elf64_Rel and + Elf64_Rela structures, so we'll leave them out until Novell (or + whoever) gets their act together. */ +/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */ + +typedef struct +{ + Elf64_Addr r_offset; /* Address */ + Elf64_Xword r_info; /* Relocation type and symbol index */ +} Elf64_Rel; + +/* Relocation table entry with addend (in section of type SHT_RELA). */ -/* Symbolic values for the entries in the auxiliary table - put on the initial stack */ -#define AT_NULL 0 /* end of vector */ -#define AT_IGNORE 1 /* entry should be ignored */ -#define AT_EXECFD 2 /* file descriptor of program */ -#define AT_PHDR 3 /* program headers for program */ -#define AT_PHENT 4 /* size of program header entry */ -#define AT_PHNUM 5 /* number of program headers */ -#define AT_PAGESZ 6 /* system page size */ -#define AT_BASE 7 /* base address of interpreter */ -#define AT_FLAGS 8 /* flags */ -#define AT_ENTRY 9 /* entry point of program */ -#define AT_NOTELF 10 /* program is not ELF */ -#define AT_UID 11 /* real uid */ -#define AT_EUID 12 /* effective uid */ -#define AT_GID 13 /* real gid */ -#define AT_EGID 14 /* effective gid */ -#define AT_PLATFORM 15 /* string identifying CPU for optimizations */ -#define AT_HWCAP 16 /* arch dependent hints at CPU capabilities */ -#define AT_CLKTCK 17 /* frequency at which times() increments */ -#define AT_FPUCW 18 /* Used FPU control word. */ -#define AT_DCACHEBSIZE 19 /* Data cache block size. */ -#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */ -#define AT_UCACHEBSIZE 21 /* Unified cache block size. */ -#define AT_IGNOREPPC 22 /* Entry should be ignored */ -#define AT_SYSINFO 32 /* pointer to global system page */ - -typedef struct dynamic{ - Elf32_Sword d_tag; - union{ - Elf32_Sword d_val; - Elf32_Addr d_ptr; - } d_un; +typedef struct +{ + Elf32_Addr r_offset; /* Address */ + Elf32_Word r_info; /* Relocation type and symbol index */ + Elf32_Sword r_addend; /* Addend */ +} Elf32_Rela; + +typedef struct +{ + Elf64_Addr r_offset; /* Address */ + Elf64_Xword r_info; /* Relocation type and symbol index */ + Elf64_Sxword r_addend; /* Addend */ +} Elf64_Rela; + +/* How to extract and insert information held in the r_info field. */ + +#define ELF32_R_SYM(val) ((val) >> 8) +#define ELF32_R_TYPE(val) ((val) & 0xff) +#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) + +#define ELF64_R_SYM(i) ((i) >> 32) +#define ELF64_R_TYPE(i) ((i) & 0xffffffff) +#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) + +/* Program segment header. */ + +typedef struct +{ + Elf32_Word p_type; /* Segment type */ + Elf32_Off p_offset; /* Segment file offset */ + Elf32_Addr p_vaddr; /* Segment virtual address */ + Elf32_Addr p_paddr; /* Segment physical address */ + Elf32_Word p_filesz; /* Segment size in file */ + Elf32_Word p_memsz; /* Segment size in memory */ + Elf32_Word p_flags; /* Segment flags */ + Elf32_Word p_align; /* Segment alignment */ +} Elf32_Phdr; + +typedef struct +{ + Elf64_Word p_type; /* Segment type */ + Elf64_Word p_flags; /* Segment flags */ + Elf64_Off p_offset; /* Segment file offset */ + Elf64_Addr p_vaddr; /* Segment virtual address */ + Elf64_Addr p_paddr; /* Segment physical address */ + Elf64_Xword p_filesz; /* Segment size in file */ + Elf64_Xword p_memsz; /* Segment size in memory */ + Elf64_Xword p_align; /* Segment alignment */ +} Elf64_Phdr; + +/* Legal values for p_type (segment type). */ + +#define PT_NULL 0 /* Program header table entry unused */ +#define PT_LOAD 1 /* Loadable program segment */ +#define PT_DYNAMIC 2 /* Dynamic linking information */ +#define PT_INTERP 3 /* Program interpreter */ +#define PT_NOTE 4 /* Auxiliary information */ +#define PT_SHLIB 5 /* Reserved */ +#define PT_PHDR 6 /* Entry for header table itself */ +#define PT_TLS 7 /* Thread-local storage segment */ +#define PT_NUM 8 /* Number of defined types */ +#define PT_LOOS 0x60000000 /* Start of OS-specific */ +#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */ +#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */ +#define PT_LOSUNW 0x6ffffffa +#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ +#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */ +#define PT_HISUNW 0x6fffffff +#define PT_HIOS 0x6fffffff /* End of OS-specific */ +#define PT_LOPROC 0x70000000 /* Start of processor-specific */ +#define PT_HIPROC 0x7fffffff /* End of processor-specific */ + +/* Legal values for p_flags (segment flags). */ + +#define PF_X (1 << 0) /* Segment is executable */ +#define PF_W (1 << 1) /* Segment is writable */ +#define PF_R (1 << 2) /* Segment is readable */ +#define PF_MASKOS 0x0ff00000 /* OS-specific */ +#define PF_MASKPROC 0xf0000000 /* Processor-specific */ + +/* Legal values for note segment descriptor types for core files. */ + +#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */ +#define NT_FPREGSET 2 /* Contains copy of fpregset struct */ +#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */ +#define NT_PRXREG 4 /* Contains copy of prxregset struct */ +#define NT_TASKSTRUCT 4 /* Contains copy of task structure */ +#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */ +#define NT_AUXV 6 /* Contains copy of auxv array */ +#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */ +#define NT_ASRS 8 /* Contains copy of asrset struct */ +#define NT_PSTATUS 10 /* Contains copy of pstatus struct */ +#define NT_PSINFO 13 /* Contains copy of psinfo struct */ +#define NT_PRCRED 14 /* Contains copy of prcred struct */ +#define NT_UTSNAME 15 /* Contains copy of utsname struct */ +#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */ +#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */ +#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct*/ + +/* Legal values for the note segment descriptor types for object files. */ + +#define NT_VERSION 1 /* Contains a version string. */ + + +/* Dynamic section entry. */ + +typedef struct +{ + Elf32_Sword d_tag; /* Dynamic entry type */ + union + { + Elf32_Word d_val; /* Integer value */ + Elf32_Addr d_ptr; /* Address value */ + } d_un; } Elf32_Dyn; -typedef struct { - Elf64_Sxword d_tag; /* entry tag value */ - union { - Elf64_Xword d_val; - Elf64_Addr d_ptr; - } d_un; +typedef struct +{ + Elf64_Sxword d_tag; /* Dynamic entry type */ + union + { + Elf64_Xword d_val; /* Integer value */ + Elf64_Addr d_ptr; /* Address value */ + } d_un; } Elf64_Dyn; -/* The following are used with relocations */ -#define ELF32_R_SYM(x) ((x) >> 8) -#define ELF32_R_TYPE(x) ((x) & 0xff) - -#define ELF64_R_SYM(x) ((x) >> 32) -#define ELF64_R_TYPE(x) ((x) & 0xffffffff) - -#define R_386_NONE 0 -#define R_386_32 1 -#define R_386_PC32 2 -#define R_386_GOT32 3 -#define R_386_PLT32 4 -#define R_386_COPY 5 -#define R_386_GLOB_DAT 6 -#define R_386_JMP_SLOT 7 -#define R_386_RELATIVE 8 -#define R_386_GOTOFF 9 -#define R_386_GOTPC 10 -#define R_386_NUM 11 - -#define R_MIPS_NONE 0 -#define R_MIPS_16 1 -#define R_MIPS_32 2 -#define R_MIPS_REL32 3 -#define R_MIPS_26 4 -#define R_MIPS_HI16 5 -#define R_MIPS_LO16 6 -#define R_MIPS_GPREL16 7 -#define R_MIPS_LITERAL 8 -#define R_MIPS_GOT16 9 -#define R_MIPS_PC16 10 -#define R_MIPS_CALL16 11 -#define R_MIPS_GPREL32 12 -/* The remaining relocs are defined on Irix, although they are not - in the MIPS ELF ABI. */ -#define R_MIPS_UNUSED1 13 -#define R_MIPS_UNUSED2 14 -#define R_MIPS_UNUSED3 15 +/* Legal values for d_tag (dynamic entry type). */ + +#define DT_NULL 0 /* Marks end of dynamic section */ +#define DT_NEEDED 1 /* Name of needed library */ +#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */ +#define DT_PLTGOT 3 /* Processor defined value */ +#define DT_HASH 4 /* Address of symbol hash table */ +#define DT_STRTAB 5 /* Address of string table */ +#define DT_SYMTAB 6 /* Address of symbol table */ +#define DT_RELA 7 /* Address of Rela relocs */ +#define DT_RELASZ 8 /* Total size of Rela relocs */ +#define DT_RELAENT 9 /* Size of one Rela reloc */ +#define DT_STRSZ 10 /* Size of string table */ +#define DT_SYMENT 11 /* Size of one symbol table entry */ +#define DT_INIT 12 /* Address of init function */ +#define DT_FINI 13 /* Address of termination function */ +#define DT_SONAME 14 /* Name of shared object */ +#define DT_RPATH 15 /* Library search path (deprecated) */ +#define DT_SYMBOLIC 16 /* Start symbol search here */ +#define DT_REL 17 /* Address of Rel relocs */ +#define DT_RELSZ 18 /* Total size of Rel relocs */ +#define DT_RELENT 19 /* Size of one Rel reloc */ +#define DT_PLTREL 20 /* Type of reloc in PLT */ +#define DT_DEBUG 21 /* For debugging; unspecified */ +#define DT_TEXTREL 22 /* Reloc might modify .text */ +#define DT_JMPREL 23 /* Address of PLT relocs */ +#define DT_BIND_NOW 24 /* Process relocations of object */ +#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */ +#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */ +#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */ +#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */ +#define DT_RUNPATH 29 /* Library search path */ +#define DT_FLAGS 30 /* Flags for the object being loaded */ +#define DT_ENCODING 32 /* Start of encoded range */ +#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ +#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ +#define DT_NUM 34 /* Number used */ +#define DT_LOOS 0x6000000d /* Start of OS-specific */ +#define DT_HIOS 0x6ffff000 /* End of OS-specific */ +#define DT_LOPROC 0x70000000 /* Start of processor-specific */ +#define DT_HIPROC 0x7fffffff /* End of processor-specific */ +#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */ + +/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the + Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's + approach. */ +#define DT_VALRNGLO 0x6ffffd00 +#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */ +#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */ +#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */ +#define DT_CHECKSUM 0x6ffffdf8 +#define DT_PLTPADSZ 0x6ffffdf9 +#define DT_MOVEENT 0x6ffffdfa +#define DT_MOVESZ 0x6ffffdfb +#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */ +#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting + the following DT_* entry. */ +#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */ +#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */ +#define DT_VALRNGHI 0x6ffffdff +#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */ +#define DT_VALNUM 12 + +/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the + Dyn.d_un.d_ptr field of the Elf*_Dyn structure. + + If any adjustment is made to the ELF object after it has been + built these entries will need to be adjusted. */ +#define DT_ADDRRNGLO 0x6ffffe00 +#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */ +#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */ +#define DT_CONFIG 0x6ffffefa /* Configuration information. */ +#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */ +#define DT_AUDIT 0x6ffffefc /* Object auditing. */ +#define DT_PLTPAD 0x6ffffefd /* PLT padding. */ +#define DT_MOVETAB 0x6ffffefe /* Move table. */ +#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */ +#define DT_ADDRRNGHI 0x6ffffeff +#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */ +#define DT_ADDRNUM 10 + +/* The versioning entry types. The next are defined as part of the + GNU extension. */ +#define DT_VERSYM 0x6ffffff0 + +#define DT_RELACOUNT 0x6ffffff9 +#define DT_RELCOUNT 0x6ffffffa + +/* These were chosen by Sun. */ +#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */ +#define DT_VERDEF 0x6ffffffc /* Address of version definition + table */ +#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */ +#define DT_VERNEED 0x6ffffffe /* Address of table with needed + versions */ +#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */ +#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ +#define DT_VERSIONTAGNUM 16 + +/* Sun added these machine-independent extensions in the "processor-specific" + range. Be compatible. */ +#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */ +#define DT_FILTER 0x7fffffff /* Shared object to get values from */ +#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) +#define DT_EXTRANUM 3 + +/* Values of `d_un.d_val' in the DT_FLAGS entry. */ +#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */ +#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */ +#define DF_TEXTREL 0x00000004 /* Object contains text relocations */ +#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */ +#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */ + +/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 + entry in the dynamic section. */ +#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ +#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ +#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */ +#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/ +#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/ +#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/ +#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */ +#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */ +#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */ +#define DF_1_TRANS 0x00000200 +#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */ +#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */ +#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */ +#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/ +#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */ +#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */ +#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */ + +/* Flags for the feature selection in DT_FEATURE_1. */ +#define DTF_1_PARINIT 0x00000001 +#define DTF_1_CONFEXP 0x00000002 + +/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */ +#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */ +#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not + generally available. */ + +/* Version definition sections. */ + +typedef struct +{ + Elf32_Half vd_version; /* Version revision */ + Elf32_Half vd_flags; /* Version information */ + Elf32_Half vd_ndx; /* Version Index */ + Elf32_Half vd_cnt; /* Number of associated aux entries */ + Elf32_Word vd_hash; /* Version name hash value */ + Elf32_Word vd_aux; /* Offset in bytes to verdaux array */ + Elf32_Word vd_next; /* Offset in bytes to next verdef + entry */ +} Elf32_Verdef; + +typedef struct +{ + Elf64_Half vd_version; /* Version revision */ + Elf64_Half vd_flags; /* Version information */ + Elf64_Half vd_ndx; /* Version Index */ + Elf64_Half vd_cnt; /* Number of associated aux entries */ + Elf64_Word vd_hash; /* Version name hash value */ + Elf64_Word vd_aux; /* Offset in bytes to verdaux array */ + Elf64_Word vd_next; /* Offset in bytes to next verdef + entry */ +} Elf64_Verdef; + + +/* Legal values for vd_version (version revision). */ +#define VER_DEF_NONE 0 /* No version */ +#define VER_DEF_CURRENT 1 /* Current version */ +#define VER_DEF_NUM 2 /* Given version number */ + +/* Legal values for vd_flags (version information flags). */ +#define VER_FLG_BASE 0x1 /* Version definition of file itself */ +#define VER_FLG_WEAK 0x2 /* Weak version identifier */ + +/* Versym symbol index values. */ +#define VER_NDX_LOCAL 0 /* Symbol is local. */ +#define VER_NDX_GLOBAL 1 /* Symbol is global. */ +#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */ +#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */ + +/* Auxialiary version information. */ + +typedef struct +{ + Elf32_Word vda_name; /* Version or dependency names */ + Elf32_Word vda_next; /* Offset in bytes to next verdaux + entry */ +} Elf32_Verdaux; + +typedef struct +{ + Elf64_Word vda_name; /* Version or dependency names */ + Elf64_Word vda_next; /* Offset in bytes to next verdaux + entry */ +} Elf64_Verdaux; + + +/* Version dependency section. */ + +typedef struct +{ + Elf32_Half vn_version; /* Version of structure */ + Elf32_Half vn_cnt; /* Number of associated aux entries */ + Elf32_Word vn_file; /* Offset of filename for this + dependency */ + Elf32_Word vn_aux; /* Offset in bytes to vernaux array */ + Elf32_Word vn_next; /* Offset in bytes to next verneed + entry */ +} Elf32_Verneed; + +typedef struct +{ + Elf64_Half vn_version; /* Version of structure */ + Elf64_Half vn_cnt; /* Number of associated aux entries */ + Elf64_Word vn_file; /* Offset of filename for this + dependency */ + Elf64_Word vn_aux; /* Offset in bytes to vernaux array */ + Elf64_Word vn_next; /* Offset in bytes to next verneed + entry */ +} Elf64_Verneed; + + +/* Legal values for vn_version (version revision). */ +#define VER_NEED_NONE 0 /* No version */ +#define VER_NEED_CURRENT 1 /* Current version */ +#define VER_NEED_NUM 2 /* Given version number */ + +/* Auxiliary needed version information. */ + +typedef struct +{ + Elf32_Word vna_hash; /* Hash value of dependency name */ + Elf32_Half vna_flags; /* Dependency specific information */ + Elf32_Half vna_other; /* Unused */ + Elf32_Word vna_name; /* Dependency name string offset */ + Elf32_Word vna_next; /* Offset in bytes to next vernaux + entry */ +} Elf32_Vernaux; + +typedef struct +{ + Elf64_Word vna_hash; /* Hash value of dependency name */ + Elf64_Half vna_flags; /* Dependency specific information */ + Elf64_Half vna_other; /* Unused */ + Elf64_Word vna_name; /* Dependency name string offset */ + Elf64_Word vna_next; /* Offset in bytes to next vernaux + entry */ +} Elf64_Vernaux; + + +/* Legal values for vna_flags. */ +#define VER_FLG_WEAK 0x2 /* Weak version identifier */ + + +/* Auxiliary vector. */ + +/* This vector is normally only used by the program interpreter. The + usual definition in an ABI supplement uses the name auxv_t. The + vector is not usually defined in a standard file, but it + can't hurt. We rename it to avoid conflicts. The sizes of these + types are an arrangement between the exec server and the program + interpreter, so we don't fully specify them here. */ + +typedef struct +{ + int a_type; /* Entry type */ + union + { + long int a_val; /* Integer value */ + void *a_ptr; /* Pointer value */ + void (*a_fcn) (void); /* Function pointer value */ + } a_un; +} Elf32_auxv_t; + +typedef struct +{ + long int a_type; /* Entry type */ + union + { + long int a_val; /* Integer value */ + void *a_ptr; /* Pointer value */ + void (*a_fcn) (void); /* Function pointer value */ + } a_un; +} Elf64_auxv_t; + +/* Legal values for a_type (entry type). */ + +#define AT_NULL 0 /* End of vector */ +#define AT_IGNORE 1 /* Entry should be ignored */ +#define AT_EXECFD 2 /* File descriptor of program */ +#define AT_PHDR 3 /* Program headers for program */ +#define AT_PHENT 4 /* Size of program header entry */ +#define AT_PHNUM 5 /* Number of program headers */ +#define AT_PAGESZ 6 /* System page size */ +#define AT_BASE 7 /* Base address of interpreter */ +#define AT_FLAGS 8 /* Flags */ +#define AT_ENTRY 9 /* Entry point of program */ +#define AT_NOTELF 10 /* Program is not ELF */ +#define AT_UID 11 /* Real uid */ +#define AT_EUID 12 /* Effective uid */ +#define AT_GID 13 /* Real gid */ +#define AT_EGID 14 /* Effective gid */ +#define AT_CLKTCK 17 /* Frequency of times() */ + +/* Some more special a_type values describing the hardware. */ +#define AT_PLATFORM 15 /* String identifying platform. */ +#define AT_HWCAP 16 /* Machine dependent hints about + processor capabilities. */ + +/* This entry gives some information about the FPU initialization + performed by the kernel. */ +#define AT_FPUCW 18 /* Used FPU control word. */ + +/* Cache block sizes. */ +#define AT_DCACHEBSIZE 19 /* Data cache block size. */ +#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */ +#define AT_UCACHEBSIZE 21 /* Unified cache block size. */ + +/* A special ignored value for PPC, used by the kernel to control the + interpretation of the AUXV. Must be > 16. */ +#define AT_IGNOREPPC 22 /* Entry should be ignored. */ + +#define AT_SECURE 23 /* Boolean, was exec setuid-like? */ + +/* Pointer to the global system page used for system calls and other + nice things. */ +#define AT_SYSINFO 32 +#define AT_SYSINFO_EHDR 33 + + +/* Note section contents. Each entry in the note section begins with + a header of a fixed form. */ + +typedef struct +{ + Elf32_Word n_namesz; /* Length of the note's name. */ + Elf32_Word n_descsz; /* Length of the note's descriptor. */ + Elf32_Word n_type; /* Type of the note. */ +} Elf32_Nhdr; + +typedef struct +{ + Elf64_Word n_namesz; /* Length of the note's name. */ + Elf64_Word n_descsz; /* Length of the note's descriptor. */ + Elf64_Word n_type; /* Type of the note. */ +} Elf64_Nhdr; + +/* Known names of notes. */ + +/* Solaris entries in the note section have this name. */ +#define ELF_NOTE_SOLARIS "SUNW Solaris" + +/* Note entries for GNU systems have this name. */ +#define ELF_NOTE_GNU "GNU" + + +/* Defined types of notes for Solaris. */ + +/* Value of descriptor (one word) is desired pagesize for the binary. */ +#define ELF_NOTE_PAGESIZE_HINT 1 + + +/* Defined note types for GNU systems. */ + +/* ABI information. The descriptor consists of words: + word 0: OS descriptor + word 1: major version of the ABI + word 2: minor version of the ABI + word 3: subminor version of the ABI +*/ +#define ELF_NOTE_ABI 1 + +/* Known OSes. These value can appear in word 0 of an ELF_NOTE_ABI + note section entry. */ +#define ELF_NOTE_OS_LINUX 0 +#define ELF_NOTE_OS_GNU 1 +#define ELF_NOTE_OS_SOLARIS2 2 +#define ELF_NOTE_OS_FREEBSD 3 + + +/* Move records. */ +typedef struct +{ + Elf32_Xword m_value; /* Symbol value. */ + Elf32_Word m_info; /* Size and index. */ + Elf32_Word m_poffset; /* Symbol offset. */ + Elf32_Half m_repeat; /* Repeat count. */ + Elf32_Half m_stride; /* Stride info. */ +} Elf32_Move; + +typedef struct +{ + Elf64_Xword m_value; /* Symbol value. */ + Elf64_Xword m_info; /* Size and index. */ + Elf64_Xword m_poffset; /* Symbol offset. */ + Elf64_Half m_repeat; /* Repeat count. */ + Elf64_Half m_stride; /* Stride info. */ +} Elf64_Move; + +/* Macro to construct move records. */ +#define ELF32_M_SYM(info) ((info) >> 8) +#define ELF32_M_SIZE(info) ((unsigned char) (info)) +#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size)) + +#define ELF64_M_SYM(info) ELF32_M_SYM (info) +#define ELF64_M_SIZE(info) ELF32_M_SIZE (info) +#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size) + + +/* Motorola 68k specific definitions. */ + +/* Values for Elf32_Ehdr.e_flags. */ +#define EF_CPU32 0x00810000 + +/* m68k relocs. */ + +#define R_68K_NONE 0 /* No reloc */ +#define R_68K_32 1 /* Direct 32 bit */ +#define R_68K_16 2 /* Direct 16 bit */ +#define R_68K_8 3 /* Direct 8 bit */ +#define R_68K_PC32 4 /* PC relative 32 bit */ +#define R_68K_PC16 5 /* PC relative 16 bit */ +#define R_68K_PC8 6 /* PC relative 8 bit */ +#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */ +#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */ +#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */ +#define R_68K_GOT32O 10 /* 32 bit GOT offset */ +#define R_68K_GOT16O 11 /* 16 bit GOT offset */ +#define R_68K_GOT8O 12 /* 8 bit GOT offset */ +#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */ +#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */ +#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */ +#define R_68K_PLT32O 16 /* 32 bit PLT offset */ +#define R_68K_PLT16O 17 /* 16 bit PLT offset */ +#define R_68K_PLT8O 18 /* 8 bit PLT offset */ +#define R_68K_COPY 19 /* Copy symbol at runtime */ +#define R_68K_GLOB_DAT 20 /* Create GOT entry */ +#define R_68K_JMP_SLOT 21 /* Create PLT entry */ +#define R_68K_RELATIVE 22 /* Adjust by program base */ +/* Keep this the last entry. */ +#define R_68K_NUM 23 + +/* Intel 80386 specific definitions. */ + +/* i386 relocs. */ + +#define R_386_NONE 0 /* No reloc */ +#define R_386_32 1 /* Direct 32 bit */ +#define R_386_PC32 2 /* PC relative 32 bit */ +#define R_386_GOT32 3 /* 32 bit GOT entry */ +#define R_386_PLT32 4 /* 32 bit PLT address */ +#define R_386_COPY 5 /* Copy symbol at runtime */ +#define R_386_GLOB_DAT 6 /* Create GOT entry */ +#define R_386_JMP_SLOT 7 /* Create PLT entry */ +#define R_386_RELATIVE 8 /* Adjust by program base */ +#define R_386_GOTOFF 9 /* 32 bit offset to GOT */ +#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */ +#define R_386_32PLT 11 +#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */ +#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS + block offset */ +#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block + offset */ +#define R_386_TLS_LE 17 /* Offset relative to static TLS + block */ +#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of + general dynamic thread local data */ +#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of + local dynamic thread local data + in LE code */ +#define R_386_16 20 +#define R_386_PC16 21 +#define R_386_8 22 +#define R_386_PC8 23 +#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic + thread local data */ +#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */ +#define R_386_TLS_GD_CALL 26 /* Relocation for call to + __tls_get_addr() */ +#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */ +#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic + thread local data in LE code */ +#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */ +#define R_386_TLS_LDM_CALL 30 /* Relocation for call to + __tls_get_addr() in LDM code */ +#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */ +#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */ +#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS + block offset */ +#define R_386_TLS_LE_32 34 /* Negated offset relative to static + TLS block */ +#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */ +#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */ +#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */ +/* Keep this the last entry. */ +#define R_386_NUM 38 + +/* SUN SPARC specific definitions. */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_REGISTER 13 /* Global register reserved to app. */ + +/* Values for Elf64_Ehdr.e_flags. */ + +#define EF_SPARCV9_MM 3 +#define EF_SPARCV9_TSO 0 +#define EF_SPARCV9_PSO 1 +#define EF_SPARCV9_RMO 2 +#define EF_SPARC_LEDATA 0x800000 /* little endian data */ +#define EF_SPARC_EXT_MASK 0xFFFF00 +#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */ +#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */ +#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */ +#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */ + +/* SPARC relocs. */ + +#define R_SPARC_NONE 0 /* No reloc */ +#define R_SPARC_8 1 /* Direct 8 bit */ +#define R_SPARC_16 2 /* Direct 16 bit */ +#define R_SPARC_32 3 /* Direct 32 bit */ +#define R_SPARC_DISP8 4 /* PC relative 8 bit */ +#define R_SPARC_DISP16 5 /* PC relative 16 bit */ +#define R_SPARC_DISP32 6 /* PC relative 32 bit */ +#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */ +#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */ +#define R_SPARC_HI22 9 /* High 22 bit */ +#define R_SPARC_22 10 /* Direct 22 bit */ +#define R_SPARC_13 11 /* Direct 13 bit */ +#define R_SPARC_LO10 12 /* Truncated 10 bit */ +#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */ +#define R_SPARC_GOT13 14 /* 13 bit GOT entry */ +#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */ +#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */ +#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */ +#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */ +#define R_SPARC_COPY 19 /* Copy symbol at runtime */ +#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */ +#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */ +#define R_SPARC_RELATIVE 22 /* Adjust by program base */ +#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */ + +/* Additional Sparc64 relocs. */ + +#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */ +#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */ +#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */ +#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */ +#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */ +#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */ +#define R_SPARC_10 30 /* Direct 10 bit */ +#define R_SPARC_11 31 /* Direct 11 bit */ +#define R_SPARC_64 32 /* Direct 64 bit */ +#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */ +#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */ +#define R_SPARC_HM10 35 /* High middle 10 bits of ... */ +#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */ +#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */ +#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */ +#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */ +#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */ +#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */ +#define R_SPARC_7 43 /* Direct 7 bit */ +#define R_SPARC_5 44 /* Direct 5 bit */ +#define R_SPARC_6 45 /* Direct 6 bit */ +#define R_SPARC_DISP64 46 /* PC relative 64 bit */ +#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */ +#define R_SPARC_HIX22 48 /* High 22 bit complemented */ +#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */ +#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */ +#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */ +#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */ +#define R_SPARC_REGISTER 53 /* Global register usage */ +#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */ +#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */ +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 +/* Keep this the last entry. */ +#define R_SPARC_NUM 80 + +/* For Sparc64, legal values for d_tag of Elf64_Dyn. */ + +#define DT_SPARC_REGISTER 0x70000001 +#define DT_SPARC_NUM 2 + +/* Bits present in AT_HWCAP, primarily for Sparc32. */ + +#define HWCAP_SPARC_FLUSH 1 /* The cpu supports flush insn. */ +#define HWCAP_SPARC_STBAR 2 +#define HWCAP_SPARC_SWAP 4 +#define HWCAP_SPARC_MULDIV 8 +#define HWCAP_SPARC_V9 16 /* The cpu is v9, so v8plus is ok. */ +#define HWCAP_SPARC_ULTRA3 32 + +/* MIPS R3000 specific definitions. */ + +/* Legal values for e_flags field of Elf32_Ehdr. */ + +#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */ +#define EF_MIPS_PIC 2 /* Contains PIC code */ +#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */ +#define EF_MIPS_XGOT 8 +#define EF_MIPS_64BIT_WHIRL 16 +#define EF_MIPS_ABI2 32 +#define EF_MIPS_ABI_ON32 64 +#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */ + +/* Legal values for MIPS architecture level. */ + +#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ +#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ +#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ +#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ +#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ +#define EF_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */ +#define EF_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */ + +/* The following are non-official names and should not be used. */ + +#define E_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ +#define E_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ +#define E_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ +#define E_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ +#define E_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ +#define E_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */ +#define E_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */ + +/* Special section indices. */ + +#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */ +#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */ +#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */ +#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */ +#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */ + +/* Legal values for sh_type field of Elf32_Shdr. */ + +#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */ +#define SHT_MIPS_MSYM 0x70000001 +#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */ +#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */ +#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */ +#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information*/ +#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */ +#define SHT_MIPS_PACKAGE 0x70000007 +#define SHT_MIPS_PACKSYM 0x70000008 +#define SHT_MIPS_RELD 0x70000009 +#define SHT_MIPS_IFACE 0x7000000b +#define SHT_MIPS_CONTENT 0x7000000c +#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */ +#define SHT_MIPS_SHDR 0x70000010 +#define SHT_MIPS_FDESC 0x70000011 +#define SHT_MIPS_EXTSYM 0x70000012 +#define SHT_MIPS_DENSE 0x70000013 +#define SHT_MIPS_PDESC 0x70000014 +#define SHT_MIPS_LOCSYM 0x70000015 +#define SHT_MIPS_AUXSYM 0x70000016 +#define SHT_MIPS_OPTSYM 0x70000017 +#define SHT_MIPS_LOCSTR 0x70000018 +#define SHT_MIPS_LINE 0x70000019 +#define SHT_MIPS_RFDESC 0x7000001a +#define SHT_MIPS_DELTASYM 0x7000001b +#define SHT_MIPS_DELTAINST 0x7000001c +#define SHT_MIPS_DELTACLASS 0x7000001d +#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */ +#define SHT_MIPS_DELTADECL 0x7000001f +#define SHT_MIPS_SYMBOL_LIB 0x70000020 +#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */ +#define SHT_MIPS_TRANSLATE 0x70000022 +#define SHT_MIPS_PIXIE 0x70000023 +#define SHT_MIPS_XLATE 0x70000024 +#define SHT_MIPS_XLATE_DEBUG 0x70000025 +#define SHT_MIPS_WHIRL 0x70000026 +#define SHT_MIPS_EH_REGION 0x70000027 +#define SHT_MIPS_XLATE_OLD 0x70000028 +#define SHT_MIPS_PDR_EXCEPTION 0x70000029 + +/* Legal values for sh_flags field of Elf32_Shdr. */ + +#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */ +#define SHF_MIPS_MERGE 0x20000000 +#define SHF_MIPS_ADDR 0x40000000 +#define SHF_MIPS_STRINGS 0x80000000 +#define SHF_MIPS_NOSTRIP 0x08000000 +#define SHF_MIPS_LOCAL 0x04000000 +#define SHF_MIPS_NAMES 0x02000000 +#define SHF_MIPS_NODUPE 0x01000000 + + +/* Symbol tables. */ + +/* MIPS specific values for `st_other'. */ +#define STO_MIPS_DEFAULT 0x0 +#define STO_MIPS_INTERNAL 0x1 +#define STO_MIPS_HIDDEN 0x2 +#define STO_MIPS_PROTECTED 0x3 +#define STO_MIPS_SC_ALIGN_UNUSED 0xff + +/* MIPS specific values for `st_info'. */ +#define STB_MIPS_SPLIT_COMMON 13 + +/* Entries found in sections of type SHT_MIPS_GPTAB. */ + +typedef union +{ + struct + { + Elf32_Word gt_current_g_value; /* -G value used for compilation */ + Elf32_Word gt_unused; /* Not used */ + } gt_header; /* First entry in section */ + struct + { + Elf32_Word gt_g_value; /* If this value were used for -G */ + Elf32_Word gt_bytes; /* This many bytes would be used */ + } gt_entry; /* Subsequent entries in section */ +} Elf32_gptab; + +/* Entry found in sections of type SHT_MIPS_REGINFO. */ + +typedef struct +{ + Elf32_Word ri_gprmask; /* General registers used */ + Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */ + Elf32_Sword ri_gp_value; /* $gp register value */ +} Elf32_RegInfo; + +/* Entries found in sections of type SHT_MIPS_OPTIONS. */ + +typedef struct +{ + unsigned char kind; /* Determines interpretation of the + variable part of descriptor. */ + unsigned char size; /* Size of descriptor, including header. */ + Elf32_Section section; /* Section header index of section affected, + 0 for global options. */ + Elf32_Word info; /* Kind-specific information. */ +} Elf_Options; + +/* Values for `kind' field in Elf_Options. */ + +#define ODK_NULL 0 /* Undefined. */ +#define ODK_REGINFO 1 /* Register usage information. */ +#define ODK_EXCEPTIONS 2 /* Exception processing options. */ +#define ODK_PAD 3 /* Section padding options. */ +#define ODK_HWPATCH 4 /* Hardware workarounds performed */ +#define ODK_FILL 5 /* record the fill value used by the linker. */ +#define ODK_TAGS 6 /* reserve space for desktop tools to write. */ +#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */ +#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */ + +/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */ + +#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */ +#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */ +#define OEX_PAGE0 0x10000 /* page zero must be mapped. */ +#define OEX_SMM 0x20000 /* Force sequential memory mode? */ +#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */ +#define OEX_PRECISEFP OEX_FPDBUG +#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */ + +#define OEX_FPU_INVAL 0x10 +#define OEX_FPU_DIV0 0x08 +#define OEX_FPU_OFLO 0x04 +#define OEX_FPU_UFLO 0x02 +#define OEX_FPU_INEX 0x01 + +/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */ + +#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */ +#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */ +#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */ +#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */ + +#define OPAD_PREFIX 0x1 +#define OPAD_POSTFIX 0x2 +#define OPAD_SYMBOL 0x4 + +/* Entry found in `.options' section. */ + +typedef struct +{ + Elf32_Word hwp_flags1; /* Extra flags. */ + Elf32_Word hwp_flags2; /* Extra flags. */ +} Elf_Options_Hw; + +/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */ + +#define OHWA0_R4KEOP_CHECKED 0x00000001 +#define OHWA1_R4KEOP_CLEAN 0x00000002 + +/* MIPS relocs. */ + +#define R_MIPS_NONE 0 /* No reloc */ +#define R_MIPS_16 1 /* Direct 16 bit */ +#define R_MIPS_32 2 /* Direct 32 bit */ +#define R_MIPS_REL32 3 /* PC relative 32 bit */ +#define R_MIPS_26 4 /* Direct 26 bit shifted */ +#define R_MIPS_HI16 5 /* High 16 bit */ +#define R_MIPS_LO16 6 /* Low 16 bit */ +#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ +#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ +#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ +#define R_MIPS_PC16 10 /* PC relative 16 bit */ +#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ +#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ + #define R_MIPS_SHIFT5 16 #define R_MIPS_SHIFT6 17 #define R_MIPS_64 18 #define R_MIPS_GOT_DISP 19 #define R_MIPS_GOT_PAGE 20 #define R_MIPS_GOT_OFST 21 -/* - * The following two relocation types are specified in the MIPS ABI - * conformance guide version 1.2 but not yet in the psABI. - */ -#define R_MIPS_GOTHI16 22 -#define R_MIPS_GOTLO16 23 +#define R_MIPS_GOT_HI16 22 +#define R_MIPS_GOT_LO16 23 #define R_MIPS_SUB 24 #define R_MIPS_INSERT_A 25 #define R_MIPS_INSERT_B 26 #define R_MIPS_DELETE 27 #define R_MIPS_HIGHER 28 #define R_MIPS_HIGHEST 29 -/* - * The following two relocation types are specified in the MIPS ABI - * conformance guide version 1.2 but not yet in the psABI. - */ -#define R_MIPS_CALLHI16 30 -#define R_MIPS_CALLLO16 31 -/* - * This range is reserved for vendor specific relocations. - */ -#define R_MIPS_LOVENDOR 100 -#define R_MIPS_HIVENDOR 127 - - -/* - * Sparc ELF relocation types - */ -#define R_SPARC_NONE 0 -#define R_SPARC_8 1 -#define R_SPARC_16 2 -#define R_SPARC_32 3 -#define R_SPARC_DISP8 4 -#define R_SPARC_DISP16 5 -#define R_SPARC_DISP32 6 -#define R_SPARC_WDISP30 7 -#define R_SPARC_WDISP22 8 -#define R_SPARC_HI22 9 -#define R_SPARC_22 10 -#define R_SPARC_13 11 -#define R_SPARC_LO10 12 -#define R_SPARC_GOT10 13 -#define R_SPARC_GOT13 14 -#define R_SPARC_GOT22 15 -#define R_SPARC_PC10 16 -#define R_SPARC_PC22 17 -#define R_SPARC_WPLT30 18 -#define R_SPARC_COPY 19 -#define R_SPARC_GLOB_DAT 20 -#define R_SPARC_JMP_SLOT 21 -#define R_SPARC_RELATIVE 22 -#define R_SPARC_UA32 23 -#define R_SPARC_PLT32 24 -#define R_SPARC_HIPLT22 25 -#define R_SPARC_LOPLT10 26 -#define R_SPARC_PCPLT32 27 -#define R_SPARC_PCPLT22 28 -#define R_SPARC_PCPLT10 29 -#define R_SPARC_10 30 -#define R_SPARC_11 31 -#define R_SPARC_WDISP16 40 -#define R_SPARC_WDISP19 41 -#define R_SPARC_7 43 -#define R_SPARC_5 44 -#define R_SPARC_6 45 +#define R_MIPS_CALL_HI16 30 +#define R_MIPS_CALL_LO16 31 +#define R_MIPS_SCN_DISP 32 +#define R_MIPS_REL16 33 +#define R_MIPS_ADD_IMMEDIATE 34 +#define R_MIPS_PJUMP 35 +#define R_MIPS_RELGOT 36 +#define R_MIPS_JALR 37 +/* Keep this the last entry. */ +#define R_MIPS_NUM 38 -/* Bits present in AT_HWCAP, primarily for Sparc32. */ +/* Legal values for p_type field of Elf32_Phdr. */ -#define HWCAP_SPARC_FLUSH 1 /* CPU supports flush instruction. */ -#define HWCAP_SPARC_STBAR 2 -#define HWCAP_SPARC_SWAP 4 -#define HWCAP_SPARC_MULDIV 8 -#define HWCAP_SPARC_V9 16 -#define HWCAP_SPARC_ULTRA3 32 +#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */ +#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */ +#define PT_MIPS_OPTIONS 0x70000002 + +/* Special program header types. */ + +#define PF_MIPS_LOCAL 0x10000000 + +/* Legal values for d_tag field of Elf32_Dyn. */ + +#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */ +#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */ +#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */ +#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */ +#define DT_MIPS_FLAGS 0x70000005 /* Flags */ +#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */ +#define DT_MIPS_MSYM 0x70000007 +#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */ +#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */ +#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */ +#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */ +#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */ +#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */ +#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */ +#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */ +#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */ +#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */ +#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */ +#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in + DT_MIPS_DELTA_CLASS. */ +#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */ +#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in + DT_MIPS_DELTA_INSTANCE. */ +#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */ +#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in + DT_MIPS_DELTA_RELOC. */ +#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta + relocations refer to. */ +#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in + DT_MIPS_DELTA_SYM. */ +#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the + class declaration. */ +#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in + DT_MIPS_DELTA_CLASSSYM. */ +#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */ +#define DT_MIPS_PIXIE_INIT 0x70000023 +#define DT_MIPS_SYMBOL_LIB 0x70000024 +#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 +#define DT_MIPS_LOCAL_GOTIDX 0x70000026 +#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 +#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 +#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */ +#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */ +#define DT_MIPS_DYNSTR_ALIGN 0x7000002b +#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */ +#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve + function stored in GOT. */ +#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added + by rld on dlopen() calls. */ +#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */ +#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */ +#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */ +#define DT_MIPS_NUM 0x32 + +/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */ + +#define RHF_NONE 0 /* No flags */ +#define RHF_QUICKSTART (1 << 0) /* Use quickstart */ +#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */ +#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */ +#define RHF_NO_MOVE (1 << 3) +#define RHF_SGI_ONLY (1 << 4) +#define RHF_GUARANTEE_INIT (1 << 5) +#define RHF_DELTA_C_PLUS_PLUS (1 << 6) +#define RHF_GUARANTEE_START_INIT (1 << 7) +#define RHF_PIXIE (1 << 8) +#define RHF_DEFAULT_DELAY_LOAD (1 << 9) +#define RHF_REQUICKSTART (1 << 10) +#define RHF_REQUICKSTARTED (1 << 11) +#define RHF_CORD (1 << 12) +#define RHF_NO_UNRES_UNDEF (1 << 13) +#define RHF_RLD_ORDER_SAFE (1 << 14) + +/* Entries found in sections of type SHT_MIPS_LIBLIST. */ + +typedef struct +{ + Elf32_Word l_name; /* Name (string table index) */ + Elf32_Word l_time_stamp; /* Timestamp */ + Elf32_Word l_checksum; /* Checksum */ + Elf32_Word l_version; /* Interface version */ + Elf32_Word l_flags; /* Flags */ +} Elf32_Lib; + +typedef struct +{ + Elf64_Word l_name; /* Name (string table index) */ + Elf64_Word l_time_stamp; /* Timestamp */ + Elf64_Word l_checksum; /* Checksum */ + Elf64_Word l_version; /* Interface version */ + Elf64_Word l_flags; /* Flags */ +} Elf64_Lib; + + +/* Legal values for l_flags. */ + +#define LL_NONE 0 +#define LL_EXACT_MATCH (1 << 0) /* Require exact match */ +#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */ +#define LL_REQUIRE_MINOR (1 << 2) +#define LL_EXPORTS (1 << 3) +#define LL_DELAY_LOAD (1 << 4) +#define LL_DELTA (1 << 5) + +/* Entries found in sections of type SHT_MIPS_CONFLICT. */ + +typedef Elf32_Addr Elf32_Conflict; + + +/* HPPA specific definitions. */ + +/* Legal values for e_flags field of Elf32_Ehdr. */ + +#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */ +#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */ +#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */ +#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */ +#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch + prediction. */ +#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */ +#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */ + +/* Defined values for `e_flags & EF_PARISC_ARCH' are: */ + +#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */ +#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */ +#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */ + +/* Additional section indeces. */ + +#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared + symbols in ANSI C. */ +#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */ + +/* Legal values for sh_type field of Elf32_Shdr. */ + +#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */ +#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */ +#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */ + +/* Legal values for sh_flags field of Elf32_Shdr. */ + +#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */ +#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */ +#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */ + +#define STT_HP_OPAQUE (STT_LOOS + 0x1) +#define STT_HP_STUB (STT_LOOS + 0x2) + +/* HPPA relocs. */ + +#define R_PARISC_NONE 0 /* No reloc. */ +#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */ +#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */ +#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */ +#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */ +#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */ +#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */ +#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */ +#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */ +#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */ +#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */ +#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */ +#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */ +#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */ +#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */ +#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */ +#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */ +#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */ +#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */ +#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */ +#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */ +#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */ +#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */ +#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */ +#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */ +#define R_PARISC_FPTR64 64 /* 64 bits function address. */ +#define R_PARISC_PLABEL32 65 /* 32 bits function address. */ +#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */ +#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */ +#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */ +#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */ +#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */ +#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */ +#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */ +#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */ +#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */ +#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */ +#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */ +#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */ +#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */ +#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */ +#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */ +#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */ +#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */ +#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */ +#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */ +#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */ +#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */ +#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */ +#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */ +#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */ +#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */ +#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */ +#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */ +#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */ +#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */ +#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */ +#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */ +#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */ +#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */ +#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */ +#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */ +#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */ +#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */ +#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */ +#define R_PARISC_LORESERVE 128 +#define R_PARISC_COPY 128 /* Copy relocation. */ +#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */ +#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */ +#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */ +#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */ +#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */ +#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */ +#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/ +#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */ +#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */ +#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */ +#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */ +#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */ +#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */ +#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */ +#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */ +#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/ +#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/ +#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */ +#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */ +#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */ +#define R_PARISC_HIRESERVE 255 + +/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */ + +#define PT_HP_TLS (PT_LOOS + 0x0) +#define PT_HP_CORE_NONE (PT_LOOS + 0x1) +#define PT_HP_CORE_VERSION (PT_LOOS + 0x2) +#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) +#define PT_HP_CORE_COMM (PT_LOOS + 0x4) +#define PT_HP_CORE_PROC (PT_LOOS + 0x5) +#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) +#define PT_HP_CORE_STACK (PT_LOOS + 0x7) +#define PT_HP_CORE_SHM (PT_LOOS + 0x8) +#define PT_HP_CORE_MMF (PT_LOOS + 0x9) +#define PT_HP_PARALLEL (PT_LOOS + 0x10) +#define PT_HP_FASTBIND (PT_LOOS + 0x11) +#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) +#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) +#define PT_HP_STACK (PT_LOOS + 0x14) + +#define PT_PARISC_ARCHEXT 0x70000000 +#define PT_PARISC_UNWIND 0x70000001 + +/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */ + +#define PF_PARISC_SBP 0x08000000 + +#define PF_HP_PAGE_SIZE 0x00100000 +#define PF_HP_FAR_SHARED 0x00200000 +#define PF_HP_NEAR_SHARED 0x00400000 +#define PF_HP_CODE 0x01000000 +#define PF_HP_MODIFY 0x02000000 +#define PF_HP_LAZYSWAP 0x04000000 +#define PF_HP_SBP 0x08000000 + + +/* Alpha specific definitions. */ + +/* Legal values for e_flags field of Elf64_Ehdr. */ + +#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */ +#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */ + +/* Legal values for sh_type field of Elf64_Shdr. */ + +/* These two are primerily concerned with ECOFF debugging info. */ +#define SHT_ALPHA_DEBUG 0x70000001 +#define SHT_ALPHA_REGINFO 0x70000002 + +/* Legal values for sh_flags field of Elf64_Shdr. */ + +#define SHF_ALPHA_GPREL 0x10000000 -/* - * 68k ELF relocation types - */ -#define R_68K_NONE 0 -#define R_68K_32 1 -#define R_68K_16 2 -#define R_68K_8 3 -#define R_68K_PC32 4 -#define R_68K_PC16 5 -#define R_68K_PC8 6 -#define R_68K_GOT32 7 -#define R_68K_GOT16 8 -#define R_68K_GOT8 9 -#define R_68K_GOT32O 10 -#define R_68K_GOT16O 11 -#define R_68K_GOT8O 12 -#define R_68K_PLT32 13 -#define R_68K_PLT16 14 -#define R_68K_PLT8 15 -#define R_68K_PLT32O 16 -#define R_68K_PLT16O 17 -#define R_68K_PLT8O 18 -#define R_68K_COPY 19 -#define R_68K_GLOB_DAT 20 -#define R_68K_JMP_SLOT 21 -#define R_68K_RELATIVE 22 - -/* - * Alpha ELF relocation types - */ -#define R_ALPHA_NONE 0 /* No reloc */ -#define R_ALPHA_REFLONG 1 /* Direct 32 bit */ -#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */ -#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */ -#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */ -#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */ -#define R_ALPHA_GPDISP 6 /* Add displacement to GP */ -#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */ -#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */ -#define R_ALPHA_SREL16 9 /* PC relative 16 bit */ +/* Legal values for st_other field of Elf64_Sym. */ +#define STO_ALPHA_NOPV 0x80 /* No PV required. */ +#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */ + +/* Alpha relocs. */ + +#define R_ALPHA_NONE 0 /* No reloc */ +#define R_ALPHA_REFLONG 1 /* Direct 32 bit */ +#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */ +#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */ +#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */ +#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */ +#define R_ALPHA_GPDISP 6 /* Add displacement to GP */ +#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */ +#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */ +#define R_ALPHA_SREL16 9 /* PC relative 16 bit */ #define R_ALPHA_SREL32 10 /* PC relative 32 bit */ #define R_ALPHA_SREL64 11 /* PC relative 64 bit */ -#define R_ALPHA_OP_PUSH 12 /* OP stack push */ -#define R_ALPHA_OP_STORE 13 /* OP stack pop and store */ -#define R_ALPHA_OP_PSUB 14 /* OP stack subtract */ -#define R_ALPHA_OP_PRSHIFT 15 /* OP stack right shift */ -#define R_ALPHA_GPVALUE 16 -#define R_ALPHA_GPRELHIGH 17 -#define R_ALPHA_GPRELLOW 18 -#define R_ALPHA_IMMED_GP_16 19 -#define R_ALPHA_IMMED_GP_HI32 20 -#define R_ALPHA_IMMED_SCN_HI32 21 -#define R_ALPHA_IMMED_BR_HI32 22 -#define R_ALPHA_IMMED_LO32 23 +#define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */ +#define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */ +#define R_ALPHA_GPREL16 19 /* GP relative 16 bit */ #define R_ALPHA_COPY 24 /* Copy symbol at runtime */ #define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */ #define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */ #define R_ALPHA_RELATIVE 27 /* Adjust by program base */ +#define R_ALPHA_TLS_GD_HI 28 +#define R_ALPHA_TLSGD 29 +#define R_ALPHA_TLS_LDM 30 +#define R_ALPHA_DTPMOD64 31 +#define R_ALPHA_GOTDTPREL 32 +#define R_ALPHA_DTPREL64 33 +#define R_ALPHA_DTPRELHI 34 +#define R_ALPHA_DTPRELLO 35 +#define R_ALPHA_DTPREL16 36 +#define R_ALPHA_GOTTPREL 37 +#define R_ALPHA_TPREL64 38 +#define R_ALPHA_TPRELHI 39 +#define R_ALPHA_TPRELLO 40 +#define R_ALPHA_TPREL16 41 +/* Keep this the last entry. */ +#define R_ALPHA_NUM 46 -/* Legal values for e_flags field of Elf64_Ehdr. */ +/* Magic values of the LITUSE relocation addend. */ +#define LITUSE_ALPHA_ADDR 0 +#define LITUSE_ALPHA_BASE 1 +#define LITUSE_ALPHA_BYTOFF 2 +#define LITUSE_ALPHA_JSR 3 +#define LITUSE_ALPHA_TLS_GD 4 +#define LITUSE_ALPHA_TLS_LDM 5 -#define EF_ALPHA_32BIT 1 /* All addresses are below 2GB */ -/* - * PowerPC - */ +/* PowerPC specific declarations */ /* Values for Elf32/64_Ehdr.e_flags. */ #define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */ /* Cygnus local bits below */ #define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/ -#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib flag */ +#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib + flag */ /* PowerPC relocations defined by the ABIs */ #define R_PPC_NONE 0 @@ -424,8 +1864,39 @@ #define R_PPC_SECTOFF_LO 34 #define R_PPC_SECTOFF_HI 35 #define R_PPC_SECTOFF_HA 36 + +/* PowerPC relocations defined for the TLS access ABI. */ +#define R_PPC_TLS 67 /* none (sym+add)@tls */ +#define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */ +#define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */ +#define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ +#define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ +#define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ +#define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */ +#define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */ +#define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ +#define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ +#define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ +#define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */ +#define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ +#define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ +#define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ +#define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ +#define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ +#define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ +#define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ +#define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ +#define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */ +#define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */ +#define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ +#define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ +#define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */ +#define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */ +#define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */ +#define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */ + /* Keep this the last entry. */ -#define R_PPC_NUM 37 +#define R_PPC_NUM 95 /* The remaining relocs are from the Embedded ELF ABI, and are not in the SVR4 ELF ABI. */ @@ -458,9 +1929,165 @@ that may still be in object files. */ #define R_PPC_TOC16 255 -/* - * ARM ELF relocation types - */ + +/* PowerPC64 relocations defined by the ABIs */ +#define R_PPC64_NONE R_PPC_NONE +#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address */ +#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned */ +#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address */ +#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of address */ +#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of address. */ +#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */ +#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned */ +#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN +#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN +#define R_PPC64_REL24 R_PPC_REL24 /* PC-rel. 26 bit, word aligned */ +#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit */ +#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN +#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN +#define R_PPC64_GOT16 R_PPC_GOT16 +#define R_PPC64_GOT16_LO R_PPC_GOT16_LO +#define R_PPC64_GOT16_HI R_PPC_GOT16_HI +#define R_PPC64_GOT16_HA R_PPC_GOT16_HA + +#define R_PPC64_COPY R_PPC_COPY +#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT +#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT +#define R_PPC64_RELATIVE R_PPC_RELATIVE + +#define R_PPC64_UADDR32 R_PPC_UADDR32 +#define R_PPC64_UADDR16 R_PPC_UADDR16 +#define R_PPC64_REL32 R_PPC_REL32 +#define R_PPC64_PLT32 R_PPC_PLT32 +#define R_PPC64_PLTREL32 R_PPC_PLTREL32 +#define R_PPC64_PLT16_LO R_PPC_PLT16_LO +#define R_PPC64_PLT16_HI R_PPC_PLT16_HI +#define R_PPC64_PLT16_HA R_PPC_PLT16_HA + +#define R_PPC64_SECTOFF R_PPC_SECTOFF +#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO +#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI +#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA +#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2 */ +#define R_PPC64_ADDR64 38 /* doubleword64 S + A */ +#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A) */ +#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A) */ +#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A) */ +#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A) */ +#define R_PPC64_UADDR64 43 /* doubleword64 S + A */ +#define R_PPC64_REL64 44 /* doubleword64 S + A - P */ +#define R_PPC64_PLT64 45 /* doubleword64 L + A */ +#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P */ +#define R_PPC64_TOC16 47 /* half16* S + A - .TOC */ +#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.) */ +#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.) */ +#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.) */ +#define R_PPC64_TOC 51 /* doubleword64 .TOC */ +#define R_PPC64_PLTGOT16 52 /* half16* M + A */ +#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A) */ +#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A) */ +#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A) */ + +#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2 */ +#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2 */ +#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2 */ +#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2 */ +#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2 */ +#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2 */ +#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2 */ +#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2 */ +#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2 */ +#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2 */ +#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2 */ + +/* PowerPC64 relocations defined for the TLS access ABI. */ +#define R_PPC64_TLS 67 /* none (sym+add)@tls */ +#define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */ +#define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */ +#define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ +#define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ +#define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ +#define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */ +#define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */ +#define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ +#define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ +#define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ +#define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */ +#define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ +#define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ +#define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ +#define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ +#define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ +#define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ +#define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ +#define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ +#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */ +#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */ +#define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ +#define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ +#define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */ +#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */ +#define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */ +#define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */ +#define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */ +#define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */ +#define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */ +#define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */ +#define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */ +#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */ +#define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */ +#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */ +#define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */ +#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */ +#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */ +#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */ + +/* Keep this the last entry. */ +#define R_PPC64_NUM 107 + +/* PowerPC64 specific values for the Dyn d_tag field. */ +#define DT_PPC64_GLINK (DT_LOPROC + 0) +#define DT_PPC64_NUM 1 + + +/* ARM specific declarations */ + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_ARM_RELEXEC 0x01 +#define EF_ARM_HASENTRY 0x02 +#define EF_ARM_INTERWORK 0x04 +#define EF_ARM_APCS_26 0x08 +#define EF_ARM_APCS_FLOAT 0x10 +#define EF_ARM_PIC 0x20 +#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */ +#define EF_ARM_NEW_ABI 0x80 +#define EF_ARM_OLD_ABI 0x100 + +/* Other constants defined in the ARM ELF spec. version B-01. */ +/* NB. These conflict with values defined above. */ +#define EF_ARM_SYMSARESORTED 0x04 +#define EF_ARM_DYNSYMSUSESEGIDX 0x08 +#define EF_ARM_MAPSYMSFIRST 0x10 +#define EF_ARM_EABIMASK 0XFF000000 + +#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK) +#define EF_ARM_EABI_UNKNOWN 0x00000000 +#define EF_ARM_EABI_VER1 0x01000000 +#define EF_ARM_EABI_VER2 0x02000000 + +/* Additional symbol types for Thumb */ +#define STT_ARM_TFUNC 0xd + +/* ARM-specific values for sh_flags */ +#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */ +#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined + in the input to a link step */ + +/* ARM-specific program header flags */ +#define PF_ARM_SB 0x10000000 /* Segment contains the location + addressed by the static base */ + +/* ARM relocs. */ #define R_ARM_NONE 0 /* No reloc */ #define R_ARM_PC24 1 /* PC relative 26 bit branch */ #define R_ARM_ABS32 2 /* Direct 32 bit */ @@ -486,6 +2113,12 @@ #define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */ #define R_ARM_GOT32 26 /* 32 bit GOT entry */ #define R_ARM_PLT32 27 /* 32 bit PLT address */ +#define R_ARM_ALU_PCREL_7_0 32 +#define R_ARM_ALU_PCREL_15_8 33 +#define R_ARM_ALU_PCREL_23_15 34 +#define R_ARM_LDR_SBREL_11_0 35 +#define R_ARM_ALU_SBREL_19_12 36 +#define R_ARM_ALU_SBREL_27_20 37 #define R_ARM_GNU_VTENTRY 100 #define R_ARM_GNU_VTINHERIT 101 #define R_ARM_THM_PC11 102 /* thumb unconditional branch */ @@ -500,19 +2133,261 @@ /* Keep this the last entry. */ #define R_ARM_NUM 256 -/* Processor specific flags for the ELF header e_flags field. */ -#define EF_ARM_RELEXEC 0x01 -#define EF_ARM_HASENTRY 0x02 -#define EF_ARM_INTERWORK 0x04 -#define EF_ARM_APCS_26 0x08 -#define EF_ARM_APCS_FLOAT 0x10 -#define EF_ARM_PIC 0x20 -#define EF_ALIGN8 0x40 /* 8-bit structure alignment is in use */ -#define EF_NEW_ABI 0x80 -#define EF_OLD_ABI 0x100 +/* IA-64 specific declarations. */ -/* Additional symbol types for Thumb */ -#define STT_ARM_TFUNC 0xd +/* Processor specific flags for the Ehdr e_flags field. */ +#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */ +#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */ +#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */ + +/* Processor specific values for the Phdr p_type field. */ +#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */ +#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */ + +/* Processor specific flags for the Phdr p_flags field. */ +#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */ + +/* Processor specific values for the Shdr sh_type field. */ +#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */ +#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */ + +/* Processor specific flags for the Shdr sh_flags field. */ +#define SHF_IA_64_SHORT 0x10000000 /* section near gp */ +#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */ + +/* Processor specific values for the Dyn d_tag field. */ +#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0) +#define DT_IA_64_NUM 1 + +/* IA-64 relocations. */ +#define R_IA64_NONE 0x00 /* none */ +#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */ +#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */ +#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */ +#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */ +#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */ +#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */ +#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */ +#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */ +#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */ +#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */ +#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */ +#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */ +#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */ +#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */ +#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */ +#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */ +#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */ +#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */ +#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */ +#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */ +#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */ +#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */ +#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */ +#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */ +#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */ +#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */ +#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */ +#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */ +#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */ +#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */ +#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */ +#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */ +#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */ +#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */ +#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */ +#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */ +#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */ +#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */ +#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */ +#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */ +#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */ +#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */ +#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */ +#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */ +#define R_IA64_REL32MSB 0x6c /* data 4 + REL */ +#define R_IA64_REL32LSB 0x6d /* data 4 + REL */ +#define R_IA64_REL64MSB 0x6e /* data 8 + REL */ +#define R_IA64_REL64LSB 0x6f /* data 8 + REL */ +#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */ +#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */ +#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */ +#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */ +#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */ +#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */ +#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */ +#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */ +#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */ +#define R_IA64_COPY 0x84 /* copy relocation */ +#define R_IA64_SUB 0x85 /* Addend and symbol difference */ +#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */ +#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */ +#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */ +#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */ +#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */ +#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */ +#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */ +#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */ +#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */ +#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */ +#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */ +#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */ +#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */ +#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */ +#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */ +#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */ +#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */ + +/* SH specific declarations */ + +/* SH relocs. */ +#define R_SH_NONE 0 +#define R_SH_DIR32 1 +#define R_SH_REL32 2 +#define R_SH_DIR8WPN 3 +#define R_SH_IND12W 4 +#define R_SH_DIR8WPL 5 +#define R_SH_DIR8WPZ 6 +#define R_SH_DIR8BP 7 +#define R_SH_DIR8W 8 +#define R_SH_DIR8L 9 +#define R_SH_SWITCH16 25 +#define R_SH_SWITCH32 26 +#define R_SH_USES 27 +#define R_SH_COUNT 28 +#define R_SH_ALIGN 29 +#define R_SH_CODE 30 +#define R_SH_DATA 31 +#define R_SH_LABEL 32 +#define R_SH_SWITCH8 33 +#define R_SH_GNU_VTINHERIT 34 +#define R_SH_GNU_VTENTRY 35 +#define R_SH_TLS_GD_32 144 +#define R_SH_TLS_LD_32 145 +#define R_SH_TLS_LDO_32 146 +#define R_SH_TLS_IE_32 147 +#define R_SH_TLS_LE_32 148 +#define R_SH_TLS_DTPMOD32 149 +#define R_SH_TLS_DTPOFF32 150 +#define R_SH_TLS_TPOFF32 151 +#define R_SH_GOT32 160 +#define R_SH_PLT32 161 +#define R_SH_COPY 162 +#define R_SH_GLOB_DAT 163 +#define R_SH_JMP_SLOT 164 +#define R_SH_RELATIVE 165 +#define R_SH_GOTOFF 166 +#define R_SH_GOTPC 167 +/* Keep this the last entry. */ +#define R_SH_NUM 256 + +/* Additional s390 relocs */ + +#define R_390_NONE 0 /* No reloc. */ +#define R_390_8 1 /* Direct 8 bit. */ +#define R_390_12 2 /* Direct 12 bit. */ +#define R_390_16 3 /* Direct 16 bit. */ +#define R_390_32 4 /* Direct 32 bit. */ +#define R_390_PC32 5 /* PC relative 32 bit. */ +#define R_390_GOT12 6 /* 12 bit GOT offset. */ +#define R_390_GOT32 7 /* 32 bit GOT offset. */ +#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */ +#define R_390_COPY 9 /* Copy symbol at runtime. */ +#define R_390_GLOB_DAT 10 /* Create GOT entry. */ +#define R_390_JMP_SLOT 11 /* Create PLT entry. */ +#define R_390_RELATIVE 12 /* Adjust by program base. */ +#define R_390_GOTOFF32 13 /* 32 bit offset to GOT. */ +#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */ +#define R_390_GOT16 15 /* 16 bit GOT offset. */ +#define R_390_PC16 16 /* PC relative 16 bit. */ +#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */ +#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */ +#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */ +#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */ +#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */ +#define R_390_64 22 /* Direct 64 bit. */ +#define R_390_PC64 23 /* PC relative 64 bit. */ +#define R_390_GOT64 24 /* 64 bit GOT offset. */ +#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */ +#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */ +#define R_390_GOTOFF16 27 /* 16 bit offset to GOT. */ +#define R_390_GOTOFF64 28 /* 64 bit offset to GOT. */ +#define R_390_GOTPLT12 29 /* 12 bit offset to jump slot. */ +#define R_390_GOTPLT16 30 /* 16 bit offset to jump slot. */ +#define R_390_GOTPLT32 31 /* 32 bit offset to jump slot. */ +#define R_390_GOTPLT64 32 /* 64 bit offset to jump slot. */ +#define R_390_GOTPLTENT 33 /* 32 bit rel. offset to jump slot. */ +#define R_390_PLTOFF16 34 /* 16 bit offset from GOT to PLT. */ +#define R_390_PLTOFF32 35 /* 32 bit offset from GOT to PLT. */ +#define R_390_PLTOFF64 36 /* 16 bit offset from GOT to PLT. */ +#define R_390_TLS_LOAD 37 /* Tag for load insn in TLS code. */ +#define R_390_TLS_GDCALL 38 /* Tag for function call in general + dynamic TLS code. */ +#define R_390_TLS_LDCALL 39 /* Tag for function call in local + dynamic TLS code. */ +#define R_390_TLS_GD32 40 /* Direct 32 bit for general dynamic + thread local data. */ +#define R_390_TLS_GD64 41 /* Direct 64 bit for general dynamic + thread local data. */ +#define R_390_TLS_GOTIE12 42 /* 12 bit GOT offset for static TLS + block offset. */ +#define R_390_TLS_GOTIE32 43 /* 32 bit GOT offset for static TLS + block offset. */ +#define R_390_TLS_GOTIE64 44 /* 64 bit GOT offset for static TLS + block offset. */ +#define R_390_TLS_LDM32 45 /* Direct 32 bit for local dynamic + thread local data in LE code. */ +#define R_390_TLS_LDM64 46 /* Direct 64 bit for local dynamic + thread local data in LE code. */ +#define R_390_TLS_IE32 47 /* 32 bit address of GOT entry for + negated static TLS block offset. */ +#define R_390_TLS_IE64 48 /* 64 bit address of GOT entry for + negated static TLS block offset. */ +#define R_390_TLS_IEENT 49 /* 32 bit rel. offset to GOT entry for + negated static TLS block offset. */ +#define R_390_TLS_LE32 50 /* 32 bit negated offset relative to + static TLS block. */ +#define R_390_TLS_LE64 51 /* 64 bit negated offset relative to + static TLS block. */ +#define R_390_TLS_LDO32 52 /* 32 bit offset relative to TLS + block. */ +#define R_390_TLS_LDO64 53 /* 64 bit offset relative to TLS + block. */ +#define R_390_TLS_DTPMOD 54 /* ID of module containing symbol. */ +#define R_390_TLS_DTPOFF 55 /* Offset in TLS block. */ +#define R_390_TLS_TPOFF 56 /* Negated offset in static TLS + block. */ + +/* Keep this the last entry. */ +#define R_390_NUM 57 + +/* CRIS relocations. */ +#define R_CRIS_NONE 0 +#define R_CRIS_8 1 +#define R_CRIS_16 2 +#define R_CRIS_32 3 +#define R_CRIS_8_PCREL 4 +#define R_CRIS_16_PCREL 5 +#define R_CRIS_32_PCREL 6 +#define R_CRIS_GNU_VTINHERIT 7 +#define R_CRIS_GNU_VTENTRY 8 +#define R_CRIS_COPY 9 +#define R_CRIS_GLOB_DAT 10 +#define R_CRIS_JUMP_SLOT 11 +#define R_CRIS_RELATIVE 12 +#define R_CRIS_16_GOT 13 +#define R_CRIS_32_GOT 14 +#define R_CRIS_16_GOTPLT 15 +#define R_CRIS_32_GOTPLT 16 +#define R_CRIS_32_GOTREL 17 +#define R_CRIS_32_PLT_GOTREL 18 +#define R_CRIS_32_PLT_PCREL 19 + +#define R_CRIS_NUM 20 /* AMD x86-64 relocations. */ #define R_X86_64_NONE 0 /* No reloc */ @@ -546,244 +2421,6 @@ #define R_X86_64_NUM 24 -typedef struct elf32_rel { - Elf32_Addr r_offset; - Elf32_Word r_info; -} Elf32_Rel; - -typedef struct elf64_rel { - Elf64_Addr r_offset; /* Location at which to apply the action */ - Elf64_Xword r_info; /* index and type of relocation */ -} Elf64_Rel; - -typedef struct elf32_rela{ - Elf32_Addr r_offset; - Elf32_Word r_info; - Elf32_Sword r_addend; -} Elf32_Rela; - -typedef struct elf64_rela { - Elf64_Addr r_offset; /* Location at which to apply the action */ - Elf64_Xword r_info; /* index and type of relocation */ - Elf64_Sxword r_addend; /* Constant addend used to compute value */ -} Elf64_Rela; - -typedef struct elf32_sym{ - Elf32_Word st_name; - Elf32_Addr st_value; - Elf32_Word st_size; - unsigned char st_info; - unsigned char st_other; - Elf32_Half st_shndx; -} Elf32_Sym; - -typedef struct elf64_sym { - Elf64_Word st_name; /* Symbol name, index in string tbl */ - unsigned char st_info; /* Type and binding attributes */ - unsigned char st_other; /* No defined meaning, 0 */ - Elf64_Half st_shndx; /* Associated section index */ - Elf64_Addr st_value; /* Value of the symbol */ - Elf64_Xword st_size; /* Associated symbol size */ -} Elf64_Sym; - - -#define EI_NIDENT 16 - -typedef struct elf32_hdr{ - unsigned char e_ident[EI_NIDENT]; - Elf32_Half e_type; - Elf32_Half e_machine; - Elf32_Word e_version; - Elf32_Addr e_entry; /* Entry point */ - Elf32_Off e_phoff; - Elf32_Off e_shoff; - Elf32_Word e_flags; - Elf32_Half e_ehsize; - Elf32_Half e_phentsize; - Elf32_Half e_phnum; - Elf32_Half e_shentsize; - Elf32_Half e_shnum; - Elf32_Half e_shstrndx; -} Elf32_Ehdr; - -typedef struct elf64_hdr { - unsigned char e_ident[16]; /* ELF "magic number" */ - Elf64_Half e_type; - Elf64_Half e_machine; - Elf64_Word e_version; - Elf64_Addr e_entry; /* Entry point virtual address */ - Elf64_Off e_phoff; /* Program header table file offset */ - Elf64_Off e_shoff; /* Section header table file offset */ - Elf64_Word e_flags; - Elf64_Half e_ehsize; - Elf64_Half e_phentsize; - Elf64_Half e_phnum; - Elf64_Half e_shentsize; - Elf64_Half e_shnum; - Elf64_Half e_shstrndx; -} Elf64_Ehdr; - -/* These constants define the permissions on sections in the program - header, p_flags. */ -#define PF_R 0x4 -#define PF_W 0x2 -#define PF_X 0x1 - -typedef struct elf32_phdr{ - Elf32_Word p_type; - Elf32_Off p_offset; - Elf32_Addr p_vaddr; - Elf32_Addr p_paddr; - Elf32_Word p_filesz; - Elf32_Word p_memsz; - Elf32_Word p_flags; - Elf32_Word p_align; -} Elf32_Phdr; - -typedef struct elf64_phdr { - Elf64_Word p_type; - Elf64_Word p_flags; - Elf64_Off p_offset; /* Segment file offset */ - Elf64_Addr p_vaddr; /* Segment virtual address */ - Elf64_Addr p_paddr; /* Segment physical address */ - Elf64_Xword p_filesz; /* Segment size in file */ - Elf64_Xword p_memsz; /* Segment size in memory */ - Elf64_Xword p_align; /* Segment alignment, file & memory */ -} Elf64_Phdr; - -/* sh_type */ -#define SHT_NULL 0 -#define SHT_PROGBITS 1 -#define SHT_SYMTAB 2 -#define SHT_STRTAB 3 -#define SHT_RELA 4 -#define SHT_HASH 5 -#define SHT_DYNAMIC 6 -#define SHT_NOTE 7 -#define SHT_NOBITS 8 -#define SHT_REL 9 -#define SHT_SHLIB 10 -#define SHT_DYNSYM 11 -#define SHT_NUM 12 -#define SHT_LOPROC 0x70000000 -#define SHT_HIPROC 0x7fffffff -#define SHT_LOUSER 0x80000000 -#define SHT_HIUSER 0xffffffff -#define SHT_MIPS_LIST 0x70000000 -#define SHT_MIPS_CONFLICT 0x70000002 -#define SHT_MIPS_GPTAB 0x70000003 -#define SHT_MIPS_UCODE 0x70000004 - -/* sh_flags */ -#define SHF_WRITE 0x1 -#define SHF_ALLOC 0x2 -#define SHF_EXECINSTR 0x4 -#define SHF_MASKPROC 0xf0000000 -#define SHF_MIPS_GPREL 0x10000000 -#define SHF_ALPHA_GPREL 0x10000000 - -/* special section indexes */ -#define SHN_UNDEF 0 -#define SHN_LORESERVE 0xff00 -#define SHN_LOPROC 0xff00 -#define SHN_HIPROC 0xff1f -#define SHN_ABS 0xfff1 -#define SHN_COMMON 0xfff2 -#define SHN_HIRESERVE 0xffff -#define SHN_MIPS_ACCOMON 0xff00 - -typedef struct { - Elf32_Word sh_name; - Elf32_Word sh_type; - Elf32_Word sh_flags; - Elf32_Addr sh_addr; - Elf32_Off sh_offset; - Elf32_Word sh_size; - Elf32_Word sh_link; - Elf32_Word sh_info; - Elf32_Word sh_addralign; - Elf32_Word sh_entsize; -} Elf32_Shdr; - -typedef struct elf64_shdr { - Elf64_Word sh_name; /* Section name, index in string tbl */ - Elf64_Word sh_type; /* Type of section */ - Elf64_Xword sh_flags; /* Miscellaneous section attributes */ - Elf64_Addr sh_addr; /* Section virtual addr at execution */ - Elf64_Off sh_offset; /* Section file offset */ - Elf64_Xword sh_size; /* Size of section in bytes */ - Elf64_Word sh_link; /* Index of another section */ - Elf64_Word sh_info; /* Additional section information */ - Elf64_Xword sh_addralign; /* Section alignment */ - Elf64_Xword sh_entsize; /* Entry size if section holds table */ -} Elf64_Shdr; - -#define EI_MAG0 0 /* e_ident[] indexes */ -#define EI_MAG1 1 -#define EI_MAG2 2 -#define EI_MAG3 3 -#define EI_CLASS 4 -#define EI_DATA 5 -#define EI_VERSION 6 -#define EI_PAD 7 - -#define ELFMAG0 0x7f /* EI_MAG */ -#define ELFMAG1 'E' -#define ELFMAG2 'L' -#define ELFMAG3 'F' -#define ELFMAG "\177ELF" -#define SELFMAG 4 - -#define ELFCLASSNONE 0 /* EI_CLASS */ -#define ELFCLASS32 1 -#define ELFCLASS64 2 -#define ELFCLASSNUM 3 - -#define ELFDATANONE 0 /* e_ident[EI_DATA] */ -#define ELFDATA2LSB 1 -#define ELFDATA2MSB 2 - -#define EV_NONE 0 /* e_version, EI_VERSION */ -#define EV_CURRENT 1 -#define EV_NUM 2 - -/* Notes used in ET_CORE */ -#define NT_PRSTATUS 1 -#define NT_PRFPREG 2 -#define NT_PRPSINFO 3 -#define NT_TASKSTRUCT 4 -#define NT_PRFPXREG 20 - -/* Note header in a PT_NOTE section */ -typedef struct elf32_note { - Elf32_Word n_namesz; /* Name size */ - Elf32_Word n_descsz; /* Content size */ - Elf32_Word n_type; /* Content type */ -} Elf32_Nhdr; - -/* Note header in a PT_NOTE section */ -typedef struct elf64_note { - Elf64_Word n_namesz; /* Name size */ - Elf64_Word n_descsz; /* Content size */ - Elf64_Word n_type; /* Content type */ -} Elf64_Nhdr; - -#if ELF_CLASS == ELFCLASS32 - -extern Elf32_Dyn _DYNAMIC []; -#define elfhdr elf32_hdr -#define elf_phdr elf32_phdr -#define elf_note elf32_note - -#else - -extern Elf64_Dyn _DYNAMIC []; -#define elfhdr elf64_hdr -#define elf_phdr elf64_phdr -#define elf_note elf64_note - -#endif - __END_DECLS -#endif +#endif /* elf.h */ diff -uNr dietlibc-0.23/include/errno.h dietlibc-0.24/include/errno.h --- dietlibc-0.23/include/errno.h Tue Aug 19 18:56:23 2003 +++ dietlibc-0.24/include/errno.h Fri Nov 14 14:01:00 2003 @@ -391,6 +391,151 @@ #define ENOMEDIUM 125 /* No medium found */ #define EMEDIUMTYPE 126 /* Wrong medium type */ +#elif defined(__hppa__) + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Argument list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ +#define ENOMSG 35 /* No message of desired type */ +#define EIDRM 36 /* Identifier removed */ +#define ECHRNG 37 /* Channel number out of range */ +#define EL2NSYNC 38 /* Level 2 not synchronized */ +#define EL3HLT 39 /* Level 3 halted */ +#define EL3RST 40 /* Level 3 reset */ +#define ELNRNG 41 /* Link number out of range */ +#define EUNATCH 42 /* Protocol driver not attached */ +#define ENOCSI 43 /* No CSI structure available */ +#define EL2HLT 44 /* Level 2 halted */ +#define EDEADLK 45 /* Resource deadlock would occur */ +#define EDEADLOCK EDEADLK +#define ENOLCK 46 /* No record locks available */ +#define EILSEQ 47 /* Illegal byte sequence */ + +#define ENONET 50 /* Machine is not on the network */ +#define ENODATA 51 /* No data available */ +#define ETIME 52 /* Timer expired */ +#define ENOSR 53 /* Out of streams resources */ +#define ENOSTR 54 /* Device not a stream */ +#define ENOPKG 55 /* Package not installed */ + +#define ENOLINK 57 /* Link has been severed */ +#define EADV 58 /* Advertise error */ +#define ESRMNT 59 /* Srmount error */ +#define ECOMM 60 /* Communication error on send */ +#define EPROTO 61 /* Protocol error */ + +#define EMULTIHOP 64 /* Multihop attempted */ + +#define EDOTDOT 66 /* RFS specific error */ +#define EBADMSG 67 /* Not a data message */ +#define EUSERS 68 /* Too many users */ +#define EDQUOT 69 /* Quota exceeded */ +#define ESTALE 70 /* Stale NFS file handle */ +#define EREMOTE 71 /* Object is remote */ +#define EOVERFLOW 72 /* Value too large for defined data type */ + +/* these errnos are defined by Linux but not HPUX. */ + +#define EBADE 160 /* Invalid exchange */ +#define EBADR 161 /* Invalid request descriptor */ +#define EXFULL 162 /* Exchange full */ +#define ENOANO 163 /* No anode */ +#define EBADRQC 164 /* Invalid request code */ +#define EBADSLT 165 /* Invalid slot */ +#define EBFONT 166 /* Bad font file format */ +#define ENOTUNIQ 167 /* Name not unique on network */ +#define EBADFD 168 /* File descriptor in bad state */ +#define EREMCHG 169 /* Remote address changed */ +#define ELIBACC 170 /* Can not access a needed shared library */ +#define ELIBBAD 171 /* Accessing a corrupted shared library */ +#define ELIBSCN 172 /* .lib section in a.out corrupted */ +#define ELIBMAX 173 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 174 /* Cannot exec a shared library directly */ +#define ERESTART 175 /* Interrupted system call should be restarted */ +#define ESTRPIPE 176 /* Streams pipe error */ +#define EUCLEAN 177 /* Structure needs cleaning */ +#define ENOTNAM 178 /* Not a XENIX named type file */ +#define ENAVAIL 179 /* No XENIX semaphores available */ +#define EISNAM 180 /* Is a named type file */ +#define EREMOTEIO 181 /* Remote I/O error */ +#define ENOMEDIUM 182 /* No medium found */ +#define EMEDIUMTYPE 183 /* Wrong medium type */ + +/* We now return you to your regularly scheduled HPUX. */ + +#define ENOSYM 215 /* symbol does not exist in executable */ +#define ENOTSOCK 216 /* Socket operation on non-socket */ +#define EDESTADDRREQ 217 /* Destination address required */ +#define EMSGSIZE 218 /* Message too long */ +#define EPROTOTYPE 219 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 220 /* Protocol not available */ +#define EPROTONOSUPPORT 221 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 222 /* Socket type not supported */ +#define EOPNOTSUPP 223 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 224 /* Protocol family not supported */ +#define EAFNOSUPPORT 225 /* Address family not supported by protocol */ +#define EADDRINUSE 226 /* Address already in use */ +#define EADDRNOTAVAIL 227 /* Cannot assign requested address */ +#define ENETDOWN 228 /* Network is down */ +#define ENETUNREACH 229 /* Network is unreachable */ +#define ENETRESET 230 /* Network dropped connection because of reset */ +#define ECONNABORTED 231 /* Software caused connection abort */ +#define ECONNRESET 232 /* Connection reset by peer */ +#define ENOBUFS 233 /* No buffer space available */ +#define EISCONN 234 /* Transport endpoint is already connected */ +#define ENOTCONN 235 /* Transport endpoint is not connected */ +#define ESHUTDOWN 236 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 237 /* Too many references: cannot splice */ +#define EREFUSED ECONNREFUSED /* for HP's NFS apparently */ +#define ETIMEDOUT 238 /* Connection timed out */ +#define ECONNREFUSED 239 /* Connection refused */ +#define EREMOTERELEASE 240 /* Remote peer released connection */ +#define EHOSTDOWN 241 /* Host is down */ +#define EHOSTUNREACH 242 /* No route to host */ + +#define EALREADY 244 /* Operation already in progress */ +#define EINPROGRESS 245 /* Operation now in progress */ +#define EWOULDBLOCK 246 /* Operation would block (Linux returns EAGAIN) */ +#define ENOTEMPTY 247 /* Directory not empty */ +#define ENAMETOOLONG 248 /* File name too long */ +#define ELOOP 249 /* Too many symbolic links encountered */ +#define ENOSYS 251 /* Function not implemented */ + +#define ENOTSUP 252 /* Function not implemented (POSIX.4 / HPUX) */ +#define ECANCELLED 253 /* aio request was canceled before complete (POSIX.4 / HPUX) */ + + #else /* i386, arm, ppc, x86_64, ia64 */ diff -uNr dietlibc-0.23/include/fcntl.h dietlibc-0.24/include/fcntl.h --- dietlibc-0.23/include/fcntl.h Tue Aug 19 18:25:08 2003 +++ dietlibc-0.24/include/fcntl.h Fri Oct 10 15:17:46 2003 @@ -322,7 +322,7 @@ }; #endif -#elif defined(__powerpc__) +#elif defined(powerpc) || defined(__powerpc64__) /* open/fcntl - O_SYNC is only implemented on blocks devices and on files located on an ext2 file system */ @@ -358,9 +358,11 @@ #define F_SETSIG 10 /* for sockets. */ #define F_GETSIG 11 /* for sockets. */ +//#if !defined(__powerpc64__) #define F_GETLK64 12 /* using 'struct flock64' */ #define F_SETLK64 13 #define F_SETLKW64 14 +//#endif /* for F_[GET|SET]FL */ #define FD_CLOEXEC 1 /* actually anything with low bit set goes */ @@ -397,6 +399,7 @@ pid_t l_pid; }; +//#if !defined(__powerpc64__) struct flock64 { short l_type; short l_whence; @@ -404,6 +407,7 @@ loff_t l_len; pid_t l_pid; }; +//#endif #elif defined (__arm__) diff -uNr dietlibc-0.23/include/getopt.h dietlibc-0.24/include/getopt.h --- dietlibc-0.23/include/getopt.h Tue Aug 19 18:25:45 2003 +++ dietlibc-0.24/include/getopt.h Wed Sep 17 02:20:17 2003 @@ -5,8 +5,6 @@ __BEGIN_DECLS -extern int optopt; - struct option { const char* name; int has_arg; diff -uNr dietlibc-0.23/include/libintl.h dietlibc-0.24/include/libintl.h --- dietlibc-0.23/include/libintl.h Tue Aug 19 18:26:41 2003 +++ dietlibc-0.24/include/libintl.h Tue Nov 4 18:17:12 2003 @@ -7,12 +7,8 @@ __BEGIN_DECLS -#define gettext(msgid) dgettext(0,msgid) -#define dgettext(domainname,msgid) dcgettext(domainname,msgid,LC_MESSAGES) - -#define ngettext(msgid1,msgid2,n) dngettext(0,msgid1,msgid2,n) -#define dngettext(dn,msgid1,msgid2,n) dngettext(dn,msgid1,msgid2,n,LC_MESSAGES) - +char* gettext(const char* msgid) __THROW; +char* dgettext(const char* domainname, const char* msgid) __THROW; char* dcgettext(const char *domainname, const char *msgid, int category) __THROW; char* dcngettext(const char *domainname, const char *msgid1, const char *msgid2, @@ -22,6 +18,13 @@ char* bindtextdomain(const char *domainname, const char *dirname) __THROW; char* bind_textdomain_codeset(const char *domainname, const char *codeset) __THROW; +#define gettext(msgid) dgettext(0,msgid) +#define dgettext(domainname,msgid) dcgettext(domainname,msgid,LC_MESSAGES) + +#define ngettext(msgid1,msgid2,n) dngettext(0,msgid1,msgid2,n) +#define dngettext(dn,msgid1,msgid2,n) dngettext(dn,msgid1,msgid2,n,LC_MESSAGES) + + __END_DECLS #endif diff -uNr dietlibc-0.23/include/math.h dietlibc-0.24/include/math.h --- dietlibc-0.23/include/math.h Tue Aug 19 18:27:04 2003 +++ dietlibc-0.24/include/math.h Wed Oct 15 15:14:41 2003 @@ -70,9 +70,13 @@ double copysign(double value, double sign) __attribute__((__const__)); # define HUGE_VAL \ - (__extension__ \ - ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) \ - { __l: 0x000000007ff00000ULL }).__d) + (__extension__ \ + ((union { unsigned long long __ll; double __d; }) \ + { __ll: 0x7ff0000000000000ULL }).__d) +# define HUGE_VALF \ + (__extension__ \ + ((union { unsigned int __i; float __f; }) \ + { __i: 0x7f800000UL }).__f) #ifdef _GNU_SOURCE void sincos(double x, double* sinx, double* cosx); diff -uNr dietlibc-0.23/include/paths.h dietlibc-0.24/include/paths.h --- dietlibc-0.23/include/paths.h Sat Mar 9 16:48:50 2002 +++ dietlibc-0.24/include/paths.h Thu Nov 20 12:09:27 2003 @@ -20,4 +20,9 @@ /* puke */ #define _PATH_MAILDIR "/var/mail" +#define _PATH_TTY "/dev/tty" +#define _PATH_MNTTAB "/etc/fstab" +#define _PATH_MOUNTED "/etc/mtab" +#define _PATH_DEV "/dev/" + #endif diff -uNr dietlibc-0.23/include/pthread.h dietlibc-0.24/include/pthread.h --- dietlibc-0.23/include/pthread.h Fri Sep 12 14:32:48 2003 +++ dietlibc-0.24/include/pthread.h Fri Nov 14 14:02:35 2003 @@ -23,7 +23,7 @@ #define MAX_SPIN_COUNT 50 #define SPIN_SLEEP_DURATION 2000001 -#define PTHREAD_DESTRUCTOR_ITERATIONS 4 +#define PTHREAD_DESTRUCTOR_ITERATIONS 1 #define PTHREAD_KEYS_MAX 32 @@ -31,7 +31,7 @@ typedef int pthread_t; /* Fast locks */ -#ifdef __parisc__ +#ifdef __hppa__ struct _pthread_fastlock { int __spinlock; } __attribute__((aligned(16))); #define PTHREAD_SPIN_LOCKED 0 diff -uNr dietlibc-0.23/include/semaphore.h dietlibc-0.24/include/semaphore.h --- dietlibc-0.23/include/semaphore.h Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/include/semaphore.h Wed Sep 17 17:06:10 2003 @@ -0,0 +1,35 @@ +#ifndef __SEMAPHORE_H__ +#define __SEMAPHORE_H__ + +#include +#include + +__BEGIN_DECLS + +typedef struct { + pthread_mutex_t lock; + pthread_cond_t cond; + int value; + unsigned int magic; +} sem_t; + +#define SEM_FAILED ((sem_t*)0) +#define SEM_VALUE_MAX ((int)((~0u)>>1)) +#define SEM_MAGIC 0x35d108f2 + +int sem_destroy(sem_t*sem) __THROW; +int sem_getvalue(sem_t*sem,int*sval) __THROW; +int sem_init(sem_t*sem,int pshared,unsigned int value) __THROW; +int sem_post(sem_t*sem) __THROW; +int sem_trywait(sem_t*sem) __THROW; +int sem_wait(sem_t*sem) __THROW; + +sem_t*sem_open(const char*name,int oflag,...) __THROW; +int sem_close(sem_t*sem) __THROW; +int sem_unlink(const char*name) __THROW; + +int sem_timedwait(sem_t*sem,const struct timespec*abstime) __THROW; + +__END_DECLS + +#endif diff -uNr dietlibc-0.23/include/setjmp.h dietlibc-0.24/include/setjmp.h --- dietlibc-0.23/include/setjmp.h Tue Aug 19 18:33:28 2003 +++ dietlibc-0.24/include/setjmp.h Fri Oct 10 15:17:46 2003 @@ -170,7 +170,7 @@ #endif #endif -#ifdef __powerpc__ +#if defined(powerpc) || defined(__powerpc64__) # define JB_GPR1 0 /* Also known as the stack pointer */ # define JB_GPR2 1 # define JB_LR 2 /* The address we will return to */ diff -uNr dietlibc-0.23/include/signal.h dietlibc-0.24/include/signal.h --- dietlibc-0.23/include/signal.h Tue Aug 19 22:28:46 2003 +++ dietlibc-0.24/include/signal.h Thu Nov 20 12:06:55 2003 @@ -32,8 +32,8 @@ #define SIGALRM 14 #define SIGTERM 15 #define SIGUNUSED 31 -#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__arm__) \ - || defined(__s390__) || defined(__ia64__) +#if defined(__i386__) || defined(__x86_64__) || defined(powerpc) || defined(__arm__) \ + || defined(__s390__) || defined(__ia64__) || defined(__powerpc64__) #define SIGBUS 7 #define SIGUSR1 10 #define SIGUSR2 12 @@ -206,10 +206,14 @@ #define MINSIGSTKSZ 2048 #define SIGSTKSZ 8192 -#if defined(__alpha__) || defined(__mips__) -#define SIG_BLOCK 1 /* for blocking signals */ -#define SIG_UNBLOCK 2 /* for unblocking signals */ -#define SIG_SETMASK 3 /* for setting the signal mask */ +#if defined(__sparc__) +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 4 +#elif defined(__alpha__) || defined(__mips__) +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 #else #define SIG_BLOCK 0 /* for blocking signals */ #define SIG_UNBLOCK 1 /* for unblocking signals */ @@ -224,6 +228,10 @@ typedef sighandler_t sig_t; #endif +#ifdef _GNU_SOURCE +typedef sighandler_t __sighandler_t; /* shoot the glibc people! */ +#endif + #define SIG_DFL ((sighandler_t)0) /* default signal handling */ #define SIG_IGN ((sighandler_t)1) /* ignore signal */ #define SIG_ERR ((sighandler_t)-1) /* error return from signal */ @@ -497,7 +505,9 @@ /* 0 is OK ! kernel puts in MAX_THREAD_TIMEOUT :) */ #define sigwaitinfo(m, i) sigtimedwait((m),(i),0) -extern const char *const sys_siglist[]; +int sigwait(const sigset_t* set,int* sig) __THROW; + +extern const char *const* sys_siglist; #include diff -uNr dietlibc-0.23/include/stdarg-cruft.h dietlibc-0.24/include/stdarg-cruft.h --- dietlibc-0.23/include/stdarg-cruft.h Wed Dec 4 19:32:33 2002 +++ dietlibc-0.24/include/stdarg-cruft.h Fri Oct 10 15:17:19 2003 @@ -109,7 +109,7 @@ #endif #endif -#elif defined(__powerpc__) +#elif defined(powerpc) typedef struct __va_list_tag { unsigned char gpr; /* index into the array of 8 GPRs stored in the @@ -275,7 +275,7 @@ == __real_type_class) && (__va).__offset <= (6 * 8)) \ ? (6 * 8) + 8 : __va_tsize (__type))))) -#else /* !__sparc__ && !__powerpc__ && !__mips__ && !__alpha__*/ +#else /* !__sparc__ && !powerpc && !__mips__ && !__alpha__*/ typedef char* va_list; diff -uNr dietlibc-0.23/include/stdio.h dietlibc-0.24/include/stdio.h --- dietlibc-0.23/include/stdio.h Sat Aug 30 00:33:18 2003 +++ dietlibc-0.24/include/stdio.h Tue Nov 11 18:35:03 2003 @@ -40,36 +40,50 @@ int fgetc(FILE *stream) __THROW; int fgetc_unlocked(FILE *stream) __THROW; char *fgets(char *s, int size, FILE *stream) __THROW; -int getc(FILE *stream) __THROW; -int getchar(void) __THROW; +char *fgets_unlocked(char *s, int size, FILE *stream) __THROW; + char *gets(char *s) __THROW; int ungetc(int c, FILE *stream) __THROW; +int ungetc_unlocked(int c, FILE *stream) __THROW; int fputc(int c, FILE *stream) __THROW; int fputc_unlocked(int c, FILE *stream) __THROW; int fputs(const char *s, FILE *stream) __THROW; +int fputs_unlocked(const char *s, FILE *stream) __THROW; +int getc(FILE *stream) __THROW; +int getchar(void) __THROW; int putchar(int c) __THROW; +int putchar_unlocked(int c) __THROW; #define putc(c,stream) fputc(c,stream) #define putchar(c) fputc(c,stdout) +#define putc_unlocked(c,stream) fputc_unlocked(c,stream) +#define putchar_unlocked(c) fputc_unlocked(c,stdout) -#define getchar() fgetc(stdin) #define getc(stream) fgetc(stream) +#define getchar() fgetc(stdin) #define getc_unlocked(stream) fgetc_unlocked(stream) +#define getchar_unlocked() fgetc_unlocked(stdin) int puts(const char *s) __THROW; int fseek(FILE *stream, long offset, int whence) __THROW; +int fseek_unlocked(FILE *stream, long offset, int whence) __THROW; long ftell(FILE *stream) __THROW; +long ftell_unlocked(FILE *stream) __THROW; int fseeko(FILE *stream, off_t offset, int whence) __THROW; +int fseeko_unlocked(FILE *stream, off_t offset, int whence) __THROW; off_t ftello(FILE *stream) __THROW; +off_t ftello_unlocked(FILE *stream) __THROW; #ifndef __NO_STAT64 int fseeko64(FILE *stream, loff_t offset, int whence) __THROW; +int fseeko64_unlocked(FILE *stream, loff_t offset, int whence) __THROW; loff_t ftello64(FILE *stream) __THROW; +loff_t ftello64_unlocked(FILE *stream) __THROW; -#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 +#if _FILE_OFFSET_BITS == 64 #define off_t loff_t #define fseeko(foo,bar,baz) fseeko64(foo,bar,baz) #define ftello(foo) ftello64(foo) @@ -82,17 +96,25 @@ int fsetpos(FILE *stream, fpos_t *pos) __THROW; size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) __THROW; +size_t fread_unlocked(void *ptr, size_t size, size_t nmemb, FILE *stream) __THROW; size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) __THROW; +size_t fwrite_unlocked(const void *ptr, size_t size, size_t nmemb, FILE *stream) __THROW; int fflush(FILE *stream) __THROW; +int fflush_unlocked(FILE *stream) __THROW; int fclose(FILE *stream) __THROW; +int fclose_unlocked(FILE *stream) __THROW; -int feof (FILE *stream) __THROW; +int feof(FILE *stream) __THROW; +int feof_unlocked(FILE *stream) __THROW; int ferror(FILE *stream) __THROW; +int ferror_unlocked(FILE *stream) __THROW; int fileno(FILE *stream) __THROW; +int fileno_unlocked(FILE *stream) __THROW; void clearerr(FILE *stream) __THROW; +void clearerr_unlocked(FILE *stream) __THROW; int remove(const char *pathname) __THROW; @@ -109,6 +131,7 @@ #define _IOFBF 2 int setvbuf(FILE *stream, char *buf, int mode , size_t size) __THROW; +int setvbuf_unlocked(FILE *stream, char *buf, int mode , size_t size) __THROW; #define setbuf(stream,buf) setvbuf(stream,buf,buf?_IOFBF:_IONBF,BUFSIZ) #define setbuffer(stream,buf,size) setvbuf(stream,buf,buf?_IOFBF:_IONBF,size) @@ -128,10 +151,13 @@ char* tmpnam(char *s) __THROW; /* DO NOT USE!!! Use mkstemp instead! */ char* tempnam(char* dir,char* _template); /* dito */ FILE* tmpfile(void) __THROW; +FILE* tmpfile_unlocked(void) __THROW; #define FILENAME_MAX 4095 #define FOPEN_MAX 16 +#define TMP_MAX 10000 + /* this is so bad, we moved it to -lcompat */ #define L_ctermid 9 char* ctermid(char* s); /* returns "/dev/tty" */ diff -uNr dietlibc-0.23/include/sys/cdefs.h dietlibc-0.24/include/sys/cdefs.h --- dietlibc-0.23/include/sys/cdefs.h Fri Aug 22 14:16:20 2003 +++ dietlibc-0.24/include/sys/cdefs.h Wed Oct 8 01:44:25 2003 @@ -29,16 +29,16 @@ #ifndef __STRICT_ANSI__ #if __GNUC__ < 3 #define __builtin_expect(foo,bar) (foo) -#define expect(foo,bar) (foo) +#define __expect(foo,bar) (foo) #else -#define expect(foo,bar) __builtin_expect((long)(foo),bar) +#define __expect(foo,bar) __builtin_expect((long)(foo),bar) #define __attribute_malloc__ __attribute__((__malloc__)) #endif #endif /* idea for these macros taken from Linux kernel */ -#define __likely(foo) expect((foo),1) -#define __unlikely(foo) expect((foo),0) +#define __likely(foo) __expect((foo),1) +#define __unlikely(foo) __expect((foo),0) #ifndef __attribute_malloc__ #define __attribute_malloc__ diff -uNr dietlibc-0.23/include/sys/ioctl.h dietlibc-0.24/include/sys/ioctl.h --- dietlibc-0.23/include/sys/ioctl.h Tue Aug 19 18:47:45 2003 +++ dietlibc-0.24/include/sys/ioctl.h Fri Oct 10 15:17:46 2003 @@ -15,7 +15,7 @@ #include #elif defined(__mips__) #include -#elif defined(__powerpc__) +#elif defined(powerpc) || defined(__powerpc64__) #include #elif defined(__s390__) #include diff -uNr dietlibc-0.23/include/sys/mman.h dietlibc-0.24/include/sys/mman.h --- dietlibc-0.23/include/sys/mman.h Tue Aug 19 18:48:32 2003 +++ dietlibc-0.24/include/sys/mman.h Fri Oct 10 15:17:46 2003 @@ -72,7 +72,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ -#elif defined(__sparc__) || defined (__powerpc__) +#elif defined(__sparc__) || defined (powerpc) || defined (__powerpc64__) #define MAP_FIXED 0x10 /* Interpret addr exactly */ #define MAP_ANONYMOUS 0x20 /* don't use a file */ #define MAP_RENAME MAP_ANONYMOUS /* In SunOS terminology */ diff -uNr dietlibc-0.23/include/sys/mtio.h dietlibc-0.24/include/sys/mtio.h --- dietlibc-0.23/include/sys/mtio.h Tue Aug 19 18:49:34 2003 +++ dietlibc-0.24/include/sys/mtio.h Thu Nov 20 14:56:05 2003 @@ -2,6 +2,7 @@ #define _SYS_MTIO_H #include +#include /* for daddr_t */ __BEGIN_DECLS @@ -56,8 +57,6 @@ /* structure for MTIOCGET - mag tape get status command */ -typedef int daddr_t; - struct mtget { long int mt_type; /* type of magtape device */ long int mt_resid; /* residual count: (not sure) diff -uNr dietlibc-0.23/include/sys/ptrace.h dietlibc-0.24/include/sys/ptrace.h --- dietlibc-0.23/include/sys/ptrace.h Tue Aug 19 18:50:20 2003 +++ dietlibc-0.24/include/sys/ptrace.h Fri Oct 10 15:17:46 2003 @@ -637,7 +637,7 @@ #define PTRACE_GETUCODE 29 /* stupid bsd-ism */ -#elif defined(__powerpc__) +#elif defined(powerpc) || defined (__powerpc64__) struct pt_regs { unsigned long gpr[32]; diff -uNr dietlibc-0.23/include/sys/shm.h dietlibc-0.24/include/sys/shm.h --- dietlibc-0.23/include/sys/shm.h Tue Aug 19 18:51:12 2003 +++ dietlibc-0.24/include/sys/shm.h Fri Oct 10 15:17:46 2003 @@ -60,7 +60,7 @@ unsigned long swap_successes; }; -#if defined(__i386__) || defined(__mips__) || defined(__arm__) || defined(__powerpc__) || defined(__s390__) || defined(__hppa__) || defined(__x86_64__) || defined(__ia64__) +#if defined(__i386__) || defined(__mips__) || defined(__arm__) || defined(powerpc) || defined (__powerpc64__) || defined(__s390__) || defined(__hppa__) || defined(__x86_64__) || defined(__ia64__) #define PAGE_SIZE 4096UL #define PAGE_SHIFT 12 #elif defined(__alpha__) || defined(__sparc__) diff -uNr dietlibc-0.23/include/sys/stat.h dietlibc-0.24/include/sys/stat.h --- dietlibc-0.23/include/sys/stat.h Tue Aug 26 19:55:24 2003 +++ dietlibc-0.24/include/sys/stat.h Fri Oct 10 15:17:46 2003 @@ -195,7 +195,8 @@ unsigned long st_pad2; __extension__ long long st_blocks; }; -#elif defined(__powerpc__) +#elif defined(powerpc) || defined(__powerpc64__) +#if defined(powerpc) struct stat { dev_t st_dev; ino_t st_ino; @@ -216,9 +217,33 @@ unsigned long __unused4; unsigned long __unused5; }; +#else +struct stat { + unsigned long st_dev; + ino_t st_ino; + nlink_t st_nlink; + mode_t st_mode; + uid_t st_uid; + gid_t st_gid; + unsigned long st_rdev; + off_t st_size; + unsigned long st_blksize; + unsigned long st_blocks; + unsigned long st_atime; + unsigned long st_atime_nsec; + unsigned long st_mtime; + unsigned long st_mtime_nsec; + unsigned long st_ctime; + unsigned long st_ctime_nsec; + unsigned long __unused4; + unsigned long __unused5; + unsigned long __unused6; +}; +#endif /* This matches struct stat64 in glibc2.1. */ +//#if !defined(__powerpc64__) struct stat64 { __extension__ unsigned long long st_dev; /* Device. */ __extension__ unsigned long long st_ino; /* File serial number. */ @@ -241,6 +266,7 @@ unsigned long int __unused4; unsigned long int __unused5; }; +//#endif #elif defined(__arm__) struct stat { unsigned short st_dev; @@ -301,6 +327,28 @@ __extension__ unsigned long long st_ino; }; #elif defined(__s390__) +#if defined(__s390x__) +struct stat { + unsigned long st_dev; + unsigned long st_ino; + unsigned long st_nlink; + unsigned int st_mode; + unsigned int st_uid; + unsigned int st_gid; + unsigned int __pad1; + unsigned long st_rdev; + unsigned long st_size; + unsigned long st_atime; + unsigned long __reserved0; /* reserved for atime.nanoseconds */ + unsigned long st_mtime; + unsigned long __reserved1; /* reserved for mtime.nanoseconds */ + unsigned long st_ctime; + unsigned long __reserved2; /* reserved for ctime.nanoseconds */ + unsigned long st_blksize; + long st_blocks; + unsigned long __unused[3]; +}; +#else struct stat { unsigned short st_dev; unsigned short __pad1; @@ -323,6 +371,7 @@ unsigned long __unused4; unsigned long __unused5; }; +#endif struct stat64 { unsigned char __pad0[6]; unsigned short st_dev; diff -uNr dietlibc-0.23/include/sys/types.h dietlibc-0.24/include/sys/types.h --- dietlibc-0.23/include/sys/types.h Tue Aug 19 19:08:24 2003 +++ dietlibc-0.24/include/sys/types.h Thu Nov 20 12:06:10 2003 @@ -43,29 +43,42 @@ Used for timer ID returned by timer_create(). */ -#if defined(__alpha__) || defined(__mips__) || defined(__powerpc__) || defined(__hppa__) || defined(__sparc64__) \ - || defined(__x86_64__) || defined(__ia64__) -typedef unsigned int uid_t; /* Used for user IDs. */ -typedef unsigned int gid_t; /* Used for group IDs. */ -typedef unsigned int dev_t; /* Used for device IDs. */ -#else -typedef unsigned short uid_t; /* Used for user IDs. */ -typedef unsigned short gid_t; /* Used for group IDs. */ -typedef unsigned short dev_t; /* Used for device IDs. */ -#endif - -#if defined(__alpha__) || defined(__mips__) || defined(__powerpc__) || defined(__sparc64__) \ - || defined(__x86_64__) || defined(__ia64__) -typedef unsigned int mode_t; /* Used for some file attributes. */ -#else -typedef unsigned short mode_t; /* Used for some file attributes. */ -#endif - -#if defined(__alpha__) || defined(__mips__) || defined(__sparc64__) \ - || defined(__x86_64__) || defined(__ia64__) -typedef unsigned int nlink_t; /* Used for link counts. */ -#else -typedef unsigned short nlink_t; /* Used for link counts. */ +#if defined(__alpha__) || defined(__ia64__) || defined(__sparc64__) || defined(__s390x__) + typedef unsigned int dev_t; /* Used for device IDs. */ + typedef unsigned int gid_t; /* Used for group IDs. */ + typedef unsigned int mode_t; /* Used for some file attributes. */ + typedef unsigned int nlink_t; /* Used for link counts. */ + typedef unsigned int uid_t; /* Used for user IDs. */ +#elif defined(__arm__) || defined(__i386__) || defined(__sparc__) || defined(__s390__) /* make sure __s390x__ hits before __s390__ */ + typedef unsigned short dev_t; + typedef unsigned short gid_t; + typedef unsigned short mode_t; + typedef unsigned short nlink_t; + typedef unsigned short uid_t; +#elif defined(__hppa__) + typedef unsigned int dev_t; + typedef unsigned int gid_t; + typedef unsigned short mode_t; + typedef unsigned short nlink_t; + typedef unsigned int uid_t; +#elif defined(__mips__) + typedef unsigned int dev_t; + typedef int gid_t; + typedef unsigned int mode_t; + typedef int nlink_t; + typedef int uid_t; +#elif defined(powerpc) + typedef unsigned int dev_t; + typedef unsigned int gid_t; + typedef unsigned int mode_t; + typedef unsigned short nlink_t; + typedef unsigned int uid_t; +#elif defined(__powerpc64__) || defined(__x86_64__) + typedef unsigned long dev_t; + typedef unsigned int gid_t; + typedef unsigned int mode_t; + typedef unsigned long nlink_t; + typedef unsigned int uid_t; #endif typedef signed int id_t; /* Used as a general identifier; can be @@ -118,6 +131,13 @@ typedef uint32_t nlong __attribute_dontuse__; typedef uint32_t ntime __attribute_dontuse__; typedef uint16_t nshort __attribute_dontuse__; + +/* never heard of these two, but dump uses them */ +typedef int64_t quad_t __attribute_dontuse__; +typedef uint64_t u_quad_t __attribute_dontuse__; +typedef long daddr_t __attribute_dontuse__; + +typedef daddr_t __daddr_t __attribute_dontuse__; #endif #ifdef _GNU_SOURCE diff -uNr dietlibc-0.23/include/sys/ucontext.h dietlibc-0.24/include/sys/ucontext.h --- dietlibc-0.23/include/sys/ucontext.h Tue Aug 19 23:27:19 2003 +++ dietlibc-0.24/include/sys/ucontext.h Fri Oct 10 15:17:46 2003 @@ -10,7 +10,7 @@ typedef struct sigcontext mcontext_t; #endif -#if defined(__i386__) || defined(__arm__) || defined(__mips__) || defined(__mips64__) || defined(__powerpc__) || defined(__hppa__) +#if defined(__i386__) || defined(__arm__) || defined(__mips__) || defined(__mips64__) || defined(powerpc) || defined(__powerpc64__) || defined(__hppa__) struct ucontext { unsigned long uc_flags; struct ucontext *uc_link; diff -uNr dietlibc-0.23/include/termios.h dietlibc-0.24/include/termios.h --- dietlibc-0.23/include/termios.h Tue Aug 19 18:36:51 2003 +++ dietlibc-0.24/include/termios.h Fri Oct 10 15:17:46 2003 @@ -103,7 +103,7 @@ cc_t c_line; /* line discipline */ cc_t c_cc[NCCS]; /* control characters */ }; -#elif defined(powerpc) || defined(__alpha__) +#elif defined(powerpc) || defined(__powerpc64__) || defined(__alpha__) #define NCCS 19 struct termios { tcflag_t c_iflag; /* input mode flags */ @@ -167,7 +167,7 @@ #define VLNEXT 15 #define VEOF 16 #define VEOL 17 -#elif defined(__powerpc__) +#elif defined(powerpc) || defined(__powerpc64__) #define VINTR 0 #define VQUIT 1 #define VERASE 2 diff -uNr dietlibc-0.23/include/time.h dietlibc-0.24/include/time.h --- dietlibc-0.23/include/time.h Tue Aug 19 18:37:00 2003 +++ dietlibc-0.24/include/time.h Thu Nov 20 14:13:57 2003 @@ -39,6 +39,13 @@ clock_t clock(void); +char *strptime(const char *s, const char *format, struct tm *tm); + +#ifdef _GNU_SOURCE +time_t timegm(struct tm *timeptr) __THROW __attribute_dontuse__ __pure ; +time_t timelocal(struct tm *timeptr) __THROW __attribute_dontuse__ __pure; +#endif + __END_DECLS #endif diff -uNr dietlibc-0.23/include/unistd.h dietlibc-0.24/include/unistd.h --- dietlibc-0.23/include/unistd.h Fri Sep 12 14:32:48 2003 +++ dietlibc-0.24/include/unistd.h Wed Oct 8 01:44:25 2003 @@ -9,8 +9,8 @@ __BEGIN_DECLS -int optind,opterr; -char *optarg; +extern int optind,opterr,optopt; +extern char *optarg; int getopt(int argc, char *const argv[], const char *options); /* Values for the second argument to access. @@ -122,14 +122,6 @@ int pause(void) __THROW; -#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 -#define open open64 -#define creat creat64 -#define truncate truncate64 -#define ftruncate ftruncate64 -#define getdents getdents64 -#endif - char* getlogin(void) __THROW; /* warning: the diet libc getlogin() simply returns getenv("LOGNAME") */ @@ -160,8 +152,6 @@ int nice(int inc) __THROW; -char **__environ; - char *crypt(const char *key, const char *salt) __THROW; void encrypt(char block[64], int edflag) __THROW; void setkey(const char *key) __THROW; @@ -235,7 +225,7 @@ /* this is so bad, we moved it to -lcompat */ #define L_cuserid 17 -char * cuserid(char * string); /* ugh! */ +char* cuserid(char * string); /* ugh! */ #define _POSIX_VERSION 199506L @@ -251,6 +241,16 @@ int vhangup(void) __THROW; +extern char **__environ; + +#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 +#define open open64 +#define creat creat64 +#define truncate truncate64 +#define ftruncate ftruncate64 +#define getdents getdents64 +#endif + __END_DECLS #endif diff -uNr dietlibc-0.23/lib/__dtostr.c dietlibc-0.24/lib/__dtostr.c --- dietlibc-0.23/lib/__dtostr.c Thu Jan 2 15:04:42 2003 +++ dietlibc-0.24/lib/__dtostr.c Wed Oct 15 15:14:41 2003 @@ -13,9 +13,12 @@ int __dtostr(double d,char *buf,unsigned int maxlen,unsigned int prec,unsigned int prec2) { #if 1 - unsigned long long *x=(unsigned long long *)&d; + union { + unsigned long long l; + double d; + } u = { .d=d }; /* step 1: extract sign, mantissa and exponent */ - signed long e=((*x>>52)&((1<<11)-1))-1023; + signed long e=((u.l>>52)&((1<<11)-1))-1023; #else #if __BYTE_ORDER == __LITTLE_ENDIAN signed long e=(((((unsigned long*)&d)[1])>>20)&((1<<11)-1))-1023; @@ -23,7 +26,7 @@ signed long e=(((*((unsigned long*)&d))>>20)&((1<<11)-1))-1023; #endif #endif -/* unsigned long long m=*x & ((1ull<<52)-1); */ +/* unsigned long long m=u.l & ((1ull<<52)-1); */ /* step 2: exponent is base 2, compute exponent for base 10 */ signed long e10; /* step 3: calculate 10^e10 */ @@ -32,8 +35,8 @@ double tmp; char *oldbuf=buf; - if (isnan(d)) return copystring(buf,maxlen,"nan"); if ((i=isinf(d))) return copystring(buf,maxlen,i>0?"inf":"-inf"); + if (isnan(d)) return copystring(buf,maxlen,"nan"); e10=1+(long)(e*0.30102999566398119802); /* log10(2) */ /* Wir iterieren von Links bis wir bei 0 sind oder maxlen erreicht * ist. Wenn maxlen erreicht ist, machen wir das nochmal in diff -uNr dietlibc-0.23/lib/__isinf.c dietlibc-0.24/lib/__isinf.c --- dietlibc-0.23/lib/__isinf.c Tue Aug 19 19:08:05 2003 +++ dietlibc-0.24/lib/__isinf.c Wed Sep 17 02:20:17 2003 @@ -1,8 +1,12 @@ #include int isinf(double d) { - unsigned long long *x=(unsigned long long *)&d; - return (*x==0x7FF0000000000000ll?1:*x==0xFFF0000000000000ll?-1:0); + union { + unsigned long long l; + double d; + } u; + u.d=d; + return (u.l==0x7FF0000000000000ll?1:u.l==0xFFF0000000000000ll?-1:0); } int __isinf(double d) __attribute__((alias("isinf"))); diff -uNr dietlibc-0.23/lib/__isnan.c dietlibc-0.24/lib/__isnan.c --- dietlibc-0.23/lib/__isnan.c Tue Dec 17 01:47:29 2002 +++ dietlibc-0.24/lib/__isnan.c Wed Sep 17 02:20:17 2003 @@ -1,8 +1,12 @@ #include int isnan(double d) { - unsigned long long *x=(unsigned long long *)&d; - return (*x==0x7FF8000000000000ll || *x==0x7FF0000000000000 || *x==0xfff8000000000000); + union { + unsigned long long l; + double d; + } u; + u.d=d; + return (u.l==0x7FF8000000000000ll || u.l==0x7FF0000000000000ll || u.l==0xfff8000000000000ll); } int __isnan(double d) __attribute__((alias("isnan"))); diff -uNr dietlibc-0.23/lib/__v_printf.c dietlibc-0.24/lib/__v_printf.c --- dietlibc-0.23/lib/__v_printf.c Tue Aug 26 19:55:24 2003 +++ dietlibc-0.24/lib/__v_printf.c Sat Oct 18 17:48:06 2003 @@ -3,6 +3,7 @@ #include #include #include +#include #include "dietstdio.h" #include "dietwarning.h" @@ -29,6 +30,9 @@ int __v_printf(struct arg_printf* fn, const unsigned char *format, va_list arg_ptr) { int len=0; +#ifdef WANT_ERROR_PRINTF + int _errno = errno; +#endif while (*format) { unsigned int sz = skip_to(format); @@ -38,8 +42,11 @@ } if (*format=='%') { char buf[128]; + union { char*s; } u_str; +#define s u_str.s - unsigned char ch, *s, padwith=' '; + int retval; + unsigned char ch, padwith=' '; char flag_in_sign=0; char flag_upcase=0; @@ -74,16 +81,13 @@ case 'h': --flag_long; goto inn_printf; + case 'q': /* BSD ... */ case 'L': ++flag_long; /* fall through */ case 'l': ++flag_long; goto inn_printf; - case '0': - padwith='0'; - goto inn_printf; - case '-': flag_left=1; goto inn_printf; @@ -96,6 +100,7 @@ flag_sign=1; goto inn_printf; + case '0': case '1': case '2': case '3': @@ -107,6 +112,7 @@ case '9': if(flag_dot) return -1; width=strtoul(format-1,(char**)&s,10); + if (ch=='0' && !flag_left) padwith='0'; format=s; goto inn_printf; @@ -133,6 +139,14 @@ A_WRITE(fn,&ch,1); ++len; break; +#ifdef WANT_ERROR_PRINTF + /* print an error message */ + case 'm': + s=strerror(_errno); + sz=strlen(s); + A_WRITE(fn,s,sz); len+=sz; + break; +#endif /* print a string */ case 's': s=va_arg(arg_ptr,char *); @@ -141,34 +155,64 @@ #endif sz = strlen(s); if (flag_dot && sz>preci) sz=preci; + preci=0; flag_dot^=flag_dot; + padwith=' '; print_out: - if (width && (!flag_left)) { -#if 0 - if (flag_in_sign) { - A_WRITE(fn,s,1); ++len; - ++s; --sz; - --width; - } -#endif - if (flag_hash>0) { - A_WRITE(fn,s,flag_hash); len+=flag_hash; - s+=flag_hash; sz-=flag_hash; - width-=flag_hash; - } -// len+=write_pad(fn,(signed int)width-(signed int)sz,padwith); + { + char *sign=s; + int todo=0; + int vs; + + if (! (width||preci) ) { + A_WRITE(fn,s,sz); len+=sz; + break; + } + + if (flag_in_sign) todo=1; + if (flag_hash>0) todo=flag_hash; + if (todo) { + s+=todo; + sz-=todo; + width-=todo; + } + + if (!flag_left) { if (flag_dot) { - len+=write_pad(fn,(signed int)width-(signed int)preci,padwith); + vs=preci>sz?preci:sz; + len+=write_pad(fn,(signed int)width-(signed int)vs,' '); + if (todo) { + A_WRITE(fn,sign,todo); + len+=todo; + } len+=write_pad(fn,(signed int)preci-(signed int)sz,'0'); - } else - len+=write_pad(fn,(signed int)width-(signed int)sz,padwith); - } - A_WRITE(fn,s,sz); len+=sz; - if (width && (flag_left)) { - len+=write_pad(fn,(signed int)width-(signed int)sz,' '); + } else { + if (todo && padwith=='0') { + A_WRITE(fn,sign,todo); + len+=todo; todo=0; + } + len+=write_pad(fn,(signed int)width-(signed int)sz, padwith); + if (todo) { + A_WRITE(fn,sign,todo); + len+=todo; + } + } + A_WRITE(fn,s,sz); len+=sz; + } else if (flag_left) { + if (todo) { + A_WRITE(fn,sign,todo); + len+=todo; + } + len+=write_pad(fn,(signed int)preci-(signed int)sz, '0'); + A_WRITE(fn,s,sz); len+=sz; + vs=preci>sz?preci:sz; + len+=write_pad(fn,(signed int)width-(signed int)vs, ' '); + } else { + A_WRITE(fn,s,sz); len+=sz; } break; + } /* print an integer value */ case 'b': @@ -184,13 +228,13 @@ case 'x': base=16; sz=0; - if (flag_dot) width=preci; if (flag_hash) { buf[1]='0'; buf[2]=ch; flag_hash=2; sz=2; } + if (preci>width) width=preci; goto num_printf; case 'd': case 'i': @@ -238,10 +282,18 @@ if (flag_long<-1) number&=0xff; #ifdef WANT_LONGLONG_PRINTF if (flag_long>1) - sz += __lltostr(s+sz,sizeof(buf)-5,(unsigned long long) llnumber,base,flag_upcase); + retval = __lltostr(s+sz,sizeof(buf)-5,(unsigned long long) llnumber,base,flag_upcase); else #endif - sz += __ltostr(s+sz,sizeof(buf)-5,(unsigned long) number,base,flag_upcase); + retval = __ltostr(s+sz,sizeof(buf)-5,(unsigned long) number,base,flag_upcase); + + /* When 0 is printed with an explicit precision 0, the output is empty. */ + if (flag_dot && retval == 1 && s[sz] == '0') { + if (preci == 0||flag_hash > 0) { + sz = 0; + } + flag_hash = 0; + } else sz += retval; if (flag_in_sign==2) { *(--s)='-'; @@ -260,20 +312,28 @@ { int g=(ch=='g'); double d=va_arg(arg_ptr,double); + s=buf+1; if (width==0) width=1; if (!flag_dot) preci=6; - sz=__dtostr(d,buf,sizeof(buf),width,preci); + if (flag_sign || d < +0.0) flag_in_sign=1; + + sz=__dtostr(d,s,sizeof(buf)-1,width,preci); + if (flag_dot) { char *tmp; - if ((tmp=strchr(buf,'.'))) { - ++tmp; + if ((tmp=strchr(s,'.'))) { + if (preci || flag_hash) ++tmp; while (preci>0 && *++tmp) --preci; *tmp=0; + } else if (flag_hash) { + s[sz]='.'; + s[++sz]='\0'; } } + if (g) { char *tmp,*tmp1; /* boy, is _this_ ugly! */ - if ((tmp=strchr(buf,'.'))) { + if ((tmp=strchr(s,'.'))) { tmp1=strchr(tmp,'e'); while (*tmp) ++tmp; if (tmp1) tmp=tmp1; @@ -283,9 +343,15 @@ if (tmp1) strcpy(tmp,tmp1); } } - preci=strlen(buf); - s=buf; - + + if ((flag_sign || flag_space) && d>=0) { + *(--s)=(flag_sign)?'+':' '; + ++sz; + } + + sz=strlen(s); + flag_dot=0; + flag_hash=0; goto print_out; } #endif diff -uNr dietlibc-0.23/lib/__v_scanf.c dietlibc-0.24/lib/__v_scanf.c --- dietlibc-0.23/lib/__v_scanf.c Fri Jun 7 19:40:09 2002 +++ dietlibc-0.24/lib/__v_scanf.c Thu Oct 16 12:03:44 2003 @@ -38,7 +38,6 @@ //while ((tpch!=-1)&&(*format)) while (*format) { -// const unsigned char *prev_fmt=format; ch=*format++; switch (ch) { /* end of format string ?!? */ @@ -128,7 +127,7 @@ #else unsigned long v=0; #endif - unsigned int consumedsofar=consumed; + unsigned int consumedsofar; int neg=0; while(isspace(tpch)) tpch=A_GETC(fn); if (tpch=='-') { @@ -138,6 +137,9 @@ if (tpch=='+') tpch=A_GETC(fn); + if (tpch==-1) return n; + consumedsofar=consumed; + if (!flag_width) { if ((_div==16) && (tpch=='0')) goto scan_hex; if (!_div) { @@ -171,6 +173,9 @@ --width; tpch=A_GETC(fn); } + + if (consumedsofar==consumed) return n; + if ((ch|0x20)<'p') { #ifdef WANT_LONGLONG_SCANF register long long l=v; @@ -207,12 +212,12 @@ pi=(int *)va_arg(arg_ptr,int*); *pi=v; } - if(consumedsofar error */ while (width && (tpch!=-1) && (!isspace(tpch))) { if (!flag_discard) *s=tpch; if (tpch) ++s; else break; --width; tpch=A_GETC(fn); } - if (!flag_discard) { *s=0; n++; } + if (!flag_discard) { *s=0; ++n; } break; /* consumed-count */ case 'n': if (!flag_discard) { - s=(char *)va_arg(arg_ptr,char*); + pi=(int *)va_arg(arg_ptr,int *); // ++n; /* in accordance to ANSI C we don't count this conversion */ + *pi=consumed-1; } - if (!flag_discard) *(s++)=consumed-1; break; #ifdef WANT_CHARACTER_CLASSES_IN_SCANF @@ -382,6 +395,16 @@ break; } } + + /* maybe a "%n" follows */ + if(*format) { + while(isspace(*format)) format++; + if(format[0] == '%' && format[1] == 'n') { + pi = (int *) va_arg(arg_ptr, int *); + *pi = consumed - 1; + } + } + err_out: if (tpch<0 && n==0) return EOF; A_PUTC(tpch,fn); diff -uNr dietlibc-0.23/lib/alloc.c dietlibc-0.24/lib/alloc.c --- dietlibc-0.23/lib/alloc.c Thu Jun 26 00:45:50 2003 +++ dietlibc-0.24/lib/alloc.c Fri Nov 7 18:22:33 2003 @@ -31,7 +31,7 @@ #define NULL ((void*)0) #endif -typedef union { +typedef struct { void* next; size_t size; } __alloc_t; diff -uNr dietlibc-0.23/lib/execl.c dietlibc-0.24/lib/execl.c --- dietlibc-0.23/lib/execl.c Thu May 31 19:03:41 2001 +++ dietlibc-0.24/lib/execl.c Fri Oct 31 03:10:21 2003 @@ -5,21 +5,22 @@ #include "dietfeatures.h" int execl( const char *path,...) { - va_list ap; + va_list ap,bak; int n,i; char **argv,*tmp; va_start(ap, path); + va_copy(bak,ap); n=1; while ((tmp=va_arg(ap,char *))) ++n; va_end (ap); if ((argv=(char **)alloca(n*sizeof(char*)))) { - va_start(ap, path); for (i=0; i0) if (j==l) break; + if (i>=j) break; + swap(base,size,i,j); + if (compar(idx(base,size,i),v)==0) { ++p; swap(base,size,p,i); } + if (compar(idx(base,size,j),v)==0) { --q; swap(base,size,q,j); } + } + swap(base,size,i,r); j=i-1; ++i; + for (k=l; kq; --k,++i) swap(base,size,k,i); + if (j>l) Qsort(base,nmemb,size,l,j,compar); + if (r>i) Qsort(base,nmemb,size,i,r,compar); +} + +void qsort(void *base, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)) { + Qsort(base,nmemb,size,0,nmemb-1,compar); +} +#endif diff -uNr dietlibc-0.23/lib/sigwait.c dietlibc-0.24/lib/sigwait.c --- dietlibc-0.23/lib/sigwait.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/lib/sigwait.c Fri Oct 10 01:57:11 2003 @@ -0,0 +1,8 @@ +#include + +int sigwait(const sigset_t* set,int* sig) { + siginfo_t si; + int r=sigwaitinfo(set,&si); + if (r!=-1) *sig=si.si_signo; + return r; +} diff -uNr dietlibc-0.23/lib/strncmp.c dietlibc-0.24/lib/strncmp.c --- dietlibc-0.23/lib/strncmp.c Sat Feb 23 23:18:42 2002 +++ dietlibc-0.24/lib/strncmp.c Thu Oct 16 12:03:44 2003 @@ -4,9 +4,9 @@ /* gcc is broken and has a non-SUSv2 compliant internal prototype. * This causes it to warn about a type mismatch here. Ignore it. */ int strncmp(const char *s1, const char *s2, size_t n) { - register const char* a=s1; - register const char* b=s2; - register const char* fini=a+n; + register const unsigned char* a=s1; + register const unsigned char* b=s2; + register const unsigned char* fini=a+n; while (a -char *strtok_r(char *s, const char *delim, char **ptrptr) -{ - int i; - char *tmp=0; +char*strtok_r(char*s,const char*delim,char**ptrptr) { + char*tmp=0; - if (s) (*ptrptr)=s; - - if (**ptrptr) - { - while(!(i=strcspn(*ptrptr,delim))) (*ptrptr)++; - if (**ptrptr) - { - tmp=(*ptrptr); - (*ptrptr)+=i; - if (**ptrptr) *(*ptrptr)++=0; - } + if (s==0) s=*ptrptr; + s+=strspn(s,delim); /* overread leading delimiter */ + if (__likely(*s)) { + tmp=s; + s+=strcspn(s,delim); + if (__likely(*s)) *s++=0; /* not the end ? => terminate it */ } + *ptrptr=s; return tmp; } diff -uNr dietlibc-0.23/lib/strtol.c dietlibc-0.24/lib/strtol.c --- dietlibc-0.23/lib/strtol.c Tue Aug 14 18:56:51 2001 +++ dietlibc-0.24/lib/strtol.c Thu Oct 16 12:03:44 2003 @@ -9,11 +9,13 @@ { int neg=0; unsigned long int v; + const char*orig=nptr; while(isspace(*nptr)) nptr++; - if (*nptr == '-') { neg=-1; ++nptr; } + if (*nptr == '-' && isalnum(nptr[1])) { neg=-1; ++nptr; } v=strtoul(nptr,endptr,base); + if (endptr && *endptr==nptr) *endptr=(char *)orig; if (v>=ABS_LONG_MIN) { if (v==ABS_LONG_MIN && neg) { errno=0; diff -uNr dietlibc-0.23/lib/strtoll.c dietlibc-0.24/lib/strtoll.c --- dietlibc-0.23/lib/strtoll.c Tue Aug 14 18:56:51 2001 +++ dietlibc-0.24/lib/strtoll.c Sat Oct 18 17:48:06 2003 @@ -1,14 +1,26 @@ #include #include +#include +#include long long int strtoll(const char *nptr, char **endptr, int base) { int neg=0; unsigned long long int v; + const char*orig=nptr; while(isspace(*nptr)) nptr++; - if (*nptr == '-' && isdigit(nptr[1])) { neg=-1; nptr++; } + if (*nptr == '-' && isalnum(nptr[1])) { neg=-1; nptr++; } v=strtoull(nptr,endptr,base); + if (endptr && *endptr==nptr) *endptr=(char *)orig; + if (v>LLONG_MAX) { + if (v==0x8000000000000000ull && neg) { + errno=0; + return v; + } + errno=ERANGE; + return (neg?LLONG_MIN:LLONG_MAX); + } return (neg?-v:v); } diff -uNr dietlibc-0.23/lib/strtoul.c dietlibc-0.24/lib/strtoul.c --- dietlibc-0.23/lib/strtoul.c Tue Aug 19 19:09:58 2003 +++ dietlibc-0.24/lib/strtoul.c Thu Nov 6 13:00:09 2003 @@ -1,48 +1,57 @@ #include -#include "dietfeatures.h" +#include #include #include -#include -unsigned long int strtoul(const char *nptr, char **endptr, int base) +unsigned long int strtoul(const char *ptr, char **endptr, int base) { - int neg = 0; + int neg = 0, overflow = 0; unsigned long int v=0; const char* orig; + const char* nptr=ptr; while(isspace(*nptr)) ++nptr; + if (*nptr == '-') { neg=1; nptr++; } - if (*nptr == '+') ++nptr; + else if (*nptr == '+') ++nptr; + orig=nptr; if (base==16 && nptr[0]=='0') goto skip0x; - if (!base) { + if (base) { + register unsigned int b=base-2; + if (__unlikely(b>34)) { errno=EINVAL; return 0; } + } else { if (*nptr=='0') { base=8; skip0x: - if (nptr[1]=='x'||nptr[1]=='X') { + if ((nptr[1]=='x'||nptr[1]=='X') && isxdigit(nptr[2])) { nptr+=2; base=16; } } else base=10; } - orig=nptr; - while(*nptr) { + while(__likely(*nptr)) { register unsigned char c=*nptr; c=(c>='a'?c-'a'+10:c>='A'?c-'A'+10:c<='9'?c-'0':0xff); - if (c>=base) { - if (nptr==orig) { if (endptr) *endptr=(char*)nptr; errno=EINVAL; return ULONG_MAX; } - break; - } + if (__unlikely(c>=base)) break; /* out of base */ { - register unsigned long int w=v*base; - if (w>8)*base+(x>>8); + if (w>(ULONG_MAX>>8)) overflow=1; + v=(w<<8)+(x&0xff); } ++nptr; } + if (__unlikely(nptr==orig)) { /* no conversion done */ +err_conv: + nptr=ptr; + errno=EINVAL; + v=0; + } if (endptr) *endptr=(char *)nptr; + if (overflow) { + errno=ERANGE; + return ULONG_MAX; + } return (neg?-v:v); } diff -uNr dietlibc-0.23/lib/strtoull.c dietlibc-0.24/lib/strtoull.c --- dietlibc-0.23/lib/strtoull.c Tue Aug 19 19:34:18 2003 +++ dietlibc-0.24/lib/strtoull.c Fri Nov 14 14:25:25 2003 @@ -1,33 +1,59 @@ #include #include +#include +#include -unsigned long long int strtoull(const char *nptr, char **endptr, int base) +unsigned long long int strtoull(const char *ptr, char **endptr, int base) { + int neg = 0, overflow = 0; long long int v=0; + const char* orig; + const char* nptr=ptr; while(isspace(*nptr)) ++nptr; - if (*nptr == '+') ++nptr; - if (!base) { + if (*nptr == '-') { neg=1; nptr++; } + else if (*nptr == '+') ++nptr; + orig=nptr; + if (base==16 && nptr[0]=='0') goto skip0x; + if (base) { + register unsigned int b=base-2; + if (__unlikely(b>34)) { errno=EINVAL; return 0; } + } else { if (*nptr=='0') { base=8; - if ((*(nptr+1)=='x')||(*(nptr+1)=='X')) { +skip0x: + if (((*(nptr+1)=='x')||(*(nptr+1)=='X')) && isxdigit(nptr[2])) { nptr+=2; base=16; } - } - else + } else base=10; } while(__likely(*nptr)) { register unsigned char c=*nptr; - c=(c>='a'?c-'a'+10:c>='A'?c-'A'+10:c-'0'); - if (__unlikely(c>=base)) break; - v=v*base+c; + c=(c>='a'?c-'a'+10:c>='A'?c-'A'+10:c<='9'?c-'0':0xff); + if (__unlikely(c>=base)) break; /* out of base */ + { + register unsigned long x=(v&0xff)*base+c; + register unsigned long long w=(v>>8)*base+(x>>8); + if (w>(ULLONG_MAX>>8)) overflow=1; + v=(w<<8)+(x&0xff); + } ++nptr; } + if (__unlikely(nptr==orig)) { /* no conversion done */ +err_conv: + nptr=ptr; + errno=EINVAL; + v=0; + } if (endptr) *endptr=(char *)nptr; - return v; + if (overflow) { + errno=ERANGE; + return ULLONG_MAX; + } + return (neg?-v:v); } /* die, BSD, die!!! */ diff -uNr dietlibc-0.23/lib/sys_siglist.c dietlibc-0.24/lib/sys_siglist.c --- dietlibc-0.23/lib/sys_siglist.c Wed Sep 25 17:03:19 2002 +++ dietlibc-0.24/lib/sys_siglist.c Sat Oct 18 17:50:35 2003 @@ -1,4 +1,4 @@ -const char *const sys_siglist[] = { +const char *const __sys_siglist[] = { "Signal 0", "Hangup", "Interrupt", @@ -172,3 +172,4 @@ 0 }; +const char *const* sys_siglist=__sys_siglist; diff -uNr dietlibc-0.23/lib/vsnprintf.c dietlibc-0.24/lib/vsnprintf.c --- dietlibc-0.23/lib/vsnprintf.c Tue Jun 3 20:11:07 2003 +++ dietlibc-0.24/lib/vsnprintf.c Fri Nov 14 22:33:50 2003 @@ -26,11 +26,14 @@ } int vsnprintf(char* str, size_t size, const char *format, va_list arg_ptr) { - int n; + long n; struct str_data sd = { str, 0, size }; struct arg_printf ap = { &sd, (int(*)(void*,size_t,void*)) swrite }; if (size) --sd.size; n=__v_printf(&ap,format,arg_ptr); - if (str) str[n]=0; + if (str) { + if ((long)n>(long)size) str[size]=0; + else str[n]=0; + } return n; } diff -uNr dietlibc-0.23/libcompat/rcmd.c dietlibc-0.24/libcompat/rcmd.c --- dietlibc-0.23/libcompat/rcmd.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libcompat/rcmd.c Thu Nov 20 15:15:43 2003 @@ -0,0 +1,8 @@ +#include + +int rcmd(char **ahost, int inport, const char *locuser, + const char *remuser, const char *cmd, int *fd2p) { + __write2("for security reasons, rcmd is not supported by the diet libc.\n"); + return -1; +} + diff -uNr dietlibc-0.23/libcruft/bindtextdomain.c dietlibc-0.24/libcruft/bindtextdomain.c --- dietlibc-0.23/libcruft/bindtextdomain.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libcruft/bindtextdomain.c Fri Nov 14 22:33:50 2003 @@ -0,0 +1,11 @@ +#include +#include +#include + +static char* dir; + +char* bindtextdomain(const char* domainname,const char* dirname) { + if (dir) free(dir); + if (!(dir=strdup(dirname))) return 0; + return dir; +} diff -uNr dietlibc-0.23/libcruft/dcgettext.c dietlibc-0.24/libcruft/dcgettext.c --- dietlibc-0.23/libcruft/dcgettext.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libcruft/dcgettext.c Tue Nov 4 18:16:38 2003 @@ -0,0 +1,5 @@ +#include + +char* dcgettext(const char *domainname, const char *msgid, int category) { + return (char*)msgid; +} diff -uNr dietlibc-0.23/libcruft/dgettext.c dietlibc-0.24/libcruft/dgettext.c --- dietlibc-0.23/libcruft/dgettext.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libcruft/dgettext.c Tue Nov 4 18:16:43 2003 @@ -0,0 +1,4 @@ +#include + +#undef dgettext +char* dgettext(const char* domainname, const char* x) { return (char*)x; } diff -uNr dietlibc-0.23/libcruft/dnscruft.c dietlibc-0.24/libcruft/dnscruft.c --- dietlibc-0.23/libcruft/dnscruft.c Fri Mar 14 22:48:56 2003 +++ dietlibc-0.24/libcruft/dnscruft.c Sat Sep 20 00:53:33 2003 @@ -90,10 +90,6 @@ int len; if (_res.nscount>0) return; { - struct sockaddr_in to; -#ifdef WANT_IPV6_DNS - struct sockaddr_in6 to6; -#endif char *cacheip=getenv("DNSCACHEIP"); #ifdef WANT_FULL_RESOLV_CONF __dns_search=0; diff -uNr dietlibc-0.23/libcruft/gettext.c dietlibc-0.24/libcruft/gettext.c --- dietlibc-0.23/libcruft/gettext.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libcruft/gettext.c Tue Nov 4 18:16:46 2003 @@ -0,0 +1,4 @@ +#include + +#undef gettext +char* gettext(const char* msg) { return (char*)msg; } diff -uNr dietlibc-0.23/libcruft/res_query.c dietlibc-0.24/libcruft/res_query.c --- dietlibc-0.23/libcruft/res_query.c Mon May 19 19:14:51 2003 +++ dietlibc-0.24/libcruft/res_query.c Sat Sep 20 02:05:00 2003 @@ -10,6 +10,7 @@ #include #include #include +#include #include "dietfeatures.h" extern void __dns_make_fd(void); @@ -34,11 +35,40 @@ { int i; /* current server */ int j; /* timeout count down */ - struct pollfd duh; struct timeval last,now; +#ifdef WANT_IPV6_PLUGPLAY_DNS + static int pnpfd=-1; + static struct sockaddr_in6 pnpsa; + struct pollfd duh[2]; + + if (pnpfd<0) { + pnpfd=socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP); + if (pnpfd>=0) fcntl(pnpfd,F_SETFD,FD_CLOEXEC); + } + memset(&pnpsa,0,sizeof(pnpsa)); + pnpsa.sin6_family=AF_INET6; + if (pnpfd!=-1) bind(pnpfd,(struct sockaddr*)&pnpsa,sizeof(pnpsa)); + pnpsa.sin6_port=htons(53); + memmove(&pnpsa.sin6_addr,"\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00dnspnp",16); + + duh[1].events=POLLIN; + duh[1].fd=pnpfd; + + if (strchr(dname,'.')) { + duh[1].fd=-1; + duh[1].revents=0; + } +#else + struct pollfd duh[1]; +#endif i=0; - duh.events=POLLIN; + duh[0].events=POLLIN; last.tv_sec=0; +#ifdef WANT_IPV6_PLUGPLAY_DNS + if (duh[1].fd!=-1) + sendto(pnpfd,packet,size,0,(struct sockaddr*)(&pnpsa),sizeof(struct sockaddr_in6)); + /* if it doesn't work, we don't care */ +#endif for (j=120; j>0; --j) { gettimeofday(&now,0); if (now.tv_sec-last.tv_sec>10) { @@ -52,25 +82,58 @@ __dns_make_fd(); tmpfd=__dns_fd; } - duh.fd=tmpfd; +#ifdef WANT_IPV6_PLUGPLAY_DNS + if (duh[0].fd!=-1) { +#endif + duh[0].fd=tmpfd; if (sendto(tmpfd,packet,size,0,s,sizeof(struct sockaddr_in6))==0) gettimeofday(&last,0); +#ifdef WANT_IPV6_PLUGPLAY_DNS + } +#endif #else - duh.fd=__dns_fd; + duh[0].fd=__dns_fd; if (sendto(__dns_fd,packet,size,0,(struct sockaddr*)&(_res.nsaddr_list[i]),sizeof(struct sockaddr))==0) gettimeofday(&last,0); #endif last=now; } if (++i >= _res.nscount) i=0; - if (poll(&duh,1,1000) == 1) { +#ifdef WANT_IPV6_PLUGPLAY_DNS + if (duh[0].fd==-1 && duh[1].fd==-1) goto nxdomain; + duh[0].revents=0; + if (poll(duh[0].fd==-1?duh+1:duh,duh[0].fd==-1?1:2,1000) > 0) { +#else + if (poll(duh,1,1000) == 1) { +#endif /* read and parse answer */ unsigned char inpkg[1500]; - int len=read(duh.fd,inpkg,1500); +#ifdef WANT_IPV6_PLUGPLAY_DNS + int len; + len=read(duh[0].revents&POLLIN?duh[0].fd:duh[1].fd,inpkg,1500); +#else + int len=read(duh[0].fd,inpkg,1500); +#endif /* header, question, answer, authority, additional */ if (inpkg[0]!=packet[0] || inpkg[1]!=packet[1]) continue; /* wrong ID */ if ((inpkg[2]&0xf9) != (_res.options&RES_RECURSE?0x81:0x80)) continue; /* not answer */ - if ((inpkg[3]&0x0f) != 0) { h_errno=HOST_NOT_FOUND; return -1; } /* error */ + if ((inpkg[3]&0x0f) != 0) { +#ifdef WANT_IPV6_PLUGPLAY_DNS +/* if the normal DNS server says NXDOMAIN, still give the multicast method some time */ + if (duh[0].revents&POLLIN) { + duh[0].fd=-1; + if (duh[1].fd!=-1) { + if (j>10) j=10; + continue; + } + } else + continue; +/* ignore NXDOMAIN from the multicast socket */ +nxdomain: +#endif + h_errno=HOST_NOT_FOUND; + return -1; + } /* error */ if (len>anslen) { h_errno=NO_RECOVERY; return -1; diff -uNr dietlibc-0.23/libcruft/scandir.c dietlibc-0.24/libcruft/scandir.c --- dietlibc-0.23/libcruft/scandir.c Fri Mar 22 13:28:17 2002 +++ dietlibc-0.24/libcruft/scandir.c Mon Nov 3 14:18:44 2003 @@ -25,6 +25,8 @@ return -1; } memccpy(tmp[num-1]->d_name,D->d_name,0,NAME_MAX); + tmp[num-1]->d_off=D->d_off; + tmp[num-1]->d_reclen=D->d_reclen; *namelist=tmp; /* printf("%p; tmp[num-1(%d)]=%p\n",*namelist,num-1,tmp[num-1]); */ } diff -uNr dietlibc-0.23/libcruft/scandir64.c dietlibc-0.24/libcruft/scandir64.c --- dietlibc-0.23/libcruft/scandir64.c Wed Feb 5 19:29:27 2003 +++ dietlibc-0.24/libcruft/scandir64.c Mon Nov 3 14:18:31 2003 @@ -25,6 +25,9 @@ return -1; } memccpy(tmp[num-1]->d_name,D->d_name,0,NAME_MAX); + tmp[num-1]->d_off=D->d_off; + tmp[num-1]->d_reclen=D->d_reclen; + tmp[num-1]->d_type=D->d_type; *namelist=tmp; /* printf("%p; tmp[num-1(%d)]=%p\n",*namelist,num-1,tmp[num-1]); */ } diff -uNr dietlibc-0.23/libcruft/setlocale.c dietlibc-0.24/libcruft/setlocale.c --- dietlibc-0.23/libcruft/setlocale.c Wed Jan 16 14:21:43 2002 +++ dietlibc-0.24/libcruft/setlocale.c Wed Oct 8 01:44:25 2003 @@ -2,6 +2,6 @@ char *setlocale (int category, const char *locale) { (void)category; - (void)locale; - return 0; + if (locale) return 0; + return "C"; } diff -uNr dietlibc-0.23/libcruft/strerror_r.c dietlibc-0.24/libcruft/strerror_r.c --- dietlibc-0.23/libcruft/strerror_r.c Fri Sep 5 22:13:57 2003 +++ dietlibc-0.24/libcruft/strerror_r.c Fri Oct 24 17:21:40 2003 @@ -2,10 +2,6 @@ extern const char __sys_err_unknown[]; -/* This function is _really_ useless, since strerror does not have a - * static buffer or possibly conflicting data manipulations that could - * be optimized away with this function. What a crook. Why oh why - * doesn't susv3 define gethostbyname_r but does define this crap? */ int strerror_r(int errnum, char *buf, size_t n) { const char* x=strerror(errnum); if (x==__sys_err_unknown || n<1) return -1; diff -uNr dietlibc-0.23/libcruft/textdomain.c dietlibc-0.24/libcruft/textdomain.c --- dietlibc-0.23/libcruft/textdomain.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libcruft/textdomain.c Fri Nov 14 14:51:01 2003 @@ -0,0 +1,11 @@ +#include +#include +#include + +static char* dom; + +char* textdomain(const char* domainname) { + if (dom) free(dom); + if (!(dom=strdup(domainname))) return 0; + return dom; +} diff -uNr dietlibc-0.23/liblatin1/latin1-isgraph.c dietlibc-0.24/liblatin1/latin1-isgraph.c --- dietlibc-0.23/liblatin1/latin1-isgraph.c Mon Jan 21 16:30:19 2002 +++ dietlibc-0.24/liblatin1/latin1-isgraph.c Wed Sep 17 02:20:17 2003 @@ -2,6 +2,6 @@ int isgraph(int x) { unsigned char c=x&0xff; - return (c>=33 && c<=126) || (c>=161 && c<=255); + return (c>=33 && c<=126) || c>=161; } diff -uNr dietlibc-0.23/liblatin1/latin1-islower.c dietlibc-0.24/liblatin1/latin1-islower.c --- dietlibc-0.23/liblatin1/latin1-islower.c Mon Jan 21 16:30:19 2002 +++ dietlibc-0.24/liblatin1/latin1-islower.c Wed Sep 17 02:20:17 2003 @@ -2,5 +2,5 @@ int islower(int c) { unsigned char x=c&0xff; - return (x>='a' && x<='z') || (x>=223 && x<=255 && x!=247); + return (x>='a' && x<='z') || (x>=223 && x!=247); } diff -uNr dietlibc-0.23/libm/pow.c dietlibc-0.24/libm/pow.c --- dietlibc-0.23/libm/pow.c Mon Nov 18 02:16:51 2002 +++ dietlibc-0.24/libm/pow.c Fri Oct 10 15:15:08 2003 @@ -38,5 +38,5 @@ } /* normal case */ - return exp2 ( log2 (mant) * expo ); + return exp ( log (mant) * expo ); } diff -uNr dietlibc-0.23/libpthread/CHANGES dietlibc-0.24/libpthread/CHANGES --- dietlibc-0.23/libpthread/CHANGES Tue Aug 19 15:05:31 2003 +++ dietlibc-0.24/libpthread/CHANGES Thu Sep 18 15:10:39 2003 @@ -1,6 +1,17 @@ This is the pthread implementation of dietlibc. Written from scratch by Olaf Dreesen. +Wed Sep 17 17:03:57 CEST 2003 + + - add the semaphore support. (changed the internals of the manager a + little for this.) + - fixed pthread_create so that it does not change the global thread + cancel-type on error. + +Mon Aug 18 17:32:52 CEST 2003 + + checkin. + Mon Aug 18 17:27:57 CEST 2003 more preparations for checkin Binary files dietlibc-0.23/libpthread/__testandset.o and dietlibc-0.24/libpthread/__testandset.o differ Binary files dietlibc-0.23/libpthread/libpthread.a and dietlibc-0.24/libpthread/libpthread.a differ Binary files dietlibc-0.23/libpthread/pthread_atfork.o and dietlibc-0.24/libpthread/pthread_atfork.o differ Binary files dietlibc-0.23/libpthread/pthread_attr_getdetachstate.o and dietlibc-0.24/libpthread/pthread_attr_getdetachstate.o differ Binary files dietlibc-0.23/libpthread/pthread_attr_getinheritsched.o and dietlibc-0.24/libpthread/pthread_attr_getinheritsched.o differ Binary files dietlibc-0.23/libpthread/pthread_attr_getschedparam.o and dietlibc-0.24/libpthread/pthread_attr_getschedparam.o differ Binary files dietlibc-0.23/libpthread/pthread_attr_getschedpolicy.o and dietlibc-0.24/libpthread/pthread_attr_getschedpolicy.o differ Binary files dietlibc-0.23/libpthread/pthread_attr_getscope.o and dietlibc-0.24/libpthread/pthread_attr_getscope.o differ Binary files dietlibc-0.23/libpthread/pthread_attr_getstackaddr.o and dietlibc-0.24/libpthread/pthread_attr_getstackaddr.o differ Binary files dietlibc-0.23/libpthread/pthread_attr_getstacksize.o and dietlibc-0.24/libpthread/pthread_attr_getstacksize.o differ Binary files dietlibc-0.23/libpthread/pthread_attr_setdetachstate.o and dietlibc-0.24/libpthread/pthread_attr_setdetachstate.o differ Binary files dietlibc-0.23/libpthread/pthread_attr_setinheritsched.o and dietlibc-0.24/libpthread/pthread_attr_setinheritsched.o differ Binary files dietlibc-0.23/libpthread/pthread_attr_setschedparam.o and dietlibc-0.24/libpthread/pthread_attr_setschedparam.o differ Binary files dietlibc-0.23/libpthread/pthread_attr_setschedpolicy.o and dietlibc-0.24/libpthread/pthread_attr_setschedpolicy.o differ Binary files dietlibc-0.23/libpthread/pthread_attr_setscope.o and dietlibc-0.24/libpthread/pthread_attr_setscope.o differ Binary files dietlibc-0.23/libpthread/pthread_attr_setstackaddr.o and dietlibc-0.24/libpthread/pthread_attr_setstackaddr.o differ Binary files dietlibc-0.23/libpthread/pthread_attr_setstacksize.o and dietlibc-0.24/libpthread/pthread_attr_setstacksize.o differ Binary files dietlibc-0.23/libpthread/pthread_cleanup.o and dietlibc-0.24/libpthread/pthread_cleanup.o differ Binary files dietlibc-0.23/libpthread/pthread_cond_broadcast.o and dietlibc-0.24/libpthread/pthread_cond_broadcast.o differ Binary files dietlibc-0.23/libpthread/pthread_cond_destroy.o and dietlibc-0.24/libpthread/pthread_cond_destroy.o differ Binary files dietlibc-0.23/libpthread/pthread_cond_init.o and dietlibc-0.24/libpthread/pthread_cond_init.o differ Binary files dietlibc-0.23/libpthread/pthread_cond_signal.o and dietlibc-0.24/libpthread/pthread_cond_signal.o differ Binary files dietlibc-0.23/libpthread/pthread_cond_timedwait.o and dietlibc-0.24/libpthread/pthread_cond_timedwait.o differ Binary files dietlibc-0.23/libpthread/pthread_cond_wait.o and dietlibc-0.24/libpthread/pthread_cond_wait.o differ Binary files dietlibc-0.23/libpthread/pthread_condattr_getshared.o and dietlibc-0.24/libpthread/pthread_condattr_getshared.o differ Binary files dietlibc-0.23/libpthread/pthread_condattr_setshared.o and dietlibc-0.24/libpthread/pthread_condattr_setshared.o differ diff -uNr dietlibc-0.23/libpthread/pthread_create.c dietlibc-0.24/libpthread/pthread_create.c --- dietlibc-0.23/libpthread/pthread_create.c Tue Aug 19 15:05:31 2003 +++ dietlibc-0.24/libpthread/pthread_create.c Thu Sep 18 15:10:39 2003 @@ -43,7 +43,10 @@ if ((stack=attr.__stackaddr)==0) { /* YES we need PROT_EXEC for signal-handling :( */ if ((st=stack=(char*)mmap(0,attr.__stacksize,PROT_READ|PROT_WRITE|PROT_EXEC,MAP_PRIVATE|MAP_ANONYMOUS,-1,0))==MAP_FAILED) - return EINVAL; + { + ret=EINVAL; + goto func_out; + } } stb=stack; #ifdef __parisc__ @@ -63,11 +66,10 @@ request.attr = &attr; request.td = td; request.tr = this; - //request.stack = stack; if (attr.__inheritsched==PTHREAD_INHERIT_SCHED) { if ((ret=__thread_getschedparam(request.tr->pid,&attr.__schedpolicy,&attr.__schedparam))!=0) - return ret; + goto func_out; } td->lock.__spinlock = PTHREAD_SPIN_UNLOCKED; td->joined.__spinlock = PTHREAD_SPIN_UNLOCKED; @@ -78,13 +80,18 @@ td->func = start_routine; td->arg = arg; - /* lett the "child thread" inherit the procmask (hope this works) */ + /* let the "child thread" inherit the procmask (hope this works) */ sigprocmask(SIG_SETMASK,0,&(td->thread_sig_mask)); sigaddset(&(td->thread_sig_mask),PTHREAD_SIG_RESTART); sigdelset(&(td->thread_sig_mask),PTHREAD_SIG_CANCEL); - if ((ret=__thread_start_new(&request))==-1) return EAGAIN; + if ((ret=__thread_start_new(&request))==-1) { + ret=EAGAIN; + goto func_out; + } *thread=ret; + ret^=ret; +func_out: __NO_ASYNC_CANCEL_END_(this); - return 0; + return ret; } Binary files dietlibc-0.23/libpthread/pthread_create.o and dietlibc-0.24/libpthread/pthread_create.o differ Binary files dietlibc-0.23/libpthread/pthread_detach.o and dietlibc-0.24/libpthread/pthread_detach.o differ Binary files dietlibc-0.23/libpthread/pthread_dns_cruft.o and dietlibc-0.24/libpthread/pthread_dns_cruft.o differ Binary files dietlibc-0.23/libpthread/pthread_equal.o and dietlibc-0.24/libpthread/pthread_equal.o differ Binary files dietlibc-0.23/libpthread/pthread_errno.o and dietlibc-0.24/libpthread/pthread_errno.o differ diff -uNr dietlibc-0.23/libpthread/pthread_fdglue2.c dietlibc-0.24/libpthread/pthread_fdglue2.c --- dietlibc-0.23/libpthread/pthread_fdglue2.c Tue Aug 19 15:05:31 2003 +++ dietlibc-0.24/libpthread/pthread_fdglue2.c Wed Sep 17 02:20:17 2003 @@ -7,11 +7,11 @@ #include extern int __stdio_atexit; -extern FILE* __stdio_init_file_nothreads(int fd,int closeonerror); +extern FILE* __stdio_init_file_nothreads(int fd,int closeonerror,int mode); -FILE* __stdio_init_file(int fd,int closeonerror) { +FILE* __stdio_init_file(int fd,int closeonerror,int mode) { pthread_mutexattr_t attr={PTHREAD_MUTEX_RECURSIVE_NP}; - FILE *tmp=__stdio_init_file_nothreads(fd,closeonerror); + FILE *tmp=__stdio_init_file_nothreads(fd,closeonerror,mode); if (tmp) pthread_mutex_init(&tmp->m,&attr); return tmp; } Binary files dietlibc-0.23/libpthread/pthread_fdglue2.o and dietlibc-0.24/libpthread/pthread_fdglue2.o differ diff -uNr dietlibc-0.23/libpthread/pthread_fflush.c dietlibc-0.24/libpthread/pthread_fflush.c --- dietlibc-0.23/libpthread/pthread_fflush.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libpthread/pthread_fflush.c Tue Nov 4 17:43:21 2003 @@ -0,0 +1,9 @@ +#include + +int fflush(FILE *stream) { + int tmp; + if (stream) pthread_mutex_lock(&stream->m); + tmp=fflush_unlocked(stream); + if (stream) pthread_mutex_unlock(&stream->m); + return tmp; +} Binary files dietlibc-0.23/libpthread/pthread_fgetc.o and dietlibc-0.24/libpthread/pthread_fgetc.o differ Binary files dietlibc-0.23/libpthread/pthread_flockfile.o and dietlibc-0.24/libpthread/pthread_flockfile.o differ Binary files dietlibc-0.23/libpthread/pthread_fputc.o and dietlibc-0.24/libpthread/pthread_fputc.o differ Binary files dietlibc-0.23/libpthread/pthread_funlockfile.o and dietlibc-0.24/libpthread/pthread_funlockfile.o differ diff -uNr dietlibc-0.23/libpthread/pthread_internal.c dietlibc-0.24/libpthread/pthread_internal.c --- dietlibc-0.23/libpthread/pthread_internal.c Fri Sep 12 16:04:10 2003 +++ dietlibc-0.24/libpthread/pthread_internal.c Tue Nov 4 17:06:58 2003 @@ -185,7 +185,7 @@ * cleanup / remove zombie thread * this is entered with "td" not in the list of threads and UNLOCKED !!! */ -int __thread_cleanup(_pthread_descr td) { +static int __thread_cleanup(_pthread_descr td) { int cnt=0; do { ++cnt; /* the next operations are only to make sure any thread_self that still uses "td" will go away */ @@ -232,10 +232,10 @@ this->p_sig=0; sigprocmask(SIG_SETMASK,0,&mask); sigdelset(&mask,PTHREAD_SIG_RESTART); - do { + while (this->p_sig!=PTHREAD_SIG_RESTART) { if (cancel && (this->cancelstate==PTHREAD_CANCEL_ENABLE) && this->canceled) break; sigsuspend(&mask); - } while (this->p_sig!=PTHREAD_SIG_RESTART); + } } /* restart a thread */ @@ -421,6 +421,29 @@ manager_thread=0; } +static void __MGR_thread_start_new(_thread_descr data) { + _pthread_descr td=data->td; + pthread_attr_t*attr=data->attr; + if ((td->pid=(*(data->pid))=__clone(__managed_start,attr->__stackaddr,CLONE_FLAGS,td))!=-1) { + sched_setscheduler(td->pid,attr->__schedpolicy,&attr->__schedparam); + __thread_add_list(td); + __thread_restart(td); /* let the thread loose */ + } +#ifdef DEBUG + printf("__MGR_thread_start_new: created thread %d\n",td->pid); +#endif + __thread_restart(data->tr); /* restart request sender */ +} + +static void __MGR_thread_join_cleanup(_pthread_descr td) { +#ifdef DEBUG + printf("__MGR_thread_join_cleanup: wind up red-tape for thread %d\n",td->pid); +#endif + __thread_del_list(td); + UNLOCK(td); + __thread_cleanup(td); +} + /* manager thread */ static char __manager_thread_stack[PTHREAD_STACK_SIZE]; __attribute__((noreturn)) @@ -457,19 +480,12 @@ _exit(0); } if (n==1) { - struct __thread_descr data; + __thread_manager_func data; if (INTR_RETRY(__libc_read(mgr_recv_fd,&data,sizeof(data)))==sizeof(data)) { - pthread_attr_t*attr=data.attr; - td=data.td; - if ((td->pid=(*data.pid)=__clone(__managed_start,data.attr->__stackaddr,CLONE_FLAGS,td))!=-1) { - sched_setscheduler(td->pid,attr->__schedpolicy,&attr->__schedparam); - __thread_add_list(td); - __thread_restart(td); /* let the thread loose */ - } #ifdef DEBUG - printf("__manager_thread: created thread %d\n",td->pid); + printf("__manager_thread: do func %08x %08x\n",data.func,data.arg); #endif - __thread_restart(data.tr); /* restart request sender */ + data.func(data.arg); } } while ((n=__libc_waitpid(-1,&status,WNOHANG|__WCLONE))!=-1) { @@ -485,7 +501,11 @@ #endif /* Oh, oohhhhhh.... */ sched_yield(); +#ifdef DEBUG + kill_all_threads(SIGKILL,1); +#else kill_all_threads(WTERMSIG(status),1); +#endif sched_yield(); __thread_sleep(); kill_all_threads(SIGKILL,1); @@ -496,10 +516,13 @@ #ifdef DEBUG printf("__manager_thread: thread %d is dead\n",n); #endif - __thread_del_list(td); - td->canceled|=2; - if (__testandset(&td->joined.__spinlock)) __thread_restart(td->jt); - else __thread_cleanup(td); + if (td->detached) __MGR_thread_join_cleanup(td); + else { + td->canceled|=2; + td->dead=1; + UNLOCK(td); + if (td->joined.__spinlock==PTHREAD_SPIN_LOCKED) __thread_restart(td->jt); + } } } } @@ -601,13 +624,21 @@ } } +/* send the manager a function and an argument to run */ +static int __MGR_send(void(*f)(void*),void*arg) { + __thread_manager_func data={ .func=f, .arg=arg, }; + __pthread_once(&__thread_started,__thread_init); + return INTR_RETRY(__libc_write(mgr_send_fd,&data,sizeof(data))); +} +int __thread_send_manager(void(*f)(void*),void*arg) __attribute__((alias("__MGR_send"))); + /* start a new thread */ int __thread_start_new(_thread_descr data) { int pid; - __pthread_once(&__thread_started,__thread_init); data->pid=&pid; - if (INTR_RETRY(__libc_write(mgr_send_fd,data,sizeof(*data)))==-1) { + + if (__MGR_send((MGR_func)__MGR_thread_start_new,data)==-1) { __thread_cleanup(data->tr); return -1; } @@ -615,5 +646,9 @@ return pid; } +int __thread_join_cleanup(_pthread_descr td) { + return __MGR_send((MGR_func)__MGR_thread_join_cleanup,td)==0; +} + //int __G_E_T() { return sizeof(struct _pthread_descr_struct); } Binary files dietlibc-0.23/libpthread/pthread_internal.o and dietlibc-0.24/libpthread/pthread_internal.o differ diff -uNr dietlibc-0.23/libpthread/pthread_join.c dietlibc-0.24/libpthread/pthread_join.c --- dietlibc-0.23/libpthread/pthread_join.c Tue Aug 19 15:05:31 2003 +++ dietlibc-0.24/libpthread/pthread_join.c Wed Oct 8 01:44:25 2003 @@ -8,22 +8,22 @@ int pthread_join(pthread_t th,void**thread_return) { int ret=ESRCH; _pthread_descr td,this=__thread_self(); - if (th==getpid()) return EDEADLK; + if (th==this->pid) return EDEADLK; __NO_ASYNC_CANCEL_BEGIN_(this); if ((td=__thread_find(th))) { /* test if detached or joined */ - if (td->canceled || td->detached || __testandset(&(td->joined.__spinlock))) { + if (td->detached || __testandset(&(td->joined.__spinlock))) { UNLOCK(td); ret=EINVAL; } else { td->jt=this; UNLOCK(td); - /* wait for thread to exit */ - __thread_suspend(this,0); + /* if not allready canceled / wait for thread to exit */ + if (!(td->dead)) __thread_suspend(this,0); if (thread_return) *thread_return=td->retval; /* clean up the mess */ - ret=__thread_cleanup(td); + ret=__thread_join_cleanup(td); } } __NO_ASYNC_CANCEL_END_(this); Binary files dietlibc-0.23/libpthread/pthread_join.o and dietlibc-0.24/libpthread/pthread_join.o differ diff -uNr dietlibc-0.23/libpthread/pthread_key.c dietlibc-0.24/libpthread/pthread_key.c --- dietlibc-0.23/libpthread/pthread_key.c Tue Aug 19 15:05:31 2003 +++ dietlibc-0.24/libpthread/pthread_key.c Wed Oct 8 01:44:25 2003 @@ -18,13 +18,13 @@ } void __thread_exit__key(_pthread_descr th) { - int i,try; + int i; void (*dstr)(const void*); for (i=0;itkd[i]&&(trytkd[i]); + const void*data=th->tkd[i]; + if (data) dstr(data); } } } Binary files dietlibc-0.23/libpthread/pthread_key.o and dietlibc-0.24/libpthread/pthread_key.o differ Binary files dietlibc-0.23/libpthread/pthread_kill.o and dietlibc-0.24/libpthread/pthread_kill.o differ Binary files dietlibc-0.23/libpthread/pthread_mutex_destroy.o and dietlibc-0.24/libpthread/pthread_mutex_destroy.o differ Binary files dietlibc-0.23/libpthread/pthread_mutex_init.o and dietlibc-0.24/libpthread/pthread_mutex_init.o differ diff -uNr dietlibc-0.23/libpthread/pthread_mutex_lock.c dietlibc-0.24/libpthread/pthread_mutex_lock.c --- dietlibc-0.23/libpthread/pthread_mutex_lock.c Tue Aug 19 15:05:31 2003 +++ dietlibc-0.24/libpthread/pthread_mutex_lock.c Tue Nov 11 18:35:04 2003 @@ -7,8 +7,7 @@ /* will never return EINVAL ! */ -int pthread_mutex_lock(pthread_mutex_t*mutex) { - _pthread_descr this=__thread_self(); +static int __thread_mutex_lock(pthread_mutex_t*mutex,_pthread_descr this) { if (mutex->owner!=this) { /* wait for mutex to free */ LOCK(mutex); @@ -19,3 +18,9 @@ if (mutex->kind==PTHREAD_MUTEX_RECURSIVE_NP) ++(mutex->count); return 0; } +int __pthread_mutex_lock(pthread_mutex_t*mutex,_pthread_descr this) +__attribute__((alias("__thread_mutex_lock"))); + +int pthread_mutex_lock(pthread_mutex_t*mutex) { + return __thread_mutex_lock(mutex,__thread_self()); +} Binary files dietlibc-0.23/libpthread/pthread_mutex_lock.o and dietlibc-0.24/libpthread/pthread_mutex_lock.o differ Binary files dietlibc-0.23/libpthread/pthread_mutex_trylock.o and dietlibc-0.24/libpthread/pthread_mutex_trylock.o differ diff -uNr dietlibc-0.23/libpthread/pthread_mutex_unlock.c dietlibc-0.24/libpthread/pthread_mutex_unlock.c --- dietlibc-0.23/libpthread/pthread_mutex_unlock.c Tue Aug 19 15:05:31 2003 +++ dietlibc-0.24/libpthread/pthread_mutex_unlock.c Tue Nov 11 18:35:04 2003 @@ -7,8 +7,7 @@ /* will never return EINVAL ! */ -int pthread_mutex_unlock(pthread_mutex_t*mutex) { - _pthread_descr this=__thread_self(); +static int __thread_mutex_unlock(pthread_mutex_t*mutex,_pthread_descr this) { if (mutex->owner==this) { if (mutex->kind==PTHREAD_MUTEX_RECURSIVE_NP) { if (--(mutex->count)) return 0; @@ -21,3 +20,9 @@ } return 0; } +int __pthread_mutex_unlock(pthread_mutex_t*mutex,_pthread_descr this) +__attribute__((alias("__thread_mutex_unlock"))); + +int pthread_mutex_unlock(pthread_mutex_t*mutex) { + return __thread_mutex_unlock(mutex,__thread_self()); +} Binary files dietlibc-0.23/libpthread/pthread_mutex_unlock.o and dietlibc-0.24/libpthread/pthread_mutex_unlock.o differ Binary files dietlibc-0.23/libpthread/pthread_mutexattr_getkind_np.o and dietlibc-0.24/libpthread/pthread_mutexattr_getkind_np.o differ Binary files dietlibc-0.23/libpthread/pthread_mutexattr_init.o and dietlibc-0.24/libpthread/pthread_mutexattr_init.o differ Binary files dietlibc-0.23/libpthread/pthread_mutexattr_setkind_np.o and dietlibc-0.24/libpthread/pthread_mutexattr_setkind_np.o differ Binary files dietlibc-0.23/libpthread/pthread_self.o and dietlibc-0.24/libpthread/pthread_self.o differ diff -uNr dietlibc-0.23/libpthread/pthread_semaphore_destroy.c dietlibc-0.24/libpthread/pthread_semaphore_destroy.c --- dietlibc-0.23/libpthread/pthread_semaphore_destroy.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libpthread/pthread_semaphore_destroy.c Wed Sep 17 17:06:10 2003 @@ -0,0 +1,15 @@ +#include +#include +#include + +#include +#include "thread_internal.h" + +int sem_destroy(sem_t*sem) { + int n; + if (sem->magic!=SEM_MAGIC) { _errno_=EINVAL; return -1; } + if ((n=pthread_cond_destroy(&sem->cond))) { _errno_=n; return -1; } + sem->magic=0; + return 0; +} + Binary files dietlibc-0.23/libpthread/pthread_semaphore_destroy.o and dietlibc-0.24/libpthread/pthread_semaphore_destroy.o differ diff -uNr dietlibc-0.23/libpthread/pthread_semaphore_getvalue.c dietlibc-0.24/libpthread/pthread_semaphore_getvalue.c --- dietlibc-0.23/libpthread/pthread_semaphore_getvalue.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libpthread/pthread_semaphore_getvalue.c Wed Sep 17 17:06:10 2003 @@ -0,0 +1,13 @@ +#include +#include +#include + +#include +#include "thread_internal.h" + +int sem_getvalue(sem_t*sem,int*sval) { + if (sem->magic!=SEM_MAGIC) { _errno_=EINVAL; return -1; } + *sval=sem->value; + return 0; +} + Binary files dietlibc-0.23/libpthread/pthread_semaphore_getvalue.o and dietlibc-0.24/libpthread/pthread_semaphore_getvalue.o differ diff -uNr dietlibc-0.23/libpthread/pthread_semaphore_init.c dietlibc-0.24/libpthread/pthread_semaphore_init.c --- dietlibc-0.23/libpthread/pthread_semaphore_init.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libpthread/pthread_semaphore_init.c Wed Sep 17 17:06:10 2003 @@ -0,0 +1,20 @@ +#include +#include +#include + +#include +#include "thread_internal.h" + +int sem_init(sem_t*sem,int pshared,unsigned int value) { + pthread_mutexattr_t attr={PTHREAD_MUTEX_RECURSIVE_NP}; + + if (value>SEM_VALUE_MAX) { _errno_=EINVAL; return -1; } + if (pshared) { _errno_=ENOSYS; return -1; } + + pthread_mutex_init(&(sem->lock),&attr); + pthread_cond_init(&(sem->cond),0); + sem->value=value; + sem->magic=SEM_MAGIC; + return 0; +} + Binary files dietlibc-0.23/libpthread/pthread_semaphore_init.o and dietlibc-0.24/libpthread/pthread_semaphore_init.o differ diff -uNr dietlibc-0.23/libpthread/pthread_semaphore_misc.c dietlibc-0.24/libpthread/pthread_semaphore_misc.c --- dietlibc-0.23/libpthread/pthread_semaphore_misc.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libpthread/pthread_semaphore_misc.c Wed Sep 17 17:06:10 2003 @@ -0,0 +1,19 @@ +#include +#include +#include + +#include +#include "thread_internal.h" + +sem_t*sem_open(const char*name,int oflag,...) { + if (0) { name=0; oflag=0; } + _errno_=ENOSYS; + return 0; +} +int sem_close(sem_t*sem) { + if (0) sem=0; + _errno_=ENOSYS; + return -1; +} +int sem_unlink(const char *name) __attribute__((alias("sem_close"))); + Binary files dietlibc-0.23/libpthread/pthread_semaphore_misc.o and dietlibc-0.24/libpthread/pthread_semaphore_misc.o differ diff -uNr dietlibc-0.23/libpthread/pthread_semaphore_post.c dietlibc-0.24/libpthread/pthread_semaphore_post.c --- dietlibc-0.23/libpthread/pthread_semaphore_post.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libpthread/pthread_semaphore_post.c Wed Sep 17 17:06:10 2003 @@ -0,0 +1,45 @@ +#include +#include + +#include +#include "thread_internal.h" + +/* ThreadManager Function / NO_ASYNC_CANCEL + * this is a pthread_cond_signal + semaphore handling */ + +/* FIXME: is the pthread_mutex_lock(&sem->lock); and unlock needed ? */ +static int __MGR_sem_post(sem_t*sem) { + int ret=0; + if (sem->value==0) { + pthread_cond_t*cond=&sem->cond; + LOCK(cond); + if (cond->wait_chain) __thread_restart(cond->wait_chain); + UNLOCK(cond); + } + if (sem->valuevalue++; + else { _errno_=ERANGE; ret=-1; } + return ret; +} + +int sem_post(sem_t*sem) { + int ret=0; + _pthread_descr this; + + if (sem->magic!=SEM_MAGIC) { _errno_=EINVAL; return -1; } + + this=__thread_self(); + __NO_ASYNC_CANCEL_BEGIN_(this); + + if ((ret=pthread_mutex_lock(&sem->lock))) { _errno_=ret; ret=-1; } + else if (sem->lock.count>1) { + /* ok... we are in a semaphor handling and a signal handler. + * now we want to send a post... let the manager do this for us :) */ + __thread_send_manager((MGR_func)__MGR_sem_post,sem); + } + else ret=__MGR_sem_post(sem); + pthread_mutex_unlock(&sem->lock); + + __NO_ASYNC_CANCEL_END_(this); + + return ret; +} Binary files dietlibc-0.23/libpthread/pthread_semaphore_post.o and dietlibc-0.24/libpthread/pthread_semaphore_post.o differ diff -uNr dietlibc-0.23/libpthread/pthread_semaphore_trywait.c dietlibc-0.24/libpthread/pthread_semaphore_trywait.c --- dietlibc-0.23/libpthread/pthread_semaphore_trywait.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libpthread/pthread_semaphore_trywait.c Wed Sep 17 17:06:10 2003 @@ -0,0 +1,30 @@ +#include +#include +#include + +#include +#include "thread_internal.h" + +int sem_trywait(sem_t*sem) { + int ret; + _pthread_descr this; + + if (sem->magic!=SEM_MAGIC) { _errno_=EINVAL; return -1; } + + this=__thread_self(); + __NO_ASYNC_CANCEL_BEGIN_(this); + + if ((ret=pthread_mutex_lock(&(sem->lock)))) { _errno_=ret; ret=-1; } + else if (sem->value==0) { + _errno_=EAGAIN; + ret=-1; + } else { + sem->value--; + ret=0; + } + pthread_mutex_unlock(&(sem->lock)); + + __NO_ASYNC_CANCEL_END_(this); + + return ret; +} Binary files dietlibc-0.23/libpthread/pthread_semaphore_trywait.o and dietlibc-0.24/libpthread/pthread_semaphore_trywait.o differ diff -uNr dietlibc-0.23/libpthread/pthread_semaphore_wait.c dietlibc-0.24/libpthread/pthread_semaphore_wait.c --- dietlibc-0.23/libpthread/pthread_semaphore_wait.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libpthread/pthread_semaphore_wait.c Wed Sep 17 17:06:10 2003 @@ -0,0 +1,27 @@ +#include +#include +#include + +#include +#include "thread_internal.h" + +int sem_wait(sem_t*sem) { + int ret=0; + _pthread_descr this; + + if (sem->magic!=SEM_MAGIC) { _errno_=EINVAL; return -1; } + + this=__thread_self(); + __NO_ASYNC_CANCEL_BEGIN_(this); + + if ((ret=pthread_mutex_lock(&sem->lock))) { _errno_=ret; ret=-1; } + else { + while (sem->value==0) { pthread_cond_wait(&sem->cond,&sem->lock); } + sem->value--; + } + pthread_mutex_unlock(&sem->lock); + + __NO_ASYNC_CANCEL_END_(this); + + return ret; +} Binary files dietlibc-0.23/libpthread/pthread_semaphore_wait.o and dietlibc-0.24/libpthread/pthread_semaphore_wait.o differ Binary files dietlibc-0.23/libpthread/pthread_setcancelstate.o and dietlibc-0.24/libpthread/pthread_setcancelstate.o differ Binary files dietlibc-0.23/libpthread/pthread_setschedparam.o and dietlibc-0.24/libpthread/pthread_setschedparam.o differ Binary files dietlibc-0.23/libpthread/pthread_sigaction.o and dietlibc-0.24/libpthread/pthread_sigaction.o differ Binary files dietlibc-0.23/libpthread/pthread_sigmask.o and dietlibc-0.24/libpthread/pthread_sigmask.o differ Binary files dietlibc-0.23/libpthread/pthread_spinlock.o and dietlibc-0.24/libpthread/pthread_spinlock.o differ diff -uNr dietlibc-0.23/libpthread/pthread_sys_alloc.c dietlibc-0.24/libpthread/pthread_sys_alloc.c --- dietlibc-0.23/libpthread/pthread_sys_alloc.c Tue Aug 19 15:05:31 2003 +++ dietlibc-0.24/libpthread/pthread_sys_alloc.c Tue Nov 11 18:35:04 2003 @@ -10,9 +10,9 @@ void free(void *ptr) { _pthread_descr this=__thread_self(); __NO_ASYNC_CANCEL_BEGIN_(this); - pthread_mutex_lock(&mutex_alloc); + __pthread_mutex_lock(&mutex_alloc,this); __libc_free(ptr); - pthread_mutex_unlock(&mutex_alloc); + __pthread_mutex_unlock(&mutex_alloc,this); __NO_ASYNC_CANCEL_END_(this); } @@ -20,9 +20,9 @@ _pthread_descr this=__thread_self(); register void *ret; __NO_ASYNC_CANCEL_BEGIN_(this); - pthread_mutex_lock(&mutex_alloc); + __pthread_mutex_lock(&mutex_alloc,this); ret=__libc_malloc(size); - pthread_mutex_unlock(&mutex_alloc); + __pthread_mutex_unlock(&mutex_alloc,this); __NO_ASYNC_CANCEL_END_(this); return ret; } @@ -31,9 +31,9 @@ _pthread_descr this=__thread_self(); register void *ret; __NO_ASYNC_CANCEL_BEGIN_(this); - pthread_mutex_lock(&mutex_alloc); + __pthread_mutex_lock(&mutex_alloc,this); ret=__libc_realloc(ptr, size); - pthread_mutex_unlock(&mutex_alloc); + __pthread_mutex_unlock(&mutex_alloc,this); __NO_ASYNC_CANCEL_END_(this); return ret; } Binary files dietlibc-0.23/libpthread/pthread_sys_alloc.o and dietlibc-0.24/libpthread/pthread_sys_alloc.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_close.o and dietlibc-0.24/libpthread/pthread_sys_close.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_create.o and dietlibc-0.24/libpthread/pthread_sys_create.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_fcntl.o and dietlibc-0.24/libpthread/pthread_sys_fcntl.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_fdatasync.o and dietlibc-0.24/libpthread/pthread_sys_fdatasync.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_fsync.o and dietlibc-0.24/libpthread/pthread_sys_fsync.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_logging.o and dietlibc-0.24/libpthread/pthread_sys_logging.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_msync.o and dietlibc-0.24/libpthread/pthread_sys_msync.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_nanosleep.o and dietlibc-0.24/libpthread/pthread_sys_nanosleep.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_open.o and dietlibc-0.24/libpthread/pthread_sys_open.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_pause.o and dietlibc-0.24/libpthread/pthread_sys_pause.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_read.o and dietlibc-0.24/libpthread/pthread_sys_read.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_sigsuspend.o and dietlibc-0.24/libpthread/pthread_sys_sigsuspend.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_sleep.o and dietlibc-0.24/libpthread/pthread_sys_sleep.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_tcdrain.o and dietlibc-0.24/libpthread/pthread_sys_tcdrain.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_waitpid.o and dietlibc-0.24/libpthread/pthread_sys_waitpid.o differ Binary files dietlibc-0.23/libpthread/pthread_sys_write.o and dietlibc-0.24/libpthread/pthread_sys_write.o differ diff -uNr dietlibc-0.23/libpthread/test-basic.c dietlibc-0.24/libpthread/test-basic.c --- dietlibc-0.23/libpthread/test-basic.c Mon Aug 18 19:32:53 2003 +++ dietlibc-0.24/libpthread/test-basic.c Wed Oct 8 01:44:25 2003 @@ -20,9 +20,7 @@ const char foo[16]="0123456789abcdef"; char buf[sizeof(long)<<1]; int i; - for (i=sizeof(buf);i--;v>>=4) { - buf[i]=foo[v&15]; - } + for (i=sizeof(buf);i--;v>>=4) { buf[i]=foo[v&15]; } write(1,buf,sizeof(buf)); } #endif @@ -170,18 +168,10 @@ void test_thread() { pthread_t t; - pr("testing basic thread creation... "); + pr("testing basic thread creation and join... "); if ((pthread_create(&t,0,thread,0))!=0) _die_("failed...\n"); if (kill(t,0)==-1) _die_("failed... no thread cloned"); - sleep(2); - pr("OK.\n"); -} - -void test_thread_join() { - pthread_t t; - pr("testing join thread... "); - if ((pthread_create(&t,0,thread,0))!=0) _die_("failed...\n"); - pthread_join(t,0); + if (pthread_join(t,0) != 0) _die_("failed... joining thread\n"); pr("OK.\n"); } @@ -215,7 +205,6 @@ void test2() { pr("\nTEST 2: thread creation & attributes:\n\n"); test_thread(); - test_thread_join(); test_thread_join_detached(); test_thread_alt_stack(); } @@ -295,6 +284,9 @@ if (kill(t1,0)==0) _die_("failed... thread (nr. 1) ignored signal\n"); if (kill(t2,0)==0) _die_("failed... thread (nr. 2) ignored signal\n"); if (kill(t3,0)==0) _die_("failed... thread (nr. 3) ignored signal\n"); + if (pthread_join(t1,0) != 0) _die_("failed... joining thread\n"); + if (pthread_join(t2,0) != 0) _die_("failed... joining thread\n"); + if (pthread_join(t3,0) != 0) _die_("failed... joining thread\n"); pr("OK.\n"); } @@ -311,9 +303,12 @@ pr(" "); pthread_cond_broadcast(&test_cond); sleep(3); - if (pthread_join(t1,0)==0) _die_("failed... thread (nr. 1) ignored signal\n"); - if (pthread_join(t2,0)==0) _die_("failed... thread (nr. 2) ignored signal\n"); - if (pthread_join(t3,0)==0) _die_("failed... thread (nr. 3) ignored signal\n"); + if (kill(t1,0)==0) _die_("failed... thread (nr. 1) ignored signal\n"); + if (kill(t2,0)==0) _die_("failed... thread (nr. 2) ignored signal\n"); + if (kill(t3,0)==0) _die_("failed... thread (nr. 3) ignored signal\n"); + if (pthread_join(t1,0) != 0) _die_("failed... joining thread\n"); + if (pthread_join(t2,0) != 0) _die_("failed... joining thread\n"); + if (pthread_join(t3,0) != 0) _die_("failed... joining thread\n"); alarm(0); pr("OK.\n"); } @@ -347,9 +342,12 @@ pthread_mutex_lock(&test_cond_exit_mutex); pthread_cond_broadcast(&test_cond); sleep(2); - if (pthread_join(t1,0)==0) _die_("failed... thread (nr. 1) ignored signal\n"); - if (pthread_join(t2,0)==0) _die_("failed... thread (nr. 2) ignored signal\n"); - if (pthread_join(t3,0)==0) _die_("failed... thread (nr. 3) ignored signal\n"); + if (kill(t1,0)==0) _die_("failed... thread (nr. 1) ignored signal\n"); + if (kill(t2,0)==0) _die_("failed... thread (nr. 2) ignored signal\n"); + if (kill(t3,0)==0) _die_("failed... thread (nr. 3) ignored signal\n"); + if (pthread_join(t1,0) != 0) _die_("failed... joining thread\n"); + if (pthread_join(t2,0) != 0) _die_("failed... joining thread\n"); + if (pthread_join(t3,0) != 0) _die_("failed... joining thread\n"); alarm(0); pr("OK.\n"); } @@ -365,7 +363,6 @@ /* (4) cancelation & cleanup tests */ void*thread_exit() { - sleep(1); pthread_exit((void*)42); return 0; } @@ -376,8 +373,8 @@ pr("testing pthread_exit... "); if ((pthread_create(&t,0,thread_exit,0))!=0) _die_("failed... creating thread\n"); if (pthread_join(t,&retval) != 0) _die_("failed... joining thread\n"); - if (retval!=(void*)42) _die_("failed... join retval\n"); if (kill(t,0)!=-1) _die_("failed... thread exit\n"); + if (retval!=(void*)42) _die_("failed... join retval\n"); pr("OK.\n"); } @@ -398,7 +395,7 @@ pthread_t t1; pr("testing the cleanup stack... "); if ((pthread_create(&t1,0,thread_cancel,(void*)0))!=0) _die_("failed... (creating a thread)\n"); - pthread_join(t1,0); + if (pthread_join(t1,0) != 0) _die_("failed... joining thread\n"); if (thread_cleanuptest_data==0) _die_("failed... no call to cleanup\n"); pr("OK.\n"); } @@ -417,11 +414,11 @@ pr("testing cancelation and cleanup stack (takes 3-4 seconds)... "); if ((pthread_create(&t1,0,thread_cancel,(void*)1))!=0) _die_("failed... (creating a thread)\n"); if ((pthread_create(&t2,0,thread_canceler,(void*)&t1))!=0) _die_("failed... (creating a thread)\n"); - pthread_join(t1,0); - pthread_join(t2,0); + if (pthread_join(t1,0) != 0) _die_("failed... joining thread\n"); + if (pthread_join(t2,0) != 0) _die_("failed... joining thread\n"); if (thread_cleanuptest_data==0) _die_("failed... no call to cleanup\n"); - sleep(1); /* give the kernel time to shred the zombie */ if (kill(t1,0)!=-1) _die_("failed... thread cancelation\n"); + if (kill(t2,0)!=-1) _die_("failed... thread cancelation\n"); pr("OK.\n"); } @@ -443,11 +440,11 @@ pr("testing async cancelation and cleanup stack (takes 5-6 seconds)... "); if ((pthread_create(&t1,0,thread_cancel_async,(void*)1))!=0) _die_("failed... (creating a thread)\n"); if ((pthread_create(&t2,0,thread_canceler,(void*)&t1))!=0) _die_("failed... (creating a thread)\n"); - pthread_join(t1,0); - pthread_join(t2,0); + if (pthread_join(t1,0) != 0) _die_("failed... joining thread\n"); + if (pthread_join(t2,0) != 0) _die_("failed... joining thread\n"); if (thread_cleanuptest_data==0) _die_("failed... no call to cleanup\n"); - sleep(1); /* give the kernel time to shred the zombie */ if (kill(t1,0)!=-1) _die_("failed... thread cancelation\n"); + if (kill(t2,0)!=-1) _die_("failed... thread cancelation\n"); pr("OK.\n"); } @@ -485,7 +482,7 @@ test5_signaled=0; pr("IN A THREAD... "); if ((pthread_create(&t1,0,test5_0,0))!=0) _die_("failed... (creating a thread)\n"); - pthread_join(t1,0); + if (pthread_join(t1,0) != 0) _die_("failed... joining thread\n"); } void*test5_sig_send(void*arg) { @@ -501,7 +498,7 @@ pr("sending the main program a signal from a thread while joined... "); signal(SIGUSR1,test5_sighandler); if ((pthread_create(&t1,0,test5_sig_send,(void*)getpid()))!=0) _die_("failed... (creating a thread)\n"); - pthread_join(t1,0); + if (pthread_join(t1,0) != 0) _die_("failed... joining thread\n"); if (test5_signaled==0) _die_("failed to hold...\n"); pr("OK.\n"); } @@ -525,14 +522,17 @@ } void test6() { - pthread_t t1; + pthread_t t1,t2,t3,t4; pr("\nTEST 6: thread calls 'exit(42)' :\n\n"); pr("creating thread that will call exit: "); if ((pthread_create(&t1,0,thread_cancel_async,(void*)0))!=0) _die_("failed... (creating a thread)\n"); - if ((pthread_create(&t1,0,thread_cancel_async,(void*)0))!=0) _die_("failed... (creating a thread)\n"); - if ((pthread_create(&t1,0,thread_cancel_async,(void*)0))!=0) _die_("failed... (creating a thread)\n"); - if ((pthread_create(&t1,0,test6_libc_exit,0))!=0) _die_("failed... (creating a thread)\n"); - pthread_join(t1,0); + if ((pthread_create(&t2,0,thread_cancel_async,(void*)0))!=0) _die_("failed... (creating a thread)\n"); + if ((pthread_create(&t3,0,thread_cancel_async,(void*)0))!=0) _die_("failed... (creating a thread)\n"); + if ((pthread_create(&t4,0,test6_libc_exit,0))!=0) _die_("failed... (creating a thread)\n"); + if (pthread_join(t1,0) != 0) _die_("failed... joining thread\n"); + if (pthread_join(t2,0) != 0) _die_("failed... joining thread\n"); + if (pthread_join(t3,0) != 0) _die_("failed... joining thread\n"); + if (pthread_join(t4,0) != 0) _die_("failed... joining thread\n"); for (t1=0;t1<4;++t1) { sleep(2); pr("still hanging....\n"); @@ -612,7 +612,7 @@ pthread_t t1; pr("IN A THREAD... "); if ((pthread_create(&t1,0,test8_1,0))!=0) _die_("failed... (creating a thread)\n"); - pthread_join(t1,0); + if (pthread_join(t1,0) != 0) _die_("failed... joining thread\n"); } void test8() { @@ -642,7 +642,7 @@ void test9_1_0() { pthread_t t1; if ((pthread_create(&t1,0,test9_0_0,0))!=0) _die_("failed... (creating a thread)\n"); - pthread_join(t1,0); + if (pthread_join(t1,0) != 0) _die_("failed... joining thread\n"); pr("???\n"); } diff -uNr dietlibc-0.23/libpthread/test-threads_many.c dietlibc-0.24/libpthread/test-threads_many.c --- dietlibc-0.23/libpthread/test-threads_many.c Mon Aug 18 19:32:53 2003 +++ dietlibc-0.24/libpthread/test-threads_many.c Wed Oct 8 01:44:25 2003 @@ -30,8 +30,6 @@ } else { __gen_thread(nr+1); - pthread_cancel(t); -// usleep(10); } } diff -uNr dietlibc-0.23/libpthread/thread_internal.h dietlibc-0.24/libpthread/thread_internal.h --- dietlibc-0.23/libpthread/thread_internal.h Fri Sep 12 16:04:10 2003 +++ dietlibc-0.24/libpthread/thread_internal.h Tue Nov 11 18:35:04 2003 @@ -60,6 +60,7 @@ volatile unsigned char canceltype; /* type of cancellation */ /* thread flags */ + volatile char dead; /* thread has terminated */ volatile char canceled; /* thread canceled */ char detached; /* thread is detached */ char stack_free; /* stack is allocated by pthread_create */ @@ -111,6 +112,9 @@ #define TRYLOCK(td) __pthread_trylock(&((td)->lock)) #define UNLOCK(td) __pthread_unlock(&((td)->lock)) +int __pthread_mutex_lock(pthread_mutex_t*mutex,_pthread_descr this); +int __pthread_mutex_unlock(pthread_mutex_t*mutex,_pthread_descr this); + int __clone(void*(*fn)(void*),void*stack,int flags,void*arg); void __thread_manager_close(void); @@ -118,7 +122,7 @@ struct _pthread_descr_struct*__thread_find(pthread_t pid); int __thread_join(struct _pthread_descr_struct*td,void**return_value); -int __thread_cleanup(struct _pthread_descr_struct*td); +int __thread_join_cleanup(struct _pthread_descr_struct*td); void __thread_restart(struct _pthread_descr_struct*td); void __thread_suspend(struct _pthread_descr_struct*td,int cancel); @@ -138,6 +142,14 @@ #define __TEST_CANCEL() pthread_testcancel() /* manager thread stuff */ +typedef void(*MGR_func)(void*); +typedef struct __thread_manager_func { + void(*func)(void*); + void*arg; +} __thread_manager_func; + +int __thread_send_manager(void(*f)(void*),void*arg); + typedef struct __thread_descr { struct _pthread_descr_struct*tr; /* thread sending the request */ struct _pthread_descr_struct*td; /* new thread descriptor */ diff -uNr dietlibc-0.23/librpc/clnt_tcp.c dietlibc-0.24/librpc/clnt_tcp.c --- dietlibc-0.23/librpc/clnt_tcp.c Tue Aug 19 21:28:58 2003 +++ dietlibc-0.24/librpc/clnt_tcp.c Wed Sep 17 02:20:17 2003 @@ -412,10 +412,12 @@ #endif /* def FD_SETSIZE */ while (TRUE) { + struct timeval tmp; + tmp=ct->ct_wait; readfds = mask; switch (select (_rpc_dtablesize(), &readfds, 0, 0, - &(ct->ct_wait))) { + &tmp)) { case 0: ct->ct_error.re_status = RPC_TIMEDOUT; return (-1); diff -uNr dietlibc-0.23/librpc/clnt_udp.c dietlibc-0.24/librpc/clnt_udp.c --- dietlibc-0.23/librpc/clnt_udp.c Tue Aug 19 21:28:58 2003 +++ dietlibc-0.24/librpc/clnt_udp.c Sat Sep 13 00:29:11 2003 @@ -224,6 +224,7 @@ register XDR *xdrs; register int outlen; register int inlen; + struct timeval singlewait; int fromlen; #ifdef FD_SETSIZE @@ -292,7 +293,8 @@ #endif /* def FD_SETSIZE */ for (;;) { readfds = mask; - switch (select(_rpc_dtablesize(), &readfds, 0, 0, &(cu->cu_wait))) { + singlewait = cu->cu_wait; + switch (select(_rpc_dtablesize(), &readfds, 0, 0, &singlewait)) { case 0: time_waited.tv_sec += cu->cu_wait.tv_sec; diff -uNr dietlibc-0.23/librpc/pmap_rmt.c dietlibc-0.24/librpc/pmap_rmt.c --- dietlibc-0.23/librpc/pmap_rmt.c Fri Oct 5 02:26:12 2001 +++ dietlibc-0.24/librpc/pmap_rmt.c Wed Sep 17 02:20:17 2003 @@ -315,6 +315,7 @@ * The response timeout grows larger per iteration. */ for (t.tv_sec = 4; t.tv_sec <= 14; t.tv_sec += 2) { + struct timeval tmp; for (i = 0; i < nets; i++) { baddr.sin_addr = addrs[i]; if (sendto(sock, outbuf, (size_t)outlen, 0, @@ -334,7 +335,8 @@ msg.acpted_rply.ar_results.where = (char*) & r; msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_rmtcallres; readfds = mask; - switch (select(_rpc_dtablesize(), &readfds, 0, 0, &t)) { + tmp=t; + switch (select(_rpc_dtablesize(), &readfds, 0, 0, &tmp)) { case 0: /* timed out */ stat = RPC_TIMEDOUT; diff -uNr dietlibc-0.23/librpc/svc_tcp.c dietlibc-0.24/librpc/svc_tcp.c --- dietlibc-0.23/librpc/svc_tcp.c Tue Aug 19 21:28:58 2003 +++ dietlibc-0.24/librpc/svc_tcp.c Wed Sep 17 02:20:17 2003 @@ -302,8 +302,10 @@ int readfds; #endif /* def FD_SETSIZE */ do { + struct timeval tmp; readfds = mask; - if (select(_rpc_dtablesize(), &readfds, 0, 0, &wait_per_try) <= 0) { + tmp=wait_per_try; + if (select(_rpc_dtablesize(), &readfds, 0, 0, &tmp) <= 0) { if (errno == EINTR) { continue; } diff -uNr dietlibc-0.23/libshell/realpath.c dietlibc-0.24/libshell/realpath.c --- dietlibc-0.23/libshell/realpath.c Tue Oct 22 15:37:04 2002 +++ dietlibc-0.24/libshell/realpath.c Fri Oct 10 15:37:12 2003 @@ -5,27 +5,72 @@ #include #include "dietfeatures.h" -char* realpath(const char *path, char *resolved_path) { - int fd=open(".",O_RDONLY); - char* tmp=(char*)""; - if (fd<0) return 0; - if (chdir(path)) { - if (errno==ENOTDIR) { - char* match; - if ((match=strrchr(path,'/'))) { - tmp=match; - memmove(resolved_path,path,tmp-path); - resolved_path[tmp-path]=0; - if (chdir(resolved_path)) { resolved_path=0; goto abort; } - } - } else { - resolved_path=0; goto abort; - } - } - if (!getcwd(resolved_path,PATH_MAX)) { resolved_path=0; goto abort; } - strcat(resolved_path,tmp); -abort: - fchdir(fd); - close(fd); - return resolved_path; +static char *sep(char *path) +{ + char *tmp, c; + + tmp = strrchr(path, '/'); + if(tmp) { + c = tmp[1]; + tmp[1] = 0; + if (chdir(path)) { + return NULL; + } + tmp[1] = c; + + return tmp + 1; + } + + return path; + +} + +char *realpath(const char *_path, char *resolved_path) +{ + int fd = open(".", O_RDONLY), l; + char path[PATH_MAX], lnk[PATH_MAX], *tmp = (char *)""; + + if (fd < 0) { + return NULL; + } + strncpy(path, _path, PATH_MAX); + + if (chdir(path)) { + if (errno == ENOTDIR) { + l = readlink(path, lnk, PATH_MAX); + if (!(tmp = sep(path))) { + resolved_path = NULL; + goto abort; + } + if (l < 0) { + if (errno != EINVAL) { + resolved_path = NULL; + goto abort; + } + } else { + lnk[l] = 0; + if (!(tmp = sep(lnk))) { + resolved_path = NULL; + goto abort; + } + } + } else { + resolved_path = NULL; + goto abort; + } + } + if (!getcwd(resolved_path, PATH_MAX)) { + resolved_path = NULL; + goto abort; + } + + if(strcmp(resolved_path, "/") && *tmp) { + strcat(resolved_path, "/"); + } + + strcat(resolved_path, tmp); + abort: + fchdir(fd); + close(fd); + return resolved_path; } diff -uNr dietlibc-0.23/libstdio/clearerr.c dietlibc-0.24/libstdio/clearerr.c --- dietlibc-0.23/libstdio/clearerr.c Tue Feb 13 02:11:36 2001 +++ dietlibc-0.24/libstdio/clearerr.c Tue Nov 4 17:34:57 2003 @@ -1,5 +1,7 @@ #include "dietstdio.h" -void clearerr( FILE *stream) { +void clearerr_unlocked(FILE *stream) { stream->flags&=~(ERRORINDICATOR|EOFINDICATOR); } + +void clearerr(FILE *stream) __attribute__((weak,alias("clearerr_unlocked"))); diff -uNr dietlibc-0.23/libstdio/fclose.c dietlibc-0.24/libstdio/fclose.c --- dietlibc-0.23/libstdio/fclose.c Thu Jul 26 18:08:11 2001 +++ dietlibc-0.24/libstdio/fclose.c Fri Nov 14 13:57:49 2003 @@ -2,11 +2,11 @@ #include #include -int fclose(FILE *stream) { +int fclose_unlocked(FILE *stream) { int res; FILE *f,*fl; - fflush(stream); - res=close(stream->fd); + res=fflush_unlocked(stream); + res|=__libc_close(stream->fd); for (fl=0,f=__stdio_root; f; fl=f,f=f->next) if (f==stream) { if (fl) @@ -20,3 +20,5 @@ free(stream); return res; } + +int fclose(FILE *stream) __attribute__((weak,alias("fclose_unlocked"))); diff -uNr dietlibc-0.23/libstdio/fdglue2.c dietlibc-0.24/libstdio/fdglue2.c --- dietlibc-0.23/libstdio/fdglue2.c Wed Dec 4 19:32:33 2002 +++ dietlibc-0.24/libstdio/fdglue2.c Tue Nov 11 18:35:04 2003 @@ -8,15 +8,14 @@ extern int __stdio_atexit; -FILE* __stdio_init_file_nothreads(int fd,int closeonerror); -FILE* __stdio_init_file_nothreads(int fd,int closeonerror) { +FILE*__stdio_init_file(int fd,int closeonerror,int mode) { FILE *tmp=(FILE*)malloc(sizeof(FILE)); if (!tmp) goto err_out; tmp->buf=(char*)malloc(BUFSIZE); if (!tmp->buf) { free(tmp); err_out: - if (closeonerror) close(fd); + if (closeonerror) __libc_close(fd); errno=ENOMEM; return 0; } @@ -29,6 +28,11 @@ fstat(fd,&st); tmp->flags=(S_ISFIFO(st.st_mode))?FDPIPE:0; } + switch (mode&3) { + case O_RDWR: tmp->flags|=CANWRITE; + case O_RDONLY: tmp->flags|=CANREAD; break; + case O_WRONLY: tmp->flags|=CANWRITE; + } tmp->popen_kludge=0; if (__stdio_atexit==0) { __stdio_atexit=1; @@ -39,5 +43,3 @@ tmp->ungotten=0; return tmp; } - -FILE* __stdio_init_file(int fd,int closeonerror) __attribute__((weak,alias("__stdio_init_file_nothreads"))); diff -uNr dietlibc-0.23/libstdio/fdopen.c dietlibc-0.24/libstdio/fdopen.c --- dietlibc-0.23/libstdio/fdopen.c Sat Feb 9 01:45:18 2002 +++ dietlibc-0.24/libstdio/fdopen.c Tue Nov 4 17:39:37 2003 @@ -4,10 +4,12 @@ #include #include -FILE *fdopen(int filedes, const char *mode) { +FILE *fdopen_unlocked(int filedes, const char *mode) { int f=0; /* O_RDONLY, O_WRONLY or O_RDWR */ f=__stdio_parse_mode(mode); if (filedes<0) { errno=EBADF; return 0; } - return __stdio_init_file(filedes,0); + return __stdio_init_file(filedes,0,f); } + +FILE *fdopen(int filedes, const char *mode) __attribute__((weak,alias("fdopen_unlocked"))); diff -uNr dietlibc-0.23/libstdio/feof.c dietlibc-0.24/libstdio/feof.c --- dietlibc-0.23/libstdio/feof.c Mon Jul 9 16:09:42 2001 +++ dietlibc-0.24/libstdio/feof.c Tue Nov 11 18:35:04 2003 @@ -1,7 +1,9 @@ #include -int feof(FILE *stream) { +int feof_unlocked(FILE*stream) { /* yuck!!! */ if (stream->ungotten) return 0; return (stream->flags&EOFINDICATOR); } +int feof(FILE*stream) +__attribute__((weak,alias("feof_unlocked"))); diff -uNr dietlibc-0.23/libstdio/ferror.c dietlibc-0.24/libstdio/ferror.c --- dietlibc-0.23/libstdio/ferror.c Tue Jan 30 16:01:19 2001 +++ dietlibc-0.24/libstdio/ferror.c Tue Nov 11 18:35:04 2003 @@ -1,5 +1,7 @@ #include -int ferror(FILE *stream) { +int ferror_unlocked(FILE*stream) { return (stream->flags&ERRORINDICATOR); } +int ferror(FILE*stream) +__attribute__((weak,alias("ferror_unlocked"))); diff -uNr dietlibc-0.23/libstdio/fflush.c dietlibc-0.24/libstdio/fflush.c --- dietlibc-0.23/libstdio/fflush.c Thu Feb 13 20:41:31 2003 +++ dietlibc-0.24/libstdio/fflush.c Tue Nov 4 18:00:24 2003 @@ -7,11 +7,13 @@ int __stdio_atexit=0; +int fflush(FILE *stream) __attribute__((weak,alias("fflush_unlocked"))); + void __stdio_flushall(void) { fflush(0); } -int fflush(FILE *stream) { +int fflush_unlocked(FILE *stream) { if (stream==0) { int res; FILE *f; @@ -46,7 +48,7 @@ atexit(__stdio_flushall); } if ((stream->flags&BUFINPUT)!=next) { - int res=fflush(stream); + int res=fflush_unlocked(stream); stream->flags=(stream->flags&~BUFINPUT)|next; return res; } diff -uNr dietlibc-0.23/libstdio/fgetc_unlocked.c dietlibc-0.24/libstdio/fgetc_unlocked.c --- dietlibc-0.23/libstdio/fgetc_unlocked.c Tue Aug 14 18:56:51 2001 +++ dietlibc-0.24/libstdio/fgetc_unlocked.c Tue Nov 11 18:35:04 2003 @@ -3,19 +3,21 @@ int fgetc_unlocked(FILE *stream) { unsigned char c; + if (!(stream->flags&CANREAD)) goto kaputt; if (stream->ungotten) { stream->ungotten=0; return stream->ungetbuf; } - if (feof(stream)) + if (feof_unlocked(stream)) return EOF; if (__fflush4(stream,BUFINPUT)) return EOF; if (stream->bm>=stream->bs) { - int len=read(stream->fd,stream->buf,stream->buflen); + int len=__libc_read(stream->fd,stream->buf,stream->buflen); if (len==0) { stream->flags|=EOFINDICATOR; return EOF; } else if (len<0) { +kaputt: stream->flags|=ERRORINDICATOR; return EOF; } diff -uNr dietlibc-0.23/libstdio/fgets.c dietlibc-0.24/libstdio/fgets.c --- dietlibc-0.23/libstdio/fgets.c Tue Aug 14 18:56:51 2001 +++ dietlibc-0.24/libstdio/fgets.c Fri Nov 14 13:57:49 2003 @@ -1,18 +1,20 @@ #include "dietstdio.h" -char *fgets(char *s, int size, FILE *stream) { +char *fgets_unlocked(char *s, int size, FILE *stream) { char *orig=s; int l; for (l=size; l>1;) { - int c=fgetc(stream); + register int c=fgetc_unlocked(stream); if (c==EOF) break; *s=c; ++s; --l; if (c=='\n') break; } - if (l==size || ferror(stream)) + if (l==size || ferror_unlocked(stream)) return 0; *s=0; return orig; } + +char*fgets(char*s,int size,FILE*stream) __attribute__((weak,alias("fgets_unlocked"))); diff -uNr dietlibc-0.23/libstdio/fileno.c dietlibc-0.24/libstdio/fileno.c --- dietlibc-0.23/libstdio/fileno.c Tue Jan 30 16:01:19 2001 +++ dietlibc-0.24/libstdio/fileno.c Tue Nov 11 18:35:04 2003 @@ -1,5 +1,7 @@ #include -int fileno(FILE *stream) { +int fileno_unlocked(FILE*stream) { return stream->fd; } +int fileno(FILE*stream) +__attribute__((weak,alias("fileno_unlocked"))); diff -uNr dietlibc-0.23/libstdio/fopen.c dietlibc-0.24/libstdio/fopen.c --- dietlibc-0.23/libstdio/fopen.c Sat Feb 9 01:45:18 2002 +++ dietlibc-0.24/libstdio/fopen.c Tue Nov 11 18:35:04 2003 @@ -4,12 +4,17 @@ extern int __stdio_atexit; -FILE *fopen (const char *path, const char *mode) { +/* this is needed so the libpthread wrapper can initialize the mutex, + * not to lock it */ + +FILE *fopen_unlocked(const char *path, const char *mode) { int f=0; /* O_RDONLY, O_WRONLY or O_RDWR */ int fd; f=__stdio_parse_mode(mode); - if ((fd=open(path,f,0666))<0) + if ((fd=__libc_open(path,f,0666))<0) return 0; - return __stdio_init_file(fd,1); + return __stdio_init_file(fd,1,f); } + +FILE *fopen(const char *path, const char *mode) __attribute__((weak,alias("fopen_unlocked"))); diff -uNr dietlibc-0.23/libstdio/fputc_unlocked.c dietlibc-0.24/libstdio/fputc_unlocked.c --- dietlibc-0.23/libstdio/fputc_unlocked.c Fri Sep 12 14:21:53 2003 +++ dietlibc-0.24/libstdio/fputc_unlocked.c Tue Nov 11 18:35:04 2003 @@ -3,18 +3,18 @@ #include int fputc_unlocked(int c, FILE *stream) { - if (__fflush4(stream,0)) { + if (!(stream->flags&CANWRITE) || __fflush4(stream,0)) { kaputt: stream->flags|=ERRORINDICATOR; return EOF; } if (stream->bm>=stream->buflen-1) - if (fflush(stream)) goto kaputt; + if (fflush_unlocked(stream)) goto kaputt; if (stream->flags&NOBUF) { #if __BYTE_ORDER == __LITTLE_ENDIAN - if (write(stream->fd,&c,1) != 1) + if (__libc_write(stream->fd,&c,1) != 1) #else - if (write(stream->fd,(char*)&c+sizeof(c)-1,1) != 1) + if (__libc_write(stream->fd,(char*)&c+sizeof(c)-1,1) != 1) #endif goto kaputt; return 0; @@ -23,7 +23,7 @@ ++stream->bm; if (((stream->flags&BUFLINEWISE) && c=='\n') || ((stream->flags&NOBUF))) /* puke */ - if (fflush(stream)) goto kaputt; + if (fflush_unlocked(stream)) goto kaputt; return 0; } diff -uNr dietlibc-0.23/libstdio/fputs.c dietlibc-0.24/libstdio/fputs.c --- dietlibc-0.23/libstdio/fputs.c Tue Jan 30 16:01:19 2001 +++ dietlibc-0.24/libstdio/fputs.c Fri Nov 14 13:57:49 2003 @@ -1,6 +1,8 @@ #include "dietstdio.h" #include -int fputs(const char *s, FILE *stream) { - return fwrite(s,strlen(s),1,stream); +int fputs_unlocked(const char*s,FILE*stream) { + return fwrite_unlocked(s,strlen(s),1,stream); } + +int fputs(const char*s,FILE*stream) __attribute__((weak,alias("fputs_unlocked"))); diff -uNr dietlibc-0.23/libstdio/fread.c dietlibc-0.24/libstdio/fread.c --- dietlibc-0.23/libstdio/fread.c Wed Dec 4 19:32:33 2002 +++ dietlibc-0.24/libstdio/fread.c Fri Nov 14 14:48:50 2003 @@ -2,12 +2,16 @@ #include "dietstdio.h" #include -size_t fread( void *ptr, size_t size, size_t nmemb, FILE *stream) { +size_t fread_unlocked(void *ptr, size_t size, size_t nmemb, FILE *stream) { int res; unsigned long i,j; j=size*nmemb; i=0; + if (!(stream->flags&CANREAD)) { + stream->flags|=ERRORINDICATOR; + return 0; + } if (!j || j/nmemb!=size) return 0; if (stream->ungotten) { stream->ungotten=0; @@ -20,8 +24,8 @@ if ( !(stream->flags&FDPIPE) && (j>stream->buflen)) { size_t tmp=j-i; int res; - fflush(stream); - while ((res=read(stream->fd,ptr+i,tmp))<(int)tmp) { + if (fflush_unlocked(stream)) return 0; + while ((res=__libc_read(stream->fd,ptr+i,tmp))<(int)tmp) { if (res==-1) { stream->flags|=ERRORINDICATOR; goto exit; @@ -35,7 +39,7 @@ } #endif for (; i #include #include +#include #include -FILE *freopen (const char *path, const char *mode, FILE *stream) { +/* this is needed so the libpthread wrapper can initialize the mutex, + * not to lock it */ + +FILE *freopen_unlocked(const char *path, const char *mode, FILE *stream) { if (stream) { - fflush(stream); - if (close(stream->fd)) stream=0; - else { - int f=__stdio_parse_mode(mode); - if ((stream->fd=open(path,f,0666))!=-1) { - struct stat st; - fstat(stream->fd,&st); - stream->flags=(S_ISFIFO(st.st_mode))?FDPIPE:0; + int f=__stdio_parse_mode(mode); + fflush_unlocked(stream); + __libc_close(stream->fd); + if ((stream->fd=__libc_open(path,f,0666))!=-1) { + struct stat st; + fstat(stream->fd,&st); + stream->flags=(S_ISFIFO(st.st_mode))?FDPIPE:0; + switch (f&3) { + case O_RDWR: stream->flags|=CANWRITE; + case O_RDONLY: stream->flags|=CANREAD; break; + case O_WRONLY: stream->flags|=CANWRITE; } } } else errno=EINVAL; return stream; } + +FILE *freopen(const char *path, const char *mode, FILE *stream) __attribute__((weak,alias("freopen_unlocked"))); diff -uNr dietlibc-0.23/libstdio/fseek.c dietlibc-0.24/libstdio/fseek.c --- dietlibc-0.23/libstdio/fseek.c Wed Jul 18 02:24:31 2001 +++ dietlibc-0.24/libstdio/fseek.c Tue Nov 4 17:30:45 2003 @@ -1,10 +1,12 @@ #include #include -int fseek(FILE *stream, long offset, int whence) { - fflush(stream); +int fseek_unlocked(FILE *stream, long offset, int whence) { + fflush_unlocked(stream); stream->bm=0; stream->bs=0; stream->flags&=~(ERRORINDICATOR|EOFINDICATOR); stream->ungotten=0; return lseek(stream->fd,offset,whence)!=-1?0:-1; } + +int fseek(FILE *stream, long offset, int whence) __attribute__((weak,alias("fseek_unlocked"))); diff -uNr dietlibc-0.23/libstdio/fseeko.c dietlibc-0.24/libstdio/fseeko.c --- dietlibc-0.23/libstdio/fseeko.c Wed Jul 18 02:24:31 2001 +++ dietlibc-0.24/libstdio/fseeko.c Tue Nov 4 17:31:06 2003 @@ -1,10 +1,12 @@ #include #include -int fseeko(FILE *stream, off_t offset, int whence) { +int fseeko_unlocked(FILE *stream, off_t offset, int whence) { fflush(stream); stream->bm=0; stream->bs=0; stream->flags&=~(ERRORINDICATOR|EOFINDICATOR); stream->ungotten=0; return lseek(stream->fd,offset,whence)!=-1?0:-1; } + +int fseeko(FILE *stream, off_t offset, int whence) __attribute__((weak,alias("fseeko_unlocked"))); diff -uNr dietlibc-0.23/libstdio/fseeko64.c dietlibc-0.24/libstdio/fseeko64.c --- dietlibc-0.23/libstdio/fseeko64.c Wed Jul 18 02:24:31 2001 +++ dietlibc-0.24/libstdio/fseeko64.c Tue Nov 4 17:31:43 2003 @@ -2,11 +2,13 @@ #include #ifndef __NO_STAT64 -int fseeko64(FILE *stream, off64_t offset, int whence) { - fflush(stream); +int fseeko64_unlocked(FILE *stream, off64_t offset, int whence) { + fflush_unlocked(stream); stream->bm=0; stream->bs=0; stream->flags&=~(ERRORINDICATOR|EOFINDICATOR); stream->ungotten=0; return lseek64(stream->fd,offset,whence)!=-1?0:-1; } + +int fseeko64(FILE *stream, off64_t offset, int whence) __attribute__((weak,alias("fseeko64_unlocked"))); #endif diff -uNr dietlibc-0.23/libstdio/ftell.c dietlibc-0.24/libstdio/ftell.c --- dietlibc-0.23/libstdio/ftell.c Sun May 12 15:24:05 2002 +++ dietlibc-0.24/libstdio/ftell.c Fri Nov 14 14:47:52 2003 @@ -1,7 +1,13 @@ #include #include +#include -long ftell(FILE *stream) { - fflush(stream); - return (lseek(stream->fd,0,SEEK_CUR)-stream->ungotten); +long ftell_unlocked(FILE *stream) { + off_t l; + if (fflush_unlocked(stream)) return -1; + l=lseek(stream->fd,0,SEEK_CUR); + if (l==-1) return -1; + return l-stream->ungotten; } + +long ftell(FILE *stream) __attribute__((weak,alias("ftell_unlocked"))); diff -uNr dietlibc-0.23/libstdio/ftello.c dietlibc-0.24/libstdio/ftello.c --- dietlibc-0.23/libstdio/ftello.c Sat May 19 03:42:03 2001 +++ dietlibc-0.24/libstdio/ftello.c Fri Nov 14 14:49:18 2003 @@ -1,7 +1,10 @@ #include #include -off_t ftello(FILE *stream) { - fflush(stream); - return (lseek(stream->fd,0,SEEK_CUR)); +off_t ftello_unlocked(FILE *stream) { + off_t l; + if (fflush_unlocked(stream)) return -1; + return ((l=lseek(stream->fd,0,SEEK_CUR))==-1?-1:l-stream->ungotten); } + +off_t ftello(FILE *stream) __attribute__((weak,alias("ftello_unlocked"))); diff -uNr dietlibc-0.23/libstdio/ftello64.c dietlibc-0.24/libstdio/ftello64.c --- dietlibc-0.23/libstdio/ftello64.c Tue Aug 14 18:56:51 2001 +++ dietlibc-0.24/libstdio/ftello64.c Fri Nov 14 14:49:23 2003 @@ -2,8 +2,11 @@ #include #ifndef __NO_STAT64 -off64_t ftello64(FILE *stream) { - fflush(stream); - return (lseek64(stream->fd,0ull,SEEK_CUR)); +off64_t ftello64_unlocked(FILE *stream) { + off64_t l; + if (fflush_unlocked(stream)) return -1; + return ((l=lseek64(stream->fd,0ull,SEEK_CUR))==-1?-1:l-stream->ungotten); } + +off64_t ftello64(FILE *stream) __attribute__((weak,alias("ftello64_unlocked"))); #endif diff -uNr dietlibc-0.23/libstdio/fwrite.c dietlibc-0.24/libstdio/fwrite.c --- dietlibc-0.23/libstdio/fwrite.c Thu Aug 8 14:01:03 2002 +++ dietlibc-0.24/libstdio/fwrite.c Fri Nov 14 14:48:56 2003 @@ -3,20 +3,24 @@ #include #include -size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) { +size_t fwrite_unlocked(const void *ptr, size_t size, size_t nmemb, FILE *stream) { int res; unsigned long len=size*nmemb; long i; + if (!(stream->flags&CANWRITE)) { + stream->flags|=ERRORINDICATOR; + return 0; + } if (!nmemb || len/nmemb!=size) return 0; /* check for integer overflow */ if (len>stream->buflen || (stream->flags&NOBUF)) { - fflush(stream); + if (fflush_unlocked(stream)) return 0; do { - res=write(stream->fd,ptr,size*nmemb); + res=__libc_write(stream->fd,ptr,size*nmemb); } while (res==-1 && errno==EINTR); } else { register const unsigned char *c=ptr; for (i=len; i>0; --i,++c) - if (fputc(*c,stream)) { res=len-i; goto abort; } + if (fputc_unlocked(*c,stream)) { res=len-i; goto abort; } res=len; } if (res<0) { @@ -26,3 +30,5 @@ abort: return size?res/size:0; } + +size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) __attribute__((weak,alias("fwrite_unlocked"))); diff -uNr dietlibc-0.23/libstdio/puts.c dietlibc-0.24/libstdio/puts.c --- dietlibc-0.23/libstdio/puts.c Sat Feb 9 01:45:19 2002 +++ dietlibc-0.24/libstdio/puts.c Tue Nov 11 18:35:04 2003 @@ -3,13 +3,11 @@ #include "dietstdio.h" #include "dietfeatures.h" -int __cheap_outs(const char *s,size_t len); -int __cheap_outs(const char *s,size_t len) { - return (size_t)write(1,s,len)==len?1:0; +int __stdio_outs(const char *s,size_t len) __attribute__((weak)); +int __stdio_outs(const char *s,size_t len) { + return (write(1,s,len)==(int)len)?1:0; } -int __stdio_outs(const char *s,size_t len) __attribute__((weak,alias("__cheap_outs"))); - int puts(const char *s) { return (__stdio_outs(s,strlen(s)) && __stdio_outs("\n",1))?0:-1; } diff -uNr dietlibc-0.23/libstdio/setvbuf.c dietlibc-0.24/libstdio/setvbuf.c --- dietlibc-0.23/libstdio/setvbuf.c Thu Jan 24 01:27:58 2002 +++ dietlibc-0.24/libstdio/setvbuf.c Tue Nov 4 17:56:01 2003 @@ -4,7 +4,7 @@ #include #include "dietwarning.h" -static int set_flags (FILE *stream, int flags) { +static int set_flags(FILE *stream, int flags) { switch (flags) { case _IONBF: stream->flags = (stream->flags & ~(BUFLINEWISE)) | NOBUF; break; case _IOLBF: stream->flags = (stream->flags & ~(NOBUF)) | BUFLINEWISE; break; @@ -14,7 +14,7 @@ return 0; } -int setvbuf(FILE *stream, char *buf, int flags, size_t size) { +int setvbuf_unlocked(FILE *stream, char *buf, int flags, size_t size) { if (buf) { if (!(stream->flags&STATICBUF)) free(stream->buf); stream->buf=buf; @@ -32,3 +32,5 @@ stream->bm=stream->bs=0; return set_flags(stream,flags); } + +int setvbuf(FILE *stream, char *buf, int flags, size_t size) __attribute__((weak,alias("setvbuf_unlocked"))); diff -uNr dietlibc-0.23/libstdio/stderr.c dietlibc-0.24/libstdio/stderr.c --- dietlibc-0.23/libstdio/stderr.c Mon May 19 19:14:51 2003 +++ dietlibc-0.24/libstdio/stderr.c Wed Sep 17 02:20:17 2003 @@ -2,7 +2,7 @@ static FILE __stderr = { .fd=2, - .flags=NOBUF, + .flags=NOBUF|CANWRITE, .bs=0, .bm=0, .buflen=0, .buf=0, diff -uNr dietlibc-0.23/libstdio/stdin.c dietlibc-0.24/libstdio/stdin.c --- dietlibc-0.23/libstdio/stdin.c Mon May 19 19:14:51 2003 +++ dietlibc-0.24/libstdio/stdin.c Fri Oct 31 03:10:22 2003 @@ -3,7 +3,7 @@ static char __stdin_buf[BUFSIZE]; static FILE __stdin = { .fd=0, - .flags=BUFINPUT|STATICBUF, + .flags=BUFINPUT|BUFLINEWISE|STATICBUF|CANREAD, .bs=0, .bm=0, .buflen=BUFSIZE, .buf=__stdin_buf, diff -uNr dietlibc-0.23/libstdio/stdout.c dietlibc-0.24/libstdio/stdout.c --- dietlibc-0.23/libstdio/stdout.c Mon May 19 19:14:51 2003 +++ dietlibc-0.24/libstdio/stdout.c Wed Sep 17 02:20:17 2003 @@ -3,7 +3,7 @@ static char __stdout_buf[BUFSIZE]; static FILE __stdout = { .fd=1, - .flags=BUFLINEWISE|STATICBUF, + .flags=BUFLINEWISE|STATICBUF|CANWRITE, .bs=0, .bm=0, .buflen=BUFSIZE, .buf=__stdout_buf, diff -uNr dietlibc-0.23/libstdio/tmpfile.c dietlibc-0.24/libstdio/tmpfile.c --- dietlibc-0.23/libstdio/tmpfile.c Sat Feb 9 01:45:19 2002 +++ dietlibc-0.24/libstdio/tmpfile.c Tue Nov 4 17:57:08 2003 @@ -1,12 +1,18 @@ #include "dietstdio.h" #include #include +#include -FILE *tmpfile (void) { +/* this is needed so the libpthread wrapper can initialize the mutex, + * not to lock it */ + +FILE *tmpfile_unlocked(void) { int fd; char template[20] = "/tmp/tmpfile-XXXXXX"; if ((fd=mkstemp(template))<0) return 0; unlink(template); - return __stdio_init_file(fd,1); + return __stdio_init_file(fd,1,O_RDWR); } + +FILE *tmpfile(void) __attribute__((weak,alias("tmpfile_unlocked"))); diff -uNr dietlibc-0.23/libstdio/ungetc.c dietlibc-0.24/libstdio/ungetc.c --- dietlibc-0.23/libstdio/ungetc.c Tue Nov 13 01:25:11 2001 +++ dietlibc-0.24/libstdio/ungetc.c Tue Nov 4 17:57:30 2003 @@ -1,6 +1,6 @@ #include "dietstdio.h" -int ungetc(int c, FILE *stream) { +int ungetc_unlocked(int c, FILE *stream) { if (stream->ungotten || c<0 || c>255) return EOF; stream->ungotten=1; @@ -8,3 +8,5 @@ stream->flags&=~(ERRORINDICATOR|EOFINDICATOR); return c; } + +int ungetc(int c, FILE *stream) __attribute__((weak,alias("ungetc_unlocked"))); diff -uNr dietlibc-0.23/libugly/addmntent.c dietlibc-0.24/libugly/addmntent.c --- dietlibc-0.23/libugly/addmntent.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libugly/addmntent.c Fri Nov 14 22:33:50 2003 @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +#include + +/* FIXME: what happens with spaces/tabs/newlines in the + * mountpoint/options/type*/ + +int addmntent(FILE*filep,const struct mntent*mnt) { + struct mntent m=*mnt; + char buf[2048]; + if (strlen(m.mnt_opts)==0) m.mnt_opts="rw"; + if (snprintf(buf,sizeof(buf),"%s %s %s %s %d %d\n", + m.mnt_fsname,m.mnt_dir,m.mnt_type,m.mnt_opts, + m.mnt_freq,m.mnt_passno)>=(int)sizeof(buf)) return 1; + if (fputs(buf,filep)==EOF) return 1; + return 0; +} + diff -uNr dietlibc-0.23/libugly/getaddrinfo.c dietlibc-0.24/libugly/getaddrinfo.c --- dietlibc-0.23/libugly/getaddrinfo.c Sun Oct 7 01:49:59 2001 +++ dietlibc-0.24/libugly/getaddrinfo.c Wed Oct 8 01:44:26 2003 @@ -4,6 +4,7 @@ #include #include #include +#include #include /* XXX TODO FIXME */ @@ -23,8 +24,10 @@ int herrno=0; char buf[4096]; int lookupok=0; + char* interface; h.h_addr_list=(char**)buf+16; if (node) { + if ((interface=strchr(node,'%'))) ++interface; if (inet_pton(family,node,buf)>0) { h.h_name=(char*)node; h.h_addr_list[0]=buf; @@ -38,6 +41,7 @@ } else { h.h_name=0; h.h_addr_list[0]=buf; + interface=0; memset(buf,0,16); if (!hints || !(hints->ai_flags&AI_PASSIVE)) { if (family==AF_INET) { @@ -67,6 +71,7 @@ if (family==PF_INET6) { memset(&foo->ip,0,sizeof(foo->ip)); memmove(&foo->ip.ip6.sin6_addr,h.h_addr_list[0],16); + if (interface) foo->ip.ip6.sin6_scope_id=if_nametoindex(interface); } else { memmove(&foo->ip.ip4.sin_addr,h.h_addr_list[0],4); } diff -uNr dietlibc-0.23/libugly/getnameinfo.c dietlibc-0.24/libugly/getnameinfo.c --- dietlibc-0.23/libugly/getnameinfo.c Sat Feb 23 23:18:44 2002 +++ dietlibc-0.24/libugly/getnameinfo.c Fri Oct 31 03:10:22 2003 @@ -40,6 +40,8 @@ struct servent *s; if (!(s=getservbyport(port,flags&NI_DGRAM?"udp":"tcp"))) return EAI_SERVICE; + strncpy(serv,s->s_name,servlen-1); + serv[servlen-1]=0; } } return 0; diff -uNr dietlibc-0.23/libugly/logging.c dietlibc-0.24/libugly/logging.c --- dietlibc-0.23/libugly/logging.c Thu Jun 26 00:45:50 2003 +++ dietlibc-0.24/libugly/logging.c Tue Nov 11 18:35:04 2003 @@ -18,6 +18,12 @@ #define MAX_LOGTAG 1000 +/* declare internal functions */ +int __libc_open(const char*name,int flags, ...); +int __libc_write(int fd,void*buf,int len); +int __libc_fcntl(int fd,int op,...); +int __libc_close(int fd); + /* those have to be global *sigh* */ static volatile int connected; /* have done connect */ static volatile int LogMask = 0xff; /* mask of priorities to be logged */ @@ -32,7 +38,7 @@ static void closelog_intern(void) { if (!connected) return; - close(LogFile); + __libc_close(LogFile); LogFile = -1; connected = 0; } @@ -61,14 +67,14 @@ if (LogStat & LOG_NDELAY) { if ((LogFile = socket(AF_UNIX, LogType, 0)) == -1) return; - fcntl(LogFile, F_SETFD, 1); + __libc_fcntl(LogFile, F_SETFD, 1); } } if ((LogFile != -1) && !connected) { int old_errno=errno; if(connect(LogFile, &SyslogAddr, sizeof(SyslogAddr)) == -1) { int saved_errno=errno; - close(LogFile); + __libc_close(LogFile); LogFile = -1; if((LogType == SOCK_DGRAM) && (saved_errno == EPROTOTYPE)) { /* retry with SOCK_STREAM instead of SOCK_DGRAM */ @@ -149,8 +155,8 @@ buflen = vsnprintf(buffer+headerlen, BUF_SIZE - headerlen, format, arg_ptr); } if (LogStat & LOG_PERROR) { - write(1, buffer+headerlen, buflen); - if (buffer[headerlen+buflen] != '\n') write(1,"\n", 1); + __libc_write(1, buffer+headerlen, buflen); + if (buffer[headerlen+buflen] != '\n') __libc_write(1,"\n", 1); } /* prepare for broken connection */ @@ -176,10 +182,11 @@ * is the one from the syslogd failure. */ if ((LogStat & LOG_CONS) && - ((fd = open(_PATH_CONSOLE, O_WRONLY|O_NOCTTY, 0)) >= 0)) + ((fd = __libc_open(_PATH_CONSOLE, O_WRONLY|O_NOCTTY, 0)) >= 0)) { - write(fd, buffer, buflen+headerlen); - write(fd, "\r\n", 2); + __libc_write(fd, buffer, buflen+headerlen); + __libc_write(fd, "\r\n", 2); + __libc_close(fd); } } diff -uNr dietlibc-0.23/libugly/mktime.c dietlibc-0.24/libugly/mktime.c --- dietlibc-0.23/libugly/mktime.c Fri May 3 23:22:06 2002 +++ dietlibc-0.24/libugly/mktime.c Thu Nov 20 14:12:27 2003 @@ -2,6 +2,9 @@ extern const short __spm []; +/* apparently mktime is expected to treat the time as local time. + * I don't understand what that is supposed to mean, though */ + time_t mktime ( register struct tm* const t ) { register time_t day; @@ -25,6 +28,8 @@ return ((day + t->tm_hour) * i + t->tm_min) * i + t->tm_sec; } +time_t timelocal(struct tm* const t) __attribute__((alias("mktime"))); + #if 0 #include diff -uNr dietlibc-0.23/libugly/strptime.c dietlibc-0.24/libugly/strptime.c --- dietlibc-0.23/libugly/strptime.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libugly/strptime.c Tue Nov 18 14:02:52 2003 @@ -0,0 +1,144 @@ +#include +#include +#include +#include + +static const char* months [12] = { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" +}; + +static int getint(const char** s,int max) { + int i,j; + for (i=j=0; jtm_mon=i; + break; + case 'c': + s=strptime(s,"%b %a %d %k:%M:%S %Z %Y",tm); + break; + case 'C': + i=getint(&s,2); + if (i==-1) return (char*)s; + tm->tm_year=(tm->tm_year%100)+(i*100); + break; + case 'd': case 'e': + i=getint(&s,2); + if (i==-1 || i>31) return (char*)s; + tm->tm_mday=i; + break; + case 'D': + s=strptime(s,"%m/%d/%y",tm); + break; + case 'H': case 'k': + i=getint(&s,2); + if (i==-1 || i>23) return (char*)s; + tm->tm_hour=i; + break; + case 'I': case 'l': + i=getint(&s,2); + if (i==-1 || i>12) return (char*)s; + tm->tm_hour=(tm->tm_hour/12)*12+i; + break; + case 'j': + getint(&s,3); /* not used */ + break; + case 'm': + i=getint(&s,2); + if (i==-1 || i>12) return (char*)s; + tm->tm_mon=i; + break; + case 'M': + i=getint(&s,2); + if (i==-1 || i>59) return (char*)s; + tm->tm_min=i; + break; + case 'n': case 't': + while (isblank(*s)) ++s; + break; + case 'p': case 'P': + if (*s=='p' || *s=='P') tm->tm_hour=(tm->tm_hour%12)+12; + s+=2; + break; + case 'r': + s=strptime(s,"%I:%M:%S %p",tm); + break; + case 'R': + s=strptime(s,"%H:%M",tm); + break; + case 'S': + i=getint(&s,2); + if (i==-1 || i>60) return (char*)s; + tm->tm_sec=i; + break; + case 'T': + s=strptime(s,"%H:%M:%S",tm); + break; + case 'U': case 'W': + if (getint(&s,2)==-1) return (char*)s; + break; + case 'w': + if (*s<'0' || *s>'6') return (char*)s; + ++s; + break; + case 'x': + s=strptime(s,"%b %a %d",tm); + break; + case 'X': + s=strptime(s,"%k:%M:%S",tm); + break; + case 'y': + i=getint(&s,2); + if (i==-1) return (char*)s; + tm->tm_year=(tm->tm_year/100)*100+i; + break; + case 'Y': + i=getint(&s,5); + if (i==-1) return (char*)s; + tm->tm_year=i; + break; + } + ++format; + break; + default: + if (*s != *format) return (char*)s; + ++format; ++s; + break; + } + } + return (char*)s; +} diff -uNr dietlibc-0.23/libugly/timegm.c dietlibc-0.24/libugly/timegm.c --- dietlibc-0.23/libugly/timegm.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/libugly/timegm.c Thu Nov 20 14:13:17 2003 @@ -0,0 +1,29 @@ +#define _GNU_SOURCE +#include + +/* this is cut and paste from mktime. */ + +extern const short __spm []; + +time_t timegm(struct tm *const t) { + register time_t day; + register time_t i; + + if ( t->tm_year < 70 ) + return (time_t) -1; + + day = t->tm_yday = __spm [t->tm_mon] + t->tm_mday-1 + ( __isleap (t->tm_year+1900) & (t->tm_mon > 1) ); + + for ( i = 70; i < t->tm_year; i++ ) + day += 365 + __isleap (i+1900); + + /* day is now the number of days since 'Jan 1 1970' */ + i = 7; + t->tm_wday = (day + 4) % i; /* Sunday=0, Monday=1, ..., Saturday=6 */ + + i = 24; + day *= i; + i = 60; + return ((day + t->tm_hour) * i + t->tm_min) * i + t->tm_sec; +} + diff -uNr dietlibc-0.23/libugly/vasprintf.c dietlibc-0.24/libugly/vasprintf.c --- dietlibc-0.23/libugly/vasprintf.c Sat Aug 30 00:18:54 2003 +++ dietlibc-0.24/libugly/vasprintf.c Fri Oct 31 03:10:22 2003 @@ -11,6 +11,7 @@ va_list arg_ptr; va_copy(arg_ptr,ap); n=vsnprintf(0,1000000,format,arg_ptr); + va_end(arg_ptr); if ((*s=malloc(n+1))) { n=vsnprintf(*s,n+1,format,ap); return n; diff -uNr dietlibc-0.23/mips/syscalls.h dietlibc-0.24/mips/syscalls.h --- dietlibc-0.23/mips/syscalls.h Wed Dec 11 20:31:04 2002 +++ dietlibc-0.24/mips/syscalls.h Fri Nov 7 13:49:40 2003 @@ -1188,8 +1188,26 @@ #define __NR_madvise (__NR_Linux + 218) #define __NR_getdents64 (__NR_Linux + 219) #define __NR_fcntl64 (__NR_Linux + 220) -#define __NR_gettid (__NR_Linux + 221) -#define __NR_tkill (__NR_Linux + 222) +#define __NR_security (__NR_Linux + 221) +#define __NR_gettid (__NR_Linux + 222) +#define __NR_readahead (__NR_Linux + 223) +#define __NR_setxattr (__NR_Linux + 224) +#define __NR_lsetxattr (__NR_Linux + 225) +#define __NR_fsetxattr (__NR_Linux + 226) +#define __NR_getxattr (__NR_Linux + 227) +#define __NR_lgetxattr (__NR_Linux + 228) +#define __NR_fgetxattr (__NR_Linux + 229) +#define __NR_listxattr (__NR_Linux + 230) +#define __NR_llistxattr (__NR_Linux + 231) +#define __NR_flistxattr (__NR_Linux + 232) +#define __NR_removexattr (__NR_Linux + 233) +#define __NR_lremovexattr (__NR_Linux + 234) +#define __NR_fremovexattr (__NR_Linux + 235) +#define __NR_tkill (__NR_Linux + 236) +#define __NR_sendfile64 (__NR_Linux + 237) +#define __NR_futex (__NR_Linux + 238) +#define __NR_sched_setaffinity (__NR_Linux + 239) +#define __NR_sched_getaffinity (__NR_Linux + 240) #define syscall_weak(name,wsym,sym) \ .text; \ diff -uNr dietlibc-0.23/parisc/setjmp.S dietlibc-0.24/parisc/setjmp.S --- dietlibc-0.23/parisc/setjmp.S Fri Jan 11 19:06:53 2002 +++ dietlibc-0.24/parisc/setjmp.S Wed Oct 8 01:44:26 2003 @@ -52,7 +52,7 @@ stw %sp, 0x4c(%sr0, %r26) stw %rp, 0x50(%sr0, %r26) /* Floating point stack in %r19 */ - ldo 58(%r26), %r19 + ldo 0x58(%r26), %r19 /* Save Floating point registers */ fstd,ma %fr12, 8(%sr0, %r19) fstd,ma %fr13, 8(%sr0, %r19) diff -uNr dietlibc-0.23/parisc/start.S dietlibc-0.24/parisc/start.S --- dietlibc-0.23/parisc/start.S Fri Jan 11 19:06:53 2002 +++ dietlibc-0.24/parisc/start.S Fri Nov 14 13:58:19 2003 @@ -31,6 +31,10 @@ add %r19, %r24, %r24 ldil LP%environ, %r19 ldo RP%environ(%r19), %r19 + + /* Expand the stack to store the 5th through 7th args */ + ldo 64(%sp), %sp + stw %r24, 0(%sr0, %r19) ldil L%$global$, %dp bl main, %rp diff -uNr dietlibc-0.23/parisc/strchr.S dietlibc-0.24/parisc/strchr.S --- dietlibc-0.23/parisc/strchr.S Thu Sep 4 03:50:50 2003 +++ dietlibc-0.24/parisc/strchr.S Wed Oct 8 01:44:26 2003 @@ -23,7 +23,7 @@ b,n .Lfoobar uxor,sbz %r0, %r20, %r0 b,n .Lmdoit - bv,n %r0(%rp) + bv %r0(%rp) or %r0, %r0, %r28 .Lfoobar: addi -4, %r26, %r26 diff -uNr dietlibc-0.23/parisc/strcpy.S dietlibc-0.24/parisc/strcpy.S --- dietlibc-0.23/parisc/strcpy.S Thu Sep 4 03:50:50 2003 +++ dietlibc-0.24/parisc/strcpy.S Thu Jan 1 01:00:00 1970 @@ -1,41 +0,0 @@ -/* strcpy -- strcpy(3) -- Copy a string - - Copyright (C) 2002 Thomas M. Ogrisegg - - Created: 09/22/02 - Last updated: 09/23/02 - - Remarks: - All copies are done in word-mode. This might result in a - buffer overflow if the destination buffer is too short. -*/ - -.LEVEL 1.1 - -.text - -strcpy: - .PROC - .CALLINFO - .ENTRY - copy %r26, %r28 - ldi 3, %r19 - and,<> %r26, %r19, %r20 - b,n .Lstrcpy2 - sub %r19, %r20, %r20 -.Lstrcpy1: - addi -1, %r20, %r20 - cmpb,< %r0, %r20, .Lstrcpy2 - ldb,ma 1(%r25), %r19 - cmpb,<> %r0, %r19, .Lstrcpy1 - stb,ma %r19, 1(%r26) - bv,n %r0(%rp) -.Lstrcpy2: - ldw,ma 4(%r25), %r19 - stbys,b,m %r19, 4(%r26) - uxor,sbz %r19, %r0, %r0 - b,n .Lstrcpy2 - bv,n %r0(%rp) - .EXIT - .PROCEND - .EXPORT strcpy diff -uNr dietlibc-0.23/parisc/strlen.S dietlibc-0.24/parisc/strlen.S --- dietlibc-0.23/parisc/strlen.S Thu Sep 4 03:50:50 2003 +++ dietlibc-0.24/parisc/strlen.S Sun Sep 21 15:03:49 2003 @@ -10,40 +10,41 @@ than the HP-UX libc implementation, which is also uxor-based. */ -.LEVEL 1.1 +.LEVEL 1.1 .text .globl strlen strlen: - .PROC - .CALLINFO - .ENTRY - xor %r28, %r28, %r28 - ldi 3, %r19 - and,<> %r26, %r19, %r20 - b,n .Lstrlen17 - sub %r19, %r20, %r20 - addi 1, %r20, %r20 + .PROC + .CALLINFO + .ENTRY + xor %r28, %r28, %r28 + ldi 3, %r19 + and,<> %r26, %r19, %r20 + b,n .Lstrlen17 + sub %r19, %r20, %r20 + addi 1, %r20, %r20 .Lstrlen23: - ldb,ma 1(%r26), %r19 - cmpb,= %r0, %r19, .Lstrlen42 - addi 1, %r28, %r28 - addi,= -1, %r20, %r20 - b,n .Lstrlen23 + ldb,ma 1(%r26), %r19 + cmpb,=,n %r0, %r19, .Lstrlen42 + addi 1, %r28, %r28 + addi,= -1, %r20, %r20 + b,n .Lstrlen23 .Lstrlen17: - ldw,ma 4(%r26), %r19 - uxor,sbz %r19, %r0, %r0 - b .Lstrlen17 - addi 4, %r28, %r28 - addi -4, %r28, %r28 + ldw,ma 4(%r26), %r19 + uxor,sbz %r19, %r0, %r0 + b .Lstrlen17 + addi 4, %r28, %r28 + addi -5, %r28, %r28 .Lstrlen72: - depw %r19, 23, 24, %r19 - extrs,= %r19, 7, 8, %r20 - cmpb,<> %r0, %r20, .Lstrlen72 - addi 1, %r28, %r28 + extrs %r19, 7, 8, %r20 + addi 1, %r28, %r28 + cmpb,<> %r0, %r20, .Lstrlen72 + depw %r19, 23, 24, %r19 .Lstrlen42: - bv,n %r0(%rp) - .EXIT - .PROCEND - .EXPORT strlen + bv,n %r0(%rp) + .EXIT + .PROCEND + .EXPORT strlen + diff -uNr dietlibc-0.23/parisc/strstr.S dietlibc-0.24/parisc/strstr.S --- dietlibc-0.23/parisc/strstr.S Thu Sep 4 03:50:50 2003 +++ dietlibc-0.24/parisc/strstr.S Wed Sep 17 02:20:17 2003 @@ -10,7 +10,7 @@ ldb,ma 1(%r26), %r19 ldi 2, %ret0 .L1: - cmpb,=,n %r0, %r19, .Lret + cmpb,=,n %r0, %r19, .Lret2 cmpb,<> %r20, %r19, .L1 ldb,ma 1(%r26), %r19 copy %r19, %r24 @@ -25,8 +25,10 @@ cmpb,<>,n %r21, %r0, .Lloop nop .Lret: + addi 0, %r26, %ret0 +.Lret2: bv %r0(%rp) - addi -2, %r26, %ret0 + addi -2, %ret0, %ret0 .EXIT .PROCEND .EXPORT strstr diff -uNr dietlibc-0.23/parisc/umount.S dietlibc-0.24/parisc/umount.S --- dietlibc-0.23/parisc/umount.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/parisc/umount.S Tue Sep 16 16:25:07 2003 @@ -0,0 +1,10 @@ +#include "parisc/syscalls.h" + +.text +.type umount,@function +.globl umount +.export umount +umount: + ldi 0, %r25 + b __unified_syscall + ldi __NR_umount2, %r20 diff -uNr dietlibc-0.23/ppc/syscalls.h dietlibc-0.24/ppc/syscalls.h --- dietlibc-0.23/ppc/syscalls.h Sun Nov 24 16:23:03 2002 +++ dietlibc-0.24/ppc/syscalls.h Fri Nov 7 14:16:23 2003 @@ -221,7 +221,7 @@ #define __NR_futex 221 #define __NR_sched_setaffinity 222 #define __NR_sched_getaffinity 223 -#define __NR_security 224 +/* 224 currently unused */ #define __NR_tuxcall 225 #define __NR_sendfile64 226 #define __NR_io_setup 227 @@ -229,14 +229,29 @@ #define __NR_io_getevents 229 #define __NR_io_submit 230 #define __NR_io_cancel 231 -#define __NR_alloc_hugepages 232 -#define __NR_free_hugepages 233 +#define __NR_set_tid_address 232 +#define __NR_fadvise64 233 #define __NR_exit_group 234 #define __NR_lookup_dcookie 235 -#define __NR_sys_epoll_create 236 -#define __NR_sys_epoll_ctl 237 -#define __NR_sys_epoll_wait 238 +#define __NR_epoll_create 236 +#define __NR_epoll_ctl 237 +#define __NR_epoll_wait 238 #define __NR_remap_file_pages 239 +#define __NR_timer_create 240 +#define __NR_timer_settime 241 +#define __NR_timer_gettime 242 +#define __NR_timer_getoverrun 243 +#define __NR_timer_delete 244 +#define __NR_clock_settime 245 +#define __NR_clock_gettime 246 +#define __NR_clock_getres 247 +#define __NR_clock_nanosleep 248 +#define __NR_swapcontext 249 +#define __NR_tgkill 250 +#define __NR_utimes 251 +#define __NR_statfs64 252 +#define __NR_fstatfs64 253 +#define __NR_fadvise64_64 254 #define syscall_weak(name,wsym,sym) \ .text; \ diff -uNr dietlibc-0.23/ppc64/Makefile.add dietlibc-0.24/ppc64/Makefile.add --- dietlibc-0.23/ppc64/Makefile.add Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/ppc64/Makefile.add Fri Oct 10 15:17:46 2003 @@ -0,0 +1,3 @@ + +CFLAGS+=-Os -mpowerpc64 +VPATH:=ppc64:syscalls.s:$(VPATH) diff -uNr dietlibc-0.23/ppc64/__longjmp.S dietlibc-0.24/ppc64/__longjmp.S --- dietlibc-0.23/ppc64/__longjmp.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/ppc64/__longjmp.S Fri Oct 10 15:17:46 2003 @@ -0,0 +1,59 @@ +#include + + +#ifdef PIC +#define JUMPTARGET(name) name##@plt +#else +#define JUMPTARGET(name) name +#endif + +.global __longjmp +.type __longjmp,@function +.align 2 +__longjmp: + lwz 1,(JB_GPR1*4)(3) + lwz 2,(JB_GPR2*4)(3) + lwz 0,(JB_LR*4)(3) + lwz 14,((JB_GPRS+0)*4)(3) + lfd 14,((JB_FPRS+0*2)*4)(3) + lwz 15,((JB_GPRS+1)*4)(3) + lfd 15,((JB_FPRS+1*2)*4)(3) + lwz 16,((JB_GPRS+2)*4)(3) + lfd 16,((JB_FPRS+2*2)*4)(3) + lwz 17,((JB_GPRS+3)*4)(3) + lfd 17,((JB_FPRS+3*2)*4)(3) + lwz 18,((JB_GPRS+4)*4)(3) + lfd 18,((JB_FPRS+4*2)*4)(3) + lwz 19,((JB_GPRS+5)*4)(3) + lfd 19,((JB_FPRS+5*2)*4)(3) + lwz 20,((JB_GPRS+6)*4)(3) + lfd 20,((JB_FPRS+6*2)*4)(3) + mtlr 0 + lwz 21,((JB_GPRS+7)*4)(3) + lfd 21,((JB_FPRS+7*2)*4)(3) + lwz 22,((JB_GPRS+8)*4)(3) + lfd 22,((JB_FPRS+8*2)*4)(3) + lwz 0,(JB_CR*4)(3) + lwz 23,((JB_GPRS+9)*4)(3) + lfd 23,((JB_FPRS+9*2)*4)(3) + lwz 24,((JB_GPRS+10)*4)(3) + lfd 24,((JB_FPRS+10*2)*4)(3) + lwz 25,((JB_GPRS+11)*4)(3) + lfd 25,((JB_FPRS+11*2)*4)(3) + mtcrf 0xFF,0 + lwz 26,((JB_GPRS+12)*4)(3) + lfd 26,((JB_FPRS+12*2)*4)(3) + lwz 27,((JB_GPRS+13)*4)(3) + lfd 27,((JB_FPRS+13*2)*4)(3) + lwz 28,((JB_GPRS+14)*4)(3) + lfd 28,((JB_FPRS+14*2)*4)(3) + lwz 29,((JB_GPRS+15)*4)(3) + lfd 29,((JB_FPRS+15*2)*4)(3) + lwz 30,((JB_GPRS+16)*4)(3) + lfd 30,((JB_FPRS+16*2)*4)(3) + lwz 31,((JB_GPRS+17)*4)(3) + lfd 31,((JB_FPRS+17*2)*4)(3) + mr 3,4 + blr +.size __longjmp,.-__longjmp + diff -uNr dietlibc-0.23/ppc64/__testandset.S dietlibc-0.24/ppc64/__testandset.S --- dietlibc-0.23/ppc64/__testandset.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/ppc64/__testandset.S Fri Oct 10 15:17:46 2003 @@ -0,0 +1,12 @@ +.global __testandset +.type __testandset,@function +.align 2 +__testandset: +1: lwarx 5,0,3 + li 0,1 + stwcx. 0,0,3 + bne- 1b + mr 3,5 + blr +.size __testandset,.-__testandset + diff -uNr dietlibc-0.23/ppc64/clone.S dietlibc-0.24/ppc64/clone.S --- dietlibc-0.23/ppc64/clone.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/ppc64/clone.S Fri Oct 10 15:17:46 2003 @@ -0,0 +1,48 @@ +#include +#include "syscalls.h" +#include + +.text +.weak clone +clone: +.global __clone +__clone: + cmpwi 4,0 /* check have non null child_stack pointer */ + cmpwi cr1, 3,0 /* check have non null thread_funcion */ + cror eq,4*cr1+eq,eq /* now if eq is set one is or both are zero */ + beq .Lclone_error + + stwu 1,-32(1) /* alloc some space on the stack */ + stmw 29, 16(1) /* save r29,r30,r31 on stack */ + + rlwinm 4,4,0,0,27 /* mask out lower 4 bits */ + + /* move parameter to positions clone wants them */ + mr 29,3 /* r29 = r3 fn */ + mr 30,4 /* r30 = r4 stack */ + mr 31,6 /* r31 = r6 arg */ + mr 3, 5 /* r3 = r5 flags */ + + li 0, __NR_clone /* load syscall nr. */ + sc + + cmpwi cr1,3,0 /* compare return of syscall with 0 */ + crandc 4*cr1+eq,4*cr1+eq,so + bne .Lclone_parent /* return was non zero -> .Lclone_parent */ + + /* we are the cloned process */ + mr 1, 30 /* set stack pointer */ + mtctr 29 /* set count register to fn ? */ + mr 3, 31 /* set argument */ + bctrl /* branch trough count register and link */ + b _exit /* exit thread */ + +.Lclone_parent: + lmw 29,16(1) /* restore saved registers */ + addi 1, 1,32 /* free stack */ + bnslr+ /* had cloned a thread so return to parent */ + b error_unified_syscall + +.Lclone_error: + li 3, EINVAL + b error_unified_syscall diff -uNr dietlibc-0.23/ppc64/setjmp.S dietlibc-0.24/ppc64/setjmp.S --- dietlibc-0.23/ppc64/setjmp.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/ppc64/setjmp.S Fri Oct 10 15:17:46 2003 @@ -0,0 +1,56 @@ +#include + +#ifdef PIC +#define JUMPTARGET(name) name##@plt +#else +#define JUMPTARGET(name) name +#endif + +.global __sigsetjmp +.type __sigsetjmp,@function +.align 2 +__sigsetjmp: + stw 1,(JB_GPR1*4)(3) + mflr 0 + stw 2,(JB_GPR2*4)(3) + stw 14,((JB_GPRS+0)*4)(3) + stfd 14,((JB_FPRS+0*2)*4)(3) + stw 0,(JB_LR*4)(3) + stw 15,((JB_GPRS+1)*4)(3) + stfd 15,((JB_FPRS+1*2)*4)(3) + mfcr 0 + stw 16,((JB_GPRS+2)*4)(3) + stfd 16,((JB_FPRS+2*2)*4)(3) + stw 0,(JB_CR*4)(3) + stw 17,((JB_GPRS+3)*4)(3) + stfd 17,((JB_FPRS+3*2)*4)(3) + stw 18,((JB_GPRS+4)*4)(3) + stfd 18,((JB_FPRS+4*2)*4)(3) + stw 19,((JB_GPRS+5)*4)(3) + stfd 19,((JB_FPRS+5*2)*4)(3) + stw 20,((JB_GPRS+6)*4)(3) + stfd 20,((JB_FPRS+6*2)*4)(3) + stw 21,((JB_GPRS+7)*4)(3) + stfd 21,((JB_FPRS+7*2)*4)(3) + stw 22,((JB_GPRS+8)*4)(3) + stfd 22,((JB_FPRS+8*2)*4)(3) + stw 23,((JB_GPRS+9)*4)(3) + stfd 23,((JB_FPRS+9*2)*4)(3) + stw 24,((JB_GPRS+10)*4)(3) + stfd 24,((JB_FPRS+10*2)*4)(3) + stw 25,((JB_GPRS+11)*4)(3) + stfd 25,((JB_FPRS+11*2)*4)(3) + stw 26,((JB_GPRS+12)*4)(3) + stfd 26,((JB_FPRS+12*2)*4)(3) + stw 27,((JB_GPRS+13)*4)(3) + stfd 27,((JB_FPRS+13*2)*4)(3) + stw 28,((JB_GPRS+14)*4)(3) + stfd 28,((JB_FPRS+14*2)*4)(3) + stw 29,((JB_GPRS+15)*4)(3) + stfd 29,((JB_FPRS+15*2)*4)(3) + stw 30,((JB_GPRS+16)*4)(3) + stfd 30,((JB_FPRS+16*2)*4)(3) + stw 31,((JB_GPRS+17)*4)(3) + stfd 31,((JB_FPRS+17*2)*4)(3) + b JUMPTARGET (__sigjmp_save) +.size __sigsetjmp,.-__sigsetjmp diff -uNr dietlibc-0.23/ppc64/start.S dietlibc-0.24/ppc64/start.S --- dietlibc-0.23/ppc64/start.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/ppc64/start.S Fri Oct 10 15:17:46 2003 @@ -0,0 +1,74 @@ + .section ".text" + .align 2 + .globl ._start + .type ._start,@function + .globl _start + .section ".opd","aw" +_start: + .quad ._start + .quad .TOC.@tocbase, 0 + .previous +._start: + +/* + .section ".text" + .align 2 + .globl ._start + .type ._start,@function + .globl _start + .section ".opd","aw" +_start: + .quad ._start + .quad .TOC.@tocbase, 0 + .previous +._start: +*/ + /* Save the stack pointer, in case we're statically linked under Linux. */ + mr 9,1 + /* Set up an initial stack frame, and clear the LR. */ + clrrdi 1,1,4 + li 0,0 + stdu 1,-128(1) + mtlr 0 + std 0,0(1) + + /* r9 contains the initial stack pointer + argc = (r9) + argv = (r9+4) + envp = argv+(argc+1)*4 */ + + ldu 3,0(9) /* argc */ + addi 4,9,8 /* argv */ + add 5,0,3 /* argc... */ + addi 5,5,1 /* argc+1...*/ + slwi 5,5,3 /* (argc+1)*4 */ + add 5,5,4 /* argv+(argc+1)*4 */ + + lis 14,environ@ha + std 5,environ@l(14) + +#ifdef WANT_DYNAMIC +#warning dynamic + mr 6,7 + bl ._dyn_start +#else +#warning static + bl .main +#endif + b .exit + +.LT_start: + .long 0 + .quad 0x000c000000000000 | 0x0000200000000000 | 0x0000004000000000 + .long .LT_start-._start + .short .LT_start_name_end-.LT_start_name_start +.LT_start_name_start: + .ascii "_start" +.LT_start_name_end: + .align 2 + .size _start,.-_start + +/* Define a symbol for the first piece of initialized data. */ + .section ".data" +__data_start: + diff -uNr dietlibc-0.23/ppc64/syscalls.h dietlibc-0.24/ppc64/syscalls.h --- dietlibc-0.23/ppc64/syscalls.h Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/ppc64/syscalls.h Fri Nov 7 14:19:01 2003 @@ -0,0 +1,289 @@ + +#define __NR_exit 1 +#define __NR_fork 2 +#define __NR_read 3 +#define __NR_write 4 +#define __NR_open 5 +#define __NR_close 6 +#define __NR_waitpid 7 +#define __NR_creat 8 +#define __NR_link 9 +#define __NR_unlink 10 +#define __NR_execve 11 +#define __NR_chdir 12 +#define __NR_time 13 +#define __NR_mknod 14 +#define __NR_chmod 15 +#define __NR_lchown 16 +#define __NR_break 17 +#define __NR_oldstat 18 +#define __NR_lseek 19 +#define __NR_getpid 20 +#define __NR_mount 21 +#define __NR_umount 22 +#define __NR_setuid 23 +#define __NR_getuid 24 +#define __NR_stime 25 +#define __NR_ptrace 26 +#define __NR_alarm 27 +#define __NR_oldfstat 28 +#define __NR_pause 29 +#define __NR_utime 30 +#define __NR_stty 31 +#define __NR_gtty 32 +#define __NR_access 33 +#define __NR_nice 34 +#define __NR_ftime 35 +#define __NR_sync 36 +#define __NR_kill 37 +#define __NR_rename 38 +#define __NR_mkdir 39 +#define __NR_rmdir 40 +#define __NR_dup 41 +#define __NR_pipe 42 +#define __NR_times 43 +#define __NR_prof 44 +#define __NR_brk 45 +#define __NR_setgid 46 +#define __NR_getgid 47 +#define __NR_signal 48 +#define __NR_geteuid 49 +#define __NR_getegid 50 +#define __NR_acct 51 +#define __NR_umount2 52 +#define __NR_lock 53 +#define __NR_ioctl 54 +#define __NR_fcntl 55 +#define __NR_mpx 56 +#define __NR_setpgid 57 +#define __NR_ulimit 58 +#define __NR_oldolduname 59 +#define __NR_umask 60 +#define __NR_chroot 61 +#define __NR_ustat 62 +#define __NR_dup2 63 +#define __NR_getppid 64 +#define __NR_getpgrp 65 +#define __NR_setsid 66 +#define __NR_sigaction 67 +#define __NR_sgetmask 68 +#define __NR_ssetmask 69 +#define __NR_setreuid 70 +#define __NR_setregid 71 +#define __NR_sigsuspend 72 +#define __NR_sigpending 73 +#define __NR_sethostname 74 +#define __NR_setrlimit 75 +#define __NR_getrlimit 76 +#define __NR_getrusage 77 +#define __NR_gettimeofday 78 +#define __NR_settimeofday 79 +#define __NR_getgroups 80 +#define __NR_setgroups 81 +#define __NR_select 82 +#define __NR_symlink 83 +#define __NR_oldlstat 84 +#define __NR_readlink 85 +#define __NR_uselib 86 +#define __NR_swapon 87 +#define __NR_reboot 88 +#define __NR_readdir 89 +#define __NR_mmap 90 +#define __NR_munmap 91 +#define __NR_truncate 92 +#define __NR_ftruncate 93 +#define __NR_fchmod 94 +#define __NR_fchown 95 +#define __NR_getpriority 96 +#define __NR_setpriority 97 +#define __NR_profil 98 +#define __NR_statfs 99 +#define __NR_fstatfs 100 +#define __NR_ioperm 101 +#define __NR_socketcall 102 +#define __NR_syslog 103 +#define __NR_setitimer 104 +#define __NR_getitimer 105 +#define __NR_stat 106 +#define __NR_lstat 107 +#define __NR_fstat 108 +#define __NR_olduname 109 +#define __NR_iopl 110 +#define __NR_vhangup 111 +#define __NR_idle 112 +#define __NR_vm86 113 +#define __NR_wait4 114 +#define __NR_swapoff 115 +#define __NR_sysinfo 116 +#define __NR_ipc 117 +#define __NR_fsync 118 +#define __NR_sigreturn 119 +#define __NR_clone 120 +#define __NR_setdomainname 121 +#define __NR_uname 122 +#define __NR_modify_ldt 123 +#define __NR_adjtimex 124 +#define __NR_mprotect 125 +#define __NR_sigprocmask 126 +#define __NR_create_module 127 +#define __NR_init_module 128 +#define __NR_delete_module 129 +#define __NR_get_kernel_syms 130 +#define __NR_quotactl 131 +#define __NR_getpgid 132 +#define __NR_fchdir 133 +#define __NR_bdflush 134 +#define __NR_sysfs 135 +#define __NR_personality 136 +#define __NR_afs_syscall 137 /* Syscall for Andrew File System */ +#define __NR_setfsuid 138 +#define __NR_setfsgid 139 +#define __NR__llseek 140 +#define __NR_getdents 141 +#define __NR__newselect 142 +#define __NR_flock 143 +#define __NR_msync 144 +#define __NR_readv 145 +#define __NR_writev 146 +#define __NR_getsid 147 +#define __NR_fdatasync 148 +#define __NR__sysctl 149 +#define __NR_mlock 150 +#define __NR_munlock 151 +#define __NR_mlockall 152 +#define __NR_munlockall 153 +#define __NR_sched_setparam 154 +#define __NR_sched_getparam 155 +#define __NR_sched_setscheduler 156 +#define __NR_sched_getscheduler 157 +#define __NR_sched_yield 158 +#define __NR_sched_get_priority_max 159 +#define __NR_sched_get_priority_min 160 +#define __NR_sched_rr_get_interval 161 +#define __NR_nanosleep 162 +#define __NR_mremap 163 +#define __NR_setresuid 164 +#define __NR_getresuid 165 +#define __NR_query_module 166 +#define __NR_poll 167 +#define __NR_nfsservctl 168 +#define __NR_setresgid 169 +#define __NR_getresgid 170 +#define __NR_prctl 171 +#define __NR_rt_sigreturn 172 +#define __NR_rt_sigaction 173 +#define __NR_rt_sigprocmask 174 +#define __NR_rt_sigpending 175 +#define __NR_rt_sigtimedwait 176 +#define __NR_rt_sigqueueinfo 177 +#define __NR_rt_sigsuspend 178 +#define __NR_pread 179 +#define __NR_pwrite 180 +#define __NR_chown 181 +#define __NR_getcwd 182 +#define __NR_capget 183 +#define __NR_capset 184 +#define __NR_sigaltstack 185 +#define __NR_sendfile 186 +#define __NR_getpmsg 187 /* some people actually want streams */ +#define __NR_putpmsg 188 /* some people actually want streams */ +#define __NR_vfork 189 +#define __NR_ugetrlimit 190 /* SuS compliant getrlimit */ +#define __NR_mmap2 192 +//#define __NR_truncate64 193 +//#define __NR_ftruncate64 194 +//#define __NR_stat64 195 +//#define __NR_lstat64 196 +//#define __NR_fstat64 197 +#define __NR_pciconfig_read 198 +#define __NR_pciconfig_write 199 +#define __NR_pciconfig_iobase 200 +#define __NR_multiplexer 201 +//#define __NR_getdents64 202 +#define __NR_pivot_root 203 +//#define __NR_fcntl64 204 +#define __NR_madvise 205 +#define __NR_mincore 206 +#define __NR_gettid 207 +#define __NR_tkill 208 +#define __NR_setxattr 209 +#define __NR_lsetxattr 210 +#define __NR_fsetxattr 211 +#define __NR_getxattr 212 +#define __NR_lgetxattr 213 +#define __NR_fgetxattr 214 +#define __NR_listxattr 215 +#define __NR_llistxattr 216 +#define __NR_flistxattr 217 +#define __NR_removexattr 218 +#define __NR_lremovexattr 219 +#define __NR_fremovexattr 220 +#define __NR_futex 221 +#define __NR_sched_setaffinity 222 +#define __NR_sched_getaffinity 223 +/* 224 currently unused */ +#define __NR_tuxcall 225 +//#define __NR_sendfile64 226 +#define __NR_io_setup 227 +#define __NR_io_destroy 228 +#define __NR_io_getevents 229 +#define __NR_io_submit 230 +#define __NR_io_cancel 231 +#define __NR_set_tid_address 232 +#define __NR_fadvise64 233 +#define __NR_exit_group 234 +#define __NR_lookup_dcookie 235 +#define __NR_sys_epoll_create 236 +#define __NR_sys_epoll_ctl 237 +#define __NR_sys_epoll_wait 238 +#define __NR_remap_file_pages 239 +#define __NR_timer_create 240 +#define __NR_timer_settime 241 +#define __NR_timer_gettime 242 +#define __NR_timer_getoverrun 243 +#define __NR_timer_delete 244 +#define __NR_clock_settime 245 +#define __NR_clock_gettime 246 +#define __NR_clock_getres 247 +#define __NR_clock_nanosleep 248 +#define __NR_swapcontext 249 +#define __NR_tgkill 250 +#define __NR_utimes 251 +#define __NR_statfs64 252 +#define __NR_fstatfs64 253 + + +#define diet_proto_weak(wsym) \ +wsym: \ + .quad .wsym,.TOC.@tocbase,0;\ + .previous;\ + .size wsym,24;\ + .type .wsym,@function;\ + .globl .wsym;\ + .weak wsym;\ + +#define diet_proto(sym) \ +sym:\ + .quad .sym,.TOC.@tocbase,0;\ + .previous;\ + .size sym,24;\ + .type .sym,@function;\ + .globl .sym;\ + +#define syscall_weak(name,wsym,sym) \ +.text; \ +diet_proto_weak(wsym); \ +diet_proto(sym); \ +.wsym:\ + .weak .wsym;\ +.sym: \ + li 0,__NR_##name; \ + b __unified_syscall + +#define syscall(name,sym) \ +.text; \ +diet_proto(sym); \ +.sym: \ + li 0,__NR_##name; \ + b __unified_syscall + diff -uNr dietlibc-0.23/ppc64/unified.S dietlibc-0.24/ppc64/unified.S --- dietlibc-0.23/ppc64/unified.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/ppc64/unified.S Fri Oct 10 15:17:46 2003 @@ -0,0 +1,68 @@ +#include +#include "syscalls.h" + + .text +.exit: + .weak .exit +._exit: + li 0,__NR_exit + .global __unified_syscall +__unified_syscall: + sc + bnslr+ + + .global error_unified_syscall +error_unified_syscall: + +#ifdef WANT_THREAD_SAFE + stdu 1,-128(1) + mflr 0 + std 0,20(1) + std 3,12(1) + bl .__errno_location + ld 0,12(1) + stw 0,0(3) + ld 0,20(1) + mtlr 0 + addi 1,1,128 +#else + lis 9,errno@ha + stw 3,errno@l(9) +#endif + li 3,-1 + +/* here we go and "reuse" the return for weak-void functions */ +//#include "dietuglyweaks.h" +.__thread_doexit: + .weak .__thread_doexit +.__fflush_stdin: + .weak .__fflush_stdin +.__fflush_stdout: + .weak .__fflush_stdout +.__fflush_stderr: + .weak .__fflush_stderr +.flockfile: + .weak .flockfile +.funlockfile: + .weak .funlockfile +.__nop: + .weak .__nop +.__you_tried_to_link_a_dietlibc_object_against_glibc: + .weak .__you_tried_to_link_a_dietlibc_object_against_glibc + + blr + .long 0 + .byte 0,0,0,1,128,0,0,0 + .size ._exit,.-._exit + .size .exit,.-.exit + +diet_proto_weak(__thread_doexit) +diet_proto_weak(__fflush_stdin) +diet_proto_weak(__fflush_stdout) +diet_proto_weak(__fflush_stderr) +diet_proto_weak(flockfile) +diet_proto_weak(funlockfile) +diet_proto_weak(__nop) +diet_proto_weak(__you_tried_to_link_a_dietlibc_object_against_glibc) +diet_proto_weak(exit) +diet_proto(_exit) diff -uNr dietlibc-0.23/s390/mmap.S dietlibc-0.24/s390/mmap.S --- dietlibc-0.23/s390/mmap.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/s390/mmap.S Fri Oct 10 15:06:18 2003 @@ -0,0 +1,47 @@ +#include +#include "syscalls.h" + +#define EINVAL 22 + + .text + .align 4 + .global mmap + .type mmap,@function +mmap: + /* Save registers and setup stack frame. */ + stm %r6,%r15,24(%r15) + lr %r1,%r15 + ahi %r15,-120 /* buy stack space */ + st %r1,0(%r15) /* store back chain */ + + /* Store parameters on stack, because old_mmap/mmap2 + * take only one parameter: a pointer to the parameter area + */ + st %r6,0x70(%r15) /* Store 'fd'. */ + st %r5,0x6C(%r15) /* Store 'flags'. */ + st %r4,0x68(%r15) /* Store 'prot'. */ + st %r3,0x64(%r15) /* Store 'length'. */ + st %r2,0x60(%r15) /* Store 'start'. */ + l %r1,216(%r15) /* Load offset. */ + + tml %r1,0x0fff /* Offset page aligned ? */ + lhi %r2,-EINVAL + jnz 1f /* No -> EINVAL. */ + srl %r1,12 /* mmap2 takes the offset in pages. */ + st %r1,0x74(%r15) /* Store page offset. */ + la %r2,0x60(%r15) /* Load address of parameter list. */ + svc __NR_mmap2 /* Do the system call trap. */ + +1: l %r15,0(%r15) /* Load back chain. */ + lm %r6,%r15,24(%r15) /* Load registers. */ + + j __unified_syscall + + /* check gpr 2 for error */ +// lhi %r0,-4096 +// clr %r2,%r0 +// jnl SYSCALL_ERROR_LABEL + + /* Successful; return the syscall's value. */ +// br %r14 + diff -uNr dietlibc-0.23/s390/start.S dietlibc-0.24/s390/start.S --- dietlibc-0.23/s390/start.S Thu Nov 29 14:25:16 2001 +++ dietlibc-0.24/s390/start.S Fri Oct 10 15:06:18 2003 @@ -18,6 +18,14 @@ sll %r4,2 la %r4,8(%r4,%r15) +/* align the stack to a double word boundary */ + lhi %r0,-8 + nr %r15,%r0 + +/* Setup a stack frame and a parameter area */ + ahi %r15,-104 # make room on stack + xc 0(4,%r15),0(%r15) # clear back-chain + /* environ = envp */ l %r1,8(%r13) st %r4,0(%r1) diff -uNr dietlibc-0.23/s390/unified.S dietlibc-0.24/s390/unified.S --- dietlibc-0.23/s390/unified.S Mon Jan 21 16:55:19 2002 +++ dietlibc-0.24/s390/unified.S Fri Oct 10 15:06:18 2003 @@ -11,9 +11,9 @@ svc __NR_exit .global __unified_syscall __unified_syscall: - lhi %r4,-4095 + lhi %r4,-127 clr %r2,%r4 - jm .Lnoerror + jl .Lnoerror .global __error_unified_syscall __error_unified_syscall: diff -uNr dietlibc-0.23/s390x/Makefile.add dietlibc-0.24/s390x/Makefile.add --- dietlibc-0.23/s390x/Makefile.add Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/s390x/Makefile.add Fri Oct 10 15:06:45 2003 @@ -0,0 +1,4 @@ + +CFLAGS+=-Os # -fomit-frame-pointer -fstrict-aliasing +VPATH:=s390x:syscalls.s:$(VPATH) +LIBOBJ+=$(OBJDIR)/__waitpid.o diff -uNr dietlibc-0.23/s390x/__longjmp.S dietlibc-0.24/s390x/__longjmp.S --- dietlibc-0.23/s390x/__longjmp.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/s390x/__longjmp.S Fri Oct 10 15:06:45 2003 @@ -0,0 +1,15 @@ +#include + +.text +.global __longjmp +.type __longjmp,@function +__longjmp: + lm %r6,%r15,0(%r2) + ld %f6,48(%r2) + ld %f4,40(%r2) + chi %r3,0 + jne 1f + lhi %r3,1 +1: lr %r2,%r3 + br %r14 +.size __longjmp,.-__longjmp; diff -uNr dietlibc-0.23/s390x/__testandset.S dietlibc-0.24/s390x/__testandset.S --- dietlibc-0.23/s390x/__testandset.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/s390x/__testandset.S Fri Oct 10 15:06:45 2003 @@ -0,0 +1,11 @@ +.text +.global __testandset +.type __testandset,@function +__testandset: + la %r1,0(%r2) + lhi %r0,1 + lhi %r2,0 + cs %r2,%r0,0(%r1) + xr %r2,%r0 + br %r14 + diff -uNr dietlibc-0.23/s390x/__waitpid.c dietlibc-0.24/s390x/__waitpid.c --- dietlibc-0.23/s390x/__waitpid.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/s390x/__waitpid.c Fri Oct 10 15:06:45 2003 @@ -0,0 +1,5 @@ +#include + +pid_t waitpid(int pid, int * wait_stat, int flags) { + return wait4(pid, wait_stat, flags, 0); +} diff -uNr dietlibc-0.23/s390x/clone.S dietlibc-0.24/s390x/clone.S --- dietlibc-0.23/s390x/clone.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/s390x/clone.S Fri Oct 10 15:06:45 2003 @@ -0,0 +1,37 @@ +#include +#include "syscalls.h" + +.text +.align 4 +.global __clone +.type __clone,@function +__clone: + ltr %r1, %r2 + lhi %r2, -EINVAL + jz .Lerror + ltr %r3, %r3 + jz .Lerror + lr %r2, %r3 + lr %r3, %r4 + svc __NR_clone + ltr %r2, %r2 + jm .Lerror + jz thread_start + br %r14 + +thread_start: + lr %r2, %r5 + sr %r11,%r11 + ahi %r15,-96 + basr %r14,%r1 + + basr %r1, %r0 +.L0: al %r1, [.L1-.L0](%r1) + br %r1 +.L1: .long _exit-.L0 + +.Lerror: + basr %r1, %r0 +.L2: al %r1, [.L3-.L2](%r1) + br %r1 +.L3: .long __error_unified_syscall-.L0 diff -uNr dietlibc-0.23/s390x/mmap.S dietlibc-0.24/s390x/mmap.S --- dietlibc-0.23/s390x/mmap.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/s390x/mmap.S Fri Oct 10 15:06:45 2003 @@ -0,0 +1,36 @@ +#include +#include "syscalls.h" + + .text + .align 4 + .global mmap + .type mmap,@function +mmap: + /* Save registers and setup stack frame. */ + stmg %r6,%r15,48(%r15) + lgr %r1,%r15 + lg %r0,8(%r15) /* Load eos. */ + aghi %r15,-208 /* Buy stack space. */ + stg %r1,0(%r15) /* Store back chain. */ + stg %r0,8(%r15) /* Store eos. */ + + /* Store parameters on stack, because old_mmap + takes only one parameter: a pointer to the parameter area. */ + mvc 200(8,%r15),368(%r15) /* Move 'offset'. */ + lgfr %r6,%r6 + stg %r6,192(%r15) /* Store 'fd'. */ + lgfr %r5,%r5 + stg %r5,184(%r15) /* Store 'flags'. */ + lgfr %r4,%r4 + stg %r4,176(%r15) /* Store 'prot'. */ + stg %r3,168(%r15) /* Store 'length'. */ + stg %r2,160(%r15) /* Store 'start'. */ + + la %r2,160(%r15) /* Load address of parameter list. */ + /* Do the system call trap. */ + svc __NR_mmap + + lg %r15,0(%r15) /* Load back chain. */ + lmg %r6,%r15,48(%r15) /* Load registers. */ + + j __unified_syscall diff -uNr dietlibc-0.23/s390x/setjmp.S dietlibc-0.24/s390x/setjmp.S --- dietlibc-0.23/s390x/setjmp.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/s390x/setjmp.S Fri Oct 10 15:06:45 2003 @@ -0,0 +1,40 @@ +#include + +.text +.weak setjmp +.type setjmp,@function +setjmp: +.global __setjmp +.type __setjmp,@function +__setjmp: + lhi %r3,1 + j __sigsetjmp +.size __setjmp,.-__setjmp +.size setjmp,.-setjmp + +.global _setjmp +.type _setjmp,@function + lhi %r3,0 +.size _setjmp,.-_setjmp + + +.global __sigsetjmp +.type __sigsetjmp,@function +__sigsetjmp: + stm %r6,%r15,0(%r2) + std %f4,40(%r2) + std %f6,48(%r2) + + /* Make a tail call to __sigjmp_save; it takes the same args. */ + basr %r1,%r0 +#ifdef PIC +.L0: la %r1,.L1-.L0(0,%r1) + l %r1,__sigjmp_save@GOT12(0,%r1) + br %r1 +.L1: .long _GLOBAL_OFFSET_TABLE_-.L0 +#else + l %r1,.L1(0,%r1) + br %r1 +.L1: .long __sigjmp_save +#endif +.size __sigsetjmp,.-__sigsetjmp; diff -uNr dietlibc-0.23/s390x/start.S dietlibc-0.24/s390x/start.S --- dietlibc-0.23/s390x/start.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/s390x/start.S Fri Oct 10 15:06:45 2003 @@ -0,0 +1,44 @@ +#include "dietfeatures.h" + +.text +.global _start +_start: +#ifdef WANT_DYNAMIC + lgr %r5,%r14 /* save dynamic ld.so _fini */ +#endif + lg %r2,0(%r15) /* argc */ + la %r3,8(%r15) /* argv */ + +/* envp = argv + ( (argc+1)*8 ) */ + lgr %r4,%r2 + sll %r4,3 + la %r4,16(%r4,%r15) + +/* align the stack to a double word boundary */ + lghi %r0,-16 + ngr %r15,%r0 + +/* Setup a stack frame and a parameter area */ + aghi %r15,-176 /* make room on stack */ + xc 0(8,%r15),0(%r15) /* clear back-chain */ + +/* environ = envp */ + larl %r13,environ + stg %r4,0(%r13) + +/* call main or _dyn_start */ +#ifdef WANT_DYNAMIC + brasl %r14,_dyn_start +#else + brasl %r14,main +#endif + +/* call exit */ + brasl %r14,exit + +/* DIE! */ + .word 0 + +.align 4 +.Lstart: + .size _start,.Lstart-_start diff -uNr dietlibc-0.23/s390x/syscalls.h dietlibc-0.24/s390x/syscalls.h --- dietlibc-0.23/s390x/syscalls.h Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/s390x/syscalls.h Fri Oct 10 15:06:45 2003 @@ -0,0 +1,277 @@ + +#define __NR_exit 1 +#define __NR_fork 2 +#define __NR_read 3 +#define __NR_write 4 +#define __NR_open 5 +#define __NR_close 6 +//#define __NR_waitpid 7 +#define __NR_creat 8 +#define __NR_link 9 +#define __NR_unlink 10 +#define __NR_execve 11 +#define __NR_chdir 12 +#define __NR_time 13 +#define __NR_mknod 14 +#define __NR_chmod 15 +#define __NR_lchown 16 +//#define __NR_break 17 +//#define __NR_oldstat 18 +#define __NR_lseek 19 +#define __NR_getpid 20 +#define __NR_mount 21 +#define __NR_umount 22 +#define __NR_setuid 23 +#define __NR_getuid 24 +#define __NR_stime 25 +#define __NR_ptrace 26 +#define __NR_alarm 27 +//#define __NR_oldfstat 28 +#define __NR_pause 29 +#define __NR_utime 30 +//#define __NR_stty 31 +//#define __NR_gtty 32 +#define __NR_access 33 +#define __NR_nice 34 +//#define __NR_ftime 35 +#define __NR_sync 36 +#define __NR_kill 37 +#define __NR_rename 38 +#define __NR_mkdir 39 +#define __NR_rmdir 40 +#define __NR_dup 41 +#define __NR_pipe 42 +#define __NR_times 43 +//#define __NR_prof 44 +#define __NR_brk 45 +#define __NR_setgid 46 +#define __NR_getgid 47 +#define __NR_signal 48 +#define __NR_geteuid 49 +#define __NR_getegid 50 +#define __NR_acct 51 +#define __NR_umount2 52 +//#define __NR_lock 53 +#define __NR_ioctl 54 +#define __NR_fcntl 55 +//#define __NR_mpx 56 +#define __NR_setpgid 57 +//#define __NR_ulimit 58 +//#define __NR_oldolduname 59 +#define __NR_umask 60 +#define __NR_chroot 61 +#define __NR_ustat 62 +#define __NR_dup2 63 +#define __NR_getppid 64 +#define __NR_getpgrp 65 +#define __NR_setsid 66 +#define __NR_sigaction 67 +//#define __NR_sgetmask 68 +//#define __NR_ssetmask 69 +#define __NR_setreuid 70 +#define __NR_setregid 71 +#define __NR_sigsuspend 72 +#define __NR_sigpending 73 +#define __NR_sethostname 74 +#define __NR_setrlimit 75 +#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */ +#define __NR_getrusage 77 +#define __NR_gettimeofday 78 +#define __NR_settimeofday 79 +#define __NR_getgroups 80 +#define __NR_setgroups 81 +//#define __NR_select 82 +#define __NR_symlink 83 +//#define __NR_oldlstat 84 +#define __NR_readlink 85 +#define __NR_uselib 86 +#define __NR_swapon 87 +#define __NR_reboot 88 +#define __NR_readdir 89 +#define __NR_mmap 90 +#define __NR_munmap 91 +#define __NR_truncate 92 +#define __NR_ftruncate 93 +#define __NR_fchmod 94 +#define __NR_fchown 95 +#define __NR_getpriority 96 +#define __NR_setpriority 97 +//#define __NR_profil 98 +#define __NR_statfs 99 +#define __NR_fstatfs 100 +#define __NR_ioperm 101 +#define __NR_socketcall 102 +#define __NR_syslog 103 +#define __NR_setitimer 104 +#define __NR_getitimer 105 +#define __NR_stat 106 +#define __NR_lstat 107 +#define __NR_fstat 108 +//#define __NR_olduname 109 +//#define __NR_iopl 110 +#define __NR_vhangup 111 +#define __NR_idle 112 +//#define __NR_vm86old 113 +#define __NR_wait4 114 +#define __NR_swapoff 115 +#define __NR_sysinfo 116 +#define __NR_ipc 117 +#define __NR_fsync 118 +#define __NR_sigreturn 119 +#define __NR_clone 120 +#define __NR_setdomainname 121 +#define __NR_uname 122 +//#define __NR_modify_ldt 123 +#define __NR_adjtimex 124 +#define __NR_mprotect 125 +#define __NR_sigprocmask 126 +#define __NR_create_module 127 +#define __NR_init_module 128 +#define __NR_delete_module 129 +#define __NR_get_kernel_syms 130 +#define __NR_quotactl 131 +#define __NR_getpgid 132 +#define __NR_fchdir 133 +#define __NR_bdflush 134 +#define __NR_sysfs 135 +#define __NR_personality 136 +#define __NR_afs_syscall 137 /* Syscall for Andrew File System */ +#define __NR_setfsuid 138 +#define __NR_setfsgid 139 +#define __NR__llseek 140 +#define __NR_getdents 141 +#define __NR__newselect 142 +#define __NR_flock 143 +#define __NR_msync 144 +#define __NR_readv 145 +#define __NR_writev 146 +#define __NR_getsid 147 +#define __NR_fdatasync 148 +#define __NR__sysctl 149 +#define __NR_mlock 150 +#define __NR_munlock 151 +#define __NR_mlockall 152 +#define __NR_munlockall 153 +#define __NR_sched_setparam 154 +#define __NR_sched_getparam 155 +#define __NR_sched_setscheduler 156 +#define __NR_sched_getscheduler 157 +#define __NR_sched_yield 158 +#define __NR_sched_get_priority_max 159 +#define __NR_sched_get_priority_min 160 +#define __NR_sched_rr_get_interval 161 +#define __NR_nanosleep 162 +#define __NR_mremap 163 +#define __NR_setresuid 164 +#define __NR_getresuid 165 +//#define __NR_vm86 166 +#define __NR_query_module 167 +#define __NR_poll 168 +#define __NR_nfsservctl 169 +#define __NR_setresgid 170 +#define __NR_getresgid 171 +#define __NR_prctl 172 +#define __NR_rt_sigreturn 173 +#define __NR_rt_sigaction 174 +#define __NR_rt_sigprocmask 175 +#define __NR_rt_sigpending 176 +#define __NR_rt_sigtimedwait 177 +#define __NR_rt_sigqueueinfo 178 +#define __NR_rt_sigsuspend 179 +#define __NR_pread 180 +#define __NR_pwrite 181 +#define __NR_chown 182 +#define __NR_getcwd 183 +#define __NR_capget 184 +#define __NR_capset 185 +#define __NR_sigaltstack 186 +#define __NR_sendfile 187 +#define __NR_getpmsg 188 /* some people actually want streams */ +#define __NR_putpmsg 189 /* some people actually want streams */ +#define __NR_vfork 190 +#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */ +#define __NR_mmap2 192 +#define __NR_truncate64 193 +#define __NR_ftruncate64 194 +#define __NR_stat64 195 +#define __NR_lstat64 196 +#define __NR_fstat64 197 +#define __NR_lchown32 198 +#define __NR_getuid32 199 +#define __NR_getgid32 200 +#define __NR_geteuid32 201 +#define __NR_getegid32 202 +#define __NR_setreuid32 203 +#define __NR_setregid32 204 +#define __NR_getgroups32 205 +#define __NR_setgroups32 206 +#define __NR_fchown32 207 +#define __NR_setresuid32 208 +#define __NR_getresuid32 209 +#define __NR_setresgid32 210 +#define __NR_getresgid32 211 +#define __NR_chown32 212 +#define __NR_setuid32 213 +#define __NR_setgid32 214 +#define __NR_setfsuid32 215 +#define __NR_setfsgid32 216 +#define __NR_pivot_root 217 +#define __NR_mincore 218 +#define __NR_madvise 219 +#define __NR_madvise1 219 /* delete when C lib stub is removed */ +#define __NR_getdents64 220 +#define __NR_fcntl64 221 +#define __NR_readahead 222 +#define __NR_sendfile64 223 +#define __NR_setxattr 224 +#define __NR_lsetxattr 225 +#define __NR_fsetxattr 226 +#define __NR_getxattr 227 +#define __NR_lgetxattr 228 +#define __NR_fgetxattr 229 +#define __NR_listxattr 230 +#define __NR_llistxattr 231 +#define __NR_flistxattr 232 +#define __NR_removexattr 233 +#define __NR_lremovexattr 234 +#define __NR_fremovexattr 235 +#define __NR_gettid 236 +#define __NR_tkill 237 +#define __NR_futex 238 +#define __NR_sched_setaffinity 239 +#define __NR_sched_getaffinity 240 +#define __NR_security 241 /* syscall for security modules */ +/* + * Number 242 is reserved for tux + */ +#define __NR_io_setup 243 +#define __NR_io_destroy 244 +#define __NR_io_getevents 245 +#define __NR_io_submit 246 +#define __NR_io_cancel 247 +#define __NR_exit_group 248 +#define __NR_epoll_create 249 +#define __NR_epoll_ctl 250 +#define __NR_epoll_wait 251 +#define __NR_set_tid_address 252 +#define __NR_fadvise64 253 + +#define syscall_weak(name,wsym,sym) \ +.text; \ +.type wsym,@function; \ +.weak wsym; \ +wsym: ; \ +.type sym,@function; \ +.global sym; \ +sym: \ + svc __NR_##name ; \ + j __unified_syscall + +#define syscall(name,sym) \ +.text; \ +.type sym,@function; \ +.global sym; \ +sym: \ + svc __NR_##name ; \ + j __unified_syscall + diff -uNr dietlibc-0.23/s390x/unified.S dietlibc-0.24/s390x/unified.S --- dietlibc-0.23/s390x/unified.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/s390x/unified.S Fri Oct 10 15:06:45 2003 @@ -0,0 +1,46 @@ +#include +#include "syscalls.h" + +.text +.weak exit +.type exit,@function +exit: +.global _exit +.type _exit,@function +_exit: + svc __NR_exit +.global __unified_syscall +__unified_syscall: + lghi %r4,-127 + clr %r2,%r4 + jl .Lnoerror + +.global __error_unified_syscall +__error_unified_syscall: +#ifdef WANT_THREAD_SAFE + stmg %r13,%r15,104(%r15) + lgr %r0,%r15 + aghi %r15,-160 + stg %r0,0(%r15) + + lcr %r13,%r2 + brasl %r14,__errno_location + st %r13,0(%r2) + + lg %r15,0(%r15) + lmg %r13,%r15,104(%r15) +#else + lcr %r1,%r2 + larl %r3,errno + st %r1,0(%r3) +#endif + lghi %r2,-1 + +.Lnoerror: + +/* here we go and "reuse" the return for weak-void functions */ +#include "dietuglyweaks.h" + + br %r14 + +.align 4 diff -uNr dietlibc-0.23/sparc/memccpy.S dietlibc-0.24/sparc/memccpy.S --- dietlibc-0.23/sparc/memccpy.S Thu Sep 4 03:50:50 2003 +++ dietlibc-0.24/sparc/memccpy.S Thu Oct 16 12:03:44 2003 @@ -17,11 +17,11 @@ subcc %o3, 1, %o3 bl,a .Lret sub %g0, %o4, %o0 - ldub [%o1+%o4], %o5 + ldsb [%o1+%o4], %o5 + stb %o5, [%o0+%o4] cmp %o5, %o2 + bne .Lloop inc %o4 - bne,a .Lloop - stb %o5, [%o0+%o4] .Lret: retl add %o0, %o4, %o0 diff -uNr dietlibc-0.23/sparc/syscalls.h dietlibc-0.24/sparc/syscalls.h --- dietlibc-0.23/sparc/syscalls.h Wed Jul 11 19:52:50 2001 +++ dietlibc-0.24/sparc/syscalls.h Fri Nov 7 14:10:40 2003 @@ -138,10 +138,10 @@ #define __NR_rmdir 137 /* Common */ #define __NR_utimes 138 /* SunOS Specific */ #define __NR_stat64 139 /* Linux sparc32 Specific */ -/* #define __NR_adjtime 140 SunOS Specific */ +#define __NR_sendfile64 140 /* adjtime under SunOS */ #define __NR_getpeername 141 /* Common */ -/* #define __NR_gethostid 142 SunOS Specific */ -/* #define __NR_ni_syscall 143 ENOSYS under SunOS */ +#define __NR_futex 142 /* gethostid under SunOS */ +#define __NR_gettid 143 /* ENOSYS under SunOS */ #define __NR_getrlimit 144 /* Common */ #define __NR_setrlimit 145 /* Common */ #define __NR_pivot_root 146 /* Linux Specific, killpg under SunOS */ @@ -158,42 +158,42 @@ #define __NR_statfs 157 /* Common */ #define __NR_fstatfs 158 /* Common */ #define __NR_umount 159 /* Common */ -/* #define __NR_async_daemon 160 SunOS Specific */ -/* #define __NR_getfh 161 SunOS Specific */ +#define __NR_sched_set_affinity 160 /* Linux specific, async_daemon under SunOS */ +#define __NR_sched_get_affinity 161 /* Linux specific, getfh under SunOS */ #define __NR_getdomainname 162 /* SunOS Specific */ #define __NR_setdomainname 163 /* Common */ /* #define __NR_ni_syscall 164 ENOSYS under SunOS */ #define __NR_quotactl 165 /* Common */ -/* #define __NR_exportfs 166 SunOS Specific */ +#define __NR_set_tid_address 166 /* Linux specific, exportfs under SunOS */ #define __NR_mount 167 /* Common */ #define __NR_ustat 168 /* Common */ -/* #define __NR_semsys 169 SunOS Specific */ -/* #define __NR_msgsys 170 SunOS Specific */ -/* #define __NR_shmsys 171 SunOS Specific */ -/* #define __NR_auditsys 172 SunOS Specific */ -/* #define __NR_rfssys 173 SunOS Specific */ +#define __NR_setxattr 169 /* SunOS: semsys */ +#define __NR_lsetxattr 170 /* SunOS: msgsys */ +#define __NR_fsetxattr 171 /* SunOS: shmsys */ +#define __NR_getxattr 172 /* SunOS: auditsys */ +#define __NR_lgetxattr 173 /* SunOS: rfssys */ #define __NR_getdents 174 /* Common */ #define __NR_setsid 175 /* Common */ #define __NR_fchdir 176 /* Common */ -/* #define __NR_fchroot 177 SunOS Specific */ -/* #define __NR_vpixsys 178 SunOS Specific */ -/* #define __NR_aioread 179 SunOS Specific */ -/* #define __NR_aiowrite 180 SunOS Specific */ -/* #define __NR_aiowait 181 SunOS Specific */ -/* #define __NR_aiocancel 182 SunOS Specific */ +#define __NR_fgetxattr 177 /* SunOS: fchroot */ +#define __NR_listxattr 178 /* SunOS: vpixsys */ +#define __NR_llistxattr 179 /* SunOS: aioread */ +#define __NR_flistxattr 180 /* SunOS: aiowrite */ +#define __NR_removexattr 181 /* SunOS: aiowait */ +#define __NR_lremovexattr 182 /* SunOS: aiocancel */ #define __NR_sigpending 183 /* Common */ #define __NR_query_module 184 /* Linux Specific */ #define __NR_setpgid 185 /* Common */ -/* #define __NR_pathconf 186 SunOS Specific */ -/* #define __NR_fpathconf 187 SunOS Specific */ -/* #define __NR_sysconf 188 SunOS Specific */ +#define __NR_fremovexattr 186 /* SunOS: pathconf */ +#define __NR_tkill 187 /* SunOS: fpathconf */ +#define __NR_exit_group 188 /* Linux specific, sysconf undef SunOS */ #define __NR_uname 189 /* Linux Specific */ #define __NR_init_module 190 /* Linux Specific */ #define __NR_personality 191 /* Linux Specific */ -/* #define __NR_prof 192 Linux Specific */ -/* #define __NR_break 193 Linux Specific */ -/* #define __NR_lock 194 Linux Specific */ -/* #define __NR_mpx 195 Linux Specific */ +#define __NR_remap_file_pages 192 /* Linux Specific */ +#define __NR_epoll_create 193 /* Linux Specific */ +#define __NR_epoll_ctl 194 /* Linux Specific */ +#define __NR_epoll_wait 195 /* Linux Specific */ /* #define __NR_ulimit 196 Linux Specific */ #define __NR_getppid 197 /* Linux Specific */ #define __NR_sigaction 198 /* Linux Specific */ @@ -203,13 +203,13 @@ #define __NR_oldlstat 202 /* Linux Specific */ #define __NR_uselib 203 /* Linux Specific */ #define __NR_readdir 204 /* Linux Specific */ -/* #define __NR_ioperm 205 Linux Specific - i386 specific, unused */ +#define __NR_readahead 205 /* Linux Specific */ #define __NR_socketcall 206 /* Linux Specific */ #define __NR_syslog 207 /* Linux Specific */ -/* #define __NR_olduname 208 Linux Specific */ -/* #define __NR_iopl 209 Linux Specific - i386 specific, unused */ -/* #define __NR_idle 210 Linux Specific - was sys_idle, now unused */ -/* #define __NR_vm86 211 Linux Specific - i386 specific, unused */ +#define __NR_lookup_dcookie 208 /* Linux Specific */ +#define __NR_fadvise64 209 /* Linux Specific */ +#define __NR_fadvise64_64 210 /* Linux Specific */ +#define __NR_tgkill 211 /* Linux Specific */ #define __NR_waitpid 212 /* Linux Specific */ #define __NR_swapoff 213 /* Linux Specific */ #define __NR_sysinfo 214 /* Linux Specific */ @@ -232,8 +232,8 @@ #define __NR_time 231 /* Linux Specific */ /* #define __NR_oldstat 232 Linux Specific */ #define __NR_stime 233 /* Linux Specific */ -/* #define __NR_oldfstat 234 Linux Specific */ -/* #define __NR_phys 235 Linux Specific */ +#define __NR_statfs64 234 /* Linux Specific */ +#define __NR_fstatfs64 235 /* Linux Specific */ #define __NR__llseek 236 /* Linux Specific */ #define __NR_mlock 237 #define __NR_munlock 238 @@ -254,6 +254,17 @@ #define __NR_fdatasync 253 #define __NR_nfsservctl 254 #define __NR_aplib 255 +#define __NR_clock_settime 256 +#define __NR_clock_gettime 257 +#define __NR_clock_getres 258 +#define __NR_clock_nanosleep 259 +#define __NR_sched_getaffinity 260 +#define __NR_sched_setaffinity 261 +#define __NR_timer_settime 262 +#define __NR_timer_gettime 263 +#define __NR_timer_getoverrun 264 +#define __NR_timer_delete 265 +#define __NR_timer_create 266 #define syscall_weak(name,wsym,sym) \ .text; \ diff -uNr dietlibc-0.23/syscalls.h dietlibc-0.24/syscalls.h --- dietlibc-0.23/syscalls.h Sat Jul 20 17:11:43 2002 +++ dietlibc-0.24/syscalls.h Fri Oct 10 15:17:46 2003 @@ -11,9 +11,12 @@ #include "sparc/syscalls.h" #endif -#elif defined(__powerpc__) +#elif defined(powerpc) #include "ppc/syscalls.h" +#elif defined(__powerpc64__) +#include "ppc64/syscalls.h" + #elif defined(__mips__) #include "mips/syscalls.h" @@ -21,7 +24,11 @@ #include "arm/syscalls.h" #elif defined(__s390__) +#if defined(__s390x__) +#include "s390x/syscalls.h" +#else #include "s390/syscalls.h" +#endif #elif defined(__alpha__) #include "alpha/syscalls.h" diff -uNr dietlibc-0.23/syscalls.s/alarm.S dietlibc-0.24/syscalls.s/alarm.S --- dietlibc-0.23/syscalls.s/alarm.S Thu Oct 24 12:18:40 2002 +++ dietlibc-0.24/syscalls.s/alarm.S Fri Oct 10 15:15:08 2003 @@ -1,4 +1,6 @@ #include "syscalls.h" #ifdef __NR_alarm +#ifdef __NR_alarm syscall(alarm,alarm) #endif +#endif diff -uNr dietlibc-0.23/syscalls.s/capget.S dietlibc-0.24/syscalls.s/capget.S --- dietlibc-0.23/syscalls.s/capget.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/syscalls.s/capget.S Tue Oct 7 16:39:44 2003 @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(capget,capget) diff -uNr dietlibc-0.23/syscalls.s/capset.S dietlibc-0.24/syscalls.s/capset.S --- dietlibc-0.23/syscalls.s/capset.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/syscalls.s/capset.S Tue Oct 7 16:39:44 2003 @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(capset,capset) diff -uNr dietlibc-0.23/test/byteswap.c dietlibc-0.24/test/byteswap.c --- dietlibc-0.23/test/byteswap.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/test/byteswap.c Tue Nov 18 14:13:27 2003 @@ -0,0 +1,8 @@ +#include +#include + +main() { + printf("%x %x\n",bswap_16(0x1234),bswap_16(0x5678)); + printf("%lx\n",bswap_32(0x12345678)); + printf("%qx\n",bswap_64(0x123456789ABCDEFull)); +} diff -uNr dietlibc-0.23/test/fputc.c dietlibc-0.24/test/fputc.c --- dietlibc-0.23/test/fputc.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/test/fputc.c Sun Sep 14 06:40:37 2003 @@ -0,0 +1,9 @@ +#include +#include + +int main(void) { + assert(fputc('x', stdin) < 0); + fflush(NULL); + assert(ferror(stdin)); + return 0; +} diff -uNr dietlibc-0.23/test/printftest.c dietlibc-0.24/test/printftest.c --- dietlibc-0.23/test/printftest.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/test/printftest.c Fri Oct 17 16:36:38 2003 @@ -0,0 +1,149 @@ +#include + +char * format[] = { + "%", + "%0.", + "%.0", + "%+0.", + "%+.0", + "%.5", + "%+.5", + "%2.5", + "%22.5", + "%022.5", + "%#022.5", + "%-#022.5", + "%+#022.5", + "%-22.5", + "%+22.5", + "%--22.5", + "%++22.5", + "%+-22.5", + "%-+22.5", + "%-#022.5", + "%-#22.5", + "%-2.22", + "%+2.22", + "%-#02.22", + "%-#2.22", + "%-1.5", + "%1.5", + "%-#01.5", + "%-#1.5", + "%-#.5", + "%-#1.", + "%-#.", + NULL +}; + + +static void +intchk (const char *fmt) +{ + (void) printf("%15s :, \"", fmt); + (void) printf(fmt, 0); + (void) printf("\", \""); + (void) printf(fmt, 123); + (void) printf("\", \""); + (void) printf(fmt, -18); + (void) printf("\"\n"); +} + +static void +fltchk (const char *fmt) +{ + (void) printf("%15s :, \"", fmt); + (void) printf(fmt, 0.0); + (void) printf("\", \""); + (void) printf(fmt, 123.0001); + (void) printf("\", \""); + (void) printf(fmt, -18.0002301); + (void) printf("\"\n"); +} + +void main() +{ + char buf[256]; + int i; + + printf("%s\n\n", "# vim:syntax=off:"); + + /* integers */ + for(i=0;format[i];i++) { + strcpy(buf, format[i]); + strcat(buf, "d"); + intchk(buf); + } + + /* floats */ + for(i=0;format[i];i++) { + strcpy(buf, format[i]); + strcat(buf, "f"); + fltchk(buf); + } + /* hexa */ + for(i=0;format[i];i++) { + strcpy(buf, format[i]); + strcat(buf, "x"); + intchk(buf); + } + + printf("#%.4x %4x#\n", 4, 88); + printf("#%4x#\n",4); + printf("#%#22.8x#\n",1234567); + + printf("#%+2i#\n",18); + printf("#%i#\n",18); + printf("#%llu#\n",4294967297ULL); + printf("#%#x#\n",44444); + printf("#%-8i#\n",33); + printf("#%i#\n",18); + printf("#%d#\n",18); + printf("#%u#\n",18); + printf("#%lu#\n",18); + printf("#%li#\n",18); + printf("#%-+#06d#\n", -123); + printf("#%-+#6d#\n", -123); + printf("#%+#06d#\n", -123); + printf("#%06d#\n", -123); + printf("#%+15s#\n","ABCDEF"); + /* from ncurses make_keys */ + printf("{ %4d, %-*.*s },\t/* %s */\n", 139, 16, 16, "KEY_A1", "key_a1"); + printf("{ %4d, %-*.*s },\t/* %s */\n", 139, 16, 2, "KEY_A1", "key_a1"); + printf("{ %4d, %-*.*s },\t/* %s */\n", 139, 2, 16, "KEY_A1", "key_a1"); + printf("{ %4d, %-*.*s },\t/* %s */\n", 139, 16, 0, "KEY_A1", "key_a1"); + printf("{ %4d, %-*.*s },\t/* %s */\n", 139, 0, 16, "KEY_A1", "key_a1"); + printf("{ %4d, %-*.*s },\t/* %s */\n", 139, 0, 0, "KEY_A1", "key_a1"); + printf("{ %4d, %*.*s },\t/* %s */\n", 139, 16, 16, "KEY_A1", "key_a1"); + printf("{ %4d, %*.*s },\t/* %s */\n", 139, 16, 2, "KEY_A1", "key_a1"); + printf("{ %4d, %*.*s },\t/* %s */\n", 139, 2, 16, "KEY_A1", "key_a1"); + printf("{ %4d, %*.*s },\t/* %s */\n", 139, 16, 0, "KEY_A1", "key_a1"); + printf("{ %4d, %*.*s },\t/* %s */\n", 139, 0, 16, "KEY_A1", "key_a1"); + printf("{ %4d, %*.*s },\t/* %s */\n", 139, 0, 0, "KEY_A1", "key_a1"); + printf("%*.*f\n", 0, 16, 0.0); + printf("%*.*f\n", 16, 16, 0.0); + printf("%*.*f\n", 2, 2, -0.0); + printf("%*.*f\n", 20, 0, -123.123); + printf("%*.*f\n", 10, 0, +123.123); + + + i = printf("\"%s\"\n","A"); + printf("%i\n", i); + /* from glibc's tst-printf.c */ + + { + char buf[20]; + char buf2[512]; + int i; + + printf ("snprintf (\"%%30s\", \"foo\") == %d, \"%.*s\"\n", + snprintf (buf, sizeof (buf), "%30s", "foo"), (int) sizeof (buf), + buf); + memset(buf2,0,sizeof(buf)); + i=snprintf(buf2, 256, "%.9999u", 10); + printf("%i %i\n",i,strlen(buf2)); + + printf ("snprintf (\"%%.999999u\", 10) == %d\n", + snprintf(buf2, sizeof(buf2), "%.999999u", 10)); + } +} diff -uNr dietlibc-0.23/test/printftest.exp dietlibc-0.24/test/printftest.exp --- dietlibc-0.23/test/printftest.exp Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/test/printftest.exp Fri Oct 17 16:36:38 2003 @@ -0,0 +1,138 @@ +# vim:syntax=off: + + %d :, "0", "123", "-18" + %0.d :, "", "123", "-18" + %.0d :, "", "123", "-18" + %+0.d :, "+", "+123", "-18" + %+.0d :, "+", "+123", "-18" + %.5d :, "00000", "00123", "-00018" + %+.5d :, "+00000", "+00123", "-00018" + %2.5d :, "00000", "00123", "-00018" + %22.5d :, " 00000", " 00123", " -00018" + %022.5d :, " 00000", " 00123", " -00018" + %#022.5d :, " 00000", " 00123", " -00018" + %-#022.5d :, "00000 ", "00123 ", "-00018 " + %+#022.5d :, " +00000", " +00123", " -00018" + %-22.5d :, "00000 ", "00123 ", "-00018 " + %+22.5d :, " +00000", " +00123", " -00018" + %--22.5d :, "00000 ", "00123 ", "-00018 " + %++22.5d :, " +00000", " +00123", " -00018" + %+-22.5d :, "+00000 ", "+00123 ", "-00018 " + %-+22.5d :, "+00000 ", "+00123 ", "-00018 " + %-#022.5d :, "00000 ", "00123 ", "-00018 " + %-#22.5d :, "00000 ", "00123 ", "-00018 " + %-2.22d :, "0000000000000000000000", "0000000000000000000123", "-0000000000000000000018" + %+2.22d :, "+0000000000000000000000", "+0000000000000000000123", "-0000000000000000000018" + %-#02.22d :, "0000000000000000000000", "0000000000000000000123", "-0000000000000000000018" + %-#2.22d :, "0000000000000000000000", "0000000000000000000123", "-0000000000000000000018" + %-1.5d :, "00000", "00123", "-00018" + %1.5d :, "00000", "00123", "-00018" + %-#01.5d :, "00000", "00123", "-00018" + %-#1.5d :, "00000", "00123", "-00018" + %-#.5d :, "00000", "00123", "-00018" + %-#1.d :, " ", "123", "-18" + %-#.d :, "", "123", "-18" + %f :, "0.000000", "123.000100", "-18.000230" + %0.f :, "0", "123", "-18" + %.0f :, "0", "123", "-18" + %+0.f :, "+0", "+123", "-18" + %+.0f :, "+0", "+123", "-18" + %.5f :, "0.00000", "123.00010", "-18.00023" + %+.5f :, "+0.00000", "+123.00010", "-18.00023" + %2.5f :, "0.00000", "123.00010", "-18.00023" + %22.5f :, " 0.00000", " 123.00010", " -18.00023" + %022.5f :, "0000000000000000.00000", "0000000000000123.00010", "-000000000000018.00023" + %#022.5f :, "0000000000000000.00000", "0000000000000123.00010", "-000000000000018.00023" + %-#022.5f :, "0.00000 ", "123.00010 ", "-18.00023 " + %+#022.5f :, "+000000000000000.00000", "+000000000000123.00010", "-000000000000018.00023" + %-22.5f :, "0.00000 ", "123.00010 ", "-18.00023 " + %+22.5f :, " +0.00000", " +123.00010", " -18.00023" + %--22.5f :, "0.00000 ", "123.00010 ", "-18.00023 " + %++22.5f :, " +0.00000", " +123.00010", " -18.00023" + %+-22.5f :, "+0.00000 ", "+123.00010 ", "-18.00023 " + %-+22.5f :, "+0.00000 ", "+123.00010 ", "-18.00023 " + %-#022.5f :, "0.00000 ", "123.00010 ", "-18.00023 " + %-#22.5f :, "0.00000 ", "123.00010 ", "-18.00023 " + %-2.22f :, "0.0000000000000000000000", "123.0001000000000033196557", "-18.0002300999999995667622" + %+2.22f :, "+0.0000000000000000000000", "+123.0001000000000033196557", "-18.0002300999999995667622" + %-#02.22f :, "0.0000000000000000000000", "123.0001000000000033196557", "-18.0002300999999995667622" + %-#2.22f :, "0.0000000000000000000000", "123.0001000000000033196557", "-18.0002300999999995667622" + %-1.5f :, "0.00000", "123.00010", "-18.00023" + %1.5f :, "0.00000", "123.00010", "-18.00023" + %-#01.5f :, "0.00000", "123.00010", "-18.00023" + %-#1.5f :, "0.00000", "123.00010", "-18.00023" + %-#.5f :, "0.00000", "123.00010", "-18.00023" + %-#1.f :, "0.", "123.", "-18." + %-#.f :, "0.", "123.", "-18." + %x :, "0", "7b", "ffffffee" + %0.x :, "", "7b", "ffffffee" + %.0x :, "", "7b", "ffffffee" + %+0.x :, "", "7b", "ffffffee" + %+.0x :, "", "7b", "ffffffee" + %.5x :, "00000", "0007b", "ffffffee" + %+.5x :, "00000", "0007b", "ffffffee" + %2.5x :, "00000", "0007b", "ffffffee" + %22.5x :, " 00000", " 0007b", " ffffffee" + %022.5x :, " 00000", " 0007b", " ffffffee" + %#022.5x :, " 00000", " 0x0007b", " 0xffffffee" + %-#022.5x :, "00000 ", "0x0007b ", "0xffffffee " + %+#022.5x :, " 00000", " 0x0007b", " 0xffffffee" + %-22.5x :, "00000 ", "0007b ", "ffffffee " + %+22.5x :, " 00000", " 0007b", " ffffffee" + %--22.5x :, "00000 ", "0007b ", "ffffffee " + %++22.5x :, " 00000", " 0007b", " ffffffee" + %+-22.5x :, "00000 ", "0007b ", "ffffffee " + %-+22.5x :, "00000 ", "0007b ", "ffffffee " + %-#022.5x :, "00000 ", "0x0007b ", "0xffffffee " + %-#22.5x :, "00000 ", "0x0007b ", "0xffffffee " + %-2.22x :, "0000000000000000000000", "000000000000000000007b", "00000000000000ffffffee" + %+2.22x :, "0000000000000000000000", "000000000000000000007b", "00000000000000ffffffee" + %-#02.22x :, "0000000000000000000000", "0x000000000000000000007b", "0x00000000000000ffffffee" + %-#2.22x :, "0000000000000000000000", "0x000000000000000000007b", "0x00000000000000ffffffee" + %-1.5x :, "00000", "0007b", "ffffffee" + %1.5x :, "00000", "0007b", "ffffffee" + %-#01.5x :, "00000", "0x0007b", "0xffffffee" + %-#1.5x :, "00000", "0x0007b", "0xffffffee" + %-#.5x :, "00000", "0x0007b", "0xffffffee" + %-#1.x :, " ", "0x7b", "0xffffffee" + %-#.x :, "", "0x7b", "0xffffffee" +#0004 58# +# 4# +# 0x0012d687# +#+18# +#18# +#4294967297# +#0xad9c# +#33 # +#18# +#18# +#18# +#18# +#18# +#-123 # +#-123 # +#-00123# +#-00123# +# ABCDEF# +{ 139, KEY_A1 }, /* key_a1 */ +{ 139, KE }, /* key_a1 */ +{ 139, KEY_A1 }, /* key_a1 */ +{ 139, }, /* key_a1 */ +{ 139, KEY_A1 }, /* key_a1 */ +{ 139, }, /* key_a1 */ +{ 139, KEY_A1 }, /* key_a1 */ +{ 139, KE }, /* key_a1 */ +{ 139, KEY_A1 }, /* key_a1 */ +{ 139, }, /* key_a1 */ +{ 139, KEY_A1 }, /* key_a1 */ +{ 139, }, /* key_a1 */ +0.0000000000000000 +0.0000000000000000 +-0.00 + -123 + 123 +"A" +4 +snprintf ("%30s", "foo") == 30, " " +9999 255 +snprintf ("%.999999u", 10) == 999999 diff -uNr dietlibc-0.23/test/siglist.c dietlibc-0.24/test/siglist.c --- dietlibc-0.23/test/siglist.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/test/siglist.c Sat Oct 18 17:52:01 2003 @@ -0,0 +1,6 @@ +#include +#include + +main() { + puts(strsignal(SIGPIPE)); +} diff -uNr dietlibc-0.23/test/strptime.c dietlibc-0.24/test/strptime.c --- dietlibc-0.23/test/strptime.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/test/strptime.c Tue Nov 18 13:57:14 2003 @@ -0,0 +1,11 @@ +#define _XOPEN_SOURCE +#include + +main() { + char buf[1024]; + struct tm* t; + time_t T=time(0); + t=localtime(&T); + strftime(buf,sizeof(buf),"%c",t); + printf("%s\n",strptime(buf,"%c",t)); +} diff -uNr dietlibc-0.23/test/strtol.c dietlibc-0.24/test/strtol.c --- dietlibc-0.23/test/strtol.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.24/test/strtol.c Thu Nov 6 13:00:09 2003 @@ -0,0 +1,80 @@ +/* I took these tests from glibc. -Felix */ + +#include +#include +#include +#include + +main() { + char* c, *s; + + assert(strtol(s="123",&c,0)==123 && c==s+3); + assert(strtol(s="+123",&c,0)==123 && c==s+4); + assert(strtol(s=" 123",&c,0)==123 && c==s+5); + assert(strtol(s=" 123 ",&c,0)==123 && c==s+4); + assert(strtol(s=" -17",&c,0)==-17 && c==s+6); + + assert(strtol(s="0123",&c,0)==0123 && c==s+4); + assert(strtol(s="0123a",&c,0)==0123 && c==s+4); + assert(strtol(s="01239",&c,0)==0123 && c==s+4); + assert(strtol(s="0x123",&c,0)==0x123 && c==s+5); + assert(strtol(s="-0x123",&c,0)==-0x123 && c==s+6); + assert(strtol(s="0x0xc",&c,0)==0 && c==s+3); + assert(strtol(s=" +0x123fg",&c,0)==0x123f && c==s+8); + + assert(strtol(s="123",&c,16)==0x123 && c==s+3); + assert(strtol(s="0x123",&c,16)==0x123 && c==s+5); + assert(strtol(s="123",&c,8)==0123 && c==s+3); + assert(strtol(s="0123",&c,8)==0123 && c==s+4); + assert(strtol(s="0123",&c,10)==123 && c==s+4); + assert(strtol(s="0x123",&c,10)==0 && c==s+1); + + assert(strtol(s="abcd",&c,16)==0xabcd && c==s+4); + assert(strtol(s="AbCd",&c,16)==0xabcd && c==s+4); + assert(strtol(s="0xABCD",&c,16)==0xabcd && c==s+6); + assert(strtol(s="0Xabcd",&c,16)==0xabcd && c==s+6); + + assert(strtol(s="0xyz",&c,35)==33*35+34 && c==s+3); + assert(strtol(s="yz!",&c,36)==34*36+35 && c==s+2); + assert(strtol(s="-yz",&c,36)==-(34*36 + 35) && c==s+3); + assert(strtol(s="GhI4",&c,20)==((16*20 + 17)*20 + 18)*20 + 4 && c==s+4); + +#if LONG_MAX == 0x7fffffff + assert(strtol(s="2147483647",&c,0)==2147483647 && c==s+10 && errno==0); + assert(strtol(s="2147483648",&c,0)==2147483647 && c==s+10 && errno==ERANGE); + assert(strtol(s="214748364888",&c,0)==2147483647 && c==s+12 && errno==ERANGE); + assert(strtol(s="2147483650",&c,0)==2147483647 && c==s+10 && errno==ERANGE); + /* glibc will actually fail this because they don't set errno to 0 + * when returning 0x8000000 in non-failure cases. */ + assert(strtol(s="-2147483648",&c,0)==0x80000000 && c==s+11 && errno==0); + assert(strtol(s="-2147483649",&c,0)==0x80000000 && c==s+11 && errno==ERANGE); + assert(strtol(s="0x1122334455z",&c,16)==2147483647 && c==s+12 && errno==ERANGE); +#else + assert(strtol(s="9223372036854775807",&c,0)==9223372036854775807 && c==s+19 && errno==0); + assert(strtol(s="9223372036854775808",&c,0)==9223372036854775807 && c==s+19 && errno==ERANGE); + assert(strtol(s="922337203685477580777",&c,0)==9223372036854775807 && c==s+21 && errno==ERANGE); + assert(strtol(s="9223372036854775810",&c,0)==9223372036854775807 && c==s+19 && errno==ERANGE); + assert(strtol(s="-2147483648",&c,0)==-2147483648 && c==s+11 && errno==0); + assert(strtol(s="-9223372036854775808",&c,0)==0x8000000000000000 && c==s+20 && errno==0); + assert(strtol(s="-9223372036854775809",&c,0)==0x8000000000000000 && c==s+20 && errno==ERANGE); + assert(strtol(s="0x112233445566778899z",&c,0)==9223372036854775807 && c==s+20 && errno==ERANGE); + assert(strtol(s="0xFFFFFFFFFFFF00FF",&c,0)==9223372036854775807 && c==s+18 && errno==ERANGE); +#endif + + assert(strtoul(s=" 0",&c,0)==0 && c==s+3); + errno=0; assert(strtoul(s="0xffffffffg",&c,0)==0xffffffff && c==s+10 && errno==0); +#if LONG_MAX == 0x7fffffff + assert(strtoul(s="-0xfedcba98",&c,0)==0x01234568 && c==s+11 && errno==0); + assert(strtoul(s="0xf1f2f3f4f5",&c,0)==0xffffffff && c==s+12 && errno==ERANGE); + assert(strtoul(s="-0x123456789",&c,0)==0xffffffff && c==s+12 && errno==ERANGE); +#else + assert(strtoul(s="0xffffffffffffffffg",&c,0)==0xffffffffffffffff && c==s+18 && errno==0); + assert(strtoul(s="-0xfedcba987654321",&c,0)==0xf0123456789abcdf && c==s+18 && errno==0); + assert(strtoul(s="0xf1f2f3f4f5f6f7f8f9",&c,0)==0xffffffffffffffff && c==s+20 && errno==ERANGE); + assert(strtoul(s="-0x123456789abcdef01",&c,0)==0xffffffffffffffff && c==s+20 && errno==ERANGE); +#endif + + assert(strtoul(s="0x,",&c,0)==0 && c==s+1); + return 0; +} +