📄 soinit.c
字号:
/* *---------------------------------------------------------------------- * T-Kernel / Standard Extension * * Copyright (C) 2006 by Ken Sakamura. All rights reserved. * T-Kernel / Standard Extension is distributed * under the T-License for T-Kernel / Standard Extension. *---------------------------------------------------------------------- * * Version: 1.00.00 * Released by T-Engine Forum(http://www.t-engine.org) at 2006/8/11. * *---------------------------------------------------------------------- *//* * @(#)soinit.c (solib) * * Shared object(SO)support library * Initialize sequence */#include "so.h"#include <stdio.h>#include <seio/unistd.h>#define TSD_SIL_KDF_M1 (-1)/* * Object management information * _Connection is done at queue by making _dlInfo as a route. * Route is a main program information. */EXPORT DLInfo __dlInfo;/* * Shared object symbol link mode that was acquired from OS */EXPORT W __so_LazyMode;/* * Shared object search location */EXPORT SOBJ_HDR __so_myfile; /* The invoking program file */EXPORT SOBJ_HDR __so_stdlib; /* Standard library file *//* * Information of the searched shared object */EXPORT QUEUE __so_sobjInfo;/* ------------------------------------------------------------------------ *//* * Initialization at process startup and load of the shared library */EXPORT ER __so_initloading( void ){IMPORT VP _start, _end; ER err; struct stat sb; static const char STDLIB[] = { STDLIB_DIR }; /* Initialization of local-use memory allocation function */ err = __so_initmalloc(); if ( err < E_OK ) { goto err_ret; } /* Acquire the symbol link mode of the shared object from OS */ __so_LazyMode = KnlDebugFunc(KD_LazyMode, TSD_SIL_KDF_M1, 0, 0); __so_myfile.type = TPA_SEIO; __so_myfile.src.path = "./"; /* Acquire the standard library */ err = tkse_stat(STDLIB, &sb); if ( err >= E_OK ) { __so_stdlib.type = TPA_SEIO; __so_stdlib.src.path = (B *)STDLIB; } else { __so_stdlib = __so_myfile; } /* Initialization of the shared object information */ QueInit(&__so_sobjInfo); /* Initialization of main program object management information */ QueInit(&__dlInfo.q); __dlInfo.count = 1; __dlInfo.dyn = _DYNAMIC; __dlInfo.ldinf.loadaddr = &_start; __dlInfo.ldinf.loadsize = (UW)&_end - (UW)&_start; __dlInfo.ldinf.entry = (FP)&_start; /* Setting of the symbol scope list */ __dlInfo.scope[0] = &__dlInfo.search; __dlInfo.lscope[0] = &__dlInfo.search; /* Readout of the dynamic section */ err = __so_getdynamicinfo(&__dlInfo); if ( err < E_OK ) { goto err_ret; } /* Load of the main program-dependency library */ err = __so_depsloading(&__dlInfo, DL_GLOBAL); if ( err < E_OK ) { goto err_ret; } /* Relocation */ err = __so_relocate(&__dlInfo, DL_LAZY); if ( err < E_OK ) { goto err_ret; } return E_OK;err_ret: SYSLOG((LOG_ERR, "solib: initial loading error (%d)", err)); DEBUG_PRINT(("__so_initloading err = %d\n", err)); return err;}/* * Initialize sequence call */EXPORT void __so_init( void ){ __so_callinit(&__dlInfo);}/* * Stop sequence call */EXPORT void __so_fini( void ){ __so_callfini(&__dlInfo);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -