You are on page 1of 2

========================

LiveMove 2
RSO how-to
========================

The LiveMove package comes with an RSO library intended for use with Nintendo's
RSO package. This document will describe how to import LiveMove 2 as an RSO.

There are five steps to getting your application to use the RSO correctly:

Step 1: Link against libLMstub.lib instead of libLM.lib

In order to ease the conversion to using LiveMove as a dynamically-loaded


object, there exists a wrapper library, libLMstub. This library provides stub
versions of the LiveMove calls so that you may convert your application to
using the RSO version of the LiveMove library rapidly and without major changes
to your source code.

Thus, instead of staticly linking the application against libLM.lib, to use


RSO link against libLMstub.lib.

Step 2: Ensure the linker includes all base functionality in the base .elf

In order to ensure that all basic system functions that libLM.rso requires are
present in the final .elf functions, you will also need to set the lcf file
used by the linker to be $(LM_DIR)/lib/libLM.lcf. Do this by replacing the
existing "-lcf <filename>" parameter on the linker command line with
-lcf $(LM_DIR)/lib/libLM.lcf

Step 3: Generate .sel files during the link step

Use the Nintendo-provided makeRSO.exe along with libLM.lst to generate a .sel


file which will allow libLM.rso to call functions statically linked into the
elf. libLM.lst can be found in the lib directory with libLM.rso.

makeRSO.exe <executable.elf> -e $(LM_DIR)/lib/libLM.lst -a


(outputs executable.sel>

Step 4: Load and link the <executable.sel> file at runtime

In your application, add a routine that loads <executable.sel> into memory,


and calls RSOListInit() on the memory block. An example of how to do this can
be found in the Nintendo RSO documentation.

Step 5: Load libLM.rso at runtime

In your application, add a routine that loads libLM.rso into memory, allocates
a buffer for the bss segment, and then calls RSOLinkList() on the memory
block. An example of how to do this can be found in the Nintendo RSO
documentation.

After the libLM.rso module has been loaded and linked, call the module prolog
function to execute any necessary setup code:

((u32(*)(void)) module->prolog)();
libLMstub.lib provides functions to automatically resolve all the symbols
defined in liveMove2.h to locations in libLM.rso. To access these, include the
header file "libLMstub.h". It will define 2 functions:

void loadLMrso( const RSOObjectHeader * LMRSO );


void unloadLMrso();

Once you have called the prolog function from the RSOObjectHeader, you can
pass it to loadLMrso() to properly link the static function stubs with the
dynamic locations of the functions loaded from libLM.rso.

At this point, you will be able to use LiveMove normally, as if it had been
linked with the ELF statically.

When you are finished with libLM functions, you can unlink the rso from
libLMstub by calling unloadLMrso(). Once you have done this, you can call the
epilog function and RSOUnLinkList() on the module as described in the Nintendo
documentation, which will prepare the memory block for deallocation.

You might also like