Date: Wed, 20 May 1998 03:12:25 +0000 (GMT) From: Terry Lambert <tlambert@primenet.com> To: syssgm@dtir.qld.gov.au (Stephen McKay) Cc: tlambert@primenet.com, freebsd-current@FreeBSD.ORG, syssgm@dtir.qld.gov.au Subject: Re: Fix for undefined "__error" and discussion of shared object versioning Message-ID: <199805200312.UAA26227@usr04.primenet.com> In-Reply-To: <199805190928.TAA10958@troll.dtir.qld.gov.au> from "Stephen McKay" at May 19, 98 07:28:50 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> I still don't think this works. I'm not testing this live, I'm faking up > test cases. Assume I changed #ifndef __GNUC__ to #ifdef __GNUC__ already. > > I've renamed stuff to show the principle not working more easily: I dunno. I didn't protect with __GNUC__ in my test cases, and I used a live build tree with the real libc_r, linked shared. Your mileage may vary, but mine didn't. My gcc -v returns: ------------------------------------------------------------------------------ hermes% gcc -v gcc version 2.7.2.1 ------------------------------------------------------------------------------ It works the same on gcc 2.8.0, which I use for ACAP and C++ threads safe exceptions and the Standard Template Library. My errno.h code looks like this: -- errno.h ------------------------------------------------------------------- #ifndef KERNEL #include <sys/cdefs.h> __BEGIN_DECLS int * __error __P((void)); static int *___error(void) { extern int errno; return &errno; } #pragma weak __error = ___error #warning "using a fake errno.h" __END_DECLS #define errno (* __error()) #endif ------------------------------------------------------------------------------ My test case looks like: -- foo.c --------------------------------------------------------------------- #include "errno.h" /* use hacked errno.h because of paranoia*/ #include <stdio.h> main() { printf( "default errno is %d\n", errno); } ------------------------------------------------------------------------------ My non-libc_r linkage does: ------------------------------------------------------------------------------ hermes% cc -o foo foo.c In file included from foo.c:2: errno.h:51: warning: #warning "using a fake errno.h" hermes% ./foo default errno is 0 ------------------------------------------------------------------------------ My libc_r linkage does: ------------------------------------------------------------------------------ hermes% cc -o foo foo.c -lc_r In file included from foo.c:2: errno.h:51: warning: #warning "using a fake errno.h" hermes% ./foo default errno is 2 ------------------------------------------------------------------------------ The difference in the output is because PHK's malloc always fails a ``readlink("/etc/malloc.conf");'' and sets errno = ENOENT (2). Are you sure you are running a futzed up compiler, like egcs? > >It is, however, the correct one, I've decided, working on getting > >this hack to actually work. > > It would be a big pain though. Could we wait for ELF instead? > > >The versioning needs major, minor, and subminor. > > I don't see how your major/minor/subminor is any better than the > current major/minor, or how it would avoid the current problem. It would avoid the problem by letting us bump the minor but not the subminor when the errno.h change went in. So long as you did not foolishly replace an existing library of the same major/minor that you had built on your own, the executable would continue to prefer the old library to the new library you had built. The old library doesn't reference __error() via use of errno. > The current problem is due to replacing a global integer with a function. > Replacing one function with another would have been simple. The lesson > here is to have no global variables! Tell POSIX/ANSI about it. Call me if they actually listen to you, since I want some things fixed. 8-). Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199805200312.UAA26227>