Dynamic library compiling method, device, storage medium and apparatus

CN116820471BActive Publication Date: 2026-10-13360 TECH GRP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210278985.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-21
Publication Date
2026-10-13
Estimated Expiration
2042-03-21

AI Technical Summary

Technical Problem

[0004]本发明的主要目的在于提供一种动态库编译方法、设备、存储介质及装置,旨在解决现有技术中动态库对函数有依赖时,会出现编译崩溃的技术问题

Benefits of technology

[0025]在本发明中,公开了获取待编译动态库的依赖函数信息,根据依赖函数信息通过引导程序在共享内存中查找依赖函数的访问路径,根据访问路径调用依赖函数对待编译动态库进行编译;由于本发明先根据待编译动态库的依赖函数信息通过引导程序在共享内存中查找依赖函数的访问路径,再根据访问路径调用依赖函数对待编译动态库进行编译,从而能够实现动态库的正常编译,避免了函数依赖导致的编译崩溃,进而提高了动态库编译的可靠性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116820471B_ABST
    Figure CN116820471B_ABST
Patent Text Reader

Abstract

The application relates to the computer technical field and discloses a dynamic library compiling method, equipment, a storage medium and a device, the method comprising the following steps: acquiring dependent function information of a dynamic library to be compiled; searching for an access path of the dependent function in shared memory through a boot program according to the dependent function information; and compiling the dynamic library to be compiled by calling the dependent function according to the access path. Since the application searches for the access path of the dependent function in the shared memory through the boot program according to the dependent function information of the dynamic library to be compiled, and then compiles the dynamic library to be compiled by calling the dependent function according to the access path, normal compilation of the dynamic library can be realized, the compilation crash caused by function dependence is avoided, and the reliability of the dynamic library compilation is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a dynamic library compilation method, apparatus, storage medium and device. Background Technology

[0002] Currently, after the interpreter is initialized, it can be called to load dynamic libraries and execute compilation. However, in practical applications, if the dynamic library depends on functions, compilation crashes may occur.

[0003] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention

[0004] The main objective of this invention is to provide a dynamic library compilation method, device, storage medium, and apparatus, aiming to solve the technical problem that compilation crashes occur when dynamic libraries depend on functions in the prior art.

[0005] To achieve the above objectives, the present invention provides a dynamic library compilation method, which includes the following steps: Obtain the dependency function information of the dynamic library to be compiled; Based on the dependency function information, the bootloader searches for the access path of the dependency function in shared memory; The dependent function is invoked according to the access path to compile the dynamic library to be compiled.

[0006] Optionally, the step of calling the dependent function to compile the dynamic library to be compiled according to the access path includes: Build the source code environment; In the source code environment, the dependent function is called according to the access path to compile the dynamic library to be compiled.

[0007] Optionally, the step of building the source code environment includes: Retrieve the hiding settings information for hidden functions; The source code environment is constructed based on the hidden settings information.

[0008] Optionally, the step of finding the access path of the dependent function in shared memory through the bootstrap program based on the dependent function information includes: The entry function is called by the bootloader based on the dependency function information. The entry function is used to locate the access path of the dependent functions in shared memory.

[0009] Optionally, the step of finding the access path of the dependent function in shared memory through the entry function includes: Generate a function table based on the dependency function information; Based on the function table, the access path of the dependent functions is found in shared memory through the entry function.

[0010] Optionally, before the step of calling the entry function through the bootstrap based on the dependency function information, the method further includes: Get function information of the default main function; Construct the entry function based on the function information.

[0011] Optionally, before the step of obtaining the dependency function information of the dynamic library to be compiled, the method further includes: Obtain the dependency functions of each dynamic library; Store the access paths of the dependent functions in shared memory.

[0012] Optionally, the step of storing the access path of the dependent function in shared memory includes: The dependency function is verified; After successful verification, the access path of the dependent function is stored in shared memory.

[0013] Optionally, the step of verifying the dependency function includes: Obtain the feature information of the dependency function; The dependency function is verified based on the feature information.

[0014] Optionally, after the step of calling the dependent function to compile the dynamic library to be compiled according to the access path, the method further includes: Upon successful compilation, obtain the dynamic library information of the compiled dynamic library; A reminder message is generated based on the dynamic library information, and the reminder message is displayed.

[0015] Optionally, after the step of calling the dependent function to compile the dynamic library to be compiled according to the access path: When compilation fails, obtain function call information; An error log is generated based on the function call information.

[0016] Furthermore, to achieve the above objectives, the present invention also proposes a dynamic library compilation device, which includes a memory, a processor, and a dynamic library compiler stored in the memory and executable on the processor. The dynamic library compiler is configured to implement the dynamic library compilation method described above.

[0017] In addition, to achieve the above objectives, the present invention also proposes a storage medium storing a dynamic library compiler, which, when executed by a processor, implements the dynamic library compilation method described above.

[0018] In addition, to achieve the above objectives, the present invention also proposes a dynamic library compilation device, which includes: an information acquisition module, a path lookup module, and a dynamic library compilation module. The information acquisition module is used to acquire the dependency function information of the dynamic library to be compiled; The path lookup module is used to find the access path of the dependent function in the shared memory through the bootstrap program based on the dependent function information. The dynamic library compilation module is used to compile the dynamic library to be compiled by calling the dependent functions according to the access path.

[0019] Optionally, the dynamic library compilation module is also used to build a source code environment; The dynamic library compilation module is also used to compile the dynamic library to be compiled by calling the dependent function according to the access path in the source code environment.

[0020] Optionally, the dynamic library compilation module is also used to obtain the hiding settings information of the hidden functions; The dynamic library compilation module is also used to build a source code environment based on the hidden settings information.

[0021] Optionally, the path lookup module is further configured to call the entry function through the bootstrap program based on the dependency function information; The path lookup module is also used to find the access path of the dependent function in the shared memory through the entry function.

[0022] Optionally, the path lookup module is further configured to generate a function table based on the dependency function information; The path lookup module is also used to find the access path of the dependent function in the shared memory according to the function table and the entry function.

[0023] Optionally, the dynamic library compilation apparatus further includes: a function construction module; The function construction module is used to obtain function information of the default main function; The function construction module is also used to construct an entry function based on the function information.

[0024] Optionally, the dynamic library compilation apparatus further includes: a function storage module; The function storage module is used to obtain the dependent functions of each dynamic library; The function storage module is also used to store the access paths of the dependent functions into shared memory.

[0025] This invention discloses a method for obtaining the dependency function information of a dynamic library to be compiled, finding the access paths of the dependency functions in shared memory using a bootloader based on the dependency function information, and then calling the dependency functions to compile the dynamic library based on the access paths. Because this invention first finds the access paths of the dependency functions in shared memory using a bootloader based on the dependency function information of the dynamic library to be compiled, and then calls the dependency functions to compile the dynamic library based on the access paths, it can achieve normal compilation of the dynamic library, avoid compilation crashes caused by function dependencies, and thus improve the reliability of dynamic library compilation. Attached Figure Description

[0026] Figure 1 This is a schematic diagram of the structure of the dynamic library compilation device of the hardware operating environment involved in the embodiments of the present invention; Figure 2 This is a flowchart illustrating the first embodiment of the dynamic library compilation method of the present invention; Figure 3 This is a flowchart illustrating the second embodiment of the dynamic library compilation method of the present invention; Figure 4 This is a flowchart illustrating the third embodiment of the dynamic library compilation method of the present invention; Figure 5 This is a structural block diagram of the first embodiment of the dynamic library compilation device of the present invention.

[0027] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0028] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0029] Reference Figure 1 , Figure 1 This is a schematic diagram of the dynamic library compilation device structure of the hardware operating environment involved in the embodiments of the present invention.

[0030] like Figure 1As shown, the dynamic library compilation device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to implement communication between these components. The user interface 1003 may include a display screen, and optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. In this invention, the wired interface of the user interface 1003 may be a USB interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wireless-Fidelity (Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (RAM) or a non-volatile memory (NVM), such as a disk storage device. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.

[0031] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on the dynamic library compilation device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0032] like Figure 1 As shown, the memory 1005, which is identified as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a dynamic library compiler.

[0033] exist Figure 1 In the dynamic library compilation device shown, the network interface 1004 is mainly used to connect to the backend server and communicate data with the backend server; the user interface 1003 is mainly used to connect to the user equipment; the dynamic library compilation device calls the dynamic library compilation program stored in the memory 1005 through the processor 1001 and executes the dynamic library compilation method provided in the embodiment of the present invention.

[0034] Based on the above hardware structure, an embodiment of the dynamic library compilation method of the present invention is proposed.

[0035] Reference Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the dynamic library compilation method of the present invention, which presents the first embodiment of the dynamic library compilation method of the present invention.

[0036] In the first embodiment, the dynamic library compilation method includes the following steps: Step S10: Obtain the dependency function information of the dynamic library to be compiled.

[0037] It should be understood that the execution subject of the method in this embodiment can be a dynamic library compilation device with data processing, network communication and program running functions, such as a computer, or other electronic devices that can achieve the same or similar functions. In this embodiment and other embodiments, a computer is used as an example for illustration.

[0038] Understandably, in practical applications, if a dynamic library depends on functions, a crash may occur when the interpreter loads the dynamic library and performs compilation. Therefore, to overcome this deficiency, in this embodiment, upon detecting a dynamic library loading failure, the bootloader first searches for the access paths of the dependent functions in shared memory based on the dependency function information. Then, it calls the dependent functions according to the access paths to compile the dynamic library, thereby enabling normal compilation of the dynamic library, avoiding compilation crashes caused by function dependencies, and ultimately improving the reliability of dynamic library compilation.

[0039] It should be understood that in this embodiment, when compiling the dynamic library, the dependency function information of the dynamic library to be compiled can be obtained directly, or the dynamic library can be compiled directly first, and the dependency function information of the dynamic library to be compiled can be obtained when the compilation of the dynamic library to be compiled fails. This embodiment does not impose any restrictions on this.

[0040] It should be noted that dependent functions can be functions that are required for the compilation of a dynamic library. Dependency function information can include function names, etc.

[0041] Understandably, in practical applications, to reduce the difficulty of obtaining dependency function information, in this embodiment, obtaining the dependency function information of the dynamic library to be compiled can be achieved by searching for the corresponding dependency function information of the dynamic library to be compiled in a preset dynamic library table. The preset dynamic library table contains the correspondence between dynamic libraries and dependency function information, and this correspondence can be pre-entered.

[0042] It should be noted that the dynamic library to be compiled can be a library of the Android system.

[0043] Step S20: Based on the dependency function information, the bootloader searches for the access path of the dependency function in shared memory.

[0044] It should be noted that the bootloader can be the bootloader of an interpreter. An interpreter can be a computer program that can directly translate and execute high-level programming languages ​​line by line.

[0045] It should be understood that in practical applications, dependent functions may be functions of different architectures; for example, dependent functions may include functions for x86 architecture and functions for ARM architecture. Therefore, in order to implement the framework passing functions, this embodiment can set up shared memory, and the bootstrap program can pass the ARM space linker-related functions to the x86 interpreter through the shared memory.

[0046] It should be understood that finding the access path of a dependent function in shared memory through the bootstrap based on the dependent function information can be achieved by calling the entry function through the bootstrap based on the dependent function information, and then finding the access path of the dependent function in shared memory through the entry function.

[0047] Step S30: Compile the dynamic library to be compiled by calling the dependent function according to the access path.

[0048] In specific implementations, for example, dlopen, when an x86 virtual machine loads a dynamic library in the ARM space, it only needs to call the interpreter, jump to the interpreter's bootloader, and have the bootloader pass the relevant functions of the ARM space linker to the x86 interpreter through address sharing, and then pass the parameters according to the stack protocol.

[0049] In the first embodiment, the method of obtaining the dependency function information of the dynamic library to be compiled is disclosed. Based on the dependency function information, the bootstrap program searches for the access paths of the dependency functions in shared memory, and then calls the dependency functions to compile the dynamic library to be compiled based on the access paths. Since this embodiment first searches for the access paths of the dependency functions in shared memory based on the dependency function information of the dynamic library to be compiled, and then calls the dependency functions to compile the dynamic library to be compiled based on the access paths, the normal compilation of the dynamic library can be achieved, avoiding compilation crashes caused by function dependencies, thereby improving the reliability of dynamic library compilation.

[0050] Reference Figure 3 , Figure 3 This is a flowchart illustrating the second embodiment of the dynamic library compilation method of the present invention, based on the above. Figure 2 The first embodiment shown presents a second embodiment of the dynamic library compilation method of the present invention.

[0051] In the second embodiment, step S20 includes: Step S201: Call the entry function through the bootstrap program based on the dependency function information.

[0052] It should be understood that, in order to improve the accuracy of access path lookup, in this embodiment, the entry function can be called by the bootstrap program based on the dependency function information, and the access path of the dependency function can be found in shared memory through the entry function.

[0053] Furthermore, to prevent the entry function from failing to execute correctly, the procedure before step S201 includes: Get function information of the default main function; Construct the entry function based on the function information.

[0054] It should be understood that, in order to avoid the entry function failing to execute correctly, in this embodiment, when constructing the entry function, the function information of the default main function can be obtained first, and the entry function can be constructed based on the function information.

[0055] It should be noted that the default main function can be set in advance. For example, the default main function can be set as the default main function.

[0056] In specific implementations, for example, when constructing an entry function, it is restricted that the entry function cannot be the default main function.

[0057] Step S202: Locate the access path of the dependent function in the shared memory through the entry function.

[0058] It is understandable that finding the access path of a dependent function in shared memory through the entry function can be achieved by executing the entry function to find the access path of the dependent function in shared memory.

[0059] Furthermore, to improve the efficiency of function lookup, step S202 includes: Generate a function table based on the dependency function information; Based on the function table, the access path of the dependent functions is found in shared memory through the entry function.

[0060] It should be understood that, in order to improve the efficiency of function lookup, in this embodiment, a function table can be generated first, and then the access path of the dependent function can be found in the shared memory through the entry function based on the function table.

[0061] It is understandable that generating a function table based on dependency function information can be achieved by filling an initial table with the dependency function information to obtain the function table.

[0062] In specific implementations, for example, in the entry function, the access paths of the required ARM space dependency functions are brought out through the parameter function table, such as dlopen, dlsym, init_defaultNamespace, etc.

[0063] In the second embodiment, it is disclosed that the entry function is called by the bootstrap program based on the dependency function information, and the access path of the dependency function is found in the shared memory through the entry function. Since this embodiment introduces an additional entry function to find the access path of the dependency function, the accuracy of the access path finding is improved.

[0064] In the second embodiment, step S30 includes: Step S301: Build the source code environment.

[0065] It should be understood that, considering practical applications, some special functions cannot be called directly. Therefore, to ensure the smooth invocation of such functions, in this embodiment, a source code environment can be built first, and then the dependent functions can be called in the source code environment according to the access path to compile the dynamic library to be compiled.

[0066] Understandably, building a source code environment can be a user-created compilation environment for a custom NDK.

[0067] Furthermore, in order to export the hidden function, step S301 includes: Retrieve the hiding settings information for hidden functions; The source code environment is constructed based on the hidden settings information.

[0068] It should be understood that, considering practical applications, some dependent functions are hidden functions in the Android system and cannot be called directly. Examples include the `ini_defaultNamespace` and `anonymous_Namespace` functions. Therefore, in order to export these hidden functions, this embodiment can first obtain the hiding settings information of the hidden functions, and then construct the source code environment based on the hiding settings information.

[0069] It should be noted that a hidden function can be a function that cannot be called directly.

[0070] It is understandable that building a source code environment based on hidden settings information can mean configuring the source code environment based on hidden settings information in order to build the source code environment.

[0071] Step S302: In the source code environment, the dependent function is called according to the access path to compile the dynamic library to be compiled.

[0072] It should be understood that, in order to ensure the smooth invocation of this type of function, in this embodiment, the dependent functions can be called in the source code environment to compile the dynamic library to be compiled based on the access path.

[0073] In the second embodiment, a source code environment is constructed, and the dependent functions are called in the source code environment according to the access path to compile the dynamic library to be compiled. Since this embodiment first constructs the source code environment and then calls the dependent functions in the source code environment according to the access path to compile the dynamic library to be compiled, the smooth calling of special functions can be ensured.

[0074] Reference Figure 4 , Figure 4This is a flowchart illustrating the third embodiment of the dynamic library compilation method of the present invention, based on the above. Figure 3 The second embodiment shown presents a third embodiment of the dynamic library compilation method of the present invention.

[0075] In the third embodiment, before step S10, the method further includes: Step S01: Obtain the dependency functions of each dynamic library.

[0076] It should be understood that, in order to facilitate finding the access paths of dependent functions, in this embodiment, the dependent functions of each dynamic library can be obtained first, and then the access paths of the dependent functions can be stored in shared memory.

[0077] It should be noted that dependent functions can be functions that are required for the compilation of a dynamic library.

[0078] Understandably, obtaining the dependency functions of each dynamic library can be achieved by searching for the corresponding dependency functions of each dynamic library in a pre-defined dynamic library table. This pre-defined dynamic library table contains the mapping between dynamic libraries and their dependency functions, and this mapping can be pre-entered.

[0079] Step S02: Store the access path of the dependent function in shared memory.

[0080] It should be understood that in practical applications, dependent functions may be functions of different architectures; for example, dependent functions may include functions for x86 architecture and functions for ARM architecture. Therefore, in order to implement the framework's function passing mechanism, in this embodiment, the access paths of the dependent functions can be stored in shared memory first.

[0081] In the third embodiment, the method of obtaining the dependent functions of each dynamic library and storing the access paths of the dependent functions in shared memory is disclosed. Since this embodiment can obtain the dependent functions of each dynamic library before compiling the dynamic library and then store the access paths of the dependent functions in shared memory, it is convenient for users to find the access paths of the dependent functions later.

[0082] Furthermore, to avoid dynamic library compilation failure due to dependency function errors, step S02 includes: The dependency function is verified; After successful verification, the access path of the dependent function is stored in shared memory.

[0083] Understandably, in order to avoid dynamic library compilation failure due to errors in dependent functions, this embodiment can first verify the dependent functions before storing the access paths of the dependent functions in shared memory. After the verification is successful, the access paths of the dependent functions can then be stored in shared memory.

[0084] It should be understood that dependency function validation can be performed based on preset validation rules. These preset validation rules can be set in advance.

[0085] Furthermore, to improve the efficiency of dependency function verification, the verification of the dependency function includes: Obtain the feature information of the dependency function; The dependency function is verified based on the feature information.

[0086] Understandably, in order to improve the efficiency of dependency function verification, in this embodiment, the feature information of the dependency function can be obtained first, and then the dependency function can be verified based on the feature information.

[0087] It should be understood that verifying the dependency function based on feature information involves matching the feature information with feature information in a preset function library. If a match is successful, the verification is considered passed; if a match fails, the verification is considered failed. The preset function library can be pre-set by the user.

[0088] In the third embodiment, after step S30, the method further includes: Step S40: Upon successful compilation, obtain the dynamic library information of the compiled dynamic library.

[0089] It should be understood that, in order to remind the user when compilation is successful, this embodiment can obtain the dynamic library information of the compiled dynamic library when compilation is successful, and then generate and display reminder information based on the dynamic library information.

[0090] It should be noted that dynamic library information may include the dynamic library name and the compilation time of the dynamic library.

[0091] Step S50: Generate a reminder message based on the dynamic library information and display the reminder message.

[0092] It is understandable that generating reminder messages based on dynamic library information could involve writing the dynamic library information into a preset template to generate the reminder message. The preset template can be pre-defined.

[0093] In the third embodiment, it is disclosed that when compilation is successful, the dynamic library information of the compiled dynamic library is obtained, a reminder message is generated based on the dynamic library information, and the reminder message is displayed. Since this embodiment can obtain the dynamic library information of the compiled dynamic library when compilation is successful, and then generate and display the reminder message based on the dynamic library information, it is possible to obtain the dynamic library information of the compiled dynamic library when compilation is successful, and then generate and display the reminder message based on the dynamic library information.

[0094] In the third embodiment, after step S30, the method further includes: When compilation fails, obtain function call information; An error log is generated based on the function call information.

[0095] It should be understood that, in order to facilitate users in finding the cause of compilation failure, this embodiment will obtain function call information and generate an error log based on the function call information when compilation fails.

[0096] It should be noted that function call information may include the name of the called function, the function type, and the time of the function call.

[0097] In the third embodiment, it is disclosed that when compilation fails, function call information is obtained and an error log is generated based on the function call information. Since this embodiment obtains function call information and generates an error log based on the function call information when compilation fails, it makes it easier for users to find the reason for compilation failure.

[0098] Furthermore, this embodiment of the invention also proposes a storage medium storing a dynamic library compiler, which, when executed by a processor, implements the dynamic library compilation method described above.

[0099] In addition, refer to Figure 5 The present invention also proposes a dynamic library compilation device, which includes: an information acquisition module 10, a path lookup module 20, and a dynamic library compilation module 30. The information acquisition module 10 is used to acquire the dependency function information of the dynamic library to be compiled.

[0100] Understandably, in practical applications, if a dynamic library depends on functions, a crash may occur when the interpreter loads the dynamic library and performs compilation. Therefore, to overcome this deficiency, in this embodiment, upon detecting a dynamic library loading failure, the bootloader first searches for the access paths of the dependent functions in shared memory based on the dependency function information. Then, it calls the dependent functions according to the access paths to compile the dynamic library, thereby enabling normal compilation of the dynamic library, avoiding compilation crashes caused by function dependencies, and ultimately improving the reliability of dynamic library compilation.

[0101] It should be understood that in this embodiment, when compiling the dynamic library, the dependency function information of the dynamic library to be compiled can be obtained directly, or the dynamic library can be compiled directly first, and the dependency function information of the dynamic library to be compiled can be obtained when the compilation of the dynamic library to be compiled fails. This embodiment does not impose any restrictions on this.

[0102] It should be noted that dependent functions can be functions that are required for the compilation of a dynamic library. Dependency function information can include function names, etc.

[0103] Understandably, in practical applications, to reduce the difficulty of obtaining dependency function information, in this embodiment, obtaining the dependency function information of the dynamic library to be compiled can be achieved by searching for the corresponding dependency function information of the dynamic library to be compiled in a preset dynamic library table. The preset dynamic library table contains the correspondence between dynamic libraries and dependency function information, and this correspondence can be pre-entered.

[0104] It should be noted that the dynamic library to be compiled can be a library of the Android system.

[0105] The path lookup module 20 is used to find the access path of the dependent function in the shared memory through the bootloader based on the dependent function information.

[0106] It should be noted that the bootloader can be the bootloader of an interpreter. An interpreter can be a computer program that can directly translate and execute high-level programming languages ​​line by line.

[0107] It should be understood that in practical applications, dependent functions may be functions of different architectures; for example, dependent functions may include functions for x86 architecture and functions for ARM architecture. Therefore, in order to implement the framework passing functions, this embodiment can set up shared memory, and the bootstrap program can pass the ARM space linker-related functions to the x86 interpreter through the shared memory.

[0108] It should be understood that finding the access path of a dependent function in shared memory through the bootstrap based on the dependent function information can be achieved by calling the entry function through the bootstrap based on the dependent function information, and then finding the access path of the dependent function in shared memory through the entry function.

[0109] The dynamic library compilation module 30 is used to compile the dynamic library to be compiled by calling the dependent function according to the access path.

[0110] In specific implementations, for example, dlopen, when an x86 virtual machine loads a dynamic library in the ARM space, it only needs to call the interpreter, jump to the interpreter's bootloader, and have the bootloader pass the relevant functions of the ARM space linker to the x86 interpreter through address sharing, and then pass the parameters according to the stack protocol.

[0111] In this embodiment, the method of obtaining the dependency function information of the dynamic library to be compiled is disclosed. Based on the dependency function information, the bootstrap program searches for the access paths of the dependency functions in shared memory, and then calls the dependency functions to compile the dynamic library based on the access paths. Since this embodiment first searches for the access paths of the dependency functions in shared memory based on the dependency function information of the dynamic library to be compiled, and then calls the dependency functions to compile the dynamic library based on the access paths, the normal compilation of the dynamic library can be achieved, avoiding compilation crashes caused by function dependencies, thereby improving the reliability of dynamic library compilation.

[0112] In one embodiment, the dynamic library compilation module 30 is also used to build a source code environment; The dynamic library compilation module 30 is also used to compile the dynamic library to be compiled by calling the dependent function according to the access path in the source code environment.

[0113] In one embodiment, the dynamic library compilation module 30 is further configured to obtain the hiding settings information of the hidden functions; The dynamic library compilation module 30 is also used to construct a source code environment based on the hidden setting information.

[0114] In one embodiment, the path lookup module 20 is further configured to call the entry function through the bootstrap program based on the dependency function information; The path lookup module 20 is also used to find the access path of the dependent function in the shared memory through the entry function.

[0115] In one embodiment, the path lookup module 20 is further configured to generate a function table based on the dependency function information; The path lookup module 20 is also used to look up the access path of the dependent function in the shared memory according to the function table and the entry function.

[0116] In one embodiment, the dynamic library compilation apparatus further includes: a function construction module; The function construction module is used to obtain function information of the default main function; The function construction module is also used to construct an entry function based on the function information.

[0117] In one embodiment, the dynamic library compilation apparatus further includes: a function storage module; The function storage module is used to obtain the dependent functions of each dynamic library; The function storage module is also used to store the access paths of the dependent functions into shared memory.

[0118] In one embodiment, the function storage module is further configured to verify the dependent functions; The function storage module is also used to store the access path of the dependent function into shared memory after the verification is successful.

[0119] In one embodiment, the function storage module is further configured to acquire feature information of the dependent function; The function storage module is also used to verify the dependent function based on the feature information.

[0120] In one embodiment, the dynamic library compilation apparatus further includes: a compilation reminder module; The compilation reminder module is used to obtain dynamic library information of the compiled dynamic library when the compilation is successful; The compilation reminder module is also used to generate reminder information based on the dynamic library information and display the reminder information.

[0121] In one embodiment, the dynamic library compilation apparatus further includes: a log generation module; The log generation module is used to obtain function call information when compilation fails; The log generation module is also used to generate error logs based on the function call information.

[0122] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.

[0123] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0124] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as a read-only memory image (ROM) / random access memory (RAM), magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0125] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A method for compiling a dynamic library, characterized in that, The dynamic library compilation method includes the following steps: Obtain the dependency function information of the dynamic library to be compiled; Based on the dependency function information, the bootloader searches for the access path of the dependency function in shared memory. The dependency function includes functions of different architectures. The bootloader passes the access path of the linker-related dependency function in the first architecture space to the interpreter of the second architecture through shared memory. The dependent function is invoked according to the access path to compile the dynamic library to be compiled.

2. The dynamic library compilation method as described in claim 1, characterized in that, The step of calling the dependent function to compile the dynamic library to be compiled according to the access path includes: Build the source code environment; In the source code environment, the dependent function is called according to the access path to compile the dynamic library to be compiled.

3. The dynamic library compilation method as described in claim 2, characterized in that, The steps for building the source code environment include: Retrieve the hidden settings information for hidden functions; The source code environment is constructed based on the hidden settings information.

4. The dynamic library compilation method as described in claim 1, characterized in that, The step of finding the access path of the dependent function in shared memory through the bootstrap program based on the dependent function information includes: The entry function is called by the bootloader based on the dependency function information. The entry function is used to locate the access path of the dependent functions in shared memory.

5. The dynamic library compilation method as described in claim 4, characterized in that, The step of finding the access path of the dependent function in shared memory through the entry function includes: Generate a function table based on the dependency function information; Based on the function table, the access path of the dependent functions is found in shared memory through the entry function.

6. The dynamic library compilation method as described in claim 4, characterized in that, Before the step of calling the entry function through the bootstrap program based on the dependency function information, the method further includes: Get the function information of the default main function; Construct the entry function based on the function information.

7. The dynamic library compilation method according to any one of claims 1 to 6, characterized in that, Before the step of obtaining the dependency function information of the dynamic library to be compiled, the method further includes: Obtain the dependency functions of each dynamic library; Store the access paths of the dependent functions in shared memory.

8. The dynamic library compilation method as described in claim 7, characterized in that, The step of storing the access path of the dependent function into shared memory includes: The dependency function is verified; After successful verification, the access path of the dependent function is stored in shared memory.

9. The dynamic library compilation method as described in claim 8, characterized in that, The step of verifying the dependency function includes: Obtain the feature information of the dependency function; The dependency function is verified based on the feature information.

10. The dynamic library compilation method according to any one of claims 1 to 6, characterized in that, After the step of calling the dependent function to compile the dynamic library to be compiled according to the access path, the method further includes: Upon successful compilation, obtain the dynamic library information of the compiled dynamic library; A reminder message is generated based on the dynamic library information, and then the reminder message is displayed.

11. The dynamic library compilation method according to any one of claims 1 to 6, characterized in that, After the step of calling the dependent function to compile the dynamic library to be compiled according to the access path: When compilation fails, obtain function call information; An error log is generated based on the function call information.

12. A dynamic library compilation device, characterized in that, The dynamic library compilation device includes: a memory, a processor, and a dynamic library compiler stored in the memory and executable on the processor. When the dynamic library compiler is executed by the processor, it implements the dynamic library compilation method as described in any one of claims 1 to 11.

13. A storage medium, characterized in that, The storage medium stores a dynamic library compiler, which, when executed by a processor, implements the dynamic library compilation method as described in any one of claims 1 to 11.

14. A dynamic library compilation apparatus, characterized in that, The dynamic library compilation device includes: an information acquisition module, a path lookup module, and a dynamic library compilation module; The information acquisition module is used to acquire the dependency function information of the dynamic library to be compiled; The path lookup module is used to find the access path of the dependent function in the shared memory through the bootstrap program based on the dependent function information. The dependent function includes functions of different architectures. The bootstrap program passes the access path of the linker-related dependent function in the first architecture space to the interpreter of the second architecture through the shared memory. The dynamic library compilation module is used to compile the dynamic library to be compiled by calling the dependent functions according to the access path.

15. The dynamic library compilation apparatus as described in claim 14, characterized in that, The dynamic library compilation module is also used to build the source code environment; The dynamic library compilation module is also used to compile the dynamic library to be compiled by calling the dependent function according to the access path in the source code environment.

16. The dynamic library compilation apparatus as described in claim 15, characterized in that, The dynamic library compilation module is also used to obtain the hiding settings information of hidden functions; The dynamic library compilation module is also used to build a source code environment based on the hidden settings information.

17. The dynamic library compilation apparatus as described in claim 14, characterized in that, The path lookup module is also used to call the entry function through the bootloader based on the dependency function information; The path lookup module is also used to find the access path of the dependent function in the shared memory through the entry function.

18. The dynamic library compilation apparatus as described in claim 17, characterized in that, The path lookup module is also used to generate a function table based on the dependency function information; The path lookup module is also used to find the access path of the dependent function in the shared memory according to the function table and the entry function.

19. The dynamic library compilation apparatus as described in claim 17, characterized in that, The dynamic library compilation device further includes: a function construction module; The function construction module is used to obtain function information of the default main function; The function construction module is also used to construct an entry function based on the function information.

20. The dynamic library compilation apparatus as described in any one of claims 14 to 19, characterized in that, The dynamic library compilation device further includes: a function storage module; The function storage module is used to obtain the dependent functions of each dynamic library; The function storage module is also used to store the access paths of the dependent functions into shared memory.

Citation Information

Patent Citations

  • Dynamic virus detection method and device for equipment based on Android system

    CN103559446A

  • Method and device of compiling modules

    CN108304185A