From c3db1c6939931bbfa3e108cb8813064711b58289 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Thu, 28 Jun 2012 14:56:50 +0200 Subject: [PATCH] various symbol referencing fixes make weak symbol references and namespace renames references the renamed versions. function renaming, weak symbol references and libc namespace.h protection interact in hairy ways and causes weak symbol references for renamed functions to be unresolved; e.g. vfork should be an alias for _vfork but _vfork doesn't exist because __vfork14() exists. this is a problem for dynamically linked executables as all symbols have to be resolved, used or not, at link time. it was masked by clang-compiled base system libraries but is a problem when gcc does it. --- lib/libc/include/namespace.h | 16 ++++++++-------- lib/libc/sys-minix/sem.c | 4 ---- lib/libc/sys-minix/vfork.c | 2 +- lib/libc/time/localtime.c | 14 +++++++------- lib/librefuse/Makefile | 2 +- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/lib/libc/include/namespace.h b/lib/libc/include/namespace.h index 6e47c11b0..077b2a89d 100644 --- a/lib/libc/include/namespace.h +++ b/lib/libc/include/namespace.h @@ -222,8 +222,8 @@ #define confstr _confstr #define csetexpandtc _csetexpandtc #define ctermid _ctermid -#define ctime_r _ctime_r -#define ctime_rz _ctime_rz +#define ctime_r __ctime_r50 +#define ctime_rz __ctime_rz50 #define daemon _daemon #define dbopen _dbopen #define devname _devname @@ -434,15 +434,15 @@ #define lcong48 _lcong48 #define llabs _llabs #define lldiv _lldiv -#define localtime_r _localtime_r -#define localtime_rz _localtime_rz +#define localtime_r __localtime_r50 +#define localtime_rz __localtime_rz50 #define lockf _lockf #define lrand48 _lrand48 #define lseek _lseek #define mergesort _mergesort #define mi_vector_hash _mi_vector_hash #define mkstemp _mkstemp -#define mktime_z _mktime_z +#define mktime_z __mktime_z50 #define mpool_close _mpool_close #define mpool_filter _mpool_filter #define mpool_get _mpool_get @@ -477,8 +477,8 @@ #define pmap_unset _pmap_unset #define pollts _pollts #define popen _popen -#define posix2time _posix2time -#define posix2time_z _posix2time_z +#define posix2time __posix2time50 +#define posix2time_z __posix2time_z50 #define pread _pread #define pselect _pselect #define psignal _psignal @@ -924,7 +924,7 @@ #define minix_mmap _minix_mmap #define minix_munmap _minix_munmap #define minix_munmap_text _minix_munmap_text -#define vfork _vfork +#define vfork __vfork14 #endif /* __minix */ #endif /* __weak_alias */ diff --git a/lib/libc/sys-minix/sem.c b/lib/libc/sys-minix/sem.c index 0deab40d2..afb9bb828 100644 --- a/lib/libc/sys-minix/sem.c +++ b/lib/libc/sys-minix/sem.c @@ -16,10 +16,6 @@ #include #include -#ifdef __weak_alias -__weak_alias(sem, _sem) -#endif - static int get_ipc_endpt(endpoint_t *pt) { return minix_rs_lookup("ipc", pt); diff --git a/lib/libc/sys-minix/vfork.c b/lib/libc/sys-minix/vfork.c index c4e8e4de5..bd489864a 100644 --- a/lib/libc/sys-minix/vfork.c +++ b/lib/libc/sys-minix/vfork.c @@ -5,7 +5,7 @@ #include #ifdef __weak_alias -__weak_alias(vfork, _vfork) +__weak_alias(vfork, __vfork14) #endif pid_t vfork() diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c index 194fd9cd5..f1be999a7 100644 --- a/lib/libc/time/localtime.c +++ b/lib/libc/time/localtime.c @@ -28,14 +28,14 @@ __RCSID("$NetBSD: localtime.c,v 1.54 2011/01/15 15:42:10 christos Exp $"); #include "reentrant.h" #if defined(__weak_alias) -__weak_alias(ctime_r,_ctime_r) -__weak_alias(ctime_rz,_ctime_rz) +__weak_alias(ctime_r,__ctime_r50) +__weak_alias(ctime_rz,__ctime_rz50) __weak_alias(daylight,_daylight) -__weak_alias(mktime_z,_mktime_z) -__weak_alias(localtime_r,_localtime_r) -__weak_alias(localtime_rz,_localtime_rz) -__weak_alias(posix2time,_posix2time) -__weak_alias(posix2time_z,_posix2time_z) +__weak_alias(mktime_z,__mktime_z50) +__weak_alias(localtime_r,__localtime_r50) +__weak_alias(localtime_rz,__localtime_rz50) +__weak_alias(posix2time,__posix2time50) +__weak_alias(posix2time_z,__posix2time_z50) __weak_alias(tzname,_tzname) #endif diff --git a/lib/librefuse/Makefile b/lib/librefuse/Makefile index d01b198bb..de640d259 100644 --- a/lib/librefuse/Makefile +++ b/lib/librefuse/Makefile @@ -1,6 +1,6 @@ # $NetBSD: Makefile,v 1.8 2007/11/05 13:41:52 pooka Exp $ -USE_FORT?= yes # data driven bugs? +USE_FORT?= no # data driven bugs? LIB= refuse LIBDPLIBS+= puffs ${.CURDIR}/../libpuffs