This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler: How to link patch code to existing code in ROM



Tool/software: TI C/C++ Compiler

Hello,

    I am creating patch code that calls existing functions that are currently in ROM. Currently, this patch will include these functions in the patch code that I am creating, however I do not want to include these functions in my patch but rather use the existing ROM function. How would I implement this linking to the existing code?

    I have been reading the ARM Assembly Language Tools User Guide and have been reading about partial linking, absolute listing, and cross reference listing but these just dont seem to be what I am wanting to do. Do you have any suggestions on how to do this custom linking to existing ROM functions?

Thanks,

Wade Oler

  • I'm still a little unclear on what you want to do.  Just for now, presume you don't need to patch anything.  In your current build, how is a call to a function in ROM implemented?

    Thanks and regards,

    -George

  • You might have to go to the extreme of getting the address of the function in ROM and hard-code it with a function pointer.
  • George,
    Sorry for the confusion. My current build is for the ROM itself. So it looks just like a normal RAM build, but it is compiled for the ROM memory space with the --rom_model flag. Once this ROM is on the device we have implementing a patching mechanism, however, I cant figure out how to feed back in the location of these functions that currently exist in ROM to the linker.

    Keith,
    That was my backup plan. Generate an absolute listing then manually add a function pointer for all the functions that my patch would call. I just didnt know if there was a better/built in way to do that with the linker itself.
  • Does the rom_map.h file in the TivaWare used on TM4C devices address your use case?

    The rom_map.h allows the user of TivaWare to call either:

    a) A function in the device ROM.

    b) A function in the device flash.

    If a bug is found in a version in the mask-programmed ROM, then the TivaWare rom_map.h can be changed to deprecate a ROM function and force a bug-fixed version in flash to be used by the application instead.

    Also the interface to ROM functions in the TM4C devices are implemented by function pointers in lookup tables in fixed addresses in ROM. That allows the device ROM content to be updated without forcing the application code to be re-compiled.

  • I think I understand what TivaWare is doing. They are creating a section of rom where they put a jump table. In the jump table they save every address of every ROM function. They then have a specific known index location for the function pointer that someone can call when they want to use it.

    So essentially this is a step further than Keiths suggestion, because you now save the address of the function in a table in rom with a known fixed location for each function.
  • On the MSP 432 it happens automagically if you precede the function call with MAP_
  • I agree that the above suggestions are workarounds. I just wanted to see if there was a way to have the linker automatically link to existing ROM function locations by feeding the linker a special type of input file or command.
  • Wade Oler said:
    I just wanted to see if there was a way to have the linker automatically link to existing ROM function locations by feeding the linker a special type of input file or command.

    Unfortunately, no.  There is no feature of the linker specifically designed to solve this problem.

    Thanks and regards,

    -George