#include <revolution/rso.h> int RSOLinkFar(RSOObjectHeader* rsoImp, const RSOObjectHeader* rsoExp, void *buff);
| rsoImp | Pointer to the module information to link. |
|---|---|
| rsoExp | Pointer to the module information to reference. |
| buff | Area in which to write the added code. |
If linking succeeded, returns the number of codes that were processed.
Returns -1 if linking failed.
Typically, branch instructions (bx) have only a 28-bit offset (±32 MB). Therefore, when a dynamic module is placed in external main memory (MEM2), functions in internal main memory (MEM1) cannot be accessed.
Use RSOLinkFar to avoid that.
The LinkFar function in the demo outputs a relay jump code to buff and enables access from the external module by linking to those functions from rsoImp.
Request the necessary buffer size with RSOGetFarCodeSize.
Note: Allocate the buffer from the same main memory (MEM2 or MEM1) as the referencing module (rsoImp).
In addition, normally after linking, the code in the module is overwritten. Thus, when using RSOLinkListFixed, proceed up to RSO_FL_INTERNAL at the release level.
If this function returns -1, indicating that linking failed, it means that rsoImp and buff are separated by ±32MB or more and cannot reach each other with a relative jump. When you allocate memory for rsoImp and buff, make sure to locate them within ±32MB of each other.
Whereas in RSOLinkJump, the relay jump code is dependent on the module that is referred to, RSOLinkFar is dependent on the referring module.
This is an effective method when the module referring across memory areas is known.
2008/07/10 Removed RSOLink.h from Syntax. Added a note indicating when a jump cannot be reached.
2006/12/19 Added Differences from RSOLinkJump.
2006/09/25 Initial version.
CONFIDENTIAL