A method for efficient dynamic software loading based on an embedded platform
By preprocessing the target file parsing and symbol relocation of the embedded platform on the host computer and using a linked list structure to store the symbol table, the problem of high performance overhead during dynamic loading of the embedded platform is solved, and the efficiency of dynamic loading and system response speed are improved.
Patent Information
- Application Number
- CN202411712697.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2044-11-27
AI Technical Summary
On embedded platforms, how can we optimize the dynamic loading process with limited hardware resources, reduce performance overhead, and solve the problems of excessively long dynamic loading times or system lag?
The parsing, symbol verification, and symbol relocation of the target file are pre-completed on the host computer with sufficient performance resources. The symbol table is stored using a linked list structure to reduce the dynamic loading workload of the lower computer.
It significantly shortens the dynamic loading time of the lower-level machine, improves the speed and efficiency of dynamic loading, maintains the flexibility and scalability of dynamic loading, and solves the problem of high performance consumption and time consumption in environments with limited hardware resources.
Smart Images

Figure CN119829157B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of embedded operating systems, and specifically relates to a method for efficient dynamic loading of software based on an embedded platform. Background Technology
[0002] With the rapid development of electronic technology, embedded devices are being used more and more widely, and their complexity is constantly increasing. By splitting software into static libraries and then linking and packaging the system and application together into a single object file, parallel development of multi-module embedded software has been achieved. However, as the program size gradually increases, the shortcomings of the static library loading model become increasingly apparent, such as wasted memory and disk space; the need to compile and link the application and operating system into a single unit during development limits development flexibility; and the need to recompile, link, and repeatedly download and run the software when encountering problems during debugging, increasing the development cycle and exacerbating the difficulty of software updates.
[0003] To address the aforementioned issues, in recent years, a new generation of high-performance embedded operating systems has begun to introduce dynamic loading technology, separating the development of the basic system and application programs. Dynamic loading technology breaks down fully functional embedded software into an initially loaded "system object file" and an on-demand loaded "application object file," eliminating the need for pre-linking between the two parts of the embedded software program; instead, linking occurs during runtime. This technological breakthrough significantly reduces the difficulty of developing and debugging embedded operating system modules, improving overall system performance. It is of great importance for ensuring system reliability, extending system lifespan, and reducing system development costs.
[0004] Dynamic loading technology is primarily used in high-performance operating systems such as Linux, requiring process space and high-performance workloads. It is not suitable for embedded operating systems that cannot allocate process space or for embedded hardware environments with severely limited memory. Therefore, based on dynamic loading, explicit runtime linking (DML) was proposed. In this technology, the system program can autonomously control the loading of specified modules at runtime and unload them when no longer needed. Furthermore, loaded modules can be shared by multiple programs on the hardware. This technology makes software programs more flexible and effectively reduces program startup time and memory usage.
[0005] In the embedded systems field, due to the limitations of hardware space, the software performance resources that embedded hardware can provide are extremely limited and precious. Although explicit runtime linking technology can delay the loading of application object files, thereby reducing system program startup time, it does not fundamentally solve the fundamental contradiction between the large performance resource consumption during dynamic loading and the limited performance of the embedded hardware environment.
[0006] The dynamic loading process involves a series of operations by the operating system, including loading and linking the application target file content. These steps inevitably consume CPU time and memory resources. Especially during the initial loading of the application target file, multiple complex steps are required, such as reading the file, resolving the symbol table, and establishing link relationships. Among these, symbol resolution, symbol verification, and symbol relocation have particularly significant performance overhead. If the dynamically loaded library is large, or if the embedded hardware performance is insufficient, the dynamic loading time may be further extended, adversely affecting the program's normal functionality and response speed. Therefore, optimizing the dynamic loading process and reducing performance overhead under limited hardware resources has become a critical problem that urgently needs to be solved in current embedded system development. Summary of the Invention
[0007] (a) Technical problems to be solved
[0008] The technical problem this invention aims to solve is how to provide an efficient dynamic software loading method based on an embedded platform, in order to optimize the dynamic loading process and reduce performance overhead under limited hardware resources.
[0009] (II) Technical Solution
[0010] To address the aforementioned technical problems, this invention proposes an efficient dynamic software loading method based on an embedded platform, which includes the following steps:
[0011] Step 1: Object file parsing: Parse the object files of the embedded software to obtain their respective symbol table information;
[0012] Step 2: Dynamic Symbol Confirmation: Confirm the dynamic symbols in the target file;
[0013] Step 3: Symbol relocation: Relocate the symbols in the application object file, converting dynamic addresses to static addresses relative to the system object file;
[0014] Step 4: Symbol table merging: Merge the system object file symbol table with all loaded application object file symbol tables, and create a linked list structure in the host computer for storage.
[0015] (III) Beneficial Effects
[0016] This invention proposes an efficient dynamic software loading method based on an embedded platform. This method utilizes ample performance resources in the host computer to pre-complete the software parsing, symbol retrieval, and symbol relocation processes for the dynamically loaded library. This reduces the dynamic loading work performed on the resource-constrained lower-level machine, shortening the processing time and performance overhead of the program during dynamic loading on the lower-level machine. It fundamentally solves the problems of excessive processing time or system lag in traditional dynamic loading technologies.
[0017] This invention ensures the correct priority of symbol retrieval and the convenience of dynamic loading by storing the processed symbol table in a linked list structure on the host computer. First, the linked list format rationally sorts executable files and dynamically loaded libraries according to their loading order, ensuring the symbol priority order. Second, the linked list integrates all loaded files into a single, directly searchable object, simplifying the processing model during reloading. Finally, the linked list approach allows for clear and accurate maintenance of loaded library files, facilitating subsequent uninstallation and inspection.
[0018] The method proposed in this invention has the following advantages:
[0019] 1. Applicable to different hardware architectures, with broad compatibility;
[0020] 2. It only uses the development environment software required for program compilation, reducing dependence on external software;
[0021] 3. The operation process is clear, and the steps are efficient and concise;
[0022] 4. While improving the efficiency of dynamic loading, it fully retains the flexibility and scalability of the dynamic loading development model;
[0023] 5. It provides a simplified and efficient processing method for subsequent dynamic loading or unloading, enhancing the maintainability and scalability of the system. Attached Figure Description
[0024] Figure 1 This is a flowchart of the method of the present invention;
[0025] Figure 2 This is a diagram showing the relationship between documents and information in this invention. Detailed Implementation
[0026] To make the objectives, contents, and advantages of the present invention clearer, the specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples.
[0027] To address the aforementioned problems in existing technologies, this invention provides a method for efficient dynamic software loading based on an embedded platform. The core of this method lies in utilizing a host computer with relatively abundant hardware performance and space resources to pre-compile the parsing of the target file, the identification of symbols, and the relocation of symbol addresses.
[0028] This invention significantly reduces the computational load and complexity of dynamic loading on resource-constrained lower-level machines, thereby greatly improving the speed of dynamic loading, optimizing the overall performance of the program, and effectively shortening the time required for dynamic loading. At the same time, this method fully retains the advantages of dynamic loading in terms of flexibility and scalability, providing a more efficient and practical solution for the dynamic loading of embedded platform software.
[0029] To achieve the above objectives, this invention provides a method for efficient dynamic software loading based on an embedded platform. This method pre-processes the dynamic loading task in a host computer environment with sufficient hardware performance and space resources, aiming to reduce the workload of the slave computer during the dynamic loading process, thereby effectively solving the problems of high performance consumption and long loading time during slave computer dynamic loading. The specific steps are as follows, and the flowchart of the implementation steps can be found in [link to flowchart]. Figure 1 See the diagram showing the relationship between files and information. Figure 2 .
[0030] This invention provides a method for efficient dynamic software loading based on an embedded platform, comprising the following steps:
[0031] Step 1: Object file parsing: Parse the object files of the embedded software to obtain their respective symbol table information;
[0032] Step 2: Dynamic Symbol Confirmation: Confirm the dynamic symbols in the target file;
[0033] Step 3: Symbol relocation: Relocate the symbols in the application object file, converting dynamic addresses to static addresses relative to the system object file;
[0034] Step 4: Symbol table merging: Merge the system object file symbol table with all loaded application object file symbol tables, and create a linked list structure in the host computer for storage.
[0035] The technical solution of the present invention is described in detail below.
[0036] Step 1: Parsing the target file
[0037] The primary step of the method described in this invention is to perform deep parsing of the embedded software's target files. These target files are categorized into system target files and application target files. During the parsing process, if the system target file has already been parsed along with other application target files and a modified symbol table has been generated, this symbol table can be directly retrieved from the host computer system, thus skipping subsequent processing in this step. However, for application target files, parsing still needs to be completed according to the following process.
[0038] S11. Open the target file using the libelf library or other development environment tools, examine the ELF file magic number, and read and parse the ELF file header. Obtain information such as the ELF file type, structure, entry point address, location and size of the program header table, and location and size of the section header table.
[0039] S12. Then, based on the section header table offset and the number of entries provided in the ELF file header, the file pointer is used to move to the location of the section header table. From this location, the system can begin reading the contents of the section header table.
[0040] S13. Subsequently, the contents of the section header table are traversed to find the section header of type SHT_SYMTAB (static symbol table) or SHT_DYNSYM (dynamic symbol table). In this section, the sh_offset member stores the offset of the symbol table in the file, and the sh_size member stores the size of the symbol table.
[0041] S14. Finally, the code segment of the corresponding sh_size size is read according to the sh_offset address in the section header table. This is the content of the extracted executable file symbol table and the symbol table of the dynamically loaded library file.
[0042] Step Two: Confirmation of Dynamic Symbols
[0043] Given the respective functional purposes of the two types of object files, the application object file needs to extensively call function interfaces and system variables provided by the system object file during compilation, but these symbols are not actually linked. To leverage the performance advantages of the host computer to accelerate the dynamic loading process, this invention requires prior identification of the functions and variables referenced by the application object file, i.e., dynamic symbols. The identification steps are as follows:
[0044] S21. Retrieve the symbol table of the application target file and filter symbols with segment type "UND". These symbols indicate that they are referenced in the application target file but are not defined in the file.
[0045] S22. The selected symbols are searched in the system object file symbol table in order, from front to back. This order is related to the subsequent modification of the system object file symbol table and aims to resolve symbol name conflicts when loading multiple application object files.
[0046] S23. Record all successfully retrieved symbols, which are the functions and variables provided by the system object files referenced by the application object files, i.e., dynamic symbols.
[0047] Step 3: Symbol Relocation
[0048] In the previous step, we obtained symbol information such as the type and address of the dynamic symbols actually defined in the system object file. In this step, we use the objcopy tool, libelf library functions, or other specialized tools to correct the application object file.
[0049] Based on the acquired dynamic symbol information, the attributes of dynamic symbols in the application target file are updated one by one, covering symbol size, relocation address, symbol type, binding information, and the segment to which it belongs. This process only uses the corresponding symbol attributes in the system target file to overwrite the dynamic symbol attributes of the application target file, without changing the size and offset address of the symbol table in the application target file. Therefore, there is no need to adjust its ELF header information and other parameters, ensuring the correctness of the encoding of the application target file.
[0050] After completing the above operations, the application target file is processed and can be deployed on the lower-level machine along with the system target file. During the execution of the target file on the lower-level machine, the system program is responsible for dynamically allocating memory addresses for the target file and sending the actual starting memory address of the target file to the upper-level machine via serial communication or network devices. This allows the upper-level machine to convert the relative addresses in the target file's symbol table into absolute physical addresses at runtime. Since the external functions and variables referenced in the symbol table have already been relocated, the dynamic linker of the lower-level machine does not need to repeat the relocation operation when running the target file.
[0051] Step 4: Symbol table merging
[0052] After the aforementioned operations, the system object file symbol table and the relocated application object file symbol table can be obtained. If the user only needs to load a single application object file for the system object file, there is no need to merge the symbol tables. However, the advantage of the dynamic loading mechanism is that it allows the system object file to load multiple application object files, thereby improving the system's scalability and modularity.
[0053] To ensure that subsequently loaded application target files can fully access the symbol tables of all previously loaded application target files, a linked list structure needs to be created in the host computer based on the system target files. Each system target file corresponds to a linked list, which stores the symbol table of the corresponding system target file and the symbol tables of all application target files loaded into that system target file. If a corresponding linked list already exists for a system target file, it is not necessary to create a new one; simply treat the existing linked list as the system target file symbol table. Linked list operations include:
[0054] S41. Store the symbol table of the system object file at the first node of the linked list;
[0055] S42. Add a jump instruction to the end of the system object file symbol table so that the search process can smoothly jump to the next node;
[0056] S43. Store the symbol table of the application target file at the tail node of the linked list;
[0057] S44. Remove all dynamic symbols and related information from the symbol table of the application target file;
[0058] S45. Based on the starting address information of the application target file, correct the global symbol addresses in its symbol table and convert the dynamic addresses to static addresses;
[0059] S46. Save the entire linked list structure as a symbol table file of the system object file in the host computer so that the system object file can be used the next time it is dynamically loaded.
[0060] The above operations ensure that when adding new application target files to the system target files, all symbol tables in the linked list are treated as symbol tables of the system target files and processed in accordance with the symbol priority rules. The symbol priority rules are as follows: symbols of the system target files are called first, followed by symbols of application target files loaded earlier, according to the loading order. If it is necessary to unload a loaded application target file, the host computer only needs to delete the corresponding node from the linked list without worrying about affecting the overall retrieval priority order.
[0061] Key points of this invention:
[0062] This invention proposes a highly efficient dynamic software loading method based on an embedded platform. This technology fully leverages the difference between the abundant performance resources of the host computer and the limited performance and precious resources of the slave computer. By pre-implementing system target file parsing, dynamic symbol verification, and symbol relocation steps on the host computer, it achieves valid address verification and precise relocation of undefined symbols in the application target file. This method effectively solves the processing delay or slow system response caused by the large number of retrieval and rewriting operations required by the slave computer during the dynamic loading of application target files.
[0063] This invention employs a linked list data structure to store the symbol tables of system target files and all loaded application target files in the host computer. This design enables faster access and retrieval of the symbol tables, providing a fast and efficient processing mechanism for subsequent dynamic loading and unloading. By treating the processed symbol tables stored in a linked list as a unified processing object, the processing flow during dynamic loading is simplified. Furthermore, this technical solution maintains logical rules for symbol priority, effectively avoiding symbol name conflicts.
[0064] Effects of the invention:
[0065] The proposed method for efficient dynamic software loading based on an embedded platform utilizes the ample performance resources of the host computer to pre-complete the software parsing, symbol retrieval, and symbol relocation processes for dynamically loaded libraries. This reduces the dynamic loading work performed on the lower-level machine with limited performance resources, shortens the processing time and performance consumption of the program during dynamic loading on the lower-level machine, and fundamentally solves the problems of excessive processing time or system lag in traditional dynamic loading technologies.
[0066] This invention ensures the correct priority of symbol retrieval and the convenience of dynamic loading by storing the processed symbol table in a linked list structure on the host computer. First, the linked list format rationally sorts executable files and dynamically loaded libraries according to their loading order, ensuring the symbol priority order. Second, the linked list integrates all loaded files into a single, directly searchable object, simplifying the processing model during reloading. Finally, the linked list approach allows for clear and accurate maintenance of loaded library files, facilitating subsequent uninstallation and inspection.
[0067] The method proposed in this invention has the following advantages:
[0068] 1. Applicable to different hardware architectures, with broad compatibility;
[0069] 2. It only uses the development environment software required for program compilation, reducing dependence on external software;
[0070] 3. The operation process is clear, and the steps are efficient and concise;
[0071] 4. While improving the efficiency of dynamic loading, it fully retains the flexibility and scalability of the dynamic loading development model;
[0072] 5. It provides a simplified and efficient processing method for subsequent dynamic loading or unloading, enhancing the maintainability and scalability of the system.
[0073] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A method for efficient dynamic software loading based on an embedded platform, characterized in that, The method includes the following steps: Step 1: Target file parsing: Parse the target files of the embedded software to obtain their respective symbol table information; Step 2: Dynamic Symbol Confirmation: Confirm the dynamic symbols in the target file; Step 3: Symbol relocation: Relocate the symbols in the application object file, converting dynamic addresses to static addresses relative to the system object file; Step 4: Symbol table merging: Merge the system object file symbol table with all loaded application object file symbol tables, and create a linked list structure in the host computer for storage; in, Step one specifically includes the following steps: S11. Open the target file using the libelf library or other development environment tools, check the ELF file magic number, read and parse the ELF file header; obtain the ELF file type, structure, entry point address, program header table location and size, and section header table location and size information; S12. Then, based on the section header table offset and the number of entries provided in the ELF file header, the file pointer is used to move to the location of the section header table; from this location, the system can begin reading the contents of the section header table; S13. Then, traverse the contents of the section header table and look for the section header of type SHT_SYMTAB or SHT_DYNSYM. In this section, the sh_offset member stores the offset of the symbol table in the file, and the sh_size member stores the size of the symbol table. S14. Finally, the code segment of the corresponding sh_size size is read according to the sh_offset address in the section header table. This is the content of the extracted executable file symbol table and the symbol table of the dynamically loaded library file. Step two specifically includes: S21. Retrieve the symbol table of the application target file and filter symbols with segment type "UND". These symbols indicate that they are referenced in the application target file but are not defined in the file. S22. The symbols selected above are searched in the system object file symbol table in order, from front to back. This order is related to the subsequent modification of the system object file symbol table. S23. Record all successfully retrieved symbols. These symbols are the functions and variables provided by the system object files referenced by the application object files, i.e., dynamic symbols.
2. The efficient dynamic software loading method based on an embedded platform as described in claim 1, characterized in that, In step one, if the system target file has been parsed with other application target files and a modified symbol table has been generated during the parsing process, the symbol table can be directly retrieved from the host computer system, thus skipping the subsequent processing of this step; however, for application target files, parsing still needs to be completed according to the process.
3. The efficient dynamic software loading method based on an embedded platform as described in claim 1, characterized in that, In step three, the application target file is modified using the objcopy tool, libelf library functions, or other specialized tools.
4. The efficient dynamic software loading method based on an embedded platform as described in claim 1, characterized in that, In step three, based on the obtained dynamic symbol information, the attributes of the dynamic symbols in the application target file are updated one by one, covering symbol size, relocation address, symbol type, binding information and the segment to which they belong. This process only uses the corresponding symbol attributes in the system target file to overwrite the dynamic symbol attributes of the application target file, without changing the size and offset address of the symbol table of the application target file. Therefore, there is no need to adjust its ELF header information and other parameters, ensuring the correctness of the encoding of the application target file.
5. The efficient dynamic software loading method based on an embedded platform as described in claim 1, characterized in that, In step three, during the execution of the target file by the lower-level machine, the system program is responsible for dynamically allocating memory addresses for the target file and sending the actual starting memory address of the target file to the upper-level machine through serial communication or network devices, so that the upper-level machine can convert the relative addresses in the target file symbol table into the absolute physical addresses at actual runtime. Since the external functions and variables referenced in the symbol table have been relocated in advance, the dynamic linker of the lower-level machine does not need to repeat the relocation operation when running the target file.
6. The efficient dynamic software loading method based on an embedded platform as described in any one of claims 3-5, characterized in that, In step four, to ensure that the application target files loaded subsequently can fully access the symbol tables of all previously loaded application target files, a linked list structure needs to be created in the host computer based on the system target files; each system target file corresponds to a linked list, which is used to store the symbol table of the corresponding system target file and the symbol tables of all application target files loaded into the system target file; If a corresponding linked list already exists for the system object file, there is no need to create a new one; simply treat the existing linked list as the symbol table of the system object file.
7. The efficient dynamic software loading method based on an embedded platform as described in claim 6, characterized in that, In step four, the linked list operations include: S41. Store the symbol table of the system object file at the first node of the linked list; S42. Add a jump instruction to the end of the system object file symbol table so that the search process can smoothly jump to the next node; S43. Store the symbol table of the application target file at the tail node of the linked list; S44. Remove all dynamic symbols and related information from the symbol table of the application target file; S45. Based on the starting address information of the application target file, correct the global symbol addresses in its symbol table and convert the dynamic addresses to static addresses; S46. Save the entire linked list structure as a symbol table file of the system object file in the host computer so that the system object file can be used the next time it is dynamically loaded.
8. The efficient dynamic software loading method based on an embedded platform as described in claim 7, characterized in that, Step four ensures that when adding new application target files to the system target file, all symbol tables in the linked list can be treated as symbol tables of the system target file and processed in accordance with the symbol priority rules. The symbol priority rules are as follows: first, the symbols of the system target file are called, and then according to the loading order, the symbols of the application target file with the earlier loading time have higher priority. If it is necessary to unload the loaded application target file, the host computer only needs to delete the corresponding node from the linked list without worrying about affecting the overall retrieval priority order.
Citation Information
Patent Citations
Local dynamic loading system and method based on direct reading and writing FLASH
CN108829465A
ELF loading method based on microkernel operating system
CN117193882A