Section 4: Linker
303
TI
-
89 / TI
-
92 Plus Sierra C Assembler Reference Manual
Not for Distribution
Beta Version February 2, 2001
4.6. Relocation
Entries
An object file contains relocation information that describes how the code in the
file must be modified when it is copied to the executable output file. The
information is stored as a series of relocation entries. Each relocation entry
locates a byte, word, or long word in the object code that refers to an undefined
symbol. The piece of code referenced by a relocation entry is called a
relocation
hole. A relocation entry also specifies a symbol that the linker adds to the hole
when the linker moves code or resolves undefined symbols.
4.7.
Relocation Hole Compression
When the linker fills in a relocation hole, it is possible that the value it places
there could have fit in a smaller hole than was left by the assembler. This is
because the assembler, unless otherwise directed, leaves 32-bit absolute
relocation holes for references it cannot resolve. To avoid wasting space, asm68
and link68 together provide an option called
relocation hole compression which
can be used to shrink oversized holes. Shrinking relocation holes not only
reduces the size of your program, but also increases its execution speed.
The hole compression technique used by Sierra Systems uses a double
assembly and linkage pass, and decreases code size by an average of four to
seven percent. The actual size decrease (speed increase) depends on a number
of factors, such as the placement of the various output sections and the number
of external references in those sections. The increase in time resulting from the
double assembly/linkage passes has been determined to be minimal, especially
when considering that the compression process will typically be performed only
once as a final optimization. An example of both invocations of the linker required
for hole compression is shown below. The majority of the linker directives are
contained in the file app.lnk in this example. Refer to the sample files supplied
with the TI-89 / TI-92 Plus SDK for information on what should be included in
app.lnk.
link68 -h holes -i app.lnk
link68 -r -H holes.hco -i app.lnk
During the first pass, the assembler and linker are each invoked as they
ordinarily are, with the addition of the
-h
flag. The argument to this flag specifies
a file that will contain the names of the object files on which hole compression is
to be performed. It is generated incrementally by the assembler during each of its
first pass invocations and is used as an input file to the linker. This file is referred
to as the hole compression input file, and by convention is designated by the file
extension .hci. In addition to the names of the object files, this file includes the
command line arguments from each assembler invocation (needed for
regenerating the object files), as well as the size of the target processor’s
address bus (needed to ensure correct address computations by the linker).