Everything
11.4 Preventing E0562330 Errors in Cases Where Optimization by the Optimizing Linkage Editor is Enabled

The optimizing linkage editor is used for optimization, which involves replacing existing code with code that takes up less space in relation to the address where each symbol referred to by the original instruction is located. To reduce the size of the code as much as possible, the linkage editor will attempt to replace numerous instructions.

 

Replacing instructions may, however, change the addresses where individual symbols are located and thus prevent reference to symbols by the optimized code. In such cases, the optimizing linkage editor reports an E0562330 error and stops operations so that code having this problem will not be output.

 

Due to the characteristics of the RX architecture, this error may arise when any symbol (e.g. a variable, constant, or switch table) located at FFFF8000h or a higher address prior to optimization is allocated to an address below FFFF8000h after optimization.

 

(1)

Outline

Examples of conditions leading to E0562330 errors are given below.

 

In a program where the reading of constants CONST1 and CONST2 is intended, section P is followed by section C, which is allocated to address FFFF8000h prior to optimization.

 

Examples 1.

Section P

            ; 6-byte instruction MOV.L #_CONST1:32, R1
            MOV.L #0FFFF8002H, R1
 
            ; 6-byte instruction MOV.L #_CONST2:32, R2
            MOV.L #0FFFF8006H, R2

 

Section C

            _CONST0:                    ; Allocated to address FFFF8000h
                .byte 00H,01H
            _CONST1:                    ; Allocated to address FFFF8002h
                .byte "123"
                .byte 00H
            _CONST2:                    ; Allocated to address FFFF8006h
                .byte "abc"
                .byte 00H

 

Since optimization changes the address of section C from FFFF8000H (a 32-bit immediate value) to -8000H (a signed 16-bit immediate value), the 32-bit immediate-value transfer MOV.L instruction will be replaced by a 16-bit immediate-value transfer instruction.

This reduces the size of section P and leads to its allocation to a lower address than section C.

 

Examples 2.

Section P

            ; 4-byte instruction MOV.L #_CONST1:16, R1
            MOV.L #-8002H, R1 ; Exceeds the range of signed 16-bit values
 
            ; 4-byte instruction MOV.L #_CONST2:16, R2
            MOV.L #-7FFEH, R2

 

Section C

            _CONST0:                    ; Allocated to address FFFF7FFCh
                .byte 00H,01H
            _CONST1:                    ; Allocated to address FFFF7FFEh
                .byte "123"
                .byte 00H
            _CONST2:                    ; Allocated to address FFFF8002h
                .byte "abc"
                .byte 00H

 

Due to optimization of multiple MOV.L instructions, constant CONST1 is allocated to an address beyond the range of signed 16-bit values, leading to an E0562330 error as shown below.

 

Examples 3.

            E0562330:Relocation size overflow : "fileA.obj"-"P"-"0000002"

 

(2)

How to identify the cause

You can identify the cause of the error in the following way.

First, specify the optimizing linkage editor options nooptimize and list and build the user program to generate a link map file. Since the information on the allocation of sections begins from the line "*** Mapping List ***" in the link map file, check sections allocated to FFFF8000h and higher addresses.

 

Examples 4.

            *** Mapping List ***
            C
                                            ffff7ffc  ffff8005        a   1

 

After that, specify the assembler option listfile and build the user program to generate a source listing file. Find the section (P in example 3) in the source listing file for the object file ("fileA.obj" in example 3) indicated by the error message.

The offset value indicated by the error message is the value after optimization.

In the source listing file, locate the instructions that are at or above the offset address (0000002 in example 3) and references to any symbols within sections allocated to the address FFFF8000h or a higher address.

In example 5, you can see that the MOV.L instruction that attempts access to constant CONST1 in section C at an address above FFFF8000h is the reason for the error.

 

Examples 5.

                            .section P, CODE
            00000000 FB1Arrrr            MOV.L #_CONST1:16, R1 <- Access to section C
            00000004 FB2Arrrr            MOV.L #_CONST2:16, R2
 
                            .section C, ROMDATA
            00000000             _CONST0:
            00000000 0001           .byte 00H,01H
            00000002             _CONST1:
            00000002 313233         .byte "123"
            00000005 00             .byte 00H
            00000006             _CONST2:
            00000006 616263         .byte "abc"
            00000009 00             .byte 00H

 

(3)

Countermeasures

Select one of the following countermeasures.

 

-

Countermeasure 1: Change the order of sections

If the first address of a section allocated to address FFFF8000h or above before optimization is shifted to an address below FFFF8000h after optimization, use the start option to change the place of that section in the order of sections.

 

Example

Before:

            -start=P,C,L,D/FFFF7000

After (switching sections C and L):

            -start=P,L,C,D/FFFF7000

 

If an E0562330 error is still output even after the order of sections is switched, change the order again until the error is no longer output.

 

-

Countermeasure 2: Allocate the section to address FFFF8000h

If the first address of a section allocated to address FFFF8000h or above before optimization is shifted to an address below FFFF8000h after optimization, use the start option to allocate that section to address FFFF8000h.

 

Example

Before:

            -start=P,C,L,D/FFFF7000

After:

            -start=P/FFFF7000,C,L,D/FFFF8000

 

-

Countermeasure 3: Disable optimization by the optimizing linkage editor

Use the -nooptimize option to completely disable optimization or select the desired sub-options for the -optimize option to prevent the output of the E0562330 error while watching the reduction of the size of code by optimization.