282 lines
29 KiB
Plaintext
282 lines
29 KiB
Plaintext
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="generator" content="TempleOS V5.03">
|
||
|
<meta name="viewport" content="width=device-width">
|
||
|
<link rel="stylesheet" href="/style/templeos.css">
|
||
|
<script src="/script/templeos.js"></script>
|
||
|
<style type="text/css">
|
||
|
.cF0{color:#000000;background-color:#ffffff;}
|
||
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
||
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
||
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
||
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
||
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
||
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
||
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
||
|
.cF8{color:#555555;background-color:#ffffff;}
|
||
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
||
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
||
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
||
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
||
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
||
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
||
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<pre id="content">
|
||
|
<a name="l1"></a><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>LoadOneImport</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> **_src,</span><span class=cF1>U8</span><span class=cF0> *module_base,</span><span class=cF9>I64</span><span class=cF0> ld_flags)
|
||
|
<a name="l2"></a>{
|
||
|
<a name="l3"></a> </span><span class=cF1>U8</span><span class=cF0> *src=*_src,*ptr2,*st_ptr;
|
||
|
<a name="l4"></a> </span><span class=cF9>I64</span><span class=cF0> i,etype;
|
||
|
<a name="l5"></a> </span><span class=cF9>CHashExport</span><span class=cF0> *tmpex=</span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l6"></a> </span><span class=cF9>CHashImport</span><span class=cF0> *tmpiss;
|
||
|
<a name="l7"></a> </span><span class=cF1>Bool</span><span class=cF0> first=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l8"></a>
|
||
|
<a name="l9"></a> </span><span class=cF1>while</span><span class=cF0> (etype=*src++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l10"></a> i=*src(</span><span class=cF9>U32</span><span class=cF0> *)++;
|
||
|
<a name="l11"></a> st_ptr=src;
|
||
|
<a name="l12"></a> src+=</span><span class=cF5>StrLen</span><span class=cF0>(st_ptr)+1;
|
||
|
<a name="l13"></a> </span><span class=cF1>if</span><span class=cF0> (*st_ptr) {
|
||
|
<a name="l14"></a> </span><span class=cF1>if</span><span class=cF0> (!first) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l15"></a> *_src=st_ptr-5;
|
||
|
<a name="l16"></a> </span><span class=cF1>return</span><span class=cF0>;
|
||
|
<a name="l17"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l18"></a> first=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l19"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>tmpex=</span><span class=cF5>HashFind</span><span class=cF0>(st_ptr,
|
||
|
<a name="l20"></a> </span><span class=cF5>Fs</span><span class=cF0>->hash_table,</span><span class=cF3>HTG_ALL</span><span class=cF0>-</span><span class=cF3>HTT_IMPORT_SYS_SYM</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>) {
|
||
|
<a name="l21"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>ld_flags & </span><span class=cF3>LDF_SILENT</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l22"></a> </span><span class=cF6>"Unresolved Reference:%s\n"</span><span class=cF0>,st_ptr;
|
||
|
<a name="l23"></a> tmpiss=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CHashImport</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l24"></a> tmpiss->str=</span><span class=cF5>StrNew</span><span class=cF0>(st_ptr);
|
||
|
<a name="l25"></a> tmpiss->type=</span><span class=cF3>HTT_IMPORT_SYS_SYM</span><span class=cF0>;
|
||
|
<a name="l26"></a> tmpiss->module_header_entry=st_ptr-5;
|
||
|
<a name="l27"></a> tmpiss->module_base=module_base;
|
||
|
<a name="l28"></a> </span><span class=cF5>HashAdd</span><span class=cF0>(tmpiss,</span><span class=cF5>Fs</span><span class=cF0>->hash_table);
|
||
|
<a name="l29"></a> }
|
||
|
<a name="l30"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l31"></a> }
|
||
|
<a name="l32"></a> </span><span class=cF1>if</span><span class=cF0> (tmpex) {
|
||
|
<a name="l33"></a> ptr2=module_base+i;
|
||
|
<a name="l34"></a> </span><span class=cF1>if</span><span class=cF0> (tmpex->type & </span><span class=cF3>HTT_FUN</span><span class=cF0>)
|
||
|
<a name="l35"></a> i=tmpex(</span><span class=cF9>CHashFun</span><span class=cF0> *)->exe_addr;
|
||
|
<a name="l36"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmpex->type & </span><span class=cF3>HTT_GLBL_VAR</span><span class=cF0>)
|
||
|
<a name="l37"></a> i=tmpex(</span><span class=cF9>CHashGlblVar</span><span class=cF0> *)->data_addr;
|
||
|
<a name="l38"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l39"></a> i=tmpex->val;
|
||
|
<a name="l40"></a> </span><span class=cF1>switch</span><span class=cF0> (etype) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l41"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_REL_I8</span><span class=cF0>: *ptr2(</span><span class=cF1>U8</span><span class=cF0> *) =i-ptr2-1; </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l42"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_IMM_U8</span><span class=cF0>: *ptr2(</span><span class=cF1>U8</span><span class=cF0> *) =i; </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l43"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_REL_I16</span><span class=cF0>: *ptr2(</span><span class=cF9>U16</span><span class=cF0> *)=i-ptr2-2; </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l44"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_IMM_U16</span><span class=cF0>: *ptr2(</span><span class=cF9>U16</span><span class=cF0> *)=i; </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l45"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_REL_I32</span><span class=cF0>: *ptr2(</span><span class=cF9>U32</span><span class=cF0> *)=i-ptr2-4; </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l46"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_IMM_U32</span><span class=cF0>: *ptr2(</span><span class=cF9>U32</span><span class=cF0> *)=i; </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l47"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_REL_I64</span><span class=cF0>: *ptr2(</span><span class=cF9>I64</span><span class=cF0> *)=i-ptr2-8; </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l48"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_IMM_I64</span><span class=cF0>: *ptr2(</span><span class=cF9>I64</span><span class=cF0> *)=i; </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l49"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l50"></a> }
|
||
|
<a name="l51"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l52"></a> *_src=src-1;
|
||
|
<a name="l53"></a>}
|
||
|
<a name="l54"></a>
|
||
|
<a name="l55"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>SysSymImportsResolve</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *st_ptr,</span><span class=cF9>I64</span><span class=cF0> ld_flags)
|
||
|
<a name="l56"></a>{
|
||
|
<a name="l57"></a> </span><span class=cF9>CHashImport</span><span class=cF0> *tmpiss;
|
||
|
<a name="l58"></a> </span><span class=cF1>U8</span><span class=cF0> *ptr;
|
||
|
<a name="l59"></a> </span><span class=cF1>while</span><span class=cF0> (tmpiss=</span><span class=cF5>HashSingleTableFind</span><span class=cF7>(</span><span class=cF0>st_ptr,
|
||
|
<a name="l60"></a> </span><span class=cF5>Fs</span><span class=cF0>->hash_table,</span><span class=cF3>HTT_IMPORT_SYS_SYM</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l61"></a> ptr=tmpiss->module_header_entry;
|
||
|
<a name="l62"></a> </span><span class=cFD>LoadOneImport</span><span class=cF0>(&ptr,tmpiss->module_base,ld_flags);
|
||
|
<a name="l63"></a> tmpiss->type=</span><span class=cF3>HTT_INVALID</span><span class=cF0>;
|
||
|
<a name="l64"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l65"></a>}
|
||
|
<a name="l66"></a>
|
||
|
<a name="l67"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>LoadPass1</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *src,</span><span class=cF1>U8</span><span class=cF0> *module_base,</span><span class=cF9>I64</span><span class=cF0> ld_flags)
|
||
|
<a name="l68"></a>{
|
||
|
<a name="l69"></a> </span><span class=cF1>U8</span><span class=cF0> *ptr2,*ptr3,*st_ptr;
|
||
|
<a name="l70"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,cnt,etype;
|
||
|
<a name="l71"></a> </span><span class=cF9>CHashExport</span><span class=cF0> *tmpex=</span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l72"></a> </span><span class=cF1>while</span><span class=cF0> (etype=*src++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l73"></a> i=*src(</span><span class=cF9>U32</span><span class=cF0> *)++;
|
||
|
<a name="l74"></a> st_ptr=src;
|
||
|
<a name="l75"></a> src+=</span><span class=cF5>StrLen</span><span class=cF0>(st_ptr)+1;
|
||
|
<a name="l76"></a> </span><span class=cF1>switch</span><span class=cF0> (etype) {
|
||
|
<a name="l77"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_REL32_EXPORT</span><span class=cF0>:
|
||
|
<a name="l78"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_IMM32_EXPORT</span><span class=cF0>:
|
||
|
<a name="l79"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_REL64_EXPORT</span><span class=cF0>:
|
||
|
<a name="l80"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_IMM64_EXPORT</span><span class=cF0>:
|
||
|
<a name="l81"></a> tmpex=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CHashExport</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l82"></a> tmpex->str=</span><span class=cF5>StrNew</span><span class=cF0>(st_ptr);
|
||
|
<a name="l83"></a> tmpex->type=</span><span class=cF3>HTT_EXPORT_SYS_SYM</span><span class=cF0>|</span><span class=cF3>HTF_IMM</span><span class=cF0>;
|
||
|
<a name="l84"></a> </span><span class=cF1>if</span><span class=cF0> (etype==</span><span class=cF3>IET_IMM32_EXPORT</span><span class=cF0>||etype==</span><span class=cF3>IET_IMM64_EXPORT</span><span class=cF0>)
|
||
|
<a name="l85"></a> tmpex->val=i;
|
||
|
<a name="l86"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l87"></a> tmpex->val=i+module_base;
|
||
|
<a name="l88"></a> </span><span class=cF5>HashAdd</span><span class=cF0>(tmpex,</span><span class=cF5>Fs</span><span class=cF0>->hash_table);
|
||
|
<a name="l89"></a> </span><span class=cF5>SysSymImportsResolve</span><span class=cF0>(st_ptr,ld_flags);
|
||
|
<a name="l90"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l91"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_REL_I0</span><span class=cF0>...</span><span class=cF3>IET_IMM_I64</span><span class=cF0>:
|
||
|
<a name="l92"></a> src=st_ptr-5;
|
||
|
<a name="l93"></a> </span><span class=cFD>LoadOneImport</span><span class=cF0>(&src,module_base,ld_flags);
|
||
|
<a name="l94"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l95"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_ABS_ADDR</span><span class=cF0>:
|
||
|
<a name="l96"></a> </span><span class=cF1>if</span><span class=cF0> (ld_flags & </span><span class=cF3>LDF_NO_ABSS</span><span class=cF0>)
|
||
|
<a name="l97"></a> src+=i*</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>U32</span><span class=cF0>);
|
||
|
<a name="l98"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l99"></a> cnt=i;
|
||
|
<a name="l100"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j<cnt;j++) {
|
||
|
<a name="l101"></a> ptr2=module_base+*src(</span><span class=cF9>U32</span><span class=cF0> *)++;
|
||
|
<a name="l102"></a> *ptr2(</span><span class=cF9>U32</span><span class=cF0> *)+=module_base;
|
||
|
<a name="l103"></a> }
|
||
|
<a name="l104"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l105"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l106"></a>
|
||
|
<a name="l107"></a> </span><span class=cF1>start</span><span class=cF0>:
|
||
|
<a name="l108"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_CODE_HEAP</span><span class=cF0>:
|
||
|
<a name="l109"></a> ptr3=</span><span class=cF5>MAlloc</span><span class=cF0>(*src</span><span class=cF7>(</span><span class=cF9>I32</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>++,</span><span class=cF5>Fs</span><span class=cF0>->code_heap);
|
||
|
<a name="l110"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l111"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_ZEROED_CODE_HEAP</span><span class=cF0>:
|
||
|
<a name="l112"></a> ptr3=</span><span class=cF5>CAlloc</span><span class=cF0>(*src</span><span class=cF7>(</span><span class=cF9>I32</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>++,</span><span class=cF5>Fs</span><span class=cF0>->code_heap);
|
||
|
<a name="l113"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l114"></a> </span><span class=cF1>end</span><span class=cF0>:
|
||
|
<a name="l115"></a> </span><span class=cF1>if</span><span class=cF0> (*st_ptr) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l116"></a> tmpex=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CHashExport</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l117"></a> tmpex->str=</span><span class=cF5>StrNew</span><span class=cF0>(st_ptr);
|
||
|
<a name="l118"></a> tmpex->type=</span><span class=cF3>HTT_EXPORT_SYS_SYM</span><span class=cF0>|</span><span class=cF3>HTF_IMM</span><span class=cF0>;
|
||
|
<a name="l119"></a> tmpex->val=ptr3;
|
||
|
<a name="l120"></a> </span><span class=cF5>HashAdd</span><span class=cF0>(tmpex,</span><span class=cF5>Fs</span><span class=cF0>->hash_table);
|
||
|
<a name="l121"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l122"></a> cnt=i;
|
||
|
<a name="l123"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j<cnt;j++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l124"></a> ptr2=module_base+*src(</span><span class=cF9>U32</span><span class=cF0> *)++;
|
||
|
<a name="l125"></a> *ptr2(</span><span class=cF9>I32</span><span class=cF0> *)+=ptr3;
|
||
|
<a name="l126"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l127"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l128"></a>
|
||
|
<a name="l129"></a> </span><span class=cF1>start</span><span class=cF0>:
|
||
|
<a name="l130"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_DATA_HEAP</span><span class=cF0>:
|
||
|
<a name="l131"></a> ptr3=</span><span class=cF5>MAlloc</span><span class=cF0>(*src</span><span class=cF7>(</span><span class=cF9>I64</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>++);
|
||
|
<a name="l132"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l133"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_ZEROED_DATA_HEAP</span><span class=cF0>:
|
||
|
<a name="l134"></a> ptr3=</span><span class=cF5>CAlloc</span><span class=cF0>(*src</span><span class=cF7>(</span><span class=cF9>I64</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>++);
|
||
|
<a name="l135"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l136"></a> </span><span class=cF1>end</span><span class=cF0>:
|
||
|
<a name="l137"></a> </span><span class=cF1>if</span><span class=cF0> (*st_ptr) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l138"></a> tmpex=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CHashExport</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l139"></a> tmpex->str=</span><span class=cF5>StrNew</span><span class=cF0>(st_ptr);
|
||
|
<a name="l140"></a> tmpex->type=</span><span class=cF3>HTT_EXPORT_SYS_SYM</span><span class=cF0>|</span><span class=cF3>HTF_IMM</span><span class=cF0>;
|
||
|
<a name="l141"></a> tmpex->val=ptr3;
|
||
|
<a name="l142"></a> </span><span class=cF5>HashAdd</span><span class=cF0>(tmpex,</span><span class=cF5>Fs</span><span class=cF0>->hash_table);
|
||
|
<a name="l143"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l144"></a> cnt=i;
|
||
|
<a name="l145"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j<cnt;j++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l146"></a> ptr2=module_base+*src(</span><span class=cF9>U32</span><span class=cF0> *)++;
|
||
|
<a name="l147"></a> *ptr2(</span><span class=cF9>I64</span><span class=cF0> *)+=ptr3;
|
||
|
<a name="l148"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l149"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l150"></a> }
|
||
|
<a name="l151"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l152"></a>}
|
||
|
<a name="l153"></a>
|
||
|
<a name="l154"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>LoadPass2</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *src,</span><span class=cF1>U8</span><span class=cF0> *module_base,</span><span class=cF9>I64</span><span class=cF0>)
|
||
|
<a name="l155"></a>{
|
||
|
<a name="l156"></a> </span><span class=cF1>U8</span><span class=cF0> *st_ptr;
|
||
|
<a name="l157"></a> </span><span class=cF9>I64</span><span class=cF0> i,etype;
|
||
|
<a name="l158"></a> </span><span class=cF1>while</span><span class=cF0> (etype=*src++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l159"></a> i=*src(</span><span class=cF9>U32</span><span class=cF0> *)++;
|
||
|
<a name="l160"></a> st_ptr=src;
|
||
|
<a name="l161"></a> src+=</span><span class=cF5>StrLen</span><span class=cF0>(st_ptr)+1;
|
||
|
<a name="l162"></a> </span><span class=cF1>switch</span><span class=cF0> (etype) {
|
||
|
<a name="l163"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_MAIN</span><span class=cF0>:
|
||
|
<a name="l164"></a> </span><span class=cF5>Call</span><span class=cF0>(i+module_base);
|
||
|
<a name="l165"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l166"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_ABS_ADDR</span><span class=cF0>:
|
||
|
<a name="l167"></a> src+=</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>U32</span><span class=cF0>)*i;
|
||
|
<a name="l168"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l169"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_CODE_HEAP</span><span class=cF0>:
|
||
|
<a name="l170"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_ZEROED_CODE_HEAP</span><span class=cF0>:
|
||
|
<a name="l171"></a> src+=4+</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>U32</span><span class=cF0>)*i;
|
||
|
<a name="l172"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l173"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_DATA_HEAP</span><span class=cF0>:
|
||
|
<a name="l174"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>IET_ZEROED_DATA_HEAP</span><span class=cF0>:
|
||
|
<a name="l175"></a> src+=8+</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>U32</span><span class=cF0>)*i;
|
||
|
<a name="l176"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l177"></a> }
|
||
|
<a name="l178"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l179"></a>}
|
||
|
<a name="l180"></a>
|
||
|
<a name="l181"></a></span><span class=cF9>CBinFile</span><span class=cF0> *</span><span class=cF5>Load</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename,</span><span class=cF9>I64</span><span class=cF0> ld_flags=0,</span><span class=cF9>CBinFile</span><span class=cF0> *bfh_addr=</span><span class=cF3>INVALID_PTR</span><span class=cF0>)
|
||
|
<a name="l182"></a>{</span><span class=cF2>//Load a .BIN file module into memory.</span><span class=cF0>
|
||
|
<a name="l183"></a></span><span class=cF2>//bfh_addr==INVALID_PTR means don't care what load addr.</span><span class=cF0>
|
||
|
<a name="l184"></a> </span><span class=cF1>U8</span><span class=cF0> *fbuf,*module_base,*absname;
|
||
|
<a name="l185"></a> </span><span class=cF9>I64</span><span class=cF0> size,module_align,misalignment;
|
||
|
<a name="l186"></a> </span><span class=cF9>CBinFile</span><span class=cF0> *bfh;
|
||
|
<a name="l187"></a>
|
||
|
<a name="l188"></a> fbuf=</span><span class=cF5>ExtDft</span><span class=cF0>(filename,</span><span class=cF6>"BIN.Z"</span><span class=cF0>);
|
||
|
<a name="l189"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>bfh=</span><span class=cF5>FileRead</span><span class=cF0>(fbuf,&size)</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l190"></a> </span><span class=cF5>Free</span><span class=cF0>(fbuf);
|
||
|
<a name="l191"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l192"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l193"></a>
|
||
|
<a name="l194"></a> </span><span class=cF2>//See </span><a href="/Wb/Compiler/CMain.HC.HTML#l448"><span class=cF4>Patch Table Generation</span></a><span class=cF0>
|
||
|
<a name="l195"></a> module_align=1<<bfh->module_align_bits;
|
||
|
<a name="l196"></a> </span><span class=cF1>if</span><span class=cF0> (!module_align || bfh->bin_signature!=</span><span class=cF3>BIN_SIGNATURE_VAL</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l197"></a> </span><span class=cF5>Free</span><span class=cF0>(bfh);
|
||
|
<a name="l198"></a> </span><span class=cF5>Free</span><span class=cF0>(fbuf);
|
||
|
<a name="l199"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'BinModul'</span><span class=cF0>);
|
||
|
<a name="l200"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l201"></a>
|
||
|
<a name="l202"></a> </span><span class=cF1>if</span><span class=cF0> (bfh_addr==</span><span class=cF3>INVALID_PTR</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l203"></a> </span><span class=cF1>if</span><span class=cF0> (bfh->org==</span><span class=cF3>INVALID_PTR</span><span class=cF0>) {
|
||
|
<a name="l204"></a> misalignment=module_align-</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CBinFile</span><span class=cF0>);
|
||
|
<a name="l205"></a> </span><span class=cF1>if</span><span class=cF0> (misalignment<0)
|
||
|
<a name="l206"></a> misalignment&=module_align-1;
|
||
|
<a name="l207"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0>->code_heap!=</span><span class=cF5>Fs</span><span class=cF0>->data_heap) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l208"></a> </span><span class=cF1>if</span><span class=cF0> (module_align<16)
|
||
|
<a name="l209"></a> module_align=16;
|
||
|
<a name="l210"></a> bfh_addr=</span><span class=cF5>MAllocAligned</span><span class=cF0>(size,module_align,</span><span class=cF5>Fs</span><span class=cF0>->code_heap,misalignment);
|
||
|
<a name="l211"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (module_align>8)
|
||
|
<a name="l212"></a> bfh_addr=</span><span class=cF5>MAllocAligned</span><span class=cF0>(size,module_align,,misalignment);
|
||
|
<a name="l213"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF2>//Less than 2Gig system memory</span><span class=cF0>
|
||
|
<a name="l214"></a> bfh_addr=bfh;
|
||
|
<a name="l215"></a> </span><span class=cF1>goto</span><span class=cF0> lo_skip; </span><span class=cF2>//File is already in code heap area, don't copy.</span><span class=cF0>
|
||
|
<a name="l216"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l217"></a> } </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l218"></a> bfh_addr=bfh->org;
|
||
|
<a name="l219"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l220"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(bfh_addr,bfh,size);
|
||
|
<a name="l221"></a> </span><span class=cF5>Free</span><span class=cF0>(bfh);
|
||
|
<a name="l222"></a>
|
||
|
<a name="l223"></a> lo_skip:
|
||
|
<a name="l224"></a> module_base=bfh_addr(</span><span class=cF1>U8</span><span class=cF0> *)+</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CBinFile</span><span class=cF0>);
|
||
|
<a name="l225"></a>
|
||
|
<a name="l226"></a> absname=</span><span class=cF5>FileNameAbs</span><span class=cF0>(fbuf);
|
||
|
<a name="l227"></a> </span><span class=cF5>Free</span><span class=cF0>(fbuf);
|
||
|
<a name="l228"></a> fbuf=</span><span class=cF5>StrNew</span><span class=cF0>(absname);
|
||
|
<a name="l229"></a> </span><span class=cF5>FileExtRem</span><span class=cF0>(fbuf);
|
||
|
<a name="l230"></a> </span><span class=cF1>if</span><span class=cF0> (fbuf[1]==</span><span class=cF6>':'</span><span class=cF0> && </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>fbuf</span><span class=cF7>)</span><span class=cF0>>2)
|
||
|
<a name="l231"></a> </span><span class=cF5>HashGenericAdd</span><span class=cF0>(fbuf+2,</span><span class=cF3>HTT_MODULE</span><span class=cF0>|</span><span class=cF3>HTF_PUBLIC</span><span class=cF0>,bfh_addr);
|
||
|
<a name="l232"></a> </span><span class=cFD>LoadPass1</span><span class=cF0>(bfh_addr</span><span class=cF7>(</span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>+bfh_addr->patch_table_offset,module_base,ld_flags);
|
||
|
<a name="l233"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>ld_flags&</span><span class=cF3>LDF_JUST_LOAD</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l234"></a> </span><span class=cFD>LoadPass2</span><span class=cF0>(bfh_addr</span><span class=cF7>(</span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>+bfh_addr->patch_table_offset,module_base,ld_flags);
|
||
|
<a name="l235"></a> </span><span class=cF5>Free</span><span class=cF0>(absname);
|
||
|
<a name="l236"></a> </span><span class=cF5>Free</span><span class=cF0>(fbuf);
|
||
|
<a name="l237"></a> </span><span class=cF1>return</span><span class=cF0> bfh_addr;
|
||
|
<a name="l238"></a>}
|
||
|
<a name="l239"></a>
|
||
|
<a name="l240"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>LoadKernel</span><span class=cF0>()
|
||
|
<a name="l241"></a>{
|
||
|
<a name="l242"></a> </span><span class=cF5>HashGenericAdd</span><span class=cF0>(</span><span class=cF3>KERNEL_MODULE_NAME</span><span class=cF0>,</span><span class=cF3>HTT_MODULE</span><span class=cF0>|</span><span class=cF3>HTF_PUBLIC</span><span class=cF0>,
|
||
|
<a name="l243"></a> </span><span class=cFB>mem_boot_base</span><span class=cF0>-</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CBinFile</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l244"></a>
|
||
|
<a name="l245"></a> </span><span class=cF2>//Abs patches done here </span><a href="/Wb/Kernel/KStart32.HC.HTML#l96"><span class=cF4>CPatchTableAbsAddr</span></a><span class=cF2>.</span><span class=cF0>
|
||
|
<a name="l246"></a> </span><span class=cFD>LoadPass1</span><span class=cF0>(</span><span class=cFB>sys_boot_patch_table_base</span><span class=cF0>,</span><span class=cFB>mem_boot_base</span><span class=cF0>,</span><span class=cF3>LDF_NO_ABSS</span><span class=cF0>|</span><span class=cF3>LDF_SILENT</span><span class=cF0>);
|
||
|
<a name="l247"></a>
|
||
|
<a name="l248"></a> </span><span class=cF2>//No main routines</span><span class=cF0>
|
||
|
<a name="l249"></a> </span><span class=cF2>// LoadPass2(sys_boot_patch_table_base,mem_boot_base,0);</span><span class=cF0>
|
||
|
<a name="l250"></a>}
|
||
|
</span></pre></body>
|
||
|
</html>
|