Method, apparatus, device, storage medium and program product for linking binary files

By forcibly ending when the link command timeout and using the remote link server to perform link operations, the problem of high resource consumption in the link stage in the existing technology is solved, and the compilation efficiency is improved.

CN119718334BActive Publication Date: 2025-07-22INST OF SOFTWARE - CHINESE ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510216649.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-26
Publication Date
2025-07-22
Estimated Expiration
2045-02-26

AI Technical Summary

Technical Problem

The existing distributed compilation system consumes a lot of resources and time during the linking stage, especially on devices with insufficient memory or single-core performance, resulting in inaccurate compilation efficiency.

Method used

By forcibly ending the link command that is not within the time limit, obtain the file path of the participating link, copy it to a temporary folder, and use the remote link server to perform link operations, modify the link command to adapt to the remote environment, and reduce link time.

Benefits of technology

It greatly reduces the time consumed in the linking stage and improves compilation efficiency, especially on devices with insufficient memory or single-core performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119718334B_ABST
    Figure CN119718334B_ABST
Patent Text Reader

Abstract

The present invention provides a method, apparatus, device, storage medium and program product for linking binary files, which relates to the technical field of software compilation. Among them, the method includes: if the linking command fails to be completed within the time limit, forcibly terminate the running of the linking command, and obtain the paths of all files participating in the linking; copy all files participating in the linking to a temporary folder according to their respective paths; modify the linking command based on the environment of the remote linking server, and send the modified linking command and the temporary folder to the remote linking server, so that the remote linking server performs a linking operation based on the modified linking command and the temporary folder to obtain a linking result; receive the linking result sent by the remote linking server. By performing the linking operation through the remote linking server, the present invention can greatly reduce the time consumed by the linking and improve the compilation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software compilation, and particularly to a method, device, equipment, storage medium and program product for linking binary files. Background Art

[0002] Due to the rapid development of emerging instruction set architectures and the rapid evolution of the instruction architectures themselves, instruction set standards often precede the introduction of high-performance hardware. With the development of binary optimization technologies such as link-time optimization, the proportion of resources and time consumed in the link stage during software compilation is increasing. How to reduce the consumption time in the link stage has become an urgent problem to be solved currently. Summary of the Invention

[0003] Embodiments of the present invention provide a method, device, equipment, storage medium and program product for linking binary files, which are used to reduce the consumption time in the link stage during software compilation and improve the link efficiency.

[0004] In a first aspect, embodiments of the present invention provide a method for linking binary files, including: if the link command fails to be completed within the time limit, forcibly ending the operation of the link command, and obtaining the paths of all files participating in the link respectively; copying all the files participating in the link to a temporary folder according to their respective paths; modifying the link command based on the environment of the remote link server, and sending the modified link command and the temporary folder to the remote link server, so that the remote link server performs a link operation based on the modified link command and the temporary folder to obtain a link result; receiving the link result sent by the remote link server.

[0005] In some embodiments, the link command uses a detailed output option; the obtaining the paths of all files participating in the link respectively includes: obtaining the output content corresponding to the link command; and obtaining the paths of all files participating in the link respectively based on the output content.

[0006] As a possible implementation, the obtaining the paths of all files participating in the link respectively based on the output content includes: obtaining the paths of all files to be linked respectively based on the output content; obtaining the paths of files involved in additional processing during the link process based on the output content; and determining all the files to be linked and the files involved in the additional processing as all the files participating in the link.

[0007] In some embodiments, before sending the modified link command and the temporary folder to the remote link server, it further includes: modifying the file paths involved in the file content of the link script file in the temporary folder to the file paths corresponding to the temporary folder.

[0008] In some embodiments, modifying the link command based on the environment of the remote link server includes: modifying the linker in the link command to the linker of the remote link server; modifying the paths of the input file and the output file in the link command to the file paths corresponding to the temporary folder.

[0009] In some embodiments, after receiving the link result sent by the remote link server, it further includes: if the link result is a link failure, re-executing the link command.

[0010] In a second aspect, an embodiment of the present invention provides a link binary file device, including: an acquisition module, configured to forcibly end the running of the link command if the link command is not completed within the time limit, and acquire the paths of all files participating in the link; a copying module, configured to copy all the files participating in the link to the temporary folder according to their respective paths; a sending module, configured to modify the link command based on the environment of the remote link server, and send the modified link command and the temporary folder to the remote link server, so that the remote link server performs a link operation based on the modified link command and the temporary folder to obtain a link result; a receiving module, configured to receive the link result sent by the remote link server.

[0011] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory storing a computer program, and when the processor executes the program, it implements the link binary file method described in the first aspect above.

[0012] In a fourth aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the link binary file method described in the first aspect above.

[0013] In a fifth aspect, an embodiment of the present invention provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the link binary file method described in the first aspect above.

[0014] The link binary file method, device, equipment, storage medium and program product provided by the embodiments of the present invention, if the link command fails to be completed within the time limit, forcibly ends the running of the link command, and obtains the paths of all files participating in the link; copies all files participating in the link to a temporary folder according to their respective paths; modifies the link command based on the environment of the remote link server, and sends the modified link command and the temporary folder to the remote link server, so that the remote link server performs a link operation based on the modified link command and the temporary folder to obtain a link result; receives the link result sent by the remote link server. By performing the link operation through the remote link server, the present invention can greatly reduce the time consumed by the link and improve the compilation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0016] Figure 1 One of the flow diagrams of the link binary file method provided by the embodiments of the present invention;

[0017] Figure 2 Another flow diagram of the link binary file method provided by the embodiments of the present invention;

[0018] Figure 3 The structural diagram of the link binary file device provided by the embodiments of the present invention;

[0019] Figure 4 The structural diagram of the electronic device provided by the embodiments of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0020] To make the objectives, technical solutions and advantages of the present invention clearer, the following will clearly and completely describe the technical solutions in the present invention with reference to the drawings in the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art without creative efforts based on the embodiments of the present invention fall within the scope of protection of the present invention.

[0021] It should be noted that the compilation process represented can be divided into four steps: preprocessing, compilation, assembly, and linking. Existing distributed compilation systems such as distcc and sccache provide distributed support for the preprocessing, compilation, and assembly stages. They can call remote compilers for compilation based on local code, greatly improving the compilation speed. If the performance of the remote machine is better than that of the local machine, performance can be improved; if there are many tasks to be compiled, multiple machines can be called simultaneously for compilation to increase the parallelism of software compilation.

[0022] However, existing distributed compilation systems such as distcc and sccache do not support the distributed linking function. But with the widespread use of techniques such as link-time optimization, it is no longer sufficient to perform distribution only in the preprocessing, compilation, and assembly stages. The use of link-time optimization consumes a large amount of memory. For machines with low configurations (such as those with less than 16G of memory), there will be a problem that there is not enough memory for link-time operations. Moreover, the use of link-time optimization requires a large amount of CPU (Central Processing Unit) computing power, and for devices with insufficient single-core performance, it will take a very long time.

[0023] To solve the above problems, embodiments of the present invention provide a method, device, equipment, storage medium, and program product for linking binary files.

[0024] Figure 1 It is one of the flow diagrams of a method for linking binary files provided by embodiments of the present invention. As Figure 1 shown, the method may include the following steps:

[0025] Step 101, if the link command does not complete within the time limit, forcibly end the running of the link command and obtain the respective paths of all files participating in the link.

[0026] In some embodiments, the method may be executed by a computer device for compiling software. In response to the link command, the local linker performs a link operation based on the link command. Among them, the link command includes relevant information such as linker information, input file path, and output file path. The link command can be input by the user or generated by a compilation program in the computer device.

[0027] As a possible implementation, a time threshold can be set when executing the link command. If the link command is completed within the time threshold, the link result of the local linker is output. If the link command does not complete within the time threshold, the running of the link command is forcibly ended, and the respective paths of all files participating in the link are obtained. Among them, the respective paths of all files participating in the link can be obtained based on the log data related to the files during the link process.

[0028] Among them, the time threshold can be preset or dynamically adjusted based on the actual operation. As an example, the time threshold can be set to 10s. As another example, the time threshold can be set to a specific time after the linker no longer outputs the log file. For example, the time threshold can be set to 1s after the linker no longer outputs the log file.

[0029] All files participating in the linking refer to all files involved in the linking operation based on the linking instruction, which may include object files obtained by compilation, linker script files, dynamic library files, static library files, etc. It should be noted that all files participating in the linking include not only the files involved in the linking instruction but also the files determined through symbol resolution, relocation, etc. during the linking process.

[0030] Step 102: Copy all files participating in the linking to the temporary folder according to their respective paths.

[0031] That is to say, when copying all files participating in the linking to the temporary folder, the original paths of all files participating in the linking need to be retained.

[0032] As an example, create the temporary folder / tmp / tmp-dir. If the path of a file participating in the linking is / tmp / build-xx / xx.o, then the path of the file after being copied to the temporary folder is / tmp / tmp-dir / / tmp / build-xx / xx.o.

[0033] Step 103: Modify the linking command based on the environment of the remote linking server, and send the modified linking command and the temporary folder to the remote linking server, so that the remote linking server performs the linking operation based on the modified linking command and the temporary folder to obtain the linking result.

[0034] In some embodiments of the present invention, for the linking commands that are not completed within the time limit, the linking operation can be performed by the remote linking server. Among them, the remote linking server is equipped with a linker program. The remote linking server can be a computer device that has a larger memory, better single-core performance, and better input / output performance compared to the local computer device. By remotely calling the linker of the remote linking server to replace the linker of the local computer device to accelerate the linking operation, the time consumed in the linking stage can be greatly reduced.

[0035] Among them, after receiving the modified link command and the temporary folder, the remote link server executes the modified link command based on the temporary folder to perform a link operation and returns the obtained link result. In some embodiments, the remote link server stores according to the path of the temporary folder. For example, the path of the temporary folder on the local computer device is / tmp / tmp-dir, and the path of the temporary folder of the remote link server is also / tmp / tmp-dir.

[0036] In order to make the link command sent to the remote link server conform to the environment of the remote link server, the link command needs to be modified. As a possible implementation, modifying the link command based on the environment of the remote link server includes: modifying the linker in the link command to the linker of the remote link server; modifying the paths of the input file and the output file in the link command to the file paths corresponding to the temporary folder.

[0037] It can be understood that since the remote link server performs a link operation based on the files in the temporary folder and the file paths in the temporary folder are different from the initial file paths, in order to enable the remote link server to execute the link command, the input file path and the output file path in the link command need to be modified to the file paths corresponding to the temporary folder.

[0038] As an example, modifying the linker in the link command to the linker of the remote link server includes: changing the path of the linker in the link command to the linker path on the remote link server; if the instruction set architectures of the local computer device and the remote link server are different, changing the path of the linker in the link command to the cross-linker path on the remote link server, and options related to the architecture can also be added; if the path of the linker in the link command is changed to the cross-linker path on the remote link server, the path of the linker plugin in the link command can also be modified to the path of the cross-linker related plugin. Among them, the linker path of the remote link server can be preset or obtained through communication with the remote link server.

[0039] In some embodiments, the link script file in the temporary folder involves the paths of many reference files. Since the path of each file has changed after the file is copied to the temporary folder, it is also necessary to modify the file paths involved in the file content of the link script file. As a possible implementation, before sending the modified link command and the temporary folder to the remote link server, it may further include: modifying the file paths involved in the file content of the link script file in the temporary folder to the file path corresponding to the temporary folder. It should be noted that the file paths involved in the link script include actual paths and relative paths. During the modification process, only the actual paths in the file content need to be modified to the file path corresponding to the temporary folder, and there is no need to modify the relative paths.

[0040] In some embodiments, the temporary folder can also be packaged and compressed according to an appropriate compression level, and the obtained compressed package is sent to the remote link server; after receiving the compressed package, the remote link server decompresses the compressed package to the temporary folder, and the path of this temporary folder is the same as the path of the temporary folder of the local computer device; based on the obtained temporary folder, the modified link command is executed. If the link is successful, the execution file obtained from the link is returned to the local computer device. If the link fails, both the output of the linker and the error code can be returned to the local computer device.

[0041] It should be noted that when sending the modified link command and the temporary folder to the remote link server, the local working path is also sent to the remote link server. After decompressing the compressed package to the temporary file, the remote link server first switches the working path based on the received local working path, and then executes the modified link command. For example, if the local working path is tmp / build-xx and the temporary folder of the server is / tmp / tmp-dir, the remote link server switches the working path to / tmp / tmp-dir / tmp / build-xx.

[0042] Step 104, receive the link result sent by the remote link server.

[0043] In some embodiments, if the link result is the execution file obtained after a successful link, the link result is directly output. If the link result is a link failure, the above link command can be executed again.

[0044] In some embodiments, the temporary folder and the link command can also be directly sent to the remote link server, and the remote link server is responsible for modifying the file path references in the file content of the link script file in the temporary folder, as well as modifying the link command. As an example, the remote link server first extracts the compressed package to the temporary folder, modifies the actual file path involved in the file content of the link script file in the temporary folder of the remote link server to the file path corresponding to this temporary folder; modifies the linker in the link command to the linker of the remote link server, and modifies the paths of the input and output files in the link command to the file paths corresponding to the temporary folder.

[0045] According to the method for linking binary files in an embodiment of the present invention, if the link command fails to complete within the time limit, the running of the link command is forcibly terminated, and the paths of all files participating in the link are obtained respectively; all files participating in the link are copied to the temporary folder according to their respective paths; based on the environment of the remote link server, the link command is modified, and the modified link command and the temporary folder are sent to the remote link server, so that the remote link server performs the link operation based on the modified link command and the temporary folder to obtain a link result; the link result sent by the remote link server is received. By performing the link operation through the remote link server, the present invention can greatly reduce the time consumed by the link and improve the efficiency of the link stage.

[0046] Currently, mainstream linkers all provide a detailed output (verbose) option. By using this option, all files participating in the link can be listed at the initial stage of the execution of the link command. Therefore, the link command in the embodiment of the present invention can be a link command that has used the detailed output option.

[0047] Figure 2 This is the second flow chart of the method for linking binary files provided by the embodiment of the present invention. As Figure 2 shown, based on the above embodiment, Figure 1 in step 101 of

[0048] obtaining the paths of all files participating in the link respectively includes the following steps:

[0049] Step 201, obtaining the output content corresponding to the link command.

[0050] In the embodiment of the present invention, the linker has added the verbose option, so all files participating in the link will be listed in the output content corresponding to the link command. Therefore, the paths of all files participating in the link can be obtained based on the output content.

[0051] The output content corresponding to the link command may include all target object files (usually.o files under Linux), link script files, system static library files, system dynamic library files, local static library files, and local dynamic library files. It should be noted that during the linking process, if a file is a symbolic link file, the file it links to also belongs to the files participating in the link; if a file is a thin static library file, the target files it references also belong to the files participating in the link.

[0052] Specifically, based on the output content, the implementation process of obtaining the paths of all files participating in the link for each file can include: based on the output content, obtaining the paths of all files to be linked for each file; based on the output content, obtaining the paths of the files involved in additional processing during the linking process; determining all the files to be linked and the files involved in additional processing as all the files participating in the link. Among them, the additional processing during the linking process can be relocation, symbol resolution, etc. The files to be linked can be the files included in the link command, that is, the files that do not require additional processing. For example, if a file is a symbolic link file and it is necessary to obtain the file it links to, then the file it links to belongs to the files involved in additional processing; if a file is a thin static library file and it is necessary to obtain the target files it references, those target files also belong to the files involved in additional processing.

[0053] According to the method for linking binary files of the embodiments of the present invention, by adding a detailed output option, it is possible to directly and efficiently obtain the paths of all files participating in the link based on the output content corresponding to the link command, and it is also possible to avoid missing files and ensure the smooth progress of remote link processing.

[0054] Next, by using the SSH (Secure Shell, a security protocol for network communication) protocol to transmit commands and files, the cc1 file in GCC (a programming language compiler developed by the GNU project) is linked to verify the method for linking binary files of this embodiment. During the compilation of the GCC software package of openEuler 24.03 LTS (an open-source Linux operating system), when linking the cc1 file, if it is on SG2042, it takes about 10 minutes; by using the SSH protocol to transmit commands and files and using AMD Ryzen 9950X for remote linking, it takes about 3 minutes; among them, the time taken to execute the link command on the server side is about 1 minute. Specifically as follows:

[0055] Among them, the link wrapper is written using Python 3.11 in combination with libraries such as subprocess and paramiko. On the local side, the verbose option is added, and the link command is attempted to be executed with a time limit of 10 seconds. If the link command cannot be completed within 10 seconds, the execution of the link command is forcibly stopped, and the output content corresponding to the link command is obtained as follows:

[0056] “attempt to open / lib64 / .. / lib64 / crt1.o succeeded

[0057] attempt to open c / c-lang.o succeeded

[0058] attempt to open / lib64 / .. / lib64 / libc.so succeeded

[0059] opened script file / lib64 / .. / lib64 / libc.so

[0060] / lib64 / .. / lib64 / libc.so

[0061] opened script file / lib64 / .. / lib64 / libc.so

[0062] attempt to open / lib64 / lp64d / libc.so.6 succeeded

[0063] attempt to open / lib64 / .. / lib64 / libm.so succeeded

[0064] attempt to open / usr / lib / gcc / riscv64-openEuler-linux / 12 / libgcc.asucceeded

[0065] / usr / lib / gcc / riscv64-openEuler-linux / 12 / libgcc.a

[0066] ( / usr / lib / gcc / riscv64-openEuler-linux / 12 / libgcc.a)_ffssi2.o

[0067] ( / usr / lib / gcc / riscv64-openEuler-linux / 12 / libgcc.a)_clz.o, etc."

[0068] Analyze the above output content to obtain the respective paths of all files involved in the link, including:

[0069] / lib64 / .. / lib64 / crt1.o

[0070] c / c-lang.o

[0071] / lib64 / .. / lib64 / libc.so

[0072] / lib64 / lp64d / libc.so.6

[0073] / lib64 / .. / lib64 / libm.so

[0074] / usr / lib / gcc / riscv64-openEuler-linux / 12 / libgcc.a

[0075] / usr / lib / gcc / riscv64-openEuler-linux / 12 / libgcc.a_ffssi2.o

[0076] / usr / lib / gcc / riscv64-openEuler-linux / 12 / libgcc.a_clz.o.

[0077] Among them, / lib64 / .. / lib64 / libm.so is a symbolic link file, and its link target is / lib64 / .. / lib64 / libm.so.6. Therefore, / lib64 / .. / lib64 / libm.so.6 also belongs to the files involved in the link.

[0078] Copy these files to a randomly generated temporary folder. Assume the temporary folder is / tmp / tmp-dir, and modify the file paths involved in the content of the link script file in the temporary folder. For example, / lib64 / .. / lib64 / libc.so is a link script file, which contains / lib64 / lp64d / libc.so.6, / usr / lib64 / lp64d / libc_nonshared.a, / lib / ld-linux-riscv64-lp64d.so.1, etc. Then add / tmp / tmp-dir in front of these paths. The modified paths are as follows:

[0079] / tmp / tmp-dir / lib64 / lp64d / libc.so.6

[0080] / tmp / tmp-dir / usr / lib64 / lp64d / libc_nonshared.a

[0081] / tmp / tmp-dir / lib / ld-linux-riscv64-lp64d.so.1

[0082] Package and compress the temporary folder / tmp / tmp-dir into / tmp / tmp-dir.tar.gz, and transfer it to the / tmp folder on the remote link server. At the same time, inform the remote link server that the local current working path is / root / rpmbuild / BUILD / gcc-12.3.0 / obj-riscv64-openEuler-linux / gcc. The remote link server extracts / tmp / tmp-dir.tar.gz to the folder / tmp / tmp-dir. The remote link server changes the working path to / tmp / tmp-dir / root / rpmbuild / BUILD / gcc-12.3.0 / obj-riscv64-openEuler-linux / gcc.

[0083] Based on the environment of the remote link server locally, modify the linking command. Change the linker in the linking command to the linker of the remote link server; change both the input file path and the output file path in the linking command to the file paths corresponding to the temporary folder. The remote link server executes the modified linking command and returns the result after execution.

[0084] Next, the link binary file device provided by the present invention will be introduced.

[0085] Figure 3 It is a schematic structural diagram of the link binary file device provided for the embodiment of the present invention. As Figure 3As shown in the figure, the device includes: an acquisition module 310, a copying module 320, a sending module 330, and a receiving module 340. The acquisition module 310 is configured to forcibly end the running of the link command if the link command is not completed within the time limit, and acquire the paths of all files participating in the link respectively; the copying module 320 is configured to copy all files participating in the link to a temporary folder according to their respective paths; the sending module 330 is configured to modify the link command based on the environment of the remote link server, and send the modified link command and the temporary folder to the remote link server, so that the remote link server performs a link operation based on the modified link command and the temporary folder to obtain a link result; the receiving module 340 is configured to receive the link result sent by the remote link server.

[0086] In some embodiments, the link command uses a detailed output option, and the acquisition module 310 is specifically configured to: acquire the output content corresponding to the link command; based on the output content, obtain the paths of all files participating in the link respectively.

[0087] As a possible implementation, the acquisition module 310 is further configured to: based on the output content, acquire the paths of all files to be linked respectively; based on the output content, acquire the paths of the files involved in additional processing during the link process; determine all files to be linked and the files involved in additional processing as all files participating in the link.

[0088] In some embodiments, the sending module 330 is further configured to: before sending the modified link command and the temporary folder to the remote link server, modify the file paths involved in the file content of the link script file in the temporary folder to the file path corresponding to the temporary folder.

[0089] In some embodiments, the sending module 330 is further configured to: modify the linker in the link command to the linker of the remote link server; modify the paths of the input file and the output file in the link command to the file path corresponding to the temporary folder.

[0090] In some embodiments, the receiving module 340 is further configured to: if the link result is a link failure, re-execute the link command.

[0091] It should be noted that the above explanations of the method for linking binary files in the above embodiments are equally applicable to the device for linking binary files in the embodiments of the present invention, and will not be elaborated here.

[0092] A linked binary file device according to an embodiment of the present invention, an acquisition module, configured to forcibly end the running of a link command and acquire the respective paths of all files participating in the link if the link command is not completed within the time limit; a copying module, configured to copy all files participating in the link to a temporary folder according to their respective paths; a sending module, configured to modify the link command based on the environment of a remote link server, and send the modified link command and the temporary folder to the remote link server, so that the remote link server performs a link operation based on the modified link command and the temporary folder to obtain a link result; a receiving module, configured to receive the link result sent by the remote link server. By performing the link operation through the remote link server, the present invention can greatly reduce the time consumed by the link and improve the compilation efficiency.

[0093] Figure 4 Schematically illustrates the physical structure of an electronic device, as Figure 4 shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430, and a communication bus 440. Among them, the processor 410, the communication interface 420, and the memory 430 complete mutual communication through the communication bus 440. The processor 410 may call a computer program in the memory 430 to execute the steps of the linked binary file method provided in the above embodiments.

[0094] Specifically include: if the link command is not completed within the time limit, forcibly end the running of the link command, and acquire the respective paths of all files participating in the link; copy all files participating in the link to a temporary folder according to their respective paths; modify the link command based on the environment of the remote link server, and send the modified link command and the temporary folder to the remote link server, so that the remote link server performs a link operation based on the modified link command and the temporary folder to obtain a link result; receive the link result sent by the remote link server.

[0095] In addition, when the logical instructions in the above-mentioned memory 430 are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.

[0096] On the other hand, the present invention also provides a computer program product. The computer program product includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the link binary file method provided in the above-mentioned various embodiments. The method includes: if the link command is not completed within the time limit, forcibly ending the running of the link command, and obtaining the respective paths of all files participating in the link; copying all files participating in the link to a temporary folder according to their respective paths; modifying the link command based on the environment of the remote link server, and sending the modified link command and the temporary folder to the remote link server, so that the remote link server performs a link operation based on the modified link command and the temporary folder to obtain a link result; receiving the link result sent by the remote link server.

[0097] In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it is implemented to execute the link binary file method provided in the above-mentioned various methods. The method includes: if the link command is not completed within the time limit, forcibly ending the running of the link command, and obtaining the respective paths of all files participating in the link; copying all files participating in the link to a temporary folder according to their respective paths; modifying the link command based on the environment of the remote link server, and sending the modified link command and the temporary folder to the remote link server, so that the remote link server performs a link operation based on the modified link command and the temporary folder to obtain a link result; receiving the link result sent by the remote link server.

[0098] The non-transitory computer-readable storage medium may be any available medium or data storage device accessible by a processor, including but not limited to magnetic memories (such as floppy disks, hard disks, magnetic tapes, magneto-optical discs (MO), etc.), optical memories (such as CDs, DVDs, BDs, HVDs, etc.), and semiconductor memories (such as ROMs, EPROMs, EEPROMs, NAND FLASH, solid state drives (SSDs)), etc.

[0099] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without creative efforts.

[0100] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course also by hardware. Based on such an understanding, the essence of the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disks, optical discs, etc., and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0101] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments or perform equivalent replacements for some of the technical features. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for linking binary files, characterized in that, including: If the link command fails to complete within the time limit, forcibly terminate the execution of the link command and obtain the paths of all files participating in the link; wherein, the paths of all files participating in the link include the paths of all files to be linked, and the paths of files involved in additional processing during the link process; the additional processing includes symbol resolution and relocation processing; Copy all the files participating in the link to a temporary folder according to their respective paths; Modify the link command based on the environment of the remote link server; specifically including: changing the linker path in the link command to the cross-linker path of the remote link server; modifying the absolute paths of the input file and the output file in the link command to the file paths corresponding to the temporary folder; wherein, the remote link server is a distributed system; Send the modified link command and the temporary folder to the remote link server, so that the remote link server performs a link operation based on the modified link command and the temporary folder to obtain a link result; Receive the link result sent by the remote link server.

2. The method according to claim 1, characterized in that The link command uses the detailed output option; the obtaining of the paths of all files participating in the link includes: Obtain the output content corresponding to the link command; Based on the output content, obtain the paths of all files participating in the link.

3. The method according to claim 1, characterized in that, Before sending the modified link command and the temporary folder to the remote link server, it further includes: Modify the file paths involved in the file content of the link script file in the temporary folder to the file paths corresponding to the temporary folder.

4. The method according to any one of claims 1 to 3, characterized in that, After receiving the link result sent by the remote link server, it further includes: If the link result is a link failure, re-execute the link command.

5. A link binary file device, characterized in that, including: An acquisition module, configured to forcibly terminate the execution of the link command and obtain the paths of all files participating in the link if the link command fails to complete within the time limit; wherein, the paths of all files participating in the link include the paths of all files to be linked, and the paths of files involved in additional processing during the link process; the additional processing includes symbol resolution and relocation processing; A copying module, configured to copy all the files participating in the link to a temporary folder according to their respective paths; A sending module, configured to modify the link command based on the environment of the remote link server; specifically including: changing the linker path in the link command to the cross-linker path of the remote link server; modifying the absolute paths of the input file and the output file in the link command to the file paths corresponding to the temporary folder; wherein, the remote link server is a distributed system; The sending module is further configured to send the modified link command and the temporary folder to the remote link server, so that the remote link server performs a link operation based on the modified link command and the temporary folder to obtain a link result; A receiving module, configured to receive the link result sent by the remote link server.

6. An electronic device, comprising a processor and a memory storing a computer program, characterized in that, When the processor executes the computer program, the method for linking binary files according to any one of claims 1 to 4 is implemented.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, the method for linking binary files according to any one of claims 1 to 4 is implemented.

8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, the method for linking binary files according to any one of claims 1 to 4 is implemented.