From owner-freebsd-arch@FreeBSD.ORG Tue May 6 02:43:23 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E2D3237B401; Tue, 6 May 2003 02:43:22 -0700 (PDT) Received: from mailhub.fokus.fraunhofer.de (mailhub.fokus.fraunhofer.de [193.174.154.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8445C43F3F; Tue, 6 May 2003 02:43:21 -0700 (PDT) (envelope-from brandt@fokus.fraunhofer.de) Received: from beagle (beagle [193.175.132.100])h469hEE01833; Tue, 6 May 2003 11:43:14 +0200 (MEST) Date: Tue, 6 May 2003 11:43:13 +0200 (CEST) From: Harti Brandt To: Peter Jeremy In-Reply-To: <20030506092519.GA3158@cirb503493.alcatel.com.au> Message-ID: <20030506112711.K838@beagle.fokus.fraunhofer.de> References: <20030501182820.GA53641@madman.celabo.org> <20030505175426.GA19352@madman.celabo.org> <20030506092519.GA3158@cirb503493.alcatel.com.au> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-arch@freebsd.org Subject: Re: Re: `Hiding' libc symbols X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 May 2003 09:43:23 -0000 On Tue, 6 May 2003, Peter Jeremy wrote: PJ>On Tue, May 06, 2003 at 09:46:12AM +0200, Harti Brandt wrote: PJ>>On Mon, 5 May 2003, Jacques A. Vidrine wrote: PJ>>JAV>So, I advocate hiding all symbols in libc by default. The Real World PJ>>JAV>doesn't seem to care whether the symbols are defined by any standard or PJ>>JAV>not. PJ>> PJ>>No. If I define my own printf() I want that printf to be called even by PJ>>library internal calls. PJ> PJ>What if I define my own printf() that doesn't fully implement all the PJ>functionality of the FreeBSD printf()? It works meets all the requirements PJ>for my code (and maybe even runs correctly elsewhere) but doesn't work PJ>on FreeBSD because a library internal call (hypothetically) relies on PJ>functionality that I don't need. That's the fault of the application. When I replace a standard defined function I have to know what I do. The problem with printf and the entire stdio stuff is, that it has interdependencies between several functions. These come from using macros in stdio.h and using internal interfaces between these library functions. If a library function calls the librarie's printf it will end up in __svfwrite which knows the internals of how an i/o stream works. The application's replacement may function differently, it's printf may be based on calls to write() using fileno() or it may replace the entire stdio. In either case the application will simply not work. Here I have to support Terry's statement that replacing libc symbols has a long history and allows you to do things, that otherwise will be impossible or much harder. PJ>This is most likely to surface in functions like strlcpy(), strlcat() PJ>and snprintf() where the return value includes a reference to the PJ>size of the buffer that would be required to perform the requested PJ>operation without truncation. This is the most likely area where an PJ>implementor may cut corners if hir application does not rely on the PJ>return value. PJ> PJ>>The situation may be different for non-standardized functions with names PJ>>in the application space like err(). PJ> PJ>Last time I checked, the base system included a program that included its PJ>own err() function - with functionality substantially different to err(3). To say it otherwise: I think hiding names that are not in Posix/Ansi is a good thing, because we must assume, that applications have functions with the same names doing entirely different things. Hiding names that are not standardized functions, but are in the standard or implementation namespace is probably a good thing to do too. Hiding functions that are in the standards is a bad thing. If applications use these names, we should assume that the function does at least what the standard requires. If not the application is broken and must be fixed. Otherwise we will break an unknown number of applications. In your example: err() is a function from the first class, so hiding it would appropriate. (And I should say, that my pdp11 emulator suffered from exactly this problem: it had an err() function with a different arguments than that in libc. I had to replace it with a different name.) harti -- harti brandt, http://www.fokus.fraunhofer.de/research/cc/cats/employees/hartmut.brandt/private brandt@fokus.fraunhofer.de, harti@freebsd.org