[comp.unix.questions] Linking Stub functions for testing

mstreet@crash.cts.com (Michael Street) (03/10/89)

I'm trying to test a C source code file that contains several separate
functions, one function at a time. To do this, I need to stub out the
other functions by linking in stub functions of the same name. I have
not been able to determine how to do this as the linker returns a 
multiply defined symbol error. There should be a way to tell the Link
Editor to ignore any previous definitions and use the last one. I do
not want to touch the existing source file.

I would appreciate any help in this matter. Thank you.

				Michael Street
-- 
UUCP: {cbosgd, hplabs!hp-sdd, sdcsvax, nosc}!crash!mstreet
ARPA: crash!mstreet@nosc.mil
INET: mstreet@crash.cts.com
PAPERNET: 1184 Blackbird St.  El Cajon,  CA.  92020
SOUNDNET: (619) 449-3515

Spock: "They are not the hell your whales."

chris@mimsy.UUCP (Chris Torek) (03/11/89)

In article <3898@crash.cts.com> mstreet@crash.cts.com (Michael Street) writes:
>I'm trying to test a C source code file that contains several separate
>functions, one function at a time. To do this, I need to stub out the
>other functions by linking in stub functions of the same name. I have
>not been able to determine how to do this as the linker returns a 
>multiply defined symbol error.

The .o file formats commonly found on Unix systems do not have
sufficiently detailed information to permit loading only the relevant
function(s) and data.  Instead, the linker must read the entire .o
file.  If you want to replace any particular function, you must supply
all symbols needed by the time ld gets around to noticing that .o file
(which must be an archive entry; ld loads all files whose names end in
.o whether needed then or not).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris