1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - ELF Loader
3   File:     import.c
4 
5   Copyright 2006-2008 Nintendo.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Date:: 2008-09-17#$
14   $Rev: 8556 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 
18 #include <twl/el/common/import.h>
19 
20 const char* ELi_LastFunctionName = NULL;
21 
ELi_UnresolvedFunc(void)22 void ELi_UnresolvedFunc(void)
23 {
24     const char* const message = "An unresolved function is called!";
25 #ifdef SDK_DEBUG
26     OS_Panic("%s: %s()", message, ELi_LastFunctionName ? ELi_LastFunctionName : "unknown" );
27 #else
28     OS_Panic("%s", message );
29 #endif
30 }
31 
EL_LoadImportTable(ELDlld dlld,ELImportEntry entries[],u32 count)32 void EL_LoadImportTable(ELDlld dlld, ELImportEntry entries[], u32 count)
33 {
34     void* fp;
35     u32 i;
36     for ( i = 0; i < count; ++i )
37     {
38         fp = EL_GetGlobalAdr(dlld, entries[i].fn);
39         if (fp)
40         {
41             entries[i].fp = fp;
42         }
43         else
44         {
45           OS_TWarning("EL_GetGlobalAdr failed: %s", entries[i].fn);
46         }
47     }
48 }
49 
EL_UnloadImportTable(ELImportEntry entries[],u32 count)50 void EL_UnloadImportTable(ELImportEntry entries[], u32 count)
51 {
52     u32 i;
53     for ( i = 0; i < count; ++i )
54     {
55         entries[i].fp = ELi_UnresolvedFunc;
56     }
57 }
58