Re: strange linking problem



Richard E Maine wrote:
In article <1114703379.735008.294480@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
 nicolasbock@xxxxxxxxx wrote:

(snip)

As far as I know, the linker goes through the object
files and looks for unsatisfied references to functions and variables.
Then it looks through the libraries and tries to satisfy those
references by linking code from the libraries into the executable.
(snip)

I'll try. For procedures (both functions and subroutines), you are right, but variables are different. For a procedure, things are relatively simple (in this regard). The linker sees 2 kinds of things: there are references to a procedure and there is a separate thing is the procedure itself. If you have references with no corresponding procedure, that is an error.

There might also be a difference between initialized data (as in BLOCK DATA), and uninitialized data (COMMON not in BLOCK DATA).


For data, however, it is possible to have multiple references to a data area, with nothing that actually is uniquely the data area itself. This is typical of non-initialized data areas. All that the linker sees is that there should be a data area of a certain size and a certain name. If something defines the area, then fine, that definition gets used. But if nothing otherwise defines the data area, the linker will allocate an an appropriate chunk of memory. This is not an error, and indeed is quite typical for COMMON blocks.

and static external variables in other languages that don't have COMMON.

I forget all the right terminology, but the "references" that the linker sees for the variable "test" here are probably of this type, where you won't get an error for a lack of other definition. The linker doesn't tend to look in libraries for this kind of reference.

As far as I know, it was Fortran's COMMON that historically started that
type of reference. It is used for external variables in other languages. The OS/360 linkers have one called SD, used for functions
and subroutines, and one called CM used for COMMON. There is another
type used for ENTRY, but has most of the same properties as SD.


OS/360 also has a reference type called weak, where it will be resolved
to point to an otherwise already loaded module, but won't cause it to
be loaded from the library.

As alluded to by others, this used to be quite a widespread problem with COMMON in f77 and earlier days. Modules are less prone to the problem, but it can still happen (only when the modules have no referenced procedures).

For OS/360 (and successors) initialized data (from BLOCK DATA) is SD,
just as subroutines and functions are. This can cause some interesting
effects if you accidentally (or not) name COMMON the same as a subroutine. OS/360 also requires that the initialized data be at least as long as the uninitialized data block with the same name. That was
once a limitation on a trick for specifying array sizes at link time
for already compiled subroutines.


-- glen

.



Relevant Pages

  • RE: Built in function errors.
    ... I have yet to work with 2007 and certainly not in a mixed environment. ... I've replaced UCase intrinsic function located in the Control ... ways of trying to match all the libraries but so far nothing has worked 100%. ... It is probably that these issues are not related to references. ...
    (microsoft.public.access.modulesdaovba)
  • RE: Built in function errors.
    ... I've replaced UCase intrinsic function located in the Control ... ways of trying to match all the libraries but so far nothing has worked 100%. ... It is probably that these issues are not related to references. ... updating the software on the client computer and reselecting all ...
    (microsoft.public.access.modulesdaovba)
  • Re: YASID: Gargoyles, but no rats
    ... There were some references to, I think, gargoyles that had ... libraries in town. ... or in the agents of a God. ...
    (rec.arts.sf.written)
  • Re: cycle through a table
    ... Doug Steele, Microsoft Access MVP ... "Phil" wrote in message ... >> program and object libraries that provide functionality that may be ... References to the specific library files, ...
    (microsoft.public.access.modulesdaovba)
  • Re: cycle through a table
    ... module as is: you have to run the SQL code using something like: ... >>>> program and object libraries that provide functionality that may be ... References to the specific library files, ... then go back in and unselect the reference you just added. ...
    (microsoft.public.access.modulesdaovba)