OK, so why _does_ ld resolve text against data?

Richard Tobin richard at aiai.ed.ac.uk
Fri Aug 24 01:07:37 AEST 1990


In article <930 at eplunix.UUCP> das at eplunix.UUCP (David Steffens) writes:
>This actually happened to one of our programmers (a good one, IMHO).
>Should I call her "stupid" just because she doesn't know that "index"
>is a _dirty name_ and might be used by some vendor in writing his library?

A few points:

 - Having the linker refuse to resolve text references against data
   definitions (and vice versa) doesn't completely solve this problem.
   Suppose the programmer had written a procedure called "index"?

 - It's useful for the linker to resolve these references.  Pointers
   to procedures are often passed around as data, and it's often 
   useful to be able to execute code in the data segment.  It might
   be reasonable for the linker to *warn* about the latter case, or
   require a flag.

 - A large part of the problem is that library procedures you call
   (which you probably know about) often call other ones (which you
   may not know about).  I had to debug a program which had run quite
   happily until it was moved onto a machine which was a Sun yellow
   pages client, and suddenly getpwent() was calling select(), which
   the programmer had used as a variable name.  The solution is for
   library routines to call other library routines under different
   names (eg ones starting with __).  On the other hand, it can be
   useful to be able to replace a library routine and have other
   library routines use your version.

-- Richard
-- 
Richard Tobin,                       JANET: R.Tobin at uk.ac.ed             
AI Applications Institute,           ARPA:  R.Tobin%uk.ac.ed at nsfnet-relay.ac.uk
Edinburgh University.                UUCP:  ...!ukc!ed.ac.uk!R.Tobin



More information about the Comp.unix.wizards mailing list