_why_ does the UNIX linker not distinguish text and data addresses???

Stephen Clamage steve at taumet.com
Wed Aug 1 02:25:17 AEST 1990


levy at mtcchi.uucp (Daniel R. Levy) writes:

|::::::::::::::
|a.c
|::::::::::::::
|main()
|{
|	(void) bogus();
|}

|::::::::::::::
|b.c
|::::::::::::::
|int bogus;

Traditional Unix object-file formats, and thus the linkers, are very
simple-minded.  They certainly could distinguish between text and
data addresses, but simply don't.  It is up to the programmer, even
in ANSI C, to take care that extern declarations/definitions in separate
compilation units match.  Lint will generally pick up mismatches.

In C++, BTW, this example will fail at link time no matter what linker
is used, since the type of the function is encoded by the compiler into
its true external name.
-- 

Steve Clamage, TauMetric Corp, steve at taumet.com



More information about the Comp.unix.questions mailing list