ARM Technical Support Knowledge Articles

ERROR 121 (IMPROPER FIXUP)

Applies to: BL51 Code-banking Linker/Locator

Answer

QUESTION

I have a FIXUP error when I link my program.

*** ERROR 121: IMPROPER FIXUP
    MODULE:  C:J1.OBJ (J1)
    SEGMENT: ?PR?MAIN?J1
    OFFSET:  0022

I have reduced my program to the following:

data int count;
idata char status[2];

void main (void)
  {
  char i;

  if (count < 261) count = 260;
  else if (count < 263)
    {
    i = status[count - 261];
    }
  }

What's wrong?

ANSWER

The above code appears as though it should work, but when you link it, the FIXUP error is generated. To find where the error occurs, check the OFFSET in the error message. In this case it is 0022 (Hex) in the J1.C file. If you look at the .LST file, you will see the following at this offset:

                                           ; SOURCE LINE # 12
0021 AF00    R     MOV     R7,count+01H
0023 7400    R     MOV     A,#status-0105H
0025 2F            ADD     A,R7
0026 F8            MOV     R0,A

Offset 0022 is where the compiler tries to calculate the offset of the status array minus the 261 that was used in the index.

    i = status[count - 261];

The problem with this is that status is an array in idata which is limited to 256 bytes in total space. Since the -261 is larger than a byte, the compiler/linker cannot resolve the address because the computed offset is 16-bits but the MOV instruction generated only allows for a byte.

To solve this problem requires a little creative type casting. The following code change solves the problem and generates the desired results:

    i = status[(unsigned char) count - (unsigned char) 261];

MORE INFORMATION

Article last edited on: 2005-07-19 15:14:05

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential