CN112162736A - Device and method for realizing software cross-platform binary compatibility among same CPU instruction set devices - Google Patents
Device and method for realizing software cross-platform binary compatibility among same CPU instruction set devices Download PDFInfo
- Publication number
- CN112162736A CN112162736A CN202010676284.1A CN202010676284A CN112162736A CN 112162736 A CN112162736 A CN 112162736A CN 202010676284 A CN202010676284 A CN 202010676284A CN 112162736 A CN112162736 A CN 112162736A
- Authority
- CN
- China
- Prior art keywords
- software
- loader
- platform
- file
- operating system
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 16
- 238000011161 development Methods 0.000 claims abstract description 18
- 230000008676 import Effects 0.000 claims description 11
- 230000006870 function Effects 0.000 claims description 10
- 230000008569 process Effects 0.000 claims description 4
- 238000013507 mapping Methods 0.000 claims description 3
- 229910002056 binary alloy Inorganic materials 0.000 abstract 1
- 238000012545 processing Methods 0.000 description 6
- 238000012360 testing method Methods 0.000 description 4
- 238000006243 chemical reaction Methods 0.000 description 3
- 238000010586 diagram Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000006978 adaptation Effects 0.000 description 1
- 230000003044 adaptive effect Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000013508 migration Methods 0.000 description 1
- 230000005012 migration Effects 0.000 description 1
- 238000013522 software testing Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/42—Syntactic analysis
- G06F8/427—Parsing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/52—Binary to binary
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses a device and a method for realizing software cross-platform binary system compatibility among devices with the same CPU instruction set, which are characterized by comprising a converter working on a development machine and a loader working on target devices, wherein the converter is used for converting an executable program or a dynamic link library into a release file, the loader and the release file are released to the target devices together, and the loader is used for calling the release file on the target devices to finish software startup.
Description
Technical Field
The invention relates to the technical field of software development, in particular to a device and a method for realizing cross-platform binary compatibility of software among devices with the same CPU instruction set.
Background
Nowadays, a variety of operating systems are available for personal computers, such as Windows, macOS, Linux, etc., which are the mainstream. It is known that even if the same CPU processor is used, application software running on one operating system cannot run on another operating system. When a software developer wishes to have its own software run on multiple operating systems, some cross-platform technical cooperation is required. The current common solutions and disadvantages are:
(1) software is developed using some cross-platform language. Software developed using this scheme requires a large amount of instruction conversion processing during operation, which can result in a significant loss of processing performance. This solution is not suitable for use in high volume in performance demanding software.
(2) Recompile the target platform through the source code. When the compiler or C/C + + language is developed to be closer to hardware instructions for performance, the source codes are often not completely compatible due to the lack of strictly uniform syntax standards of the compilers, resulting in compilation failure. The migration success rate of this scheme is low.
(3) A dedicated source code may be written for each operating system. The solution requires a lot of developers who are respectively familiar with different operating systems to develop the same function together, which leads to high development cost and high technical threshold. Moreover, different source codes cannot ensure the same execution result, and software testing work must be enhanced. This solution results in a doubling of the development and testing effort.
Disclosure of Invention
The invention aims to solve the problems in the prior art and provides a device and a method for realizing software cross-platform binary compatibility among devices with the same CPU instruction set, which can convert an executable program or a dynamic link library developed for a specific operating system into a release file irrelevant to the operating system, thereby ensuring that software source codes are not modified and recompiled, and the software runs on the devices which are provided with other operating systems and are provided with the same CPU instruction set, thereby realizing the software cross-platform binary compatibility.
Based on one aspect of the invention, a device for realizing software cross-platform binary compatibility based on the same CPU instruction set is provided, which comprises:
a translator operating on the development machine and a loader operating on the target device.
The converter is further used for extracting an execution entry address, import information, export information, memory address redirection information and all binary execution codes from the executable program or the dynamic link library, and processing the two into a release file.
The loader is further used for loading binary executable codes in the release file, completing work such as memory address conversion, external import library loading, external import function mapping, internal export function registration and the like, and finally calling an entry function from an execution entry address to complete software starting.
The release file is a cross-platform program file for releasing the software product, is universal between devices compatible with a specified target platform during compiling of a software source code, and is irrelevant to an operating system.
The target device is further a device which is compatible with a target instruction set specified during software source code development and compilation and is provided with a Windows operating system, a Linux operating system or a macOS operating system.
Based on another aspect of the present invention, a method for implementing software cross-platform binary compatibility based on the same CPU instruction set is provided, including:
step 1, converting an executable program or a dynamic link library into a release file by using a converter;
step 2, the loader and the release file are released to the target equipment together;
and 3, calling the release file on the target equipment by using a loader to finish software starting.
The invention has the beneficial effects that:
1. the cross-platform development threshold is reduced, and a software developer can convert an executable program or a dynamic link library which is developed and compiled on a development machine into a release file only by calling the converter provided by the invention without modifying source codes and recompiling.
2. The method supports the development of high-performance software, supports the development of C/C + + language, provides the best execution performance, and does not need to use other cross-platform programming languages.
3. Development and test costs are reduced, only binary copying is needed in the cross-platform process, source code modification is not involved, recompilation is not needed, and most of platform-independent test cases can be ignored, so that repeated development of software with cross-platform requirements can be avoided, development efficiency is improved, and a large amount of development and test costs are saved.
4. The method has the advantages that a consistent use experience is obtained, and the cross-platform software developed by the technology does not need to be redesigned and redeveloped aiming at different operating systems, so that the same operation process is used on any operating system.
Drawings
FIG. 1 is a schematic diagram of the principles of the present invention;
FIG. 2 is a flow chart of the converter operation of the present invention;
FIG. 3 is a flowchart of the loader operation of the present invention.
Detailed Description
The invention is further described below with reference to the accompanying drawings:
fig. 1 is a schematic diagram illustrating the principle of the present invention.
Stripping off the part related to the operating system from the executable program file to manufacture a release file unrelated to the operating system; and the self-made program is used for simulating the original executable program loading process of the target operating system, so that part of work related to the target operating system is completed, and cross-platform running of software is realized.
As shown in fig. 2, the processing flow of the converter in the present invention is shown.
Step 1, reading in an executable program or a dynamic link library generated by development and compilation of a developer.
And 2, defining and analyzing an execution entry address, import information, export information, memory address redirection information and all binary executable codes in the executable program or the dynamic link library according to the formats of the executable files of Windows, Linux and macOS.
And 3, organizing the execution entry address, the import information, the export information and the memory address redirection information into an xml format and storing the xml format as a mod file, and copying and storing the binary executable code as a code file.
In an embodiment of the present invention,. mod file and.code file are the publishing file.
Furthermore, the converter can write versions facing various devices and operating systems according to the actual situation of the development machine, namely when the development machine is a Windows operating system, the converter capable of working on Windows and analyzing the Windows executable file format is used, and the Linux operating system and the macOS operating system are the same.
Fig. 3 shows a processing flow of the loader according to the present invention.
Step 1, a loader reads in a mod file and a code file.
And 2, according to the information recorded in the mod file, performing processing such as memory address conversion, external import library loading, external import function mapping, internal export function registration and the like, and completing the operation environment adaptive to the target equipment.
And 3, calling an entry function from the execution entry address.
Further, the loader can write versions facing various devices and operating systems according to the actual situation of the target machine, namely when the target machine is a Windows operating system, the loader adapted to the Windows operating system is used, and the Linux operating system and the macOS operating system are the same.
After being equipped with a proper converter and a loader, the software cross-platform operation can be realized according to the following steps:
step 1, converting an executable program or a dynamic link library into a release file by using a converter;
step 2, the loader and the release file are released to the target equipment together;
and 3, calling the release file on the target equipment by using a loader to finish software starting.
It should be noted that, since the program calling the proprietary API of a certain operating system does not have the corresponding API on other operating systems, the present invention requires a third-party cross-platform library to serve as an adaptation layer instead of directly calling the API of the Windows operating system, or the part tightly coupled to the operating system may be separated during design. In some embodiments of the invention, Qt or wxWidgets are used instead of MFC, OpenGL is used instead of DirectX, libervent is used instead of Socket API, and the like.
By adopting the device and the method, the source code of the software can be not modified and recompiled, so that the software can run on equipment which is provided with other operating systems and is provided with the same CPU instruction set, and the cross-platform binary compatibility of the software is realized.
The above embodiments are illustrative of the present invention, and are not intended to limit the present invention, and any simple modifications of the present invention are within the scope of the present invention.
Claims (8)
1. An apparatus for implementing software cross-platform binary compatibility between devices of the same CPU instruction set, which is characterized by comprising a converter working on a development machine and a loader working on a target device.
2. The apparatus of claim 1, wherein the converter is further configured to extract an execution entry address, import information, export information, memory address redirection information, and all binary executable code from an executable program or a dynamic link library, and process the extracted execution entry address, import information, export information, and memory address redirection information into an issue file.
3. The apparatus of claim 1, wherein the loader is further configured to load binary executable code in the release file, perform memory address translation, external import library loading, external import function mapping, and internal export function registration, and finally call an entry function from an execution entry address to perform software boot.
4. The apparatus of claim 2, wherein the release file, further a cross-platform program file for software product release, is generic between devices compatible with a target platform specified at software source code compilation time, independent of the operating system.
5. The apparatus of claim 1, wherein the target device is further a device compatible with a target instruction set specified during software source code development and compilation and installed with a Windows operating system, a Linux operating system, or a macOS operating system.
6. A method for realizing software cross-platform binary compatibility among devices with the same CPU instruction set is characterized by comprising the following steps:
step 1, converting an executable program or a dynamic link library into a release file by using a converter;
step 2, the loader and the release file are released to the target equipment together;
and 3, calling the release file on the target equipment by using a loader to finish software starting.
7. The method of claim 6, wherein step 1 is preceded by the step of:
the converter is written in C language.
8. The method of claim 6, wherein step 2 is preceded by the step of:
and writing the loader adapted to the target equipment by adopting C language.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010676284.1A CN112162736A (en) | 2020-07-14 | 2020-07-14 | Device and method for realizing software cross-platform binary compatibility among same CPU instruction set devices |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010676284.1A CN112162736A (en) | 2020-07-14 | 2020-07-14 | Device and method for realizing software cross-platform binary compatibility among same CPU instruction set devices |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112162736A true CN112162736A (en) | 2021-01-01 |
Family
ID=73859497
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010676284.1A Pending CN112162736A (en) | 2020-07-14 | 2020-07-14 | Device and method for realizing software cross-platform binary compatibility among same CPU instruction set devices |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112162736A (en) |
-
2020
- 2020-07-14 CN CN202010676284.1A patent/CN112162736A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP3134808B1 (en) | Metadata-driven dynamic specialization | |
Consel et al. | A uniform approach for compile-time and run-time specialization | |
US5590331A (en) | Method and apparatus for generating platform-standard object files containing machine-independent code | |
US8091076B2 (en) | Dynamic native binding | |
JP6122493B2 (en) | Adaptively portable library | |
US7434209B2 (en) | Method and apparatus for performing native binding to execute native code | |
US6247172B1 (en) | Method for a translation system that aggressively optimizes and preserves full synchronous exception state | |
JP5415557B2 (en) | User script code conversion for debugging | |
US7877741B2 (en) | Method and corresponding apparatus for compiling high-level languages into specific processor architectures | |
US6874140B1 (en) | Debug annotations | |
CA2306545A1 (en) | Automatic stub/adapter generator | |
US7124407B1 (en) | Method and apparatus for caching native code in a virtual machine interpreter | |
US20110126179A1 (en) | Method and System for Dynamic Patching Software Using Source Code | |
US20090320007A1 (en) | Local metadata for external components | |
CN111061486B (en) | Android application program increment method | |
US6625807B1 (en) | Apparatus and method for efficiently obtaining and utilizing register usage information during software binary translation | |
US10452364B2 (en) | Method and system for preparing code to be executed by programmable control devices | |
CN110569039A (en) | Method for optimizing JAVA operation on platform | |
US6976249B1 (en) | Method for embedding object codes in source codes | |
CN112162736A (en) | Device and method for realizing software cross-platform binary compatibility among same CPU instruction set devices | |
Oh et al. | Bytecode-to-c ahead-of-time compilation for android dalvik virtual machine | |
CN102819435B (en) | A kind of position independent code generation method of Java Virtual Machine | |
US20110099534A1 (en) | Information processing apparatus, execution program operation modification method, and recording medium | |
CN113672238B (en) | Operation method, device and equipment based on real-time operating system modularized management | |
KR20130077673A (en) | A extended method for eliminating null pointer check using method specialization |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |