10 linking – Epson S5U1C62000A User Manual
Page 112
100
EPSON
S5U1C62000A MANUAL
(S1C60/62 FAMILY ASSEMBLER PACKAGE)
CHAPTER 6: LINKER
6.10 Linking
Linking rules
The linking process takes place in conformity with the following rules:
• Absolute sections are mapped ahead of relocatable sections, according to the absolute addresses
which were defined at the time of assembling. If an absolute section exceeds the available memory
area, an error will occur.
• The relocatable sections in the file of which the section start address was specified with an option
(-rcode, -rbss) are mapped from the specified address. Other relocatable sections are mapped from top
of the relocatable CODE/BSS section.
• Basically, the relocatable sections except those that are specified with the -rcode or -rbss option are
arranged successively in the order of processing. However, if a relocatable section cannot be mapped
subsequent to the previous mapped section, for instance, there is unused area indicated by the ICE
parameter file, an already mapped absolute section or if there is a page boundary, the linker searches
another area to map the section. If there is no available area, an error will occur. A section is not
divided into two or more blocks when it is mapped.
After that, another section may be mapped in the vacant area if it is possible to map there.
If the -or option is specified, the linker tries to arrange as much as possible, a relocatable section in the
same page as the section that has many branching relationships in order to decrease unnecessary pset
instructions.
Restrictions on linking
Note that all sections may not be mapped depending on each section size or address specifications
even if the relocatable object size is within the available memory size.
Example of linking
A sample case where two relocatable object files, "test1.o" and "test2.o", are linked together under the
following condition is described further below.
Memory configuration of the model
ROM:
8K words (0x0000 to 0x1fff; 16 pages
×
2 banks)
RAM:
3,585 words (0x000 to 0xdff; 14 pages)
I/O memory: 512 words (0xe00 to 0xfff; 2 pages)
Relocatable object files
test1.o
CODE1
(relocatable)
BSS1
(relocatable)
CODE2
(absolute 0x000–)
(.org is used.)
(.org is used.)
BSS2
(absolute 0xe00–)
test2.o
CODE3
(relocatable)
BSS3
(absolute 0xf00–)
CODE4
(relocatable)
(.org is used.)
BSS4
(relocatable)
Fig. 6.10.1 Structure of sample relocatable files
Sample linker command file
-code 0x0100
; Relocatable CODE section start address
-rcode test2.o = 0x0110 ; CODE section start address of test2.o
-bss 0x0500
; Relocatable BSS section start address
-rbss test2.o = 0x600
; BSS section start address of test2.o
-o test.abs
; Output file name
test1.o
; Input file 1
test2.o
; Input file 2
When linking is executed with the commands defined above, the linker maps the sections of each
module in the manner graphically presented in Figure 6.10.2.