From: Thomas Veerman Date: Mon, 28 Nov 2011 10:12:44 +0000 (+0000) Subject: Fine grained compatibility with _RENAMEd symbols X-Git-Tag: v3.2.0~215 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.rndc.html?a=commitdiff_plain;h=fb50da9dadfa3b146f7b8d340dc01a80f203ce4a;p=minix.git Fine grained compatibility with _RENAMEd symbols The NetBSD libc provides a mechanism to have versions of system calls. By 'renaming' symbols to a new version, freshly compiled programs will automatically use the new symbol iff they use the proper header files. The old, not renamed, version of the symbol will still exist (after being moved to the compat directory), so old programs can still link. Since MINIX doesn't support dynamic linking, the whole rename mechanism doesn't really work for us. However, removing it would create a huge diff with the current NetBSD libc. A lot of the compat code relies on things we don't (seem to) have, and therefore does not get built and linked. This causes trouble for tools like autoconf, which will fail to find the renamed symbols. For example, currently select gets renamed to __select50 in libc. Autoconf looks for 'select' and doesn't find it and reports we don't have it. This is where the compat.S stub comes into play: it generates the old symbols and jumps to the new symbols. However, as this is done in one object file, all renamed symbols get linked together, causing binaries to be huge. This patch fixes that by generating an object file for each renamed symbol. This patch also makes the MISSING_SYSCALLS more complete and marginally reduces the diff with NetBSD. --- diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile index 839af3a2b..cb52a6158 100644 --- a/lib/libutil/Makefile +++ b/lib/libutil/Makefile @@ -10,22 +10,17 @@ USE_SHLIBDIR= yes WARNS= 4 LIB= util CPPFLAGS+=-DLIBC_SCCS -I${.CURDIR} -SRCS= efun.c getbootfile.c \ - getmntopts.c \ - login.c loginx.c login_tty.c logout.c logoutx.c \ - logwtmp.c logwtmpx.c opendisk.c \ +.if !defined(__MINIX) +SRCS+= efun.c getbootfile.c getlabelsector.c getmaxpartitions.c \ + getmntopts.c getrawpartition.c \ + disklabel_dkcksum.c disklabel_scan.c \ + if_media.c \ + login.c loginx.c login_cap.c login_tty.c logout.c logoutx.c \ + logwtmp.c logwtmpx.c opendisk.c parsedate.y \ passwd.c pw_scan.c pidfile.c pidlock.c pty.c \ raise_default_signal.c \ - secure_path.c snprintb.c \ - ttyaction.c login_cap.c stat_flags.c \ - #disklabel_dkcksum.c disklabel_scan.c \ - #if_media.c \ - #sockaddr_snprintf.c - #getlabelsector.c - #getmaxpartitions.c - #getrawpartition.c - #ttymsg.c - #parsedate.y + secure_path.c sockaddr_snprintf.c stat_flags.c \ + ttyaction.c ttymsg.c \ MAN= efun.3 getbootfile.3 getlabelsector.3 getmaxpartitions.3 \ getmntopts.3 \ @@ -38,13 +33,39 @@ MAN= efun.3 getbootfile.3 getlabelsector.3 getmaxpartitions.3 \ snprintb.3 sockaddr_snprintf.3 stat_flags.3 ttyaction.3 \ ttymsg.3 util.3 +.else +SRCS+= efun.c getbootfile.c \ + getmntopts.c \ + login.c loginx.c login_cap.c login_tty.c logout.c logoutx.c \ + logwtmp.c logwtmpx.c opendisk.c \ + passwd.c pw_scan.c pidfile.c pidlock.c pty.c \ + raise_default_signal.c \ + secure_path.c stat_flags.c \ + ttyaction.c \ + +MAN= efun.3 getbootfile.3 \ + getmntopts.3 \ + login.3 login_cap.3 loginx.3 \ + opendisk.3 openpty.3 pidfile.3 pidlock.3 \ + pw_getconf.3 pw_init.3 pw_lock.3 secure_path.3 \ + raise_default_signal.3 \ + snprintb.3 stat_flags.3 ttyaction.3 \ + util.3 +.endif + YPREFIX=__pd #.PATH: ${NETBSDSRCDIR}/lib/libc/gen .PATH: ${NETBSDSRCDIR}/lib/nbsd_libc/gen -#.include "compat/Makefile.inc" +.if defined(__MINIX) +.include "compat-minix/Makefile.inc" +.else +.include "compat/Makefile.inc" +.endif +.if !defined(__MINIX) MLINKS+=getlabelsector.3 getlabeloffset.3 +.endif MLINKS+=login.3 logout.3 MLINKS+=login.3 logwtmp.3 MLINKS+=login_cap.3 login_getclass.3 diff --git a/lib/libutil/compat-minix/Makefile.inc b/lib/libutil/compat-minix/Makefile.inc new file mode 100644 index 000000000..278e0ad7d --- /dev/null +++ b/lib/libutil/compat-minix/Makefile.inc @@ -0,0 +1,10 @@ + +ASM= compat__login_getpwclass50.S compat__login50.S compat__loginx50.S \ + compat__pw_copy50.S compat__pw_copyx50.S \ + compat__pw_getpwconf50.S compat__setusercontext50.S +SRCS+= ${ASM} + +${ASM}: + ${_MKTARGET_CREATE} + printf '/* MINIX3 */\n\n/*\n * Compatibility jump table for renamed symbols.\n *\n * DO NOT EDIT: this file is automatically generated.\n */\n.global ${.PREFIX:S/^compat__//:C/([0-9]{2})$//};\n.global ${.PREFIX:S/^compat//};\n${.PREFIX:S/^compat__//:C/([0-9]{2})$//}: jmp ${.PREFIX:S/^compat//}\n' >${.TARGET} + diff --git a/lib/libutil/compat/Makefile.inc b/lib/libutil/compat/Makefile.inc index 982ebe3a4..9e0f550a1 100644 --- a/lib/libutil/compat/Makefile.inc +++ b/lib/libutil/compat/Makefile.inc @@ -3,6 +3,5 @@ .PATH: ${.CURDIR}/compat CPPFLAGS+=-I${.CURDIR}/../libc -I${.CURDIR}/../../sys -SRCS+=compat_passwd.c compat_loginx.c compat_parsedate.c \ +SRCS+=compat_passwd.c compat_loginx.c compat_login.c compat_parsedate.c \ compat_login_cap.c - # compat_login.c diff --git a/lib/nbsd_libc/Makefile b/lib/nbsd_libc/Makefile index 4b124caf8..32e67e752 100644 --- a/lib/nbsd_libc/Makefile +++ b/lib/nbsd_libc/Makefile @@ -44,7 +44,6 @@ assym.h: ${ARCHDIR}/genassym.cf mv -f assym.h.tmp assym.h .endif -.if !defined(__MINIX) # The following controls how to build compatibility code for old NetBSD # binaries. If BUILDCOLD is yes, then we build a separate library; otherwise # we include the code in libc. @@ -53,11 +52,8 @@ BUILDCOLD?= no SUBDIR=compat .include .else -COMPATDIR=${.CURDIR}/compat -.include "${.CURDIR}/compat/Makefile.inc" -.endif -.else -BUILDCOLD= no +COMPATDIR= ${.CURDIR}/compat-minix +.include "${.CURDIR}/compat-minix/Makefile.inc" .endif .include "${.CURDIR}/../../common/lib/libc/Makefile.inc" diff --git a/lib/nbsd_libc/compat-minix/Makefile.inc b/lib/nbsd_libc/compat-minix/Makefile.inc new file mode 100644 index 000000000..afc7ead47 --- /dev/null +++ b/lib/nbsd_libc/compat-minix/Makefile.inc @@ -0,0 +1,38 @@ + +ASM= compat__opendir230.S compat__alphasort30.S compat__ctime50.S \ + compat__ctime_r50.S compat__ctime_rz50.S compat__dbm_delete13.S \ + compat__dbm_fetch13.S compat__dbm_firstkey13.S \ + compat__dbm_nextkey13.S compat__dbm_store13.S compat__difftime50.S \ + compat__fts_children60.S compat__fts_close60.S compat__fts_open60.S \ + compat__fts_read60.S compat__fts_set60.S compat__getdents30.S \ + compat__getitimer50.S compat__getlastlogx50.S compat__getpwent50.S \ + compat__getpwent_r50.S compat__getpwnam50.S compat__getpwnam_r50.S \ + compat__getpwuid50.S compat__getpwuid_r50.S compat__getutent50.S \ + compat__getutmp50.S compat__getutmpx50.S compat__getutxent50.S \ + compat__getutxid50.S compat__getutxline50.S compat__glob30.S \ + compat__globfree30.S compat__gmtime50.S compat__gmtime_r50.S \ + compat__localtime50.S compat__localtime_r50.S compat__localtime_rz50.S \ + compat__longjmp14.S compat__mknod50.S compat__mktime50.S \ + compat__mktime_z50.S compat__nanosleep50.S compat__offtime50.S \ + compat__offtime_r50.S compat__opendir30.S compat__posix2time50.S \ + compat__posix2time_z50.S compat__pututxline50.S \ + compat__pwcache_userdb50.S compat__readdir30.S compat__readdir_r30.S \ + compat___readdir_unlocked50.S compat__scandir30.S compat__select50.S \ + compat__setitimer50.S compat__setjmp14.S compat__setlocale50.S \ + compat__settimeofday50.S compat__shmctl50.S compat__sigaction14.S \ + compat__sigaddset14.S compat__sigdelset14.S compat__sigemptyset14.S \ + compat__sigfillset14.S compat__sigismember14.S compat__siglongjmp14.S \ + compat__sigpending14.S compat__sigprocmask14.S compat__sigsetjmp14.S \ + compat__sigsuspend14.S compat__time50.S compat__time2posix50.S \ + compat__time2posix_z50.S compat__timegm50.S compat__timelocal50.S \ + compat__timelocal_z50.S compat__timeoff50.S compat__tzalloc50.S \ + compat__tzfree50.S compat__tzgetname50.S compat__tzset50.S \ + compat__tzsetwall50.S compat__unsetenv13.S compat__unvis13.S \ + compat__updlastlogx50.S compat__updwtmpx50.S compat__utime50.S \ + compat__vfork14.S +SRCS+= ${ASM} + +${ASM}: + ${_MKTARGET_CREATE} + printf '/* MINIX3 */\n\n/*\n * Compatibility jump table for renamed symbols.\n *\n * DO NOT EDIT: this file is automatically generated.\n */\n.global ${.PREFIX:S/^compat__//:C/([0-9]{2})$//};\n.global ${.PREFIX:S/^compat//};\n${.PREFIX:S/^compat__//:C/([0-9]{2})$//}: jmp ${.PREFIX:S/^compat//}\n' >${.TARGET} + diff --git a/lib/nbsd_libc/sys-minix/MISSING_SYSCALLS b/lib/nbsd_libc/sys-minix/MISSING_SYSCALLS index d6de9689c..7093d1a20 100644 --- a/lib/nbsd_libc/sys-minix/MISSING_SYSCALLS +++ b/lib/nbsd_libc/sys-minix/MISSING_SYSCALLS @@ -33,6 +33,8 @@ munlock munlockall modctl mprotect +mq_timedreceive +mq_timedsend mremap msgctl msgget @@ -68,6 +70,7 @@ swapon sysarch timer_create timer_delete +timer_gettime timer_settime undelete utimes diff --git a/lib/nbsd_libc/sys-minix/Makefile.inc b/lib/nbsd_libc/sys-minix/Makefile.inc index 3442c9385..33bf63a5b 100644 --- a/lib/nbsd_libc/sys-minix/Makefile.inc +++ b/lib/nbsd_libc/sys-minix/Makefile.inc @@ -1,6 +1,6 @@ .PATH: ${.CURDIR}/sys-minix -SRCS+= accept.c access.c bind.c brk.c sbrk.c m_closefrom.c getsid.c compat.S \ +SRCS+= accept.c access.c bind.c brk.c sbrk.c m_closefrom.c getsid.c \ chdir.c chmod.c fchmod.c chown.c fchown.c chroot.c close.c \ connect.c dup.c dup2.c execve.c fcntl.c flock.c fpathconf.c fork.c \ fstatfs.c fstatvfs.c fsync.c ftruncate.c getdents.c getegid.c getgid.c \ diff --git a/lib/nbsd_libc/sys-minix/compat.S b/lib/nbsd_libc/sys-minix/compat.S deleted file mode 100644 index 2c25cfb55..000000000 --- a/lib/nbsd_libc/sys-minix/compat.S +++ /dev/null @@ -1,88 +0,0 @@ - -#define MY_ALIAS(alias, orig) \ - .global alias; \ - .global orig; \ - alias: jmp orig - -MY_ALIAS(mknod, __mknod50) -MY_ALIAS(ctime, __ctime50) -MY_ALIAS(difftime, __difftime50) -MY_ALIAS(gmtime, __gmtime50) -MY_ALIAS(localtime, __locatime50) -MY_ALIAS(time, __time50) -MY_ALIAS(mktime, __mktime50) -MY_ALIAS(tzset, __tzset50) -MY_ALIAS(getitimer, __getitimer50) -MY_ALIAS(setitimer, __setitimer50) -MY_ALIAS(settimeofday, __settimeofday50) -MY_ALIAS(nanosleep, __nanosleep50) -MY_ALIAS(ctime_r, __ctime_r50) -MY_ALIAS(gmtime_r, __gmtime_r50) -MY_ALIAS(localtime_r, __localtime_r50) -MY_ALIAS(time2posix, __time2posix50) -MY_ALIAS(posix2time, __posix2time50) -MY_ALIAS(timegm, __timegm50) -MY_ALIAS(timeoff, __timeoff50) -MY_ALIAS(timelocal, __timelocal50) -MY_ALIAS(offtime, __offtime50) -MY_ALIAS(tzsetwall, __tzsetwall50) -MY_ALIAS(offtime_r, __offtime_r50) -MY_ALIAS(localtime_rz, __localtime_rz50) -MY_ALIAS(ctime_rz, __ctime_rz50) -MY_ALIAS(mktime_z, __mktime_z50) -MY_ALIAS(timelocal_z, __timelocal_z50) -MY_ALIAS(time2posix_z, __time2posix_z50) -MY_ALIAS(posix2time_z, __posix2time_z50) -MY_ALIAS(tzalloc, __tzalloc50) -MY_ALIAS(tzfree, __tzfree50) -MY_ALIAS(tzgetname, __tzgetname50) -MY_ALIAS(select, __select50) -MY_ALIAS(opendir, __opendir30) -MY_ALIAS(readdir, __readdir30) -MY_ALIAS(readdir_r, __readdir_r30) -MY_ALIAS(__opendir2, __opendir230) -MY_ALIAS(scandir, __scandir30) -MY_ALIAS(getdents, __getdents30) -MY_ALIAS(alphasort, __alphasort30) -MY_ALIAS(fts_children, __fts_children60) -MY_ALIAS(fts_close, __fts_close60) -MY_ALIAS(fts_open, __fts_open60) -MY_ALIAS(fts_read, __fts_read60) -MY_ALIAS(fts_set, __fts_set60) -MY_ALIAS(glob, __glob30) -MY_ALIAS(globfree, __globfree30) -MY_ALIAS(dbm_delete, __dbm_delete13) -MY_ALIAS(dbm_fetch, __dbm_fetch13) -MY_ALIAS(dbm_firstkey, __dbm_firstkey13) -MY_ALIAS(dbm_nextkey, __dbm_nextkey13) -MY_ALIAS(dbm_store, __dbm_store13) -MY_ALIAS(setjmp, __setjmp14) -MY_ALIAS(longjmp, __longjmp14) -MY_ALIAS(setlocale, __setlocale50) -MY_ALIAS(shmctl, __shmctl50) -MY_ALIAS(sigsetjmp, __sigsetjmp14) -MY_ALIAS(siglongjmp, __siglongjmp14) -MY_ALIAS(sigaction, __sigaction14) -MY_ALIAS(sigaddset, __sigaddset14) -MY_ALIAS(sigdelset, __sigdelset14) -MY_ALIAS(sigemptyset, __sigemptyset14) -MY_ALIAS(sigfillset, __sigfillset14) -MY_ALIAS(sigismember, __sigismember14) -MY_ALIAS(sigpending, __sigpending14) -MY_ALIAS(sigprocmask, __sigprocmask14) -MY_ALIAS(sigsuspend, __sigsuspend14) -MY_ALIAS(unsetenv, __unsetenv13) -MY_ALIAS(getutent, __getutent50) -MY_ALIAS(getutxent, __getutxent50) -MY_ALIAS(getutxid, __getutxid50) -MY_ALIAS(getutxline, __getutxline50) -MY_ALIAS(pututxline, __pututxline50) -MY_ALIAS(updwtmpx, __updwtmpx50) -MY_ALIAS(getlastlogx, __getlastlogx50) -MY_ALIAS(updlastlogx, __updlastlogx50) -MY_ALIAS(getutmp, __getutmp50) -MY_ALIAS(getutmpx, __getutmpx50) -MY_ALIAS(utime, __utime50) -MY_ALIAS(unvis, __unvis13) -MY_ALIAS(pwcache_userdb, __pwcache_userdb50) -MY_ALIAS(getpwnam, __getpwnam50) diff --git a/nbsd_include/time.h b/nbsd_include/time.h index 8dd65863a..7360bc629 100644 --- a/nbsd_include/time.h +++ b/nbsd_include/time.h @@ -99,7 +99,11 @@ clock_t clock(void); char *ctime(const time_t *) __RENAME(__ctime50); double difftime(time_t, time_t) __RENAME(__difftime50); struct tm *gmtime(const time_t *) __RENAME(__gmtime50); +#ifndef __MINIX struct tm *localtime(const time_t *) __RENAME(__locatime50); +#else +struct tm *localtime(const time_t *) __RENAME(__localtime50); +#endif time_t time(time_t *) __RENAME(__time50); time_t mktime(struct tm *) __RENAME(__mktime50); #endif diff --git a/nbsd_include/unistd.h b/nbsd_include/unistd.h index eef4fffd3..84bdadd73 100644 --- a/nbsd_include/unistd.h +++ b/nbsd_include/unistd.h @@ -283,13 +283,9 @@ int symlink(const char *, const char *); void sync(void); useconds_t ualarm(useconds_t, useconds_t); int usleep(useconds_t); -#ifndef __minix #ifndef __LIBC12_SOURCE__ pid_t vfork(void) __RENAME(__vfork14); #endif -#else -pid_t vfork(void); -#endif /* !__minix */ #ifndef __AUDIT__ char *getwd(char *); /* obsoleted by getcwd() */