A method and system for packaging and publishing executable files based on runtime library

Through the executable file packaging and release method based on runtime library, the compilation and compatibility problems when adapting to different domestic operating systems are solved, and the good compatibility of application software on different operating systems and the reduction of product package size is achieved.

CN114020324BActive Publication Date: 2025-02-11中孚安全技术有限公司
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111150746.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-29
Publication Date
2025-02-11
Estimated Expiration
2041-09-29

AI Technical Summary

Technical Problem

When the existing technology adapts to different domestic operating systems, application software needs to be compiled and adapted one by one, resulting in cumbersome software updates and releases, large workloads, poor compatibility, and uncontrollable product package size.

Method used

Using the executable file packaging and publishing method based on runtime library, it automatically packages and configures the runtime libraries and linkers required on the compiler to ensure that the application is completely self-sufficiency, does not depend on the running environment, and realizes architecture-level compilation and runs anywhere. .

Benefits of technology

It realizes good compatibility of application software on different operating systems, reduces product package size, reduces adaptation and modification pressure, and improves product stability and performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114020324B_ABST
    Figure CN114020324B_ABST
Patent Text Reader

Abstract

The present invention provides a method and system for packaging and publishing executable files based on a runtime library, generating a runtime dynamic library directory; placing the linker tools required by the application and the runtime library into the runtime dynamic library directory; reading the executable file format header information, parsing and obtaining the executable file information, obtaining the interpolation information and dynamic information in the segment according to the executable file information offset; modifying the dynamic information to the current dynamic library directory, modifying the interpolation information to the linker under the specified dynamic library directory; repackaging and generating an executable file. The present invention automatically packages and configures the runtime library, linker, etc. required on the compiler when packaging the application, which can ensure that the runtime software library, linker, etc. required by the application are completely self-sufficient and no longer rely on the running environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of file packaging and publishing, and in particular relates to a method and system for packaging and publishing executable files based on a runtime library. Background Art

[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.

[0003] In recent years, the information and innovation industry has flourished, and many high-quality operating system manufacturers have emerged. They are basically fighting on their own and maintaining their own software and hardware ecosystems. Most of these systems are secondary developed and enhanced through distribution versions, with a high degree of freedom, resulting in the current situation of a hundred flowers blooming in the information and innovation operating system. However, this also brings new difficulties to the adaptation of application software operating systems.

[0004] The various operating systems are not unified, and this inconsistency is reflected in all aspects of software and hardware. Here, leaving aside the hardware differences, we will mainly explain the software differences. Since operating system manufacturers are all secondary development of the release version, secondary development may include the operating system kernel, operating system peripheral application software, development libraries, etc., the operating systems of various manufacturers are not the same, which leads to difficulties in adapting the upper-level application software to the domestic operating system. The existing solutions are roughly the following:

[0005] 1. Application software is compiled and adapted for each operating system one by one, and when it is packaged and released, it is also released according to the operating system. The disadvantage is that it is more troublesome to update and release the software, and it needs to be compiled one by one. If there are many operating systems and versions, the workload will increase exponentially, and the released versions are messy, and the size of the product package cannot be controlled. In addition, the compatibility is poor. If an unknown operating system or version is encountered, the product may not be used.

[0006] 2. The application software is compiled on a sufficiently low version of the system development library, which eliminates the tediousness of adapting to each operating system one by one. The application software only needs to adapt according to the architecture, and the update and release of the application will become easier. To a certain extent, the compatibility of the application will be better. It only needs to ensure that the version of the operating system development library is higher than the version of the development library linked when the application software is compiled. However, it is not difficult to see that even if the compatibility is improved compared to solution 1, it is still limited by the operating system development library. If the development library is lower than the version required by the application, the product still cannot be run and used. Summary of the invention

[0007] In order to solve the above problems, the present invention proposes a method and system for packaging and publishing executable files based on runtime libraries. The present invention automatically packages and configures the runtime libraries, linkers, etc. required on the compiler when packaging the application, which can ensure that the runtime software libraries, linkers, etc. required by the application are completely self-sufficient and no longer rely on the running environment, truly realizing the architecture-level compilation in one place and running everywhere.

[0008] According to some embodiments, the present invention adopts the following technical solutions:

[0009] A method for packaging and publishing executable files based on a runtime library comprises the following steps:

[0010] Generate runtime dynamic library directory;

[0011] Put the linker tools required by the application and runtime library into the runtime dynamic library directory;

[0012] Read the executable file format header information, parse and obtain the executable file information, and obtain the interpolation information and dynamic information in the segment according to the executable file information offset;

[0013] Modify the dynamic information to the current dynamic library directory and modify the interpolation information to the linker under the specified dynamic library directory;

[0014] Repackage and generate executable files.

[0015] As an optional implementation, the method further includes specifying link options in compilation parameters before the application is started, so that when the application is started, the executable file is loaded and loaded preferentially from the address set in the compilation.

[0016] As an optional implementation, the method further includes specifying a linker with compilation parameters before the application is started, so that the application does not use the runtime environment linker but uses a local linker.

[0017] As an optional implementation, all libraries that the application depends on are obtained by listing dynamic library dependencies and packaged to form a runtime library directory.

[0018] As an optional implementation, the library includes program libraries, graphic libraries and function libraries required by the product.

[0019] As an optional implementation, the specific process of parsing and obtaining the executable file information includes parsing the executable file information and obtaining section and segment information.

[0020] As an optional implementation, the specific process of modifying the dynamic information to the current dynamic library directory includes parsing each runtime library in turn, parsing and obtaining dynamic information according to the executable file format, modifying the link option field therein to the directory of the runtime library, and packaging the synthesized executable file again.

[0021] A runtime library-based executable file packaging and publishing system, comprising:

[0022] The runtime dynamic library acquisition module is configured to generate a runtime dynamic library directory and put the linker tools required by the application and the runtime library into the runtime dynamic library directory;

[0023] A parsing module is configured to read the executable file format header information, parse and obtain the executable file information, and obtain the interpolation information and dynamic information in the segment according to the executable file information offset;

[0024] The packaging module is configured to modify the dynamic information to the current dynamic library directory, modify the interpolation information to the linker under the specified dynamic library directory, and repackage to generate an executable file.

[0025] A computer-readable storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor of a terminal device and executing the steps of the above method.

[0026] A terminal device includes a processor and a computer-readable storage medium, wherein the processor is used to implement various instructions; and the computer-readable storage medium is used to store multiple instructions, wherein the instructions are suitable for being loaded by the processor and executing the steps of the above method.

[0027] Compared with the prior art, the present invention has the following beneficial effects:

[0028] The packaging process provided by the present invention is completely independent of the runtime operating system environment at the software application level, and can be run anywhere as long as the architecture is the same, with good compatibility;

[0029] The product package of the present invention no longer contains binary files compiled by various systems. When the size of each product package is nearly 100 MB, the size of the product package can be reduced in some scenarios by using this method compared to this method.

[0030] For some products with graphical interfaces, the present invention can greatly reduce display anomalies caused by inconsistent or different graphics or resource library versions, thereby reducing the pressure of adaptation and modification in this regard, as it comes with its own runtime graphics library, resource library, etc.

[0031] The present invention no longer relies on certain operating environment restrictions, and allows more freedom in product creation. There is no need to worry about the operating environment, and more advanced language features, higher versions of compilers and runtime libraries can be used. Due to the addition of new features, the product may have better stability and performance.

[0032] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0034] Figure 1 The present invention is a flowchart of at least one embodiment of the present invention. DETAILED DESCRIPTION

[0035] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

[0036] It should be noted that the following detailed descriptions are all illustrative and intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.

[0037] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.

[0038] As a typical embodiment, the method for packaging and publishing elf files based on the runtime library under the Linux system is taken as an example for description, but the process scheme provided by the present invention is not only applicable to this embodiment.

[0039] like Figure 1 As shown, the elf file packaging and publishing method based on the runtime library under the Linux system includes the following steps:

[0040] Compilation parameters specify rpath: The purpose of this step is to tell the application to prioritize the address set in the compilation when loading the elf file at startup.

[0041] In this embodiment, the compilation method is as follows:

[0042] g++-Wl,-rpath=. / lib / test.cpp–odemo.

[0043] Compilation parameters specify the linker: This step tells the application not to use the runtime environment linker, but to use the local linker instead.

[0044] In this embodiment, the compilation method is as follows:

[0045] g++test.cpp–odemo–Wl,-dynamic-linker=’. / lib / ld-linux-x86-64.so’.

[0046] Package all runtime libraries that your application depends on:

[0047] All libraries that the application depends on are obtained through the ldd command, and packaged to form a runtime library directory. The runtime library may include a c library, a c++ library, a qt graphics library, etc. In this embodiment, it is added according to the needs of the product.

[0048] Package linker:

[0049] Put the linker tools needed by the application and the runtime library into the runtime library directory.

[0050] Configure the runtime library:

[0051] Parse the elf file, parse the elf file according to the elf file header information, and obtain section, segment and other information, and obtain interp information and dynamic information in the segment according to the elf header information offset.

[0052] Configuring rpath

[0053] Parse each runtime library in turn, parse and obtain dynamic information according to the elf file format, modify the rpath field to the directory of the runtime library (relative or absolute path), and package the synthesized elf file again.

[0054] This step mainly reconfigures the loading path of the elf file required for runtime library loading.

[0055] Configuring the Linker

[0056] Parse the runtime library elf file in turn, obtain the interp information, modify it to the linker in the specified directory, and package the synthesized elf file again.

[0057] This step is mainly to configure the interpreter used when loading the runtime library.

[0058] In this embodiment, the configuration process of the above runtime library can be automatically completed by an existing or developed configuration tool, which will not be described in detail in this embodiment.

[0059] This embodiment further provides the following product embodiments for the above method:

[0060] A runtime library-based executable file packaging and publishing system, comprising:

[0061] The runtime dynamic library acquisition module is configured to generate a runtime dynamic library directory and put the linker tools required by the application and the runtime library into the runtime dynamic library directory;

[0062] A parsing module is configured to read the executable file format header information, parse and obtain the executable file information, and obtain the interpolation information and dynamic information in the segment according to the executable file information offset;

[0063] The packaging module is configured to modify the dynamic information to the current dynamic library directory, modify the interpolation information to the linker under the specified dynamic library directory, and repackage to generate an executable file.

[0064] A computer-readable storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor of a terminal device and executing the steps of the above method.

[0065] A terminal device includes a processor and a computer-readable storage medium, wherein the processor is used to implement various instructions; and the computer-readable storage medium is used to store multiple instructions, wherein the instructions are suitable for being loaded by the processor and executing the steps of the above method.

[0066] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0067] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0068] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0069] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0070] Although the above describes the specific implementation mode of the present invention in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art on the basis of the technical solution of the present invention without creative work are still within the scope of protection of the present invention.

Claims

1. A method for packaging and publishing executable files based on a runtime library, characterized in that: The following steps are involved: Generate a runtime dynamic library directory; obtain all libraries that the application depends on by listing dynamic library dependencies, and package them to form a runtime library directory; the library includes program libraries, graphics libraries and function libraries required by the product; Put the linker tools required by the application and runtime library into the runtime dynamic library directory; Read the executable file format header information, parse and obtain the executable file information, and obtain the interpolation information and dynamic information in the segment according to the executable file information offset; Before the application is started, the compilation parameters specify the linker so that the application does not use the runtime environment linker but uses the local linker; Modify the dynamic information to the current dynamic library directory and modify the interpolation information to the linker under the specified dynamic library directory; The specific process of modifying the dynamic information to the current dynamic library directory includes: parsing each runtime library in turn, parsing and obtaining the dynamic information according to the executable file format, modifying the link option field therein to the directory of the runtime library, and packaging and synthesizing the executable file again; Repackage and generate executable files.

2. The method for packaging and publishing executable files based on a runtime library as claimed in claim 1, characterized in that: It also includes specifying link options in compilation parameters before the application is started, so that when the application is started, the executable file is loaded and loaded from the address set in the compilation first.

3. The method for packaging and publishing executable files based on a runtime library as claimed in claim 1, characterized in that: The specific process of parsing and obtaining the executable file information includes parsing the executable file information and obtaining section and segment information.

4. A runtime library-based executable file packaging and publishing system, characterized by: include: The runtime dynamic library acquisition module is configured to generate a runtime dynamic library directory, put the application and the linker tools required by the runtime library into the runtime dynamic library directory; obtain all the libraries that the application depends on by listing the dynamic library dependencies, and package them to form a runtime library directory; the libraries include program libraries, graphics libraries and function libraries required by the product; The parsing module is configured to read the executable file format header information, parse and obtain the executable file information, and obtain the interpolation information and dynamic information in the segment according to the executable file information offset; before the application is started, the compilation parameter specifies the linker so that the application does not use the runtime environment linker but uses the local linker; The packaging module is configured to modify the dynamic information to the current dynamic library directory, modify the interpolation information to the linker under the specified dynamic library directory, and repackage to generate an executable file; The specific process of modifying the dynamic information to the current dynamic library directory includes: parsing each runtime library in turn, parsing and obtaining dynamic information according to the executable file format, modifying the link option field therein to the directory of the runtime library, and packaging the synthetic executable file again.

5. A computer-readable storage medium, characterized in that: There are a plurality of instructions, which are suitable for being loaded by a processor of a terminal device and executing the steps of the method described in any one of claims 1-3.

6. A terminal device, characterized in that: The method comprises a processor and a computer-readable storage medium, wherein the processor is used to implement various instructions; and the computer-readable storage medium is used to store a plurality of instructions, wherein the instructions are suitable for being loaded by the processor and executing the steps of the method described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Apparatus, method, electronic device and memory for running an application across an operating system

    CN109144575A