Git Product home page Git Product logo

lanhikari22 / c-rom-linker Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 4.43 MB

This is a C ROM Linker that essentially takes a relocatable combined object file of a C project and injects all global variables and functions from the object file into the ROM file! You can compile and link your C project directly into a game ROM! This is currently only supporting the ARM7TDMI architecture.

Batchfile 3.53% Python 4.97% Java 61.92% Makefile 6.90% C 22.64% C++ 0.04%

c-rom-linker's Introduction

C-ROM-Linker

This is a C Linker wrapper that essentially takes a relocatable combined object file of a C project and injects all global/file static variables and functions from the object file into the ROM file! You can compile and link your C project directly into a game ROM! This is currently only supporting the ARM7TDMI architecture.

Limitations: Check the issues section of the git repository. All limitations are reported as issues.

Dependencies: Both python3 and the JVM are required, since this project uses java and python. DevkitPro must also be intalled. The project depends on this absolute path for the required binaries: "C:\devkitPro\devkitARM\bin" This is also only usable on windows, so far. It has been developed on windows 10.

Usage:
The linker accepts a ROM to modify, a combined relocatable object file, which represents the C project to inject into the ROM, and a memory map configuration object. The memory map configuration object specifies the regions of the text section in ROM, as well as the RAM sections the global variables are expected to be at. The text section location is specified in a ROM-relative manner, but the memory must be specified relative to what will be running this ROM. (ie, the text section addresses are relative to the file modified, but the variables are actually loaded into the machine running the ROM. so they msut be absolute)

Check the Tests folder. It has a live demo. The makefile uses the ROM Linker inside the Default folder of MMBN6. The src folder can be modified, and to build the project into the ROM, the command "make rom" needs to be specified in the Default folder.

c-rom-linker's People

Contributors

lanhikari22 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

c-rom-linker's Issues

To be developed: Snapshot Functions

They take the form:
void snap<NUM_SNAPS>_<ABS_ROM_ADDR>();
An example:
void snap10_08040000();

What this does, is that it is going to intercept at 0x08040000 (0x40000 in ROM), 10 times, for 10 different assembly instructions.
When intercepting, the logic at that instruction has to be modified to include branching logic. This must be accounted for to determine where the next instruction is, so that another intercept occurs there.

Basically, for every one instruction run in a function, it will be intercepted by the logic in the snapshot function. This can be useful to view a (almost complete) state view of the intercepted function. This can be very useful for diagnostics.

Static variables and function static variables are not supported

This is because they are treated differently in the combined relocatable object file.
They do not have a type OBJECT like other global variables. They have a type of NOTYPE.
Further, function static variables also have a strange syntax to their naming. .4158 for example, or something similar. That needs to be decoded to figure out how to deal with those variables.

To be developed: Interceptor functions

Interceptor functions that inject into the ROM both their logic AND and where they are to be called.
They intercept other functions by adding assembly code for their execution inside the calling function.
When they are executed, they contain the assembly code that has been overwritten from the caller function to call them. This way, they wouldn't corrupt the calling function. Their original content would be directly after the overwritten content.

In the C file, an interceptor function takes the form of:
intercept_<ABS_ROM_ADDR>()
For example:
void intercept_08040000(); Would declare that the intercepting logic be executed at the address 0x40000 in ROM, and the actual location of the function would be located by the linker.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.