CHAPTER 5: LINKER

test1.o

 

0x0000

test.abs

 

 

CODE1

(relocatable)

 

0x00ff

0x0100

 

CODE2

(absolute 0x0100–)

CODE2

0x010f

0x0110

DATA1

(relocatable)

CODE3

 

 

 

 

 

BSS1

(relocatable)

 

 

 

 

 

 

 

BSS2

(absolute 0xf000–)

 

CODE4

 

 

test2.o

 

 

 

 

 

 

 

 

 

 

 

 

 

 

CODE3

(relocatable)

 

CODE1

 

 

CODE4

(relocatable)

 

 

 

 

DATA2

(absolute 0x8400–)

 

 

0x1fff

 

BSS3

(absolute 0xff00–)

0x8000

 

 

 

BSS4

(relocatable)

DATA1

 

 

 

 

 

 

 

0x8400

 

0x83ff

 

 

DATA2

 

 

 

 

 

 

 

 

 

 

 

0x87ff

 

Code ROM area

Data ROM area

0x0000

BSS1

 

 

 

 

 

 

 

0x0400

 

0x03ff

 

RAM area

BSS4

 

 

 

 

 

 

 

 

0x07ff

 

 

0xf000

 

 

 

 

BSS4

 

 

 

 

 

 

 

 

 

0xfeff

 

Display memory

0xff00

 

 

I/O memory area

BSS3

 

 

 

 

 

 

 

 

0xffff

 

 

Fig. 5.10.2 Example of linking

The absolute sections CODE2, BSS2, DATA2 and BSS3 are mapped to the location specified in the source files.

The start addresses of the CODE and BSS relocatable sections in "test2.o" is specified by the -rcode and -rbss options, so CODE3 is mapped from address 0x0110 and CODE 4 follows CODE3. BSS4 is mapped from address 0x0400.

Since the start addresses of the relocatable CODE, DATA and BSS sections in "test1.o" have not been specified, they are mapped from the relocatable section start addresses specified by the -code, -data and -bss options. First the linker will try to map CODE1 from address 0x0000 to address 0x00ff. If CODE 1 is smaller than 0x100 words, CODE1 can be mapped from address 0x0000. In this example, CODE1 is mapped behind CODE4 because CODE1 is larger than 0x100 words.

DATA1 is mapped from address 0x8000 and BSS1 is mapped from address 0x0000.

A section cannot be overlapped to other sections, therefore an error will occur if there is no free area larger than the section size. For example, an error will occur if CODE2 is larger than 0x10 words.

S5U1C63000A MANUAL

EPSON

101

(S1C63 FAMILY ASSEMBLER PACKAGE)