CN115495158B - Dynamic construction method for system service in microkernel operating system - Google Patents
Dynamic construction method for system service in microkernel operating system Download PDFInfo
- Publication number
- CN115495158B CN115495158B CN202211226300.2A CN202211226300A CN115495158B CN 115495158 B CN115495158 B CN 115495158B CN 202211226300 A CN202211226300 A CN 202211226300A CN 115495158 B CN115495158 B CN 115495158B
- Authority
- CN
- China
- Prior art keywords
- elf
- system service
- dynamic link
- module
- executable file
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/4401—Bootstrapping
- G06F9/4406—Loading of operating system
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/4401—Bootstrapping
- G06F9/4411—Configuring for operating with peripheral devices; Loading of device drivers
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
Description
技术领域technical field
本发明属于微内核操作系统技术领域,更为具体地讲,涉及一种微内核操作系统中系统服务动态构建方法。The invention belongs to the technical field of microkernel operating systems, and more specifically relates to a method for dynamically constructing system services in a microkernel operating system.
背景技术Background technique
随着物联网和工业控制场景中对嵌入式系统的安全性和可靠性提出了更高的要求,微内核架构的操作系统受到极大关注。微内核操作系统尽管内核微小,但却可以在用户态实现丰富的系统服务模块来适应对操作系统功能的复杂需求,这样的模块化设计保证了操作系统的安全性和故障隔离。As the Internet of Things and industrial control scenarios put forward higher requirements for the security and reliability of embedded systems, the operating system of the microkernel architecture has received great attention. Although the microkernel operating system has a small kernel, it can implement rich system service modules in user mode to meet the complex requirements for operating system functions. Such a modular design ensures the security and fault isolation of the operating system.
在微内核操作系统中,内核只保留了精简的功能,操作系统中绝大部分的服务被解耦出来作为独立的用户态应用程序运行在彼此隔离的用户态地址空间中,因此基于微内核操作系统需要考虑用什么样的方法来构建系统服务。在当前微内核操作系统构建过程中,往往是将系统服务与内核集成,也就是说只是根据需求静态地选择部分服务模块编译到操作系统,这种方法最大的缺点是如果一个模块需要升级或替换,那么需要重新编译、发布和启动系统,无法满足系统的快速构建、资源的动态扩展。而当前在物联网和工业控制环境中,往往要求操作系统可以支持系统服务的动态增加或减少以适配硬件资源的动态变化或者适应分布式处理环境中多样的节点环境,现有的技术方案无法满足这种需求。In the microkernel operating system, the kernel only retains simplified functions, and most of the services in the operating system are decoupled and run as independent user-mode applications in user-mode address spaces isolated from each other. Therefore, microkernel-based operations The system needs to consider what method to use to build system services. In the current microkernel operating system construction process, system services are often integrated with the kernel, that is to say, only some service modules are statically selected and compiled into the operating system according to requirements. The biggest disadvantage of this method is that if a module needs to be upgraded or replaced , then the system needs to be recompiled, released and started, which cannot satisfy the rapid construction of the system and the dynamic expansion of resources. However, in the current Internet of Things and industrial control environment, it is often required that the operating system can support the dynamic increase or decrease of system services to adapt to the dynamic changes of hardware resources or adapt to the diverse node environments in the distributed processing environment. The existing technical solutions cannot meet this need.
现有技术在动态构建操作系统上的研究十分缺乏,文献“微内核系统直接加载ELF文件机制的设计与研究”中在L4/Fiasco微内核操作系统中运行时加载Linux上编译的ELF(Executable and Linkable Format,可执行连接格式)文件,但在只研究了静态链接的可执行文件的加载方法。在静态构建方法中,需要将系统服务模块编译为目标文件,再由链接器将这些系统服务模块与内核链接为一个操作系统镜像,然后启动执行。这种方法最大的缺点是如果一个系统模块需要升级或替换,那么需要重新编译、发布和启动操作系统。并且在静态构建方法中,系统服务都是静态链接的可执行文件,其映射和加载过程相对简单,但公共的共享库的代码和数据需要在每个系统服务模块中都有副本,存在着极大的系统资源浪费。There is a lack of research on the dynamic construction of operating systems in the prior art. In the document "Design and Research on the Mechanism of Directly Loading ELF Files in Microkernel Systems", the ELF (Executable and ELF (Executable and Linkable Format, executable connection format) files, but only the loading method of statically linked executable files is studied. In the static construction method, the system service modules need to be compiled into target files, and then the linker will link these system service modules and the kernel into an operating system image, and then start the execution. The biggest disadvantage of this method is that if a system module needs to be upgraded or replaced, then the operating system needs to be recompiled, released and started. And in the static construction method, the system services are all statically linked executable files, and the mapping and loading process is relatively simple, but the code and data of the public shared library need to have a copy in each system service module, and there are extremely Big waste of system resources.
发明内容Contents of the invention
本发明的目的在于克服现有技术的不足,提供一种微内核操作系统中系统服务动态构建方法,通过部署系统服务加载器,使其与内核打包发布,在无需重新启动微内核操作系统的情况下动态加载模块的ELF可执行文件和动态链接共享库,以实现微内核操作系统的系统服务动态构建。The purpose of the present invention is to overcome the deficiencies of the prior art and provide a method for dynamically constructing system services in a microkernel operating system. By deploying a system service loader, it can be packaged and released with the kernel without restarting the microkernel operating system. The ELF executable file of the dynamic loading module and the dynamic link shared library are used to realize the dynamic construction of the system service of the microkernel operating system.
为了实现上述发明目的,本发明微内核操作系统中系统服务动态构建方法包括以下步骤:In order to realize the object of the above invention, the system service dynamic construction method in the microkernel operating system of the present invention comprises the following steps:
S1:对于所需的系统服务模块和设备驱动,如果满足编译为ELF动态链接库的条件,则编译为ELF动态链接库,并作为共享库供ELF可执行文件调用,否则编译为ELF可执行文件;将所需的应用程序编译为ELF可执行文件;S1: For the required system service modules and device drivers, if the conditions for compiling into an ELF dynamic link library are met, compile it into an ELF dynamic link library, and use it as a shared library for the ELF executable file to call, otherwise compile it into an ELF executable file ; Compile the desired application into an ELF executable;
S2:在微内核操作系统中的用户态部署系统服务加载器,用于加载ELF可执行文件和链接ELF动态链接库,将系统服务加载器编译为镜像文件并和内核镜像集成;S2: Deploy the system service loader in the user mode of the microkernel operating system, which is used to load the ELF executable file and link the ELF dynamic link library, compile the system service loader into an image file and integrate it with the kernel image;
S3:在微内核操作系统启动过程中,内核启动后即启动系统服务加载器;对于编译为ELF可执行文件的系统服务模块、设备驱动和应用程序,当其中任意一个模块需要加载时,系统服务加载器读取对应的ELF可执行文件并进行加载,加载完成后该模块作为独立任务运行在与其他模块相互隔离的地址空间;当该模块加载过程中需要链接某个编译为ELF动态链接库的系统服务模块或设备驱动时,系统服务加载器将该ELF动态链接库动态链接到该模块的地址空间中,此后即可开始执行该模块,该模块执行过程中即可调用所链接的ELF动态链接库;S3: During the startup process of the microkernel operating system, the system service loader is started after the kernel is started; for system service modules, device drivers and applications compiled into ELF executable files, when any module needs to be loaded, the system service loader The loader reads the corresponding ELF executable file and loads it. After the loading is completed, the module runs as an independent task in an address space isolated from other modules; when the module is loaded, it needs to be linked to an ELF dynamic link library. When the system service module or device is driven, the system service loader dynamically links the ELF dynamic link library into the address space of the module, and then starts to execute the module, and the linked ELF dynamic link can be called during the execution of the module Library;
S4:当需要卸载以ELF可执行文件形式进行加载的系统服务模块、设备驱动或应用程序中任意一个模块时,系统服务加载器卸载对应的ELF可执行文件,回收缓存并取消加载过程中所完成的映射;S4: When it is necessary to unload any module in the system service module, device driver or application that is loaded in the form of an ELF executable file, the system service loader unloads the corresponding ELF executable file, reclaims the cache and cancels the completion of the loading process the mapping;
当以ELF动态链接库形式进行链接的系统服务模块、设备驱动中任意一个模块不再使用时,系统服务加载器断开其与各个依赖于他的相关模块的动态链接,并回收其系统资源;When any one of the system service modules and device drivers linked in the form of ELF dynamic link library is no longer used, the system service loader disconnects its dynamic link with each dependent module and reclaims its system resources;
S5:当以ELF可执行文件形式进行加载的系统服务模块、设备驱动或应用程序中任意一个模块需要进行更新时,先进行卸载,然后重新加载更新后的ELF可执行文件,并重新对所需共享库进行动态链接;S5: When any module in the system service module, device driver, or application program loaded in the form of an ELF executable file needs to be updated, first unload it, then reload the updated ELF executable file, and re-install the required Shared library for dynamic linking;
当以ELF动态链接库形式进行链接的系统服务模块或设备驱动中任意一个模块需要更新进行时,先停用依赖于它的相关模块的执行,然后系统服务加载器将更新后的ELF动态链接库动态链接至这些相关模块。When any module in the system service module or device driver that is linked in the form of an ELF dynamic link library needs to be updated, first disable the execution of related modules that depend on it, and then the system service loader will update the ELF dynamic link library Dynamically link to these dependent modules.
本发明微内核操作系统中系统服务动态构建方法,将所需的系统服务模块、设备驱动和应用程序编译为相互独立的ELF可执行文件或ELF动态链接库,在微内核操作系统中的用户态部署系统服务加载器,将系统服务加载器编译为镜像文件并和内核镜像集成;系统服务加载器在内核启动后即进行启动,然后根据键入的指令读取需要加载模块的ELF可执行文件并进行加载,加载完成后该模块作为独立任务运行在与其他模块相互隔离的地址空间,并将该模块所需共享库动态链接到该模块的地址空间中;系统服务加载器还可完成可执行程序模块、共享库的卸载和更新。The system service dynamic construction method in the microkernel operating system of the present invention compiles the required system service modules, device drivers and application programs into mutually independent ELF executable files or ELF dynamic link libraries, and the user state in the microkernel operating system Deploy the system service loader, compile the system service loader into an image file and integrate it with the kernel image; the system service loader starts after the kernel starts, and then reads the ELF executable file that needs to be loaded according to the typed instruction and executes Loading, after loading, the module runs as an independent task in an address space isolated from other modules, and dynamically links the shared library required by the module to the address space of the module; the system service loader can also complete the executable program module , Uninstall and update of shared libraries.
本发明具有以下有益效果:The present invention has the following beneficial effects:
1)本发明将系统服务模块、设备驱动和应用程序编译为ELF可执行文件,支持在操作系统运行时动态地载入或卸载系统服务,且各个模块加载后作为独立任务运行在相互隔离的地址空间,可以独立维护,可以有效解决静态服务构建缺乏灵活性的问题,提升微内核操作系统系统服务构建的灵活性;1) The present invention compiles system service modules, device drivers and application programs into ELF executable files, supports dynamic loading or unloading of system services when the operating system is running, and each module runs as an independent task at an isolated address after loading Space, which can be maintained independently, can effectively solve the problem of lack of flexibility in static service construction, and improve the flexibility of microkernel operating system system service construction;
2)本发明将可共享的系统服务模块和设备驱动构建为ELF动态链接库,需要使用共享库的多个模块采用动态链接的方法与ELF动态链接库进行链接,解决了静态服务构建中共享库的资源浪费问题,可以极大地节省内存空间资源。2) The present invention builds shareable system service modules and device drivers into an ELF dynamic link library, and multiple modules that need to use the shared library adopt a dynamic link method to link with the ELF dynamic link library, which solves the problem of shared libraries in static service construction The resource waste problem can greatly save memory space resources.
附图说明Description of drawings
图1是本发明微内核操作系统中系统服务动态构建方法的具体实施方式流程图;Fig. 1 is the flow chart of the specific embodiment of the system service dynamic construction method in the microkernel operating system of the present invention;
图2是本发明系统服务动态构建框架图;Fig. 2 is a framework diagram of dynamic construction of system services of the present invention;
图3是本实施例中系统服务加载器对ELF可执行文件的加载和动态链接库的链接的流程图;Fig. 3 is the flow chart of the linking of system service loader to the loading of ELF executable file and the link of dynamic link library in the present embodiment;
图4是本实施例中加载主模块的流程图;Fig. 4 is the flowchart of loading main module in the present embodiment;
图5是本实施例中动态链接ELF动态链接库的流程图。Fig. 5 is a flow chart of dynamically linking the ELF dynamic link library in this embodiment.
具体实施方式Detailed ways
下面结合附图对本发明的具体实施方式进行描述,以便本领域的技术人员更好地理解本发明。需要特别提醒注意的是,在以下的描述中,当已知功能和设计的详细描述也许会淡化本发明的主要内容时,这些描述在这里将被忽略。Specific embodiments of the present invention will be described below in conjunction with the accompanying drawings, so that those skilled in the art can better understand the present invention. It should be noted that in the following description, when detailed descriptions of known functions and designs may dilute the main content of the present invention, these descriptions will be omitted here.
实施例Example
图1是本发明微内核操作系统中系统服务动态构建方法的具体实施方式流程图。如图1所示,本发明微内核操作系统中系统服务动态构建方法的具体步骤包括:FIG. 1 is a flowchart of a specific embodiment of a method for dynamically constructing system services in a microkernel operating system according to the present invention. As shown in Figure 1, the specific steps of the system service dynamic construction method in the microkernel operating system of the present invention include:
S101:构建ELF文件:S101: Construct the ELF file:
对于所需的系统服务模块和设备驱动,如果满足编译为ELF动态链接库的条件,则编译为ELF动态链接库,并作为共享库供ELF可执行文件调用,否则编译为ELF可执行文件。将所需的应用程序编译为ELF可执行文件。For the required system service modules and device drivers, if the conditions for compiling into an ELF dynamic link library are met, they will be compiled into an ELF dynamic link library and used as a shared library for the ELF executable file to call, otherwise they will be compiled into an ELF executable file. Compile the desired application into an ELF executable.
系统服务模块通常包括网络协议栈、UI框架、日志系统等,设备驱动通常包括网卡驱动、串口驱动等,目前系统服务模块和设备驱动多是编译为ELF可执行文件。能够编译成为共享库的系统服务模块通常包括C库,C++库和密码库等。在编译过程中,为了便于共享库供不同模块同时使用,在编译为ELF动态链接库时使用地址无关代码(PIC)编译,ELF可执行文件采用常规编译方法即可。System service modules usually include network protocol stack, UI framework, log system, etc. Device drivers usually include network card drivers, serial port drivers, etc. Currently, system service modules and device drivers are mostly compiled into ELF executable files. A system service module that can be compiled into a shared library usually includes a C library, a C++ library, and a cryptographic library. In the compilation process, in order to facilitate the shared library to be used by different modules at the same time, address-independent code (PIC) is used to compile the ELF dynamic link library, and the ELF executable file can be compiled by a conventional compilation method.
S102:部署系统服务加载器:S102: Deploy the system service loader:
在微内核操作系统中的用户态部署系统服务加载器,用于加载ELF可执行文件和链接ELF动态链接库,将系统服务加载器编译为镜像文件并和内核镜像集成。The user state deployment system service loader in the microkernel operating system is used to load the ELF executable file and link the ELF dynamic link library, compile the system service loader into an image file and integrate it with the kernel image.
一般来说,在微内核操作系统中的用户态,还会部署少量必须的基础服务,包括文件系统、内存管理、Shell、错误处理等,本发明中系统服务加载器也需要借助这些基础服务。同样地,这些基础服务也是编译为镜像文件并和内核镜像集成,以便于在内核启动后直接进行加载。Generally speaking, in the user mode in the microkernel operating system, a small number of necessary basic services will be deployed, including file system, memory management, Shell, error handling, etc., and the system service loader in the present invention also needs to rely on these basic services. Similarly, these basic services are also compiled into image files and integrated with the kernel image so that they can be loaded directly after the kernel starts.
S103:加载ELF可执行文件并链接ELF动态链接库:S103: Load the ELF executable file and link the ELF dynamic link library:
在微内核操作系统启动过程中,内核启动后即启动系统服务加载器。对于编译为ELF可执行文件的系统服务模块、设备驱动和应用程序,当其中任意一个模块需要加载时,系统服务加载器读取对应的ELF可执行文件并进行加载,加载完成后该模块作为独立任务运行在与其他模块相互隔离的地址空间。当该模块加载过程中需要链接某个编译为ELF动态链接库的系统服务模块或设备驱动时,系统服务加载器将该ELF动态链接库动态链接到该模块的地址空间中。此后即可开始执行该模块,该模块执行过程中即可调用所链接的ELF动态链接库。During the startup process of the microkernel operating system, the system service loader is started after the kernel is started. For system service modules, device drivers, and applications compiled into ELF executable files, when any module needs to be loaded, the system service loader reads the corresponding ELF executable file and loads it. Tasks run in address spaces isolated from other modules. When a certain system service module or device driver compiled into an ELF dynamic link library needs to be linked during the loading process of the module, the system service loader dynamically links the ELF dynamic link library into the address space of the module. After that, the module can be started to be executed, and the linked ELF dynamic link library can be called during the execution of the module.
一般来说,如果某个应用程序的执行需要依赖于某个系统服务模块或设备驱动时,在加载时需要先行加载系统服务模块或设备驱动。Generally speaking, if the execution of an application needs to depend on a certain system service module or device driver, the system service module or device driver needs to be loaded first when loading.
S104:卸载ELF可执行文件或ELF动态链接库:S104: Uninstall the ELF executable file or the ELF dynamic link library:
当需要卸载以ELF可执行文件形式进行加载的系统服务模块、设备驱动或应用程序中任意一个模块时,系统服务加载器卸载对应的ELF可执行文件,回收缓存并取消加载过程中所完成的映射。When it is necessary to unload any module in the system service module, device driver or application that is loaded in the form of an ELF executable file, the system service loader unloads the corresponding ELF executable file, reclaims the cache and cancels the mapping completed during the loading process .
当以ELF动态链接库形式进行链接的系统服务模块、设备驱动中任意一个模块不再使用时,系统服务加载器断开其与各个依赖于他的相关模块的动态链接,并回收其系统资源。When any one of the system service modules and device drivers linked in the form of ELF dynamic link library is no longer used, the system service loader breaks its dynamic link with each dependent module and reclaims its system resources.
S105:更新ELF可执行文件或ELF动态链接库:S105: Updating the ELF executable file or the ELF dynamic link library:
当以ELF可执行文件形式进行加载的系统服务模块、设备驱动或应用程序中任意一个模块需要进行更新时,先进行卸载,然后重新加载更新后的ELF可执行文件,并重新对所需共享库进行动态链接。When any of the system service modules, device drivers, or application modules loaded in the form of ELF executable files needs to be updated, first unload them, then reload the updated ELF executable files, and re-install the required shared libraries Do dynamic linking.
当以ELF动态链接库形式进行链接的系统服务模块或设备驱动中任意一个模块需要更新进行时,先停用依赖于它的相关模块的执行,然后系统服务加载器将更新后的ELF动态链接库动态链接至这些相关模块。When any module in the system service module or device driver that is linked in the form of an ELF dynamic link library needs to be updated, first disable the execution of related modules that depend on it, and then the system service loader will update the ELF dynamic link library Dynamically link to these dependent modules.
图2是本发明系统服务动态构建框架图。如图2所示,系统服务加载器对系统服务模块、设备驱动、应用程序进行加载,加载的同时将所需的共享库动态连接到对应模块的地址空间中。在这种系统服务动态构建框架下,微内核操作系统支持在运行的同时动态的加载或卸载系统服务,实现了操作系统功能的热插拔,增强了系统的灵活性和可伸缩性。此外,系统服务模块编译成为共享库后进行动态链接可以减少公共服务代码在系统中的副本数量以降低存储空间资源浪费,并且这种方式还支持在运行时更新系统服务共享库,这也大大增加了系统使用的便利性。Fig. 2 is a framework diagram of dynamic construction of system services in the present invention. As shown in Figure 2, the system service loader loads system service modules, device drivers, and application programs, and dynamically connects the required shared library to the address space of the corresponding module while loading. Under the framework of dynamic construction of system services, the microkernel operating system supports dynamic loading or unloading of system services while running, which realizes hot swapping of operating system functions and enhances the flexibility and scalability of the system. In addition, the system service module is compiled into a shared library and then dynamically linked to reduce the number of copies of the public service code in the system to reduce the waste of storage space resources, and this method also supports updating the system service shared library at runtime, which greatly increases Ease of use of the system.
为了使得系统服务加载器更快捷地对ELF可执行文件和ELF动态链接库进行加载和链接,本实施例中提出了一种优选的实现方法。图3是本实施例中系统服务加载器对ELF可执行文件进行加载和ELF动态链接库进行链接的流程图。如图3所示,本实施例中系统服务加载器对ELF可执行文件进行加载和ELF动态链接库进行链接的具体步骤包括:In order to make the system service loader load and link the ELF executable file and the ELF dynamic link library more quickly, a preferred implementation method is proposed in this embodiment. FIG. 3 is a flow chart of the system service loader loading the ELF executable file and linking the ELF dynamic link library in this embodiment. As shown in Figure 3, the specific steps that the system service loader loads the ELF executable file and links the ELF dynamic link library in the present embodiment include:
S301:创建elf_task任务:S301: create elf_task task:
在微内核操作系统中,用户通过在Shell中输入命令或通过系统调用,请求系统服务加载器加载ELF可执行文件格式的系统服务、设备驱动或应用程序,系统服务加载器接收到用户请求后,在微内核中为每个加载过程创建一个elf_task(装载执行ELF程序)任务,该任务用于执行系统服务加载器的代码对ELF可执行文件进行加载和对ELF动态链接库进行链接,加载完成后系统服务、设备驱动和应用程序都将会运行在对应任务和其他任务相互隔离的地址空间中。In the microkernel operating system, the user requests the system service loader to load the system service, device driver or application program in the ELF executable file format by entering a command in the Shell or through a system call. After the system service loader receives the user request, Create an elf_task (loading and executing ELF program) task for each loading process in the microkernel. This task is used to execute the code of the system service loader to load the ELF executable file and link the ELF dynamic link library. After the loading is completed System services, device drivers, and applications will all run in address spaces that are isolated from each other for their corresponding tasks.
S302:加载主模块:S302: Load the main module:
elf_task任务启动系统服务加载器并加载主模块,主模块是指ELF可执行文件所在的模块。图4是本实施例中加载主模块的流程图。如图4所示,本实施例中加载主模块的具体步骤包括:The elf_task task starts the system service loader and loads the main module. The main module refers to the module where the ELF executable file is located. Fig. 4 is a flow chart of loading the main module in this embodiment. As shown in Figure 4, the specific steps of loading the main module in this embodiment include:
S401:校验ELF头部合法性:S401: Verify the validity of the ELF header:
读取ELF可执行文件,校验ELF头部合法性,如果合法,则进入步骤S402,否则进行错误提示。Read the ELF executable file, check the legality of the ELF header, if it is legal, go to step S402, otherwise give an error prompt.
S402:解析文件:S402: Parse the file:
对ELF可执行文件进行解析,判断是否存在PT_INTERP段。在ELF可执行文件中,PT_INTERP段用于给出一个字符串的位置和长度,该字符串被当做解释器来调用,该段仅对可执行文件有意义,需要动态链接的可执行文件含有该段。因此,如果存在PT_INTERP段,则需要链接ELF动态链接库,如果不存在,则无需链接ELF动态链接库。然后记录解析得到的PT_LOAD(可加载)段和PT_DYNAMIC(动态链接信息)段。Parse the ELF executable file to determine whether there is a PT_INTERP segment. In the ELF executable file, the PT_INTERP segment is used to give the position and length of a string, which is called as an interpreter. This segment is only meaningful for executable files. The executable file that needs to be dynamically linked contains this part. Therefore, if the PT_INTERP section exists, the ELF dynamic link library needs to be linked, and if it does not exist, the ELF dynamic link library does not need to be linked. Then record the parsed PT_LOAD (loadable) segment and PT_DYNAMIC (dynamic link information) segment.
S403:PT_LOAD装载:S403: PT_LOAD loading:
对PT_LOAD段进行映射,然后将其装载到内存。本实施例中在内核中配置了一个适配系统服务加载器的接口SYS_MMAP,用于为ELF可执行文件和ELF动态链接库分配内存空间、映射内存,并载入到物理内存。Map the PT_LOAD segment and load it into memory. In this embodiment, an interface SYS_MMAP adapted to the system service loader is configured in the kernel to allocate memory space for the ELF executable file and the ELF dynamic link library, map the memory, and load it into the physical memory.
S404:获取依赖库:S404: Obtain dependent libraries:
遍历PT_DYNAMIC段,查找并记录所依赖的ELF动态链接库,得到依赖库列表。Traverse the PT_DYNAMIC section, find and record the dependent ELF dynamic link library, and get the list of dependent libraries.
S405:查找动态链接表格:S405: Find the dynamic link table:
查找并记录用于动态链接的表格,包括动态符号表、动态字符串表、hash(哈希)表。Find and record tables for dynamic linking, including dynamic symbol tables, dynamic string tables, and hash (hash) tables.
S406:解析起止段:S406: Analyzing the start and end segments:
解析并记录init段和finit段,init段和finit段用于在ELF可执行文件所对应模块的执行过程中进行初始化和收尾。Parse and record the init segment and the finit segment, which are used to initialize and finish during the execution of the module corresponding to the ELF executable file.
S303:判断步骤S302在加载主模块过程中是否检测到需要链接ELF动态链接库,如果是,进入步骤S304,否则加载结束。S303: Determine whether step S302 detects that the ELF dynamic link library needs to be linked during the process of loading the main module, if yes, go to step S304, otherwise, the loading ends.
S304:链接ELF动态链接库:S304: Link the ELF dynamic link library:
遍历ELF可执行文件中的依赖库列表,依次链接各个ELF动态链接库。图5是本实施例中链接ELF动态链接库的流程图。如图5所示,本实施例中链接ELF动态链接库的具体步骤包括:Traverse the list of dependent libraries in the ELF executable file, and link each ELF dynamic link library in turn. Fig. 5 is a flow chart of linking the ELF dynamic link library in this embodiment. As shown in Figure 5, the specific steps of linking the ELF dynamic link library in the present embodiment include:
S501:映射ELF动态链接库:S501: Mapping the ELF dynamic link library:
从依赖库列表中依次取出ELF动态链接库,如果该ELF动态链接库未被装载过,则将ELF动态链接库加入到装载集合中,否则不作任何操作。Take out the ELF dynamic link library sequentially from the dependent library list, if the ELF dynamic link library has not been loaded, then add the ELF dynamic link library to the loading set, otherwise do nothing.
S502:重定向:S502: Redirection:
遍历节区头部表,查找重定向节区SHT_REL(重定位表节区)和SHT_RELA(重定向表节区),对重定向节区中的外部符号(包括变量和函数)根据类型进行重定向,即将该外部符号在ELF动态链接库的相对地址按照动态链接的ELF可执行文件的地址空间转换为该地址空间中的确定地址。Traverse the section header table, find the redirection section SHT_REL (relocation table section) and SHT_RELA (redirection table section), and redirect the external symbols (including variables and functions) in the redirection section according to the type That is, the relative address of the external symbol in the ELF dynamic link library is converted into a definite address in the address space according to the address space of the dynamically linked ELF executable file.
S503:将ELF动态链接库装载到内存:S503: Load the ELF dynamic link library into memory:
从装载集合中依次取出各个ELF动态链接库的代码段和数据段,装载至内存。The code segments and data segments of each ELF dynamic link library are sequentially taken out from the loading set, and loaded into the memory.
尽管上面对本发明说明性的具体实施方式进行了描述,以便于本技术领域的技术人员理解本发明,但应该清楚,本发明不限于具体实施方式的范围,对本技术领域的普通技术人员来讲,只要各种变化在所附的权利要求限定和确定的本发明的精神和范围内,这些变化是显而易见的,一切利用本发明构思的发明创造均在保护之列。Although the illustrative specific embodiments of the present invention have been described above, so that those skilled in the art can understand the present invention, it should be clear that the present invention is not limited to the scope of the specific embodiments. For those of ordinary skill in the art, As long as various changes are within the spirit and scope of the present invention defined and determined by the appended claims, these changes are obvious, and all inventions and creations using the concept of the present invention are included in the protection list.
Claims (3)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211226300.2A CN115495158B (en) | 2022-10-09 | 2022-10-09 | Dynamic construction method for system service in microkernel operating system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211226300.2A CN115495158B (en) | 2022-10-09 | 2022-10-09 | Dynamic construction method for system service in microkernel operating system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115495158A CN115495158A (en) | 2022-12-20 |
CN115495158B true CN115495158B (en) | 2023-08-08 |
Family
ID=84472525
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211226300.2A Active CN115495158B (en) | 2022-10-09 | 2022-10-09 | Dynamic construction method for system service in microkernel operating system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115495158B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN119271220A (en) * | 2023-07-06 | 2025-01-07 | 华为技术有限公司 | Application installation package generation method, application installation method and related equipment |
CN119166269A (en) * | 2023-07-28 | 2024-12-20 | 京东科技信息技术有限公司 | Runtime virtual machine system, system operation method and device |
CN117421056B (en) * | 2023-12-18 | 2024-03-05 | 美智纵横科技有限责任公司 | System loading method and device, storage medium, computer program product and chip |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101697131A (en) * | 2009-11-04 | 2010-04-21 | 中兴通讯股份有限公司 | Method and device for dynamically loading relocatable file |
CN101706725A (en) * | 2009-11-20 | 2010-05-12 | 中兴通讯股份有限公司 | Method and system for loading and debugging relocatable program |
CN112328319A (en) * | 2020-09-30 | 2021-02-05 | 北京空间飞行器总体设计部 | Satellite-borne APP dynamic loading method supporting RAM file system |
CN113641413A (en) * | 2021-08-25 | 2021-11-12 | Oppo广东移动通信有限公司 | Target model loading and updating method and device, readable medium and electronic equipment |
-
2022
- 2022-10-09 CN CN202211226300.2A patent/CN115495158B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101697131A (en) * | 2009-11-04 | 2010-04-21 | 中兴通讯股份有限公司 | Method and device for dynamically loading relocatable file |
CN101706725A (en) * | 2009-11-20 | 2010-05-12 | 中兴通讯股份有限公司 | Method and system for loading and debugging relocatable program |
CN112328319A (en) * | 2020-09-30 | 2021-02-05 | 北京空间飞行器总体设计部 | Satellite-borne APP dynamic loading method supporting RAM file system |
CN113641413A (en) * | 2021-08-25 | 2021-11-12 | Oppo广东移动通信有限公司 | Target model loading and updating method and device, readable medium and electronic equipment |
Non-Patent Citations (1)
Title |
---|
袁鸿野.基于嵌入式操作系统的动态链接器设计与实现.电子科技大学硕士电子期刊.2013,(第2014年第01期期),全文. * |
Also Published As
Publication number | Publication date |
---|---|
CN115495158A (en) | 2022-12-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN115495158B (en) | Dynamic construction method for system service in microkernel operating system | |
RU2443012C2 (en) | Configuration of isolated extensions and device drivers | |
US7784044B2 (en) | Patching of in-use functions on a running computer system | |
US8612930B2 (en) | Methods and apparatus for dynamic class reloading and versioning | |
US8782670B2 (en) | System and method for application isolation | |
US9891939B2 (en) | Application compatibility with library operating systems | |
US8924922B2 (en) | Pre-compiling hosted managed code | |
JP4615971B2 (en) | Driver specific context for kernel mode shimming | |
US7340730B2 (en) | On demand, network accessible, run time compile server | |
US6317870B1 (en) | System and method for optimization of inter-module procedure calls | |
US8112745B2 (en) | Apparatus and method for capabilities verification and restriction of managed applications in an execution environment | |
US10019598B2 (en) | Dynamic service discovery | |
US8458651B2 (en) | Seamless migration of tuxedo® applications to a CICS® hosting environment | |
JP2004530184A (en) | Methods and systems for managing executables using shared libraries | |
US20100262694A1 (en) | System and Method for Application Isolation | |
WO2019079080A1 (en) | Using semantic annotations to control compatibility behaviors | |
US20050071856A1 (en) | Dynamically loadable stub modules | |
JP2006092544A (en) | Dynamic link of module in pre-operating system environment | |
US20040083467A1 (en) | System and method for executing intermediate code | |
US9183011B2 (en) | Method and system for runtime environment emulation | |
CN102364433A (en) | Method for realizing Wine construction tool transplanting on ARM (Advanced RISC Machines) processor | |
US9841982B2 (en) | Locating import class files at alternate locations than specified in classpath information | |
US20120005464A1 (en) | Start up processing method, information processing apparatus, and computer-readable storage medium storing program | |
US20060288085A1 (en) | Modular server architecture for multi-environment HTTP request processing | |
US20050071833A1 (en) | Utilization of platform-based optimization routines by a computer system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |