HP UX Software Transition Kit (STK) manual Looking Inside a Compiler, What is an Object File?

Models: UX Software Transition Kit (STK)

1 228
Download 228 pages 54.84 Kb
Page 18
Image 18

Figure 1 High-level View of the Compiler

Looking Inside a Compiler

On the surface, it appears as though an HP-UX compiler generates an a.out file by itself. Actually, an HP-UX compiler is a driver that calls other commands to create the a.out file. The driver performs different tasks (or phases) for different languages, but two phases are common to all languages:

1.For each source file, the driver calls the language compiler to create an object file. (See also “What is an Object File?” (page 18))

2.The HP-UX linker (ld) links the specified object files to create either a reusable object file, also called a shared library, or an executable, which is named a.out by default unless a name is specified. (See also “Compiler-Linker Interaction” (page 19).)

Figure 2 summarizes how a compiler driver works.

Figure 2 Looking Inside a Compiler

The C, aC++, and Fortran90 compilers provide the -v(verbose) option to display the phases a compiler is performing.

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

18 Compiling and Linking Programs on HP-UX

Page 18
Image 18
HP UX Software Transition Kit (STK) manual Looking Inside a Compiler, What is an Object File?