[comp.lang.c] How to link without stdio

roy@alanine.phri.nyu.edu (Roy Smith) (09/25/90)

	I have a program that used to use stdio, but I've converted to use
my own io package, which is very similar to stdio.  Mostly changing from
one to the other involved changing "getc", "fopen", etc to "rfgetc",
"rfopen", etc, everyplace they occurred.  To make sure I got all of them,
what I'd like to do is force the linker to ignore any stdio routines in
/lib/libc.a; that way, if there are any stdio calls left that I missed,
they will show up as link errors.  Any way to do this, other than
rebuilding libc.a from scratch, which seems impractical.
--
Roy Smith, Public Health Research Institute
455 First Avenue, New York, NY 10016
roy@alanine.phri.nyu.edu -OR- {att,cmcl2,rutgers,hombre}!phri!roy
"Arcane?  Did you say arcane?  It wouldn't be Unix if it wasn't arcane!"

wallace@ynotme.enet.dec.com (Ray Wallace) (09/26/90)

In article <1990Sep25.161300.29421@phri.nyu.edu>, roy@alanine.phri.nyu.edu (Roy Smith) writes...
>To make sure I got all of them,
>what I'd like to do is force the linker to ignore any stdio routines in
>/lib/libc.a; that way, if there are any stdio calls left that I missed,
Why not rename libc.a for the interim of the link (make sure no one else is
trying to link files at the same time).

---
Ray Wallace		
		(INTERNET,UUCP) wallace@oldtmr.enet.dec.com
		(UUCP)		...!decwrl!oldtmr.enet!wallace
		(INTERNET)	wallace%oldtmr.enet@decwrl.dec.com
---

cpcahil@virtech.uucp (Conor P. Cahill) (09/26/90)

In article <1990Sep25.161300.29421@phri.nyu.edu> roy@alanine.phri.nyu.edu (Roy Smith) writes:
>what I'd like to do is force the linker to ignore any stdio routines in
>/lib/libc.a; that way, if there are any stdio calls left that I missed,
>they will show up as link errors.  Any way to do this, other than
>rebuilding libc.a from scratch, which seems impractical.

There is no way to tell the linker to skip all stdio objects.  However,
you could ar xv libc.a and then search the objects for STDIO references
(using strings if you header files include ident strings, or nm (looking
for stdio functin references/declarations) otherwise) and then use 
ar cv testlibc.a with all the objects that did not match.

-- 
Conor P. Cahill            (703)430-9247        Virtual Technologies, Inc.,
uunet!virtech!cpcahil                           46030 Manekin Plaza, Suite 160
                                                Sterling, VA 22170 

ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) (09/26/90)

In article <1990Sep25.161300.29421@phri.nyu.edu>, roy@alanine.phri.nyu.edu (Roy Smith) writes:
> To make sure I got all of them,
> what I'd like to do is force the linker to ignore any stdio routines in
> /lib/libc.a

The simplest thing is to use the "nm -u" command to find out which external
symbols each of your object files wants, and to look for the stdio function
and variable names among those symbols.  That will tell you which of your
files still refers to stdio.
-- 
Fixed in the next release.

bengsig@oracle.nl (Bjorn Engsig) (09/27/90)

[It was asked how to make your own stdio and somehow have the compiler/linker
 complain if you used the default one.  Various followups suggested twidling
 around with /lib/libc.a]

As I also mailed directly to the original poster, this is in general not
possible.  I know of at least one system (IBM RISC/6000), where you cannot
remove parts of /lib/libc.a, since it contains little more than one big
object module, which is shared among all processes.

-- 
Bjorn Engsig,	Domain:		bengsig@oracle.nl, bengsig@oracle.com
		Path:		uunet!mcsun!orcenl!bengsig
		From IBM:	auschs!ibmaus!cs.utexas.edu!uunet!oracle!bengsig

conor@lion.inmos.co.uk (Conor O'Neill) (09/27/90)

In article <1990Sep25.223036.25429@virtech.uucp> cpcahil@virtech.UUCP (Conor P. Cahill) writes:
>In article <1990Sep25.161300.29421@phri.nyu.edu> roy@alanine.phri.nyu.edu (Roy Smith) writes:
>>what I'd like to do is force the linker to ignore any stdio routines in
>>/lib/libc.a; that way, if there are any stdio calls left that I missed,
>>they will show up as link errors.  Any way to do this, other than
>>rebuilding libc.a from scratch, which seems impractical.
>
>There is no way to tell the linker to skip all stdio objects.  However,
 [stuff deleted]


There is with my C compiler. "libc.a" doesn't even exist.

Please take UNIX specific bits out of comp.lang.c


---
Conor O'Neill, Software Group, INMOS Ltd., UK.
UK: conor@inmos.co.uk		US: conor@inmos.com
"It's state-of-the-art" "But it doesn't work!" "That is the state-of-the-art".