/*---------------------------------------------------------------------------* Project: RSO File: rso.h Copyright 2006 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. @version $Id: rso.h,v 1.2 2008/06/13 04:48:28 mitu Exp $ *---------------------------------------------------------------------------*/ #ifndef __RSO_H__ #define __RSO_H__ #include #ifdef __cplusplus extern "C" { #endif #define RSO_VERSION 1 //version 0.10 typedef struct RSOExportFuncTable RSOExportFuncTable; typedef struct RSOExportTable RSOExportTable; typedef struct RSOImportTable RSOImportTable; typedef struct RSOSymbolHeader RSOSymbolHeader; typedef struct RSOObjectLink RSOObjectLink; typedef struct RSOObjectInfo RSOObjectInfo; typedef struct RSOObjectHeader RSOObjectHeader; typedef u32 RSOHash; struct RSOExportFuncTable { const char* symbol_name; u32* symbol_ptr; }; struct RSOExportTable { u32 strOffset; u32 value; u32 section; RSOHash hash; }; struct RSOImportTable { u32 strOffset; u32 value; u32 relOffset; }; struct RSOSymbolHeader { u32 tableOffset; // Offset to symbol table u32 tableSize; // Symbol table size u32 stringOffset; // Offset to symbol name table }; struct RSOObjectLink { RSOObjectInfo* next; RSOObjectInfo* prev; }; struct RSOObjectInfo { RSOObjectLink link; u32 numSections; // # of sections u32 sectionInfoOffset; // Offset to section info table u32 nameOffset; // Offset to module name u32 nameSize; // Size of module name u32 version; // Version number }; struct RSOObjectHeader { // CAUTION: Info must be the 1st member RSOObjectInfo info; u32 bssSize; // Total size of bss sections in bytes u8 prologSection; u8 epilogSection; u8 unresolvedSection; u8 bssSection; u32 prolog; u32 epilog; u32 unresolved; // Data ordering (Be careful when changing) // (Deletes the latter half data after linking module) // Information necessary for referencing from outside // expHeader.tableOffset -> expHeader.stringOffset -> // Information necessary for referencing outside // externalRelOffset -> impHeader.tableOffset -> impHeader.stringOffset -> // Information necessary for internal referencing // internalRelOffset // Internal referencing (self-contained) u32 internalRelOffset; u32 internalRelSize; // External referencing (reference other modules) u32 externalRelOffset; u32 externalRelSize; // Information to be referenced from outside RSOSymbolHeader expHeader; // Information referencing outside RSOSymbolHeader impHeader; }; // Fixed level typedef enum { RSO_FL_NON = 0, RSO_FL_INTERNAL, // Up to the internal reference information RSO_FL_EXTERNAL // Up to the information necessary for referencing outside } RSOFixedLevel; // RSO_FL_EXTERNAL includes RSO_FL_INTERNAL // Size of a single intermediate code export. #define RSO_FAR_JUMP_SIZE 24 /*---------------------------------------------------------------------------* RSOObject *---------------------------------------------------------------------------*/ RSOImportTable* RSOGetImport ( const RSOSymbolHeader* imp ); const RSOExportTable* RSOGetExport ( const RSOSymbolHeader* exp ); BOOL RSOLocateObject ( void* newModule, void* bss ); BOOL RSOLocateObjectFixed (void* newModule,void* bss); BOOL RSOStaticLocateObject ( void* newModule ); BOOL RSOUnLocateObject ( void* oldModule ); int RSOLink ( RSOObjectHeader* rsoImp, const RSOObjectHeader* rsoExp ); void RSOUnLink ( RSOObjectHeader* rsoImp, const RSOObjectHeader* rsoExp ); RSOHash RSOGetHash ( const char * symbolname ); /*---------------------------------------------------------------------------* RSOImport *---------------------------------------------------------------------------*/ BOOL RSOIsImportSymbolResolved ( const RSOObjectHeader* rso, int index ); BOOL RSOIsImportSymbolResolvedAll ( const RSOObjectHeader* rso ); int RSOGetNumImportSymbols ( const RSOSymbolHeader* imp ); const char* RSOGetImportSymbolName ( const RSOSymbolHeader* imp, int index ); int RSOGetNumImportSymbolsUnresolved( const RSOObjectHeader* rso ); /*---------------------------------------------------------------------------* RSOExport *---------------------------------------------------------------------------*/ int RSOGetNumExportSymbols ( const RSOSymbolHeader* exp ); const void* RSOFindExportSymbolAddr ( const RSOObjectHeader* rso, const char* name ); RSOExportTable* RSOFindExportSymbol ( const RSOObjectHeader* rso, const char* name ); const char* RSOGetExportSymbolName ( const RSOSymbolHeader* exp, int index ); const void* RSOGetExportSymbolAddr ( const RSOObjectHeader* rso, int index ); /*---------------------------------------------------------------------------* RSOLinkList *---------------------------------------------------------------------------*/ BOOL RSOListInit (void* i_staticRso); BOOL RSOLinkList (void* i_newRso, void* i_bss); BOOL RSOLinkListFixed (void* i_newRso, void* i_bss,RSOFixedLevel i_fixed); BOOL RSOUnLinkList (void* i_oldRso); u32 RSOGetFixedSize (void *i_rso,RSOFixedLevel i_fixed_level); /*---------------------------------------------------------------------------* RSOLinkFar *---------------------------------------------------------------------------*/ int RSOGetFarCodeSize(const RSOObjectHeader* rsoImp, const RSOObjectHeader* rsoExp); int RSOLinkFar(RSOObjectHeader* rsoImp, const RSOObjectHeader* rsoExp,void *buff); /*---------------------------------------------------------------------------* RSOLinkJump *---------------------------------------------------------------------------*/ int RSOGetJumpCodeSize(const RSOObjectHeader *i_rsoRso); void RSOMakeJumpCode(const RSOObjectHeader *i_rsoExp,void *i_buff); int RSOLinkJump(RSOObjectHeader* i_rsoImp,const RSOObjectHeader* i_rsoExp,void *i_buff); #ifdef __cplusplus } #endif #endif // __OSMODULE_H__