Kenwood HP 9000 Personal Computer User Manual


 
40 Chapter 2
What Happens When You Compile and Link a Program
What is an Object File?
What is an Object File?
An object file is basically a file containing machine language
instructions and data in a form that the linker can use to create an
executable program. Each routine or data item defined in an object file
has a corresponding symbol name by which it is referenced. A symbol
generated for a routine or data definition can be either a local
definition or global definition. Any reference to a symbol outside the
object file is known as an external reference.
To keep track of where all the symbols and external references occur, an
object file has a symbol table. The linker uses the symbol tables of all
input object files to match up external references to global definitions.
Local Definitions
A local definition is a definition of a routine or data that is accessible only
within the object file in which it is defined. Such a definition cannot be
accessed from another object file. Local definitions are used primarily by
debuggers, such as adb. More important for this discussion are global
definitions and external references.
Global Definitions
A global definition is a definition of a procedure, function, or data item
that can be accessed by code in another object file. For example, the C
compiler generates global definitions for all variable and function
definitions that are not static. The FORTRAN compiler generates
global definitions for subroutines and common blocks. In Pascal, global
definitions are generated for external procedures, external variables, and
global data areas for each module.
External References
An external reference is an attempt by code in one object file to access a
global definition in another object file. A compiler cannot resolve external
references because it works on only one source file at a time. Therefore,
the compiler simply places external references in an object file's symbol
table; the matching of external references to global definitions is left to
the linker or loader.