CN117234590B - Instruction set generation method, device, medium and equipment - Google Patents

Instruction set generation method, device, medium and equipment Download PDF

Info

Publication number
CN117234590B
CN117234590B CN202310966938.8A CN202310966938A CN117234590B CN 117234590 B CN117234590 B CN 117234590B CN 202310966938 A CN202310966938 A CN 202310966938A CN 117234590 B CN117234590 B CN 117234590B
Authority
CN
China
Prior art keywords
indirect
reference method
file
call instruction
application
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.)
Active
Application number
CN202310966938.8A
Other languages
Chinese (zh)
Other versions
CN117234590A (en
Inventor
刘源杰
徐俊江
赵轶
郑江东
王幼君
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Watchdata Co ltd
Original Assignee
Beijing Watchdata Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Watchdata Co ltd filed Critical Beijing Watchdata Co ltd
Priority to CN202310966938.8A priority Critical patent/CN117234590B/en
Publication of CN117234590A publication Critical patent/CN117234590A/en
Application granted granted Critical
Publication of CN117234590B publication Critical patent/CN117234590B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention discloses a method, a device, a medium and equipment for generating an instruction set, wherein the method comprises the following steps: acquiring input data, wherein the input data comprises application program source codes and an imported packet information file; analyzing the source codes of the application program, and determining a direct reference method and an indirect reference method; constructing a direct reference method call instruction corresponding to the direct reference method, and constructing an indirect reference method call instruction corresponding to the indirect reference method; outputting a direct reference method call instruction and an indirect reference method call instruction. The application program source codes are analyzed to determine the direct reference method and the indirect reference method, and the direct reference method calling instruction corresponding to the direct reference method is constructed in advance, so that the problem that the direct reference method needs to analyze and search the corresponding method actual reference set data in the execution process is avoided, and the executable file on the secure element is prevented from carrying a large amount of reference set data related to the method, so that the secure element downloading process is efficient and good in compatibility.

Description

Instruction set generation method, device, medium and equipment
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a medium, and a device for generating an instruction set.
Background
The secure element may provide a variety of security functions such as identification, security authentication, sensitive data storage, etc. Smart cards, which are one type of security element, are widely used in people's daily lives in the form of access cards, bank cards, bus cards, etc. The development of the secure element application is simplified by the virtual machine system and the secure element operating system which can be downloaded later, and the secure element can bear a large number of service functions through the application in the secure element, so that core security protection is provided, and the security and service requirements of various industries are supported.
Business applications require dynamic management such as downloading, installing, personalizing, deleting, etc., which are based on the operating system in the secure element, while the running of the application is more dependent on the virtual machine in the secure operating system. For a virtual machine in a secure element, an instruction set execution engine is relied on to complete application logic and service functions, the instruction set data is obtained by processing a source code file through an instruction set generating device (the instruction set generating device can be a compiler, an interpreter or a program or software for processing the output file of the compiler), and a method calling instruction set is an indispensable instruction type in the instruction set.
For a Java virtual machine, the method call instruction set is: an invokevirtual (representing virtual method calls), an invokespecific (representing special instance method calls, such as example initialization methods, private methods, and parent methods), an invokestatic (representing static method calls), an invokeinterface (representing interface method calls). For Dalvik virtual machines, the method call instruction set is invoke-virtual (representing virtual method calls), invoke-super (representing parent virtual method calls), invoke-direct (representing special instance method calls, such as initialization methods, private instance methods), invoke-static (representing static method calls), invoke-interface (representing interface method calls).
An executable file of the secure element is a representation of application package data that includes various instruction set data and reference set data (e.g., constant pool data) within the application package. The reference set data has multiple types, and different methods refer to data for different types of methods, such as virtual methods, static methods, parent methods and the like, so that executable files on the secure element carry a large amount of reference set data related to the methods, which can cause the downloading process to be inefficient and even can not finish downloading and installation due to smaller capacity of the secure element.
Disclosure of Invention
The embodiment of the application provides an instruction set generation method, an instruction set generation device, a medium and an instruction set generation device. The following presents a simplified summary in order to provide a basic understanding of some aspects of the disclosed embodiments. This summary is not an extensive overview and is intended to neither identify key/critical elements nor delineate the scope of such embodiments. Its sole purpose is to present some concepts in a simplified form as a prelude to the more detailed description that is presented later.
In a first aspect, an embodiment of the present application provides an instruction set generating method, including:
acquiring input data, wherein the input data comprises application program source codes and an imported packet information file;
analyzing the source codes of the application program, and determining a direct reference method and an indirect reference method; the direct reference method is a method which can be determined by the called method at the compiling period and is not changeable at the running period, and the indirect reference method is a method which can not be determined by the called method at the compiling period and is determined at the running period;
constructing a direct reference method call instruction corresponding to the direct reference method, and constructing an indirect reference method call instruction corresponding to the indirect reference method;
outputting a direct reference method call instruction and an indirect reference method call instruction.
Optionally, analyzing the source code of the application program to determine a direct reference method and an indirect reference method, including:
compiling the source code of the application program to obtain a compiling intermediate result;
semantic analysis is carried out on the compiling intermediate result, and the calling version of each called method in the source code of the application program is determined;
methods for which there is a unique calling version are identified as direct reference methods, and methods for which there is no unique calling version are identified as indirect reference methods.
Optionally, constructing a direct reference method call instruction corresponding to the direct reference method includes:
acquiring an executable file of application source codes;
sequentially placing instruction set data of each direct reference method in the source code of the application program into an executable file to sequentially obtain a method offset position of each direct reference method in the executable file;
and generating a direct reference method call instruction according to the preset direct method call type and the method offset position.
Optionally, constructing an indirect referencing method call instruction corresponding to the indirect referencing method includes:
sequentially placing instruction set data of the indirect referencing method into an executable file, and identifying an indirect method result corresponding to the source code of the application program;
generating a method reference corresponding to the indirect reference method according to the identified indirect method result and the imported package information file;
sequentially placing method references corresponding to the indirect referencing methods into a referencing set to obtain a referencing set data index of each indirect referencing method;
and generating an indirect method call instruction according to the preset indirect method call type and the reference set data index of each indirect reference method.
Optionally, generating the indirect method call instruction according to the preset indirect method call type and the reference set data index of each indirect reference method includes:
determining a preset indirect method call type;
generating a method calling instruction code by presetting an indirect method calling type;
generating an indirect referencing method calling instruction operand through indexes of each indirect referencing method in a preset application set;
and combining the indirect referencing method call instruction operand and the corresponding method call instruction code to generate the indirect method call instruction.
Optionally, before acquiring the input data, the method further includes:
compiling the application program source code through a compiler to obtain a compiling file;
packaging the compiled file to obtain an application programming interface calling file;
analyzing the source codes of the application programs or the compiled files through an application executable file generator to obtain the public interface information in the whole package;
establishing association between the public interface information and a preset link reference to obtain association data;
processing and outputting the associated data according to a preset export information file format to obtain an application programming interface export information file;
and combining the application programming interface calling file and the application programming interface export information file to obtain the import packet information file.
Optionally, before acquiring the input data, the method further includes:
converting the source code of the application program into a Class file;
analyzing the Class information file according to the Class file and the imported packet information file;
acquiring all kinds of information of the Class information file;
and organizing data information for forming the application executable file according to the class information, and generating the application executable file.
In a second aspect, an embodiment of the present application provides an instruction set generating apparatus, including:
the data acquisition module is used for acquiring input data, wherein the input data comprises application source codes and an imported packet information file thereof;
the source code analysis module is used for analyzing the source codes of the application programs and determining a direct reference method and an indirect reference method; the direct reference method is a method which can be determined by a called method at the compiling period and is not changeable at the running period, and the indirect reference method is a method which can not be determined by the called method at the compiling period and is determined at the running period;
the instruction construction module is used for constructing a direct reference method call instruction corresponding to the direct reference method and constructing an indirect reference method call instruction corresponding to the indirect reference method;
and the instruction output module is used for outputting the direct reference method call instruction and the indirect reference method call instruction.
In a third aspect, embodiments of the present application provide a computer storage medium having stored thereon a plurality of instructions adapted to be loaded by a processor and to perform the above-described method steps.
In a fourth aspect, embodiments of the present application provide an apparatus, which may include: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the method steps described above.
The technical scheme provided by the embodiment of the application can comprise the following beneficial effects:
in the embodiment of the application, an instruction set generating device firstly acquires input data, wherein the input data comprises application program source codes and an import packet information file thereof; then analyzing the source codes of the application program to determine a direct reference method and an indirect reference method; secondly, constructing a direct reference method call instruction corresponding to the direct reference method, and constructing an indirect reference method call instruction corresponding to the indirect reference method; and finally outputting a direct reference method call instruction and an indirect reference method call instruction. The application program source codes are analyzed to determine the direct reference method and the indirect reference method, and the direct reference method calling instruction corresponding to the direct reference method is constructed in advance, so that the problem that the direct reference method needs to analyze and search the corresponding method actual reference set data in the execution process is avoided, and the executable file on the secure element is prevented from carrying a large amount of reference set data related to the method, so that the secure element downloading process is efficient and good in compatibility.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention as claimed.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
FIG. 1 is a flow chart of an instruction set generating method according to an embodiment of the present application;
FIG. 2 is a process schematic block diagram of an instruction generation process provided by an embodiment of the present application;
fig. 3 is a schematic device processing flow diagram of an instruction set generating device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an instruction set generating device according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an apparatus according to an embodiment of the present application.
Detailed Description
The following description and the drawings sufficiently illustrate specific embodiments of the invention to enable those skilled in the art to practice them.
It should be understood that the described embodiments are merely some, but not all, embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention as detailed in the accompanying claims.
In the description of the present invention, it should be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. The specific meaning of the above terms in the present invention will be understood in specific cases by those of ordinary skill in the art. Furthermore, in the description of the present invention, unless otherwise indicated, "a plurality" means two or more. "and/or", describes an association relationship of an association object, and indicates that there may be three relationships, for example, a and/or B, and may indicate: a exists alone, A and B exist together, and B exists alone. The character "/" generally indicates that the context-dependent object is an "or" relationship.
The application provides a method, a device, a medium and equipment for generating an instruction set, so as to solve the problems in the related technical problems. In the technical scheme provided by the application program source code is analyzed to determine the direct reference method and the indirect reference method, and the direct reference method calling instruction corresponding to the direct reference method is constructed in advance, so that the problem that the direct reference method needs to analyze and search the corresponding method actual reference set data in the execution process is avoided, and the fact that the executable file on the secure element carries a large number of method-related reference set data is avoided, so that the secure element downloading process is efficient, the compatibility is good, and the method is described in detail by adopting an exemplary embodiment.
The instruction set generating method provided in the embodiment of the present application will be described in detail with reference to fig. 1 to fig. 3. The method may be implemented in dependence on a computer program, and may be run on an instruction set generating device based on von neumann systems. The computer program may be integrated in the application or may run as a stand-alone tool class application.
Referring to fig. 1, a flowchart of an instruction set generating method is provided in an embodiment of the present application.
As shown in fig. 1, the method of the embodiment of the present application may include the following steps:
s101, acquiring input data, wherein the input data comprises application source codes and an imported packet information file;
the application source code is a code file edited by an engineer for specific business logic, for example, source code edited by a Java language for a certain business logic. The import packet information contains published interface information (e.g., public class, public method, etc.) of all classes in a packet.
In the embodiment of the application, when an import packet information file is generated, compiling application source codes through a compiler to obtain a compiled file; packaging the compiled file to obtain an application programming interface calling file; then analyzing the source codes of the application programs or the compiled files through an application executable file generator to obtain the public interface information in the whole package; secondly, establishing association between the public interface information and a preset link reference to obtain association data; processing and outputting the associated data according to a preset export information file format to obtain an export information file of the application programming interface; and finally, combining the application programming interface calling file and the application programming interface export information file to obtain the import packet information file.
In one possible implementation, the import packet information file includes an application programming interface call file and an application programming interface export information file provided by the import packet.
The application programming interface invokes the file generation process: the compiler compiles the application programming interface source code to generate an intermediate file (e.g., a class file in Java) and packages the intermediate file (e.g., a jar file in Java).
The application programming interface exports the information file generation process: the application executable file generator analyzes the application source code or the intermediate file in the application package, acquires the public interface information in the whole package, establishes the association between the public interface information and the link reference, and finally outputs the association according to the export information file format.
Specifically, when an application executable file is generated, firstly, converting the source code of an application program into a Class file; then analyzing the Class information file according to the Class file and the imported packet information file; secondly, obtaining all kinds of information of the Class information file; and finally, organizing data information for forming the application executable file according to the class information, and generating the application executable file.
In this embodiment, when the instruction set is generated, input data needs to be acquired, where the input data includes source codes of an application program and an import packet information file thereof.
S102, analyzing application program source codes and determining a direct reference method and an indirect reference method; the direct reference method is a method which can be determined by the called method at the compiling period and is not changeable at the running period, and the indirect reference method is a method which can not be determined by the called method at the compiling period and is determined at the running period;
in the embodiment of the application, when analyzing the source codes of the application program and determining a direct reference method and an indirect reference method, compiling the source codes of the application program to obtain a compiling intermediate result; then, carrying out semantic analysis on the compiling intermediate result to determine the calling version of each called method in the source code of the application program; and finally, identifying the method with the unique calling version as a direct reference method, and identifying the method without the unique calling version as an indirect reference method.
In one possible implementation, determining the processes of the direct method and the indirect method, firstly compiling the codes by an instruction generator to obtain intermediate results; then, carrying out semantic analysis on the intermediate result, and analyzing the realization version of each called method; finally, the method capable of determining the unique calling version is a direct method, or else, is an indirect method.
S103, constructing a direct reference method call instruction corresponding to the direct reference method, and constructing an indirect reference method call instruction corresponding to the indirect reference method;
in the embodiment of the application, when a direct reference method call instruction corresponding to a direct reference method is constructed, firstly, an executable file of an application program source code is acquired; sequentially placing instruction set data of each direct reference method in the source code of the application program into the executable file to sequentially obtain a method offset position of each direct reference method in the executable file; and finally, generating a direct reference method call instruction according to the method offset position. The direct reference method call instruction of the register-based virtual machine instruction is shown in table 1, for example. The direct reference method call instruction for stack-based virtual machine instructions is shown in table 2, for example.
TABLE 1
TABLE 2
For example, first, the instruction set data of each method is put into an executable file in turn; then sequentially obtaining the offset position of each method in the executable file; and finally, generating a direct method call instruction by using the direct method result identified before and combining the method call type and the offset of the method in the executable file.
In the embodiment of the application, when an indirect referencing method call instruction corresponding to an indirect referencing method is constructed, firstly, sequentially placing instruction set data of the indirect referencing method into an executable file, and identifying an indirect method result corresponding to application source codes; then generating a method reference corresponding to the indirect reference method according to the identified indirect method result and the imported package information file; secondly, sequentially placing method references corresponding to the indirect referencing methods into a referencing set to obtain a referencing set data index of each indirect referencing method; and finally, generating an indirect method calling instruction according to the preset indirect method calling type and the reference set data index of each indirect reference method. The direct reference method call instruction of the register-based virtual machine instruction is shown in table 3, for example. The direct reference method call instruction for stack-based virtual machine instructions is shown in table 4, for example.
TABLE 3 Table 3
TABLE 4 Table 4
For example, the procedure of constructing the indirect referencing method call instruction corresponding to the indirect referencing method is as follows: sequentially placing the instruction set data of each method into an executable file; according to the previously identified indirect method result, combining the lead-in package information file to generate a corresponding method reference, and sequentially placing the method reference into a reference set to obtain a reference set index of the method; and generating the indirect method call instruction according to the indirect method call type and the reference set index of the method.
Specifically, when generating an indirect method call instruction according to a preset indirect method call type and a reference set data index of each indirect reference method, firstly determining the preset indirect method call type; then, generating a method calling instruction code by presetting an indirect method calling type; secondly, generating an indirect referencing method calling instruction operand through indexes of each indirect referencing method in a preset application set; and finally, combining the indirect referencing method call instruction operand and the corresponding method call instruction code to generate the indirect method call instruction.
For example, by indirect method call types, a method call instruction code (e.g., invokestatic) is generated; and generating a method call instruction operand (such as index byte1 index byte 2) through indexes (such as a constant pool index) of the indirect method in an application set, combining the two, and generating a final method call byte code (such as invokestatic indexbyte1 index byte 2) to obtain the indirect method call instruction.
Specifically, when the executable file is downloaded, the method reference links in the method call instruction are completed by analyzing and processing various data information (such as constant pool information, class information and method information).
S104, outputting a direct reference method call instruction and an indirect reference method call instruction.
In one possible implementation, the direct reference method call instruction and the indirect reference method call instruction may be output after they are obtained.
For example, as shown in fig. 2, fig. 2 is a schematic block diagram of an instruction generating process provided in the present application, where input data is first obtained, where the input data includes application source code and import packet information, the output data is input into an instruction set generating device, and after the output data is processed by the device, the data includes an instruction set and other data that assists in executing the instruction set, and the other data includes directly-referenced reference set data, other reference set data, and other data.
For example, as shown in fig. 3, fig. 3 is a schematic diagram of a device processing flow of an instruction set generating device provided in the present application, firstly, an instruction set generator receives input data, including application source codes and import packet information, and the instruction set generator analyzes the input data to determine a direct reference method and an indirect reference method, then generates a direct reference method call instruction for the direct reference method, secondly, generates a reference data set and an instruction set for the indirect reference method, generates an indirect reference method call instruction, and finally outputs the generated instruction set, reference set data, and other data.
It should be noted that, the size of the reference set is reduced by eliminating the reference set data, so as to reduce the size of the application executable file data; the execution speed of the method calling instruction set is improved through direct reference, so that the execution efficiency of application logic is improved.
In the embodiment of the application, an instruction set generating device firstly acquires input data, wherein the input data comprises application program source codes and an import packet information file thereof; then analyzing the source codes of the application program to determine a direct reference method and an indirect reference method; secondly, constructing a direct reference method call instruction corresponding to the direct reference method, and constructing an indirect reference method call instruction corresponding to the indirect reference method; and finally outputting a direct reference method call instruction and an indirect reference method call instruction. The application program source codes are analyzed to determine the direct reference method and the indirect reference method, and the direct reference method calling instruction corresponding to the direct reference method is constructed in advance, so that the problem that the direct reference method needs to analyze and search the corresponding method actual reference set data in the execution process is avoided, and the executable file on the secure element is prevented from carrying a large amount of reference set data related to the method, so that the secure element downloading process is efficient and good in compatibility.
The following are examples of the apparatus of the present invention that may be used to perform the method embodiments of the present invention. For details not disclosed in the embodiments of the apparatus of the present invention, please refer to the embodiments of the method of the present invention.
Referring to fig. 4, a schematic structural diagram of an instruction set generating device according to an exemplary embodiment of the present invention is shown. The instruction set generating means may be implemented as all or part of a device by software, hardware or a combination of both. The device 1 comprises a data acquisition module 10, a source code analysis module 20, an instruction construction module 30 and an instruction output module 40.
The data acquisition module 10 is used for acquiring input data, wherein the input data comprises application source codes and an imported packet information file thereof;
the source code analysis module 20 is used for analyzing the source code of the application program and determining a direct reference method and an indirect reference method; the direct reference method is a method which can be determined by a called method at the compiling period and is not changeable at the running period, and the indirect reference method is a method which can not be determined by the called method at the compiling period and is determined at the running period;
the instruction construction module 30 is configured to construct a direct reference method call instruction corresponding to the direct reference method, and construct an indirect reference method call instruction corresponding to the indirect reference method;
the instruction output module 40 is configured to output a direct reference method call instruction and an indirect reference method call instruction.
It should be noted that, when the instruction set generating apparatus provided in the foregoing embodiment executes the instruction set generating method, only the division of the foregoing functional modules is used as an example, in practical application, the foregoing functional allocation may be performed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules, so as to complete all or part of the functions described above. In addition, the instruction set generating device and the instruction set generating method provided in the foregoing embodiments belong to the same concept, which embody the detailed implementation process in the method embodiment, and are not repeated here.
The foregoing embodiment numbers of the present application are merely for describing, and do not represent advantages or disadvantages of the embodiments.
In the embodiment of the application, an instruction set generating device firstly acquires input data, wherein the input data comprises application program source codes and an import packet information file thereof; then analyzing the source codes of the application program to determine a direct reference method and an indirect reference method; secondly, constructing a direct reference method call instruction corresponding to the direct reference method, and constructing an indirect reference method call instruction corresponding to the indirect reference method; and finally outputting a direct reference method call instruction and an indirect reference method call instruction. The application program source codes are analyzed to determine the direct reference method and the indirect reference method, and the direct reference method calling instruction corresponding to the direct reference method is constructed in advance, so that the problem that the direct reference method needs to analyze and search the corresponding method actual reference set data in the execution process is avoided, and the executable file on the secure element is prevented from carrying a large amount of reference set data related to the method, so that the secure element downloading process is efficient and good in compatibility.
The present invention also provides a computer readable medium having stored thereon program instructions which, when executed by a processor, implement the instruction set generating method provided by the above-described respective method embodiments.
The invention also provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform the instruction set generation method of the various method embodiments described above.
Referring to fig. 5, a schematic structural diagram of an apparatus is provided in an embodiment of the present application. As shown in fig. 5, the apparatus 1000 may include: at least one processor 1001, at least one network interface 1004, a user interface 1003, a memory 1005, at least one communication bus 1002.
Wherein the communication bus 1002 is used to enable connected communication between these components.
The user interface 1003 may include a Display screen (Display) and a Camera (Camera), and the optional user interface 1003 may further include a standard wired interface and a wireless interface.
The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface), among others.
Wherein the processor 1001 may include one or more processing cores. The processor 1001 connects various parts within the overall electronic device 1000 using various interfaces and lines, performs various functions of the electronic device 1000 and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 1005, and invoking data stored in the memory 1005. Alternatively, the processor 1001 may be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), programmable logic array (Programmable Logic Array, PLA). The processor 1001 may integrate one or a combination of several of a central processing unit (Central Processing Unit, CPU), an image processor (Graphics Processing Unit, GPU), and a modem, etc. The CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing the content required to be displayed by the display screen; the modem is used to handle wireless communications. It will be appreciated that the modem may not be integrated into the processor 1001 and may be implemented by a single chip.
The Memory 1005 may include a random access Memory (Random Access Memory, RAM) or a Read-Only Memory (Read-Only Memory). Optionally, the memory 1005 includes a non-transitory computer readable medium (non-transitory computer-readable storage medium). The memory 1005 may be used to store instructions, programs, code, sets of codes, or sets of instructions. The memory 1005 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the above-described respective method embodiments, etc.; the storage data area may store data or the like referred to in the above respective method embodiments. The memory 1005 may also optionally be at least one storage device located remotely from the processor 1001. As shown in fig. 5, an operating system, a network communication module, a user interface module, and an instruction set generating application program may be included in the memory 1005, which is one type of computer storage medium.
In the device 1000 shown in fig. 5, the user interface 1003 is mainly used for providing an input interface for a user, and acquiring data input by the user; and the processor 1001 may be configured to invoke the instruction set generating application program stored in the memory 1005, and specifically perform the following operations:
acquiring input data, wherein the input data comprises application program source codes and an imported packet information file;
analyzing the source codes of the application program, and determining a direct reference method and an indirect reference method; the direct reference method is a method which can be determined by the called method at the compiling period and is not changeable at the running period, and the indirect reference method is a method which can not be determined by the called method at the compiling period and is determined at the running period;
constructing a direct reference method call instruction corresponding to the direct reference method, and constructing an indirect reference method call instruction corresponding to the indirect reference method;
outputting a direct reference method call instruction and an indirect reference method call instruction.
In one embodiment, the processor 1001, when executing the analysis application source code, determines a direct reference method and an indirect reference method, further performs the following operations:
compiling the source code of the application program to obtain a compiling intermediate result;
semantic analysis is carried out on the compiling intermediate result, and the calling version of each called method in the source code of the application program is determined;
the method with the unique calling version is taken as a direct reference method, and the method without the unique calling version is taken as an indirect reference method.
In one embodiment, the processor 1001, when executing a direct reference method call instruction corresponding to a build direct reference method, specifically performs the following operations:
acquiring an executable file of application source codes;
sequentially placing instruction set data of each direct reference method in the source code of the application program into an executable file to sequentially obtain a method offset position of each direct reference method in the executable file;
and generating a direct reference method call instruction according to the method offset position.
In one embodiment, the processor 1001, when executing the indirect referencing method call instruction corresponding to the build indirect referencing method, specifically performs the following operations:
sequentially placing instruction set data of the indirect referencing method into an executable file, and identifying an indirect method result corresponding to the source code of the application program;
generating a method reference corresponding to the indirect reference method according to the identified indirect method result and the imported package information file;
sequentially placing method references corresponding to the indirect referencing methods into a referencing set to obtain a referencing set data index of each indirect referencing method;
and generating an indirect method call instruction according to the preset indirect method call type and the reference set data index of each indirect reference method.
In one embodiment, the processor 1001, when executing the reference set data index according to the preset indirect method call type and each indirect reference method, generates the indirect method call instruction, specifically performs the following operations:
determining a preset indirect method call type;
generating a method calling instruction code by presetting an indirect method calling type;
generating an indirect referencing method calling instruction operand through indexes of each indirect referencing method in a preset application set;
and combining the indirect referencing method call instruction operand and the corresponding method call instruction code to generate the indirect method call instruction.
In one embodiment, the processor 1001, prior to executing the acquiring of the input data, further performs the following:
compiling the application program source code through a compiler to obtain a compiling file;
packaging the compiled file to obtain an application programming interface calling file;
analyzing the source codes of the application programs or the compiled files through an application executable file generator to obtain the public interface information in the whole package;
establishing association between the public interface information and a preset link reference to obtain association data;
processing and outputting the associated data according to a preset export information file format to obtain an application programming interface export information file;
and combining the application programming interface calling file and the application programming interface export information file to obtain the import packet information file.
In one embodiment, the processor 1001, prior to executing the acquiring of the input data, further performs the following:
converting the source code of the application program into a Class file;
analyzing the Class information file according to the Class file and the imported packet information file;
acquiring all kinds of information of the Class information file;
and organizing data information for forming the application executable file according to the class information, and generating the application executable file.
In the embodiment of the application, an instruction set generating device firstly acquires input data, wherein the input data comprises application program source codes and an import packet information file thereof; then analyzing the source codes of the application program to determine a direct reference method and an indirect reference method; secondly, constructing a direct reference method call instruction corresponding to the direct reference method, and constructing an indirect reference method call instruction corresponding to the indirect reference method; and finally outputting a direct reference method call instruction and an indirect reference method call instruction. The application program source codes are analyzed to determine the direct reference method and the indirect reference method, and the direct reference method calling instruction corresponding to the direct reference method is constructed in advance, so that the problem that the direct reference method needs to analyze and search the corresponding method actual reference set data in the execution process is avoided, and the executable file on the secure element is prevented from carrying a large amount of reference set data related to the method, so that the secure element downloading process is efficient and good in compatibility.
Those skilled in the art will appreciate that implementing all or part of the above-described methods in the embodiments may be accomplished by computer programs to instruct related hardware, and that the programs generated by the instruction sets may be stored in a computer readable storage medium, and the programs may include the processes of the embodiments of the above-described methods when executed. The storage medium of the program generated by the instruction set can be a magnetic disk, an optical disk, a read-only memory, a random access memory or the like.
The foregoing disclosure is only illustrative of the preferred embodiments of the present application and is not intended to limit the scope of the claims herein, as the equivalent of the claims herein shall be construed to fall within the scope of the claims herein.

Claims (10)

1. A method of instruction set generation, the method comprising:
acquiring input data, wherein the input data comprises application source codes and an imported packet information file;
analyzing the source codes of the application programs and determining a direct reference method and an indirect reference method; the direct reference method is a method which can be determined by a called method at the compiling period and is not variable at the running period, and the indirect reference method is a method which can not be determined by the called method at the compiling period and is determined at the running period;
constructing a direct reference method call instruction corresponding to the direct reference method, and constructing an indirect reference method call instruction corresponding to the indirect reference method;
outputting the direct reference method call instruction and the indirect reference method call instruction.
2. The method of claim 1, wherein analyzing the application source code to determine a direct reference method and an indirect reference method comprises:
compiling the application program source code to obtain a compiling intermediate result;
carrying out semantic analysis on the compiling intermediate result to determine a calling version of each called method in the application program source code;
methods for which there is a unique calling version are identified as direct reference methods, and methods for which there is no unique calling version are identified as indirect reference methods.
3. The method according to claim 1, wherein said constructing a direct reference method call instruction corresponding to the direct reference method includes:
acquiring an executable file of the application program source code;
sequentially placing instruction set data of each direct reference method in the application program source code into the executable file to sequentially obtain a method offset position of each direct reference method in the executable file;
and generating a direct reference method call instruction according to the preset direct method call type and the method offset position.
4. The method according to claim 1, wherein said constructing the indirect referencing method call instruction corresponding to the indirect referencing method includes:
sequentially placing the instruction set data of the indirect referencing method into an executable file, and identifying an indirect method result corresponding to the application program source code;
generating a method reference corresponding to the indirect reference method according to the identified indirect method result and the import packet information file;
sequentially placing method references corresponding to the indirect referencing methods into a referencing set to obtain a referencing set data index of each indirect referencing method;
and generating an indirect method call instruction according to the preset indirect method call type and the reference set data index of each indirect reference method.
5. The method of claim 1, wherein generating the indirect method call instruction according to the preset indirect method call type and the reference set data index of each indirect reference method comprises:
determining a preset indirect method call type;
generating a method calling instruction code through the preset indirect method calling type;
generating an indirect referencing method calling instruction operand through indexes of each indirect referencing method in a preset application set;
and combining the indirect referencing method call instruction operand and the corresponding method call instruction code to generate an indirect method call instruction.
6. The method of claim 1, wherein prior to the obtaining the input data, further comprising:
compiling the application program source code through a compiler to obtain a compiling file;
packaging the compiling file to obtain an application programming interface calling file;
analyzing the source codes of the application programs or the compiled files through an application executable file generator to obtain the public interface information in the whole package;
establishing association between the public interface information and a preset link reference to obtain association data;
processing and outputting the associated data according to a preset export information file format to obtain an application programming interface export information file;
and combining the application programming interface calling file and the application programming interface export information file to obtain an import packet information file.
7. The method of claim 1, wherein prior to the obtaining the input data, further comprising:
converting the application program source code into a Class file;
analyzing the Class information file according to the Class file and the lead-in package information file;
acquiring all kinds of information of the Class information file;
and organizing data information for forming the application executable file according to the class information, and generating the application executable file.
8. An instruction set generating apparatus, the apparatus comprising:
the data acquisition module is used for acquiring input data, wherein the input data comprises application source codes and an imported packet information file thereof;
the source code analysis module is used for analyzing the source codes of the application programs and determining a direct reference method and an indirect reference method; the direct reference method is a method which can be determined by the called method at the compiling period and is not changeable at the running period, and the indirect reference method is a method which can not be determined by the called method at the compiling period and is determined at the running period;
the instruction construction module is used for constructing a direct reference method call instruction corresponding to the direct reference method and constructing an indirect reference method call instruction corresponding to the indirect reference method;
and the instruction output module is used for outputting the direct reference method call instruction and the indirect reference method call instruction.
9. A computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the method of any of claims 1-7.
10. An apparatus, comprising: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the method according to any of claims 1-7.
CN202310966938.8A 2023-08-02 2023-08-02 Instruction set generation method, device, medium and equipment Active CN117234590B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310966938.8A CN117234590B (en) 2023-08-02 2023-08-02 Instruction set generation method, device, medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310966938.8A CN117234590B (en) 2023-08-02 2023-08-02 Instruction set generation method, device, medium and equipment

Publications (2)

Publication Number Publication Date
CN117234590A CN117234590A (en) 2023-12-15
CN117234590B true CN117234590B (en) 2024-03-29

Family

ID=89085160

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310966938.8A Active CN117234590B (en) 2023-08-02 2023-08-02 Instruction set generation method, device, medium and equipment

Country Status (1)

Country Link
CN (1) CN117234590B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1172303A (en) * 1996-05-30 1998-02-04 太阳微系统有限公司 Method and system for loading classes in read-only memory
CN111736816A (en) * 2020-07-20 2020-10-02 华控清交信息科技(北京)有限公司 Compiling and linking method and device and compiling and linking device
CN112434266A (en) * 2021-01-26 2021-03-02 成都无糖信息技术有限公司 Shell code control flow flattening confusion method
CN112631722A (en) * 2020-12-24 2021-04-09 北京握奇数据股份有限公司 Byte code instruction set simplifying method and system
CN114428639A (en) * 2021-12-24 2022-05-03 北京握奇数据股份有限公司 Instruction simplification method and system of byte code instruction set
CN115033871A (en) * 2022-06-06 2022-09-09 北京熵核科技有限公司 Method and device for generating running environment of application program
CN116069459A (en) * 2021-11-03 2023-05-05 英特尔公司 Programmable GPU command buffer using variable command list

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10635705B2 (en) * 2015-05-14 2020-04-28 Emory University Methods, systems and computer readable storage media for determining relevant documents based on citation information

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1172303A (en) * 1996-05-30 1998-02-04 太阳微系统有限公司 Method and system for loading classes in read-only memory
CN111736816A (en) * 2020-07-20 2020-10-02 华控清交信息科技(北京)有限公司 Compiling and linking method and device and compiling and linking device
CN112631722A (en) * 2020-12-24 2021-04-09 北京握奇数据股份有限公司 Byte code instruction set simplifying method and system
CN112434266A (en) * 2021-01-26 2021-03-02 成都无糖信息技术有限公司 Shell code control flow flattening confusion method
CN116069459A (en) * 2021-11-03 2023-05-05 英特尔公司 Programmable GPU command buffer using variable command list
CN114428639A (en) * 2021-12-24 2022-05-03 北京握奇数据股份有限公司 Instruction simplification method and system of byte code instruction set
CN115033871A (en) * 2022-06-06 2022-09-09 北京熵核科技有限公司 Method and device for generating running environment of application program

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Java智能卡解析优化方法;张大伟;丁文锐;;北京航空航天大学学报;20090115(第01期);全文 *
一种精简二进制代码的程序理解方法;李卷孺;谷大武;陆海宁;;计算机应用;20081001(第10期);全文 *

Also Published As

Publication number Publication date
CN117234590A (en) 2023-12-15

Similar Documents

Publication Publication Date Title
CN109976761B (en) Software development kit generation method and device and terminal equipment
KR100750834B1 (en) A method of data call stack tracing in data monitoring of JAVA byte code and a device for storing the method in compter program type
CN111443921A (en) Method, system and computer equipment for subpackage deployment of web front-end projects
CN105718289A (en) Component relationship establishing method and equipment
CN106648755B (en) Method and device for dynamically loading dex in android art environment
US20170124306A1 (en) Method and apparatus for preventing application from being deciphered
CN109933350A (en) The method, apparatus and electronic equipment of embedded code in the application
CN112052000A (en) Component multiplexing and rendering method and device
CN113127055A (en) Dynamic link library file generation method, application verification method, device and equipment
CN112631649A (en) Intelligent contract management method, device, terminal equipment and medium
CN113407255A (en) Component calling method and device and computer readable storage medium
CN114610318A (en) Android application packaging method, device, equipment and storage medium
CN117234590B (en) Instruction set generation method, device, medium and equipment
CN111949312B (en) Packaging method and device for data module, computer equipment and storage medium
CN111596905A (en) Method, device, storage medium and terminal for generating java object
CN111399863A (en) Dependent file packaging method, device, equipment and computer readable storage medium
CN113778564B (en) Method, equipment and storage medium for efficiently executing EVM intelligent contract
CN114860204A (en) Program processing method, program operating device, terminal, smart card and storage medium
CN110795169B (en) Method and related device for acquiring data
CN112114870A (en) Method and device for packaging codes, terminal equipment and storage medium
CN108573142B (en) Method and device for realizing hook
CN113704618B (en) Data processing method, device, equipment and medium based on deep learning model
CN113032003B (en) Development file export method, development file export device, electronic equipment and computer storage medium
CN108182362B (en) Multi-dex file analysis method and system
CN115268938A (en) Network service packaging method, device and equipment for remote sensing and geographic information algorithm

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
GR01 Patent grant
GR01 Patent grant