The N64 SDK provides the makerom tool to create a ROM image given a file describing the ROM layout called spec and the various object files it refers to such as the N64 OS, RCP microcode, and the game's code itself. Additionally, the manual recommends the use of overlays due to the memory restrictions of the console. However, the example described in the overlay page above does not provide details for creating overlays which are relocatable; instead they are at a fixed location.

This seemed simple enough to do by setting the RAW attribute so that any relocation info wouldn't be stripped. However, when doing this, the overlay and the boot segment were never linked by makerom, and as such any references to functions contained in the boot file are never resolved.

Is there any way to link my overlay with the boot segment as to resolve these references while keeping the boot and overlay segments separate without removing relocation information?

  • 1
    You sure you really want this? Overlays aren't automatic on the Nintendo 64, you need to write the code that copies them from ROM to RAM as necessary yourself. You would similarly need to write the code that relocates the overlay. Further it would also be your responsibility to adjust any references made by the boot segment (or anything else) to the overlay. – user722 Jul 17 '18 at 5:17
  • @RossRidge Yes, I already have DMA functions that can successfully load the overlay from ROM, and there are only a few types of relocation data that are actually used by my compiler, so it won’t be much of a problem. Finally, regarding references to the overlay, upon load, pointers to the overlay functions will be stored in a table to be referenced by the boot segment. My issue right now is just maintaining the relocation data. – fin Jul 17 '18 at 6:23
  • Well, from the looks of things you're going need to write your tool to create the ROM image. The makerom utility isn't going to know where or what format to store the relocations or how to populate your function table. If you can get your compiler to generate position-independent code that might help simplify things. – user722 Jul 17 '18 at 6:55
  • 1
    @RossRidge The compiled object files for my overlays have the relocations stored (ELF format), I just need to be able to resolve the symbols in that ELF and vice versa. Regarding writing my own tool, I'm working on it right now, trying to see if I can resolve the issue myself – fin Jul 17 '18 at 17:19
  • You're essentially going to have write your own dynamic linker, and that natural ELF format for that is not relocatable object files. – user722 Jul 17 '18 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.