User manual
Linker ST Assembler-Linker
42/89 Doc ID 11392 Rev 4
5.5 The linker in more detail
5.5.1 The composition of the .OBJ files
The .OBJ files produced by the assembler contain an enormous amount of overhead,
mostly as coded expressions describing exactly what needs to go into the 'blank spaces' the
assembler has been so liberal with. The linker contains a full arithmetic parser for working
out complex expressions that include external labels: this means (unlike most other
assemblers) there are few restrictions on where external labels may appear.
The assembler also includes line-number information with the .OBJ file, connecting each
piece of generated object code with a line number from a given source file.
.OBJ files also contain 'special' markers for handling SKIP and DATE type directive.
5.5.2 The composition of the .COD files
The .COD files, on the other hand, contain very little overhead; there are six bytes per
segment that describe the start address and length of that segment. Besides that, the rest of
the code is in its final form. A segment of zero length marks the end of the file. It only
remains for OBSEND to take the code segment by segment and send it on to its destination.
5.5.3 Reading a mapfile listing
The linker also generates files with the suffix .SYM and .MAP in addition to the .COD file we
have already discussed. The .SYM file contains a compact symbol table list suitable with the
debuggers and simulators.
The .MAP file listing shows three important things: a table of segments with their absolute
address, a table of all classes in the program, and a list of all external labels with their true
values, modules they were defined in and size.
Here is an example MAPFILE, where one of the class, ROM, has gone past its limit,
overwriting (or more correctly, having part of itself overwritten by) VECTORS.
The [void] on some segments in the segment list says that these segments were not used
to create object code, but were used for non-coding-creating tasks such as allocating label
values with ds.b etc. The number in straight brackets on the segment as true address list
shows how many segments 'into' the module this segment is, that is, the 1
s
t
, 2
nd
etc. of the
given module. The first x-y shows the range of addresses. The def (line) field on the
external labels list shows the source code file and line number that this label was defined in.
The number at the start of each class list line is the cod-file that the class contents were sent
to (default is 0).
Segment address list:
prog [1] 10- 86 0- 6 ‘RAM0' [void]
prog [2] 88- 278 100- 138 'RAM1' [void]
main [1] 8- 563 8000- 875B 'eprom'
prog [4] 282- 889 C000- C508 'rom'
main [2] 568- 1456 C509- F578 'rom'
monitor [1] 8- 446 F579- FFF9 'rom'
monitor [2] 448- 467 FFEE- FFFF 'vectors’