Software efficient dynamic loading method based on embedded platform

By pre-completed the analysis and relocation of the dynamic loading library in the host computer, and storing the symbol table using the linked list structure, the problem of dynamic loading process optimization under limited hardware resources is solved, and more efficient dynamic loading and system performance improvement is achieved.

CN119829157AActive Publication Date: 2025-04-15BEIJING INST OF COMP TECH & APPL

Patent Information

Application Number
CN202411712697.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-27
Publication Date
2025-04-15
Estimated Expiration
2044-11-27

AI Technical Summary

Technical Problem

With limited hardware resources, how to optimize the dynamic loading process, reduce performance overhead, and solve the problem that the dynamic loading time may be extended, affecting program functions and response speed.

Method used

Use sufficient performance resources in the upper computer to pre-complete the software parsing, symbol retrieval and symbol relocation processes of the dynamic loading library, reduce the dynamic loading work on the lower computer, and store the processed symbol tables through the linked list structure to ensure the priority of symbol retrieval and the convenience of dynamic loading.

Benefits of technology

It significantly reduces the processing time and performance usage of dynamic loading on the lower computer, solves the problem of excessive processing time or system lag in traditional dynamic loading technology, and improves dynamic loading efficiency and system performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829157A_ABST
    Figure CN119829157A_ABST
Patent Text Reader

Abstract

The invention relates to a software efficient dynamic loading method based on an embedded platform, and belongs to the field of embedded operating systems. The method comprises the following steps: analyzing a target file of embedded software to obtain respective symbol table information; confirming a dynamic symbol in the application target file; repositioning symbols in the application target file, and converting a dynamic address into a static address relative to the system target file; and combining the system target file symbol table with all the loaded application target file symbol tables, and creating a linked list structure in the upper computer for storage. According to the method, the dynamic loading work performed on the lower computer with limited performance resources is reduced, and the processing time and performance occupation of dynamic loading of the program in the lower computer are shortened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of embedded operating systems, and in particular relates to a software efficient dynamic loading method based on an embedded platform. Background Art

[0002] With the rapid development of electronic technology, the application of embedded devices is becoming more and more extensive, and the complexity is also increasing. By splitting the software in the form of static libraries, and then linking the system and the application to form a target file, the multi-module parallel development of embedded software is realized. However, as the scale of the program gradually expands, the shortcomings of the static library loading mode are gradually highlighted, such as the waste of memory and disk space; the application needs to be compiled and linked to the operating system as a whole during the development process, which limits the flexibility of development; when problems are encountered during debugging, it is necessary to re-link and download and run repeatedly, which increases the development cycle and aggravates the difficulty of software updates.

[0003] In response to the above problems, in recent years, a new generation of high-performance embedded operating systems has begun to introduce dynamic loading technology to separate the development of basic systems and application programs. Dynamic loading technology splits embedded software with complete functions into the "system target file" loaded initially and the "application target file" loaded on demand, so that the two parts of the embedded software program are no longer linked in advance, but are linked when the program is running. This technological breakthrough has greatly reduced the difficulty of developing and debugging embedded operating system modules and improved the overall performance of the system. It is of great significance to ensure system reliability, extend system life cycle, and reduce system development costs.

[0004] Dynamic loading technology is mainly used in high-performance operating systems such as Linux. It requires the support of process space and high-performance loads, and is not suitable for embedded operating systems that cannot allocate process space and embedded hardware environments with severely limited memory. Therefore, based on dynamic loading technology, the explicit run-time linking technology is proposed. In this technology, the system program can autonomously control the loading of specified modules at runtime and unload them when they are not needed. At the same time, the loaded modules can also be shared by multiple programs on the hardware. The introduction of this technology makes software programs more flexible and effectively reduces the startup time and memory usage of programs.

[0005] In the embedded field, due to the limitation 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 time of application target files and thus reduce the startup time of system programs, it does not fundamentally solve the fundamental contradiction between the large performance resource usage during dynamic loading and the limited performance of embedded hardware environment.

[0006] The dynamic loading process involves a series of operations such as loading and linking the application target file content by the operating system. These steps will inevitably consume a certain amount of CPU time and memory resources. Especially when the application target file is loaded for the first time, it is necessary to execute multiple complex links such as reading files, parsing symbol tables, and establishing link relationships. Among them, the performance overhead of symbol resolution, symbol confirmation, and symbol relocation is particularly significant. If the content of the dynamic loading library is relatively large, or the performance of the embedded hardware is insufficient, the dynamic loading time may be further extended, which will have an adverse effect on the normal function and response speed of the program. Therefore, how to optimize the dynamic loading process and reduce performance overhead under limited hardware resources has become a key issue that needs to be solved in the current embedded system development. Summary of the invention

[0007] 1. Technical issues to be resolved

[0008] The technical problem to be solved by the present invention is how to provide a method for efficiently dynamically loading software based on an embedded platform, so as to solve the problem of how to optimize the dynamic loading process and reduce performance overhead under limited hardware resources.

[0009] (II) Technical solution

[0010] In order to solve the above technical problems, the present invention proposes a method for efficient dynamic loading of software based on an embedded platform, the method comprising the following steps:

[0011] Step 1: Target file parsing: Parse the target file of the embedded software to obtain the respective symbol table information;

[0012] Step 2: Dynamic symbol confirmation: confirm the dynamic symbols in the application target file;

[0013] Step 3: Symbol relocation: relocate the symbols in the application target file and convert the dynamic address into a static address relative to the system target file;

[0014] Step 4: Symbol table merging: Merge the system target file symbol table with all loaded application target file symbol tables, and create a linked list structure in the host computer for storage.

[0015] (III) Beneficial effects

[0016] The present invention proposes an embedded platform-based efficient software dynamic loading method. The embedded platform-based efficient software dynamic loading method proposed by the present invention utilizes sufficient performance resources in a host computer to pre-complete software parsing, symbol retrieval and symbol relocation processes of a dynamic loading library, thereby reducing dynamic loading work on a slave computer with limited performance resources, shortening the processing time and performance occupancy of dynamic loading of a program in the slave computer, and fundamentally solving the problem of long processing time of the slave computer or system freeze in traditional dynamic loading technology.

[0017] The present invention ensures the priority correctness of symbol retrieval and the convenience of dynamic loading by storing the processed symbol table in a linked list structure in the upper computer. First, the linked list format reasonably sorts the executable file and the dynamic loading library according to the loading order, ensuring the symbol priority order; secondly, the linked list integrates all loaded files into a whole object that can be directly retrieved, simplifying the processing model when loading again; finally, the linked list method can clearly and accurately maintain the loaded library files, facilitating subsequent unloading and inspection work.

[0018] The method proposed by the present invention has the following advantages:

[0019] 1. Applicable to different hardware architectures and has wide compatibility;

[0020] 2. Only the development environment software required for program compilation is used, reducing the 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, the flexibility and scalability of the dynamic loading development model are fully preserved;

[0023] 5. It provides a simplified and efficient processing method for subsequent dynamic loading or unloading, enhancing the maintainability and scalability of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 is a flow chart of the method of the present invention;

[0025] Figure 2 It is a document and information relationship diagram of the present invention. DETAILED DESCRIPTION

[0026] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.

[0027] In order to solve the above problems existing in the prior art, the present invention provides a method for efficient dynamic loading of software based on an embedded platform. The core of the method is to use a host computer with relatively sufficient hardware performance and space resources to pre-complete the analysis of the target file, the confirmation of the symbol and the relocation of the symbol address.

[0028] The present invention can significantly reduce the amount of calculation and complexity of dynamic loading on a lower computer with limited performance resources, 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, the method also fully retains the advantages of dynamic loading in terms of flexibility and scalability, and provides a more efficient and practical solution for dynamic loading of embedded platform software.

[0029] To achieve the above purpose, the present invention provides a method for efficient dynamic loading of software based on an embedded platform. The 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 lower computer during the dynamic loading process, thereby effectively solving the problem of high performance occupation and long time consumption during dynamic loading of the lower computer. The specific process steps are as follows, and the implementation step flow chart is shown in Figure 1 , the file and information relationship diagram is shown in Figure 2 .

[0030] The present invention provides a method for efficiently dynamically loading software based on an embedded platform, comprising the following steps:

[0031] Step 1: Target file parsing: Parse the target file of the embedded software to obtain the respective symbol table information;

[0032] Step 2: Dynamic symbol confirmation: confirm the dynamic symbols in the application target file;

[0033] Step 3: Symbol relocation: relocate the symbols in the application target file and convert the dynamic address into a static address relative to the system target file;

[0034] Step 4: Symbol table merging: Merge the system target file symbol table with all loaded application target file symbol tables, and create a linked list structure in the host computer for storage.

[0035] The technical solution of the present invention is specifically described as follows.

[0036] Step 1: Target file parsing

[0037] The first step of the method of the present invention is to deeply analyze the target file of the embedded software, and the analyzed target file is divided into two categories: system target file and application target file. During the analysis process, if the system target file has been analyzed with other application target files and a modified symbol table has been generated, the symbol table can be directly called from the host computer system, thereby skipping the subsequent processing of this step. However, for the application target file, it is still necessary to complete the analysis according to the following process.

[0038] S11. Use libelf library or other development environment tools to open the target file, check the ELF file magic number, read and parse the ELF file header of the file, and obtain the type, architecture, entry point address, location and size of the program header table, location and size of the section header table, etc. of the ELF file.

[0039] S12, then, according to the section header table offset and the number of entries information provided by the ELF file header, the file pointer is used to move to the section header table position. From this position, the system can start to read the content of the section header table.

[0040] S13. Then, traverse the contents of the section header table to find a 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, which is the symbol table content of the executable file and the symbol table content of the dynamically loaded library file extracted by parsing.

[0042] Step 2: Dynamic symbol confirmation

[0043] In view of the functional purposes of the two types of target files, the application target file needs to call a large number of function interfaces and system variables provided by the system target file during the compilation process, but does not actually link these symbols. In order to take advantage of the performance of the host computer to accelerate the dynamic loading process, the present invention needs to confirm the functions and variables referenced by the application target file, that is, dynamic symbols, in advance. The confirmation steps are as follows:

[0044] S21. Search the application target file symbol table and filter out symbols with a segment type of "UND". Such symbols are referenced in the application target file but not defined in the file.

[0045] S22, the symbols selected above are searched in order in the system target file symbol table, and the search order is from front to back. This order is related to the subsequent modification of the system target file symbol table, and is intended to solve the symbol name conflict when loading multiple application target files.

[0046] S23. Record all successfully retrieved symbols, which are functions and variables provided by the system target file referenced by the application target file, namely dynamic symbols.

[0047] Step 3: Symbol relocation

[0048] In the previous step, the symbol information such as the type and address actually defined by the dynamic symbol in the system target file has been obtained. In this step, the application target file is corrected using the objcopy tool, libelf library function or other professional tools.

[0049] Based on the obtained dynamic symbol information, the properties of the dynamic symbols in the application target file are updated one by one, including symbol size, relocation address, symbol type, binding information, and belonging segment, etc. This process only uses the corresponding symbol properties in the system target file to overwrite the dynamic symbol properties of the application target file, and does not change 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 to ensure 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 computer together with the system target file. During the execution of the target file by the lower computer, 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 computer through serial communication or network equipment, so that the upper computer can convert the relative address in the symbol table of the target file into the absolute physical address 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 computer does not need to repeat the relocation operation when running the target file.

[0051] Step 4: Symbol table merging

[0052] After the above operations, the symbol table of the system target file and the symbol table of the relocated application target file can be obtained. If the user only needs to load a single application target file for the system target file, there is no need to merge the symbol tables. However, the advantage of the dynamic loading mechanism is that it allows the system target file to load multiple application target files, thereby improving the scalability and modularity of the system.

[0053] To ensure that the application target file loaded later can fully access the symbol tables of all previously loaded application target files, it is necessary to create a linked list structure based on the system target file in the host computer. Each system target file corresponds to a linked list, which is used to store the corresponding system target file symbol table and all application target file symbol tables loaded into the system target file. If the corresponding linked list already exists for the system target file, there is no need to create a new one. You only need to treat the existing linked list as the system target file symbol table. Linked list operations include:

[0054] S41, the symbol table of the system target file is stored in the first node position of the linked list;

[0055] S42, adding a jump instruction at the end of the system target file symbol table so as to smoothly jump to the next node during the retrieval process;

[0056] S43, storing the symbol table of the application target file at the tail node position of the linked list;

[0057] S44, removing all dynamic symbols and related information from the symbol table of the application target file;

[0058] S45, according to the starting address information of the application target file, the global symbol address in the symbol table is corrected, and the dynamic address is converted into a static address;

[0059] S46, saving the entire linked list structure in the host computer as a symbol table file of the system target file, so that the system target file can be used when dynamically loaded next time.

[0060] The above operation ensures that when a new application target file is added to the system target file later, all symbol tables in the linked list can be uniformly treated as symbol tables of the system target file and the symbol priority rule is met. The symbol priority rule is: first call the symbol of the system target file, and then follow the loading order. The earlier the application target file is loaded, the higher the symbol priority. If the loaded application target file needs to be unloaded, the host computer only needs to delete the corresponding node from the linked list without worrying about affecting the overall retrieval priority order.

[0061] The key points of the present invention are:

[0062] The present invention proposes a method for efficient dynamic loading of software based on an embedded platform. This technology makes full use of the difference between the abundant performance resources of the host computer and the limited performance and precious resources of the lower computer. By pre-implementing the system target file parsing, dynamic symbol confirmation and symbol relocation steps on the host computer, the effective address confirmation and accurate relocation of undefined symbols in the application target file are realized. This method effectively solves the problem of processing delay or slow system response caused by the need to perform a large number of retrieval and rewriting operations in the process of dynamic loading of application target files by the lower computer.

[0063] The present invention adopts a linked list data structure to store the symbol table of the system target file and the symbol table of all loaded application target files in the host computer. This design makes the access and retrieval of the symbol table faster, and provides a fast and efficient processing mechanism for subsequent dynamic loading and dynamic unloading. By treating the processed symbol table storage linked list as a unified processing object, the processing flow in the dynamic loading process is simplified. In addition, the technical solution also maintains the logical rule of symbol priority, effectively avoiding symbol name conflicts.

[0064] Effects of the present invention:

[0065] The invention proposes an efficient software dynamic loading method based on an embedded platform, which utilizes sufficient performance resources in the upper computer to complete the software parsing, symbol retrieval and symbol relocation processes of the dynamic loading library in advance, thereby reducing the dynamic loading work performed on the lower computer with limited performance resources, shortening the processing time and performance occupancy of the program dynamically loaded in the lower computer, and fundamentally solving the problem of long processing time of the lower computer or system jamming in traditional dynamic loading technology.

[0066] The present invention ensures the priority correctness of symbol retrieval and the convenience of dynamic loading by storing the processed symbol table in a linked list structure in the upper computer. First, the linked list format reasonably sorts the executable file and the dynamic loading library according to the loading order, ensuring the symbol priority order; secondly, the linked list integrates all loaded files into a whole object that can be directly retrieved, simplifying the processing model when loading again; finally, the linked list method can clearly and accurately maintain the loaded library files, facilitating subsequent unloading and inspection work.

[0067] The method proposed by the present invention has the following advantages:

[0068] 1. Applicable to different hardware architectures and has wide compatibility;

[0069] 2. Only the development environment software required for program compilation is used, reducing the 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, the flexibility and scalability of the dynamic loading development model are fully preserved;

[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 is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A software efficient dynamic loading method based on an embedded platform, characterized in that: The method comprises the following steps: Step 1: Target file parsing: Parse the target file of the embedded software to obtain the respective symbol table information; Step 2: Dynamic symbol confirmation: confirm the dynamic symbols in the application target file; Step 3: Symbol relocation: relocate the symbols in the application target file and convert the dynamic address into a static address relative to the system target file; Step 4: Symbol table merging: Merge the system target file symbol table with all loaded application target file symbol tables, and create a linked list structure in the host computer for storage.

2. The method for efficient dynamic loading of software based on an embedded platform as claimed in claim 1, characterized in that: In step 1, during the parsing process, if the system target file has been parsed with other application target files and a modified symbol table has been generated, the symbol table can be directly retrieved from the host computer system, thereby skipping the subsequent processing of this step; however, for the application target file, the parsing still needs to be completed according to the following process.

3. The method for efficient dynamic loading of software based on an embedded platform as claimed in claim 1, characterized in that: The step 1 specifically includes the following steps: S11, use libelf library or other development environment tools to open the target file, check the ELF file magic number, read and parse the ELF file header of the file; obtain the type, architecture, entry point address, location and size of the program header table, location and size information of the section header table of the ELF file; S12, then, according to the section header table offset and the number of entries information provided by the ELF file header, the file pointer is used to move to the section header table location; starting from this location, the system can start to read the contents of the section header table; S13, then, traverse the contents of the section header table, and search for a 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, which is the symbol table content of the executable file and the symbol table content of the dynamically loaded library file extracted by parsing.

4. The method for efficient dynamic loading of software based on an embedded platform as claimed in claim 2 or 3, characterized in that: The step 2 specifically includes: S21, searching the symbol table of the application target file, filtering symbols with a segment type of "UND", such symbols indicating that they are referenced in the application target file but not defined in the file; S22, the above-mentioned symbols screened out are searched in order in the system target file symbol table, and the search order is to search from front to back, and this order is related to the subsequent modification of the system target file symbol table; S23. Record all successfully retrieved symbols, which are functions and variables provided by the system target file referenced by the application target file, namely dynamic symbols.

5. The method for efficiently dynamically loading software based on an embedded platform as claimed in claim 4, characterized in that: In the step three, the application target file is modified using the objcopy tool, libelf library function or other professional tools.

6. The method for efficient dynamic loading of software based on an embedded platform as claimed in claim 4, characterized in that: In the step three, based on the acquired dynamic symbol information, the attributes of the dynamic symbols in the application target file are updated one by one, covering the 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, and does not change the size and offset address of the symbol table of the application target file, so there is no need to adjust its ELF header information and other parameters, thereby ensuring the encoding correctness of the application target file.

7. The method for efficient dynamic loading of software based on an embedded platform as claimed in claim 4, characterized in that: In the step three, during the execution of the target file by the lower computer, the system program is responsible for dynamically allocating a memory address for the target file, and sending the actual starting memory address of the target file to the upper computer through serial communication or network equipment, so that the upper computer converts the relative address in the symbol table of the target file into an absolute physical address during actual runtime; since the external functions and variables referenced in the symbol table have been relocated in advance, when the lower computer runs the target file, its dynamic linker does not need to repeatedly perform the relocation operation.

8. The method for efficient dynamic loading of software based on an embedded platform according to any one of claims 4 to 7, characterized in that: In the step 4, in order to ensure that the application target file loaded subsequently can fully access the symbol tables of all the application target files loaded previously, it is necessary to create a linked list structure in the host computer based on the system target file; each system target file corresponds to a linked list, and the linked list is used to store the corresponding system target file symbol table and all the application target file symbol tables loaded into the system target file; If the system target file already has a corresponding linked list, there is no need to create a new one. Just treat the existing linked list as the system target file symbol table.

9. The method for efficient dynamic loading of software based on an embedded platform as claimed in claim 8, characterized in that: In step 4, the linked list operation includes: S41, the symbol table of the system target file is stored in the first node position of the linked list; S42, adding a jump instruction at the end of the system target file symbol table so as to smoothly jump to the next node during the retrieval process; S43, storing the symbol table of the application target file at the tail node position of the linked list; S44, removing all dynamic symbols and related information from the symbol table of the application target file; S45, according to the starting address information of the application target file, the global symbol address in the symbol table is corrected, and the dynamic address is converted into a static address; S46, saving the entire linked list structure in the host computer as a symbol table file of the system target file, so that the system target file can be used when dynamically loaded next time.

10. The method for efficient dynamic loading of software based on an embedded platform as claimed in claim 8, characterized in that: The step 4 ensures that when a new application target file is subsequently added to the system target file, all symbol tables in the linked list can be uniformly regarded as symbol tables of the system target file for processing and meet the symbol priority rule; the symbol priority rule is: first call the symbol of the system target file, and then follow the loading order, the earlier the application target file is loaded, the higher the symbol priority; if the loaded application target file needs to be unloaded, 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

  • Method for dynamically upgrading software modules in embedded systems

    CN107943504A

  • Local dynamic loading system and method based on direct reading and writing FLASH

    CN108829465A

  • ELF loading method based on microkernel operating system

    CN117193882A

  • Method and device for dynamically loading relocatable file

    US20120209895A1

Cited By

  • Information organization acquisition method and system for real data in PLC (Programmable Logic Controller)

    CN120929455A

  • Method and system for obtaining information organization of real data in PLC

    CN120929455B

  • Embedded operating system dynamic loading method based on LoongArch processor

    CN121387379A