This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C library calls at fixed ROM addresses

I need to write a small function running in XRAM that uses the C runtime library routines that are present in existing ROM code. I know the absolute locations of the library routines from the ROM link map. What is the syntax to force the BL51 linker to use these locations but not link in the code?

For example,
the internal multiply routine is at 0x17D8 in the ROM, common bank. I need to use this statement in a function:

 ...
 a = b * 5;
 ...

and I want the linker to LCALL 0x17D8 when it calls ?C?IMUL. This is running on a customized 80320 processor. I have specialized hardware that transfers control to XRAM when a selectable address in the ROM is about to be executed.

Thanks

  • Sounds like you want to resolve two different addresses for a function call at run-time.

    Without dynamic vectoring (which the lib's don't support), its going to be a bit difficult to do this without some post processing tricks.

    ???

  • I don't quite understand the question. You don't need to force the linker to use the addresses in the link map. It will use those anyway. (That's how they got into the link map in the first place.)

    It doesn't make any difference whether your program store is physically RAM or ROM. You have to decode your RAM into the code space in order to fetch and execute instructions there. (Normally I think of von Neumann memory the other way around; that is, mapping the code space into the xdata address space. Whatever.)

    Do you mean that you have ROM and a RAM that overlays that ROM, and you switch to the RAM when you execute at a certain address? (This would be some sort of specialized debubging hardware to let you set breakpoints in your code? Or perhaps some sort of patch buffer?) In that case, just fill the RAM with the complete program that matches the ROM -- assuming it's big enough and covers the whole address space.

    If you have part of the code space implemented in ROM and part in RAM, then tell the linker where to put the parts that live in RAM. The linker will call back down into the ROM segments normally.

    If the problem is just that you want an image of one bank of a banked application, then you could let the linker generate the entire image as it likes, and then just trim down the hex/bin/omf file to keep the part that you want.

  • OK,
    more info:
    This is a patch to an existing program in ROM code. The patches reside in XRAM while maintaining the context of Bank 3 of the ROM. Hardware makes this happen. The C runtime libraries exist in the common bank of the ROM. I have very little space in the XRAM so adding the libraries there is not an option.

    When I have implemented patches in assembly I have just called the library routines directly using LCALL. I want to be able to do the same thing from C. When I built a test function it compiled fine, but the multiplication operation is expecting the C runtime library multiply routine. I would like to set the link file or some pragma to get the linker to realize the library exists but that it does not have to actually link it into the absolute image. I could do this manually for my own functions but I cannot do it for the compiler as it specifies the routines it needs to generate the relocatable image.
    So to re-iterate: for example my C runtime library routine to multiply two integers is at location 0x1234 in the ROM. I know this by examining the link map generated by the ROM build. I want to configure the compiler and the linker such that when the compiler encounters "a = b * c" and calls the multiply routine, the linker supplies the absolute address as it exists in the ROM to my image.

  • how about compiling and linking the whole kit and kaboodle, then make a small routine that removes banks 0-2 fron the .hex file.

    Erik

  • Thanks,
    I'll try that. Let you know the results.

  • Could you just have a little assembler file that defines a Public label called "?C?IMUL" at the appropriate address?

    After all, as far as the linker is concerned, all symbols are just symbolic names for addresses - so all it needs is some (code) address to associate with the name "?C?IMUL"

  • This worked great! Thanks to all for the fast response.