PCR Relocation Errors

Help
Jon Kirwan
2010-03-21
2013-03-12
  • Jon Kirwan
    Jon Kirwan
    2010-03-21

    (I apologize for placing this in Open Discussion first.  My mistake not noticing where I was posting at the time.)

    I'm receiving errors from the linker that I cannot seem to understand how to fix. The linker is complaining about a PC relative error, showing the following message:

    ?ASlink-Warning-Byte PCR relocation error
    file module area offset
    Refby C:\Projects\an curve CSEG 01F3
    Defin C:\Projects\an curve CSEG 00AD
    + c:\PROGRA~1\SDCC\BIN\sdld.exe -nf "C:\Projects\anh\SDCC\FOT_01\FOT_DEMO.lnk"
    + c:\PROGRA~1\SDCC\BIN\sdld.exe -nf "C:\Projects\anh\SDCC\FOT_01\FOT_DEMO.lnk" returned errorcode 2

    I'd probably have preferred it if the linker did a better job showing the file names, but I think I know that it must be coming from my curve.c file. However, there are no code changes there. The error occurs when I insert one line more of code into my main.c file and then recompile and link. Take the line out, the error goes away. Add it, it returns. Move the line down in main.c, anywhere is fine, and the error returns. Replace that line with something else that generates code, doesn't matter much what it is, and the error returns.

    This is a SiLabs 8051 type device.

    When I look at the map file, I can see that the address offset of 01F3 occurs in main. Which makes some sense, as that is what I'm modifying to get the error. So I'm guessing that some of the later code in main that attempts to access a function in curve.c can't get "patched up" correctly at link time. But I have no clue how to remedy the problem or how to nail down exactly what is happening here.

    Could someone provide a suggestion about the whys and wherefores of these errors (a predictable way to produce them?) or a useful discussion about the linker that might help me?

    Thanks,
    Jon

     
  • Jon Kirwan
    Jon Kirwan
    2010-03-21

    I may have my own answer.  Replacing an AJMP instruction in the curve.c code with an LJMP appears to have repaired it.  I believe there was a 2k block boundary issue that cropped up with certain coding in earlier-linked files that pushed curve.c code around. Good that the linker caught it.  Bad that it took seven hours for the idea to drift in to mind about why.

    Jon