CN117668824A - Code data processing method, device, equipment and medium - Google Patents

Code data processing method, device, equipment and medium Download PDF

Info

Publication number
CN117668824A
CN117668824A CN202311775547.4A CN202311775547A CN117668824A CN 117668824 A CN117668824 A CN 117668824A CN 202311775547 A CN202311775547 A CN 202311775547A CN 117668824 A CN117668824 A CN 117668824A
Authority
CN
China
Prior art keywords
data
code
target
conversion
determining
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
Application number
CN202311775547.4A
Other languages
Chinese (zh)
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 Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology 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 Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202311775547.4A priority Critical patent/CN117668824A/en
Publication of CN117668824A publication Critical patent/CN117668824A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

The disclosure provides a code data processing method, a device, equipment and a medium, relates to the technical field of computers, and particularly relates to the technical field of code data processing and compiling. The implementation scheme is as follows: acquiring original code data, wherein the original code data comprises a plurality of code elements, and the code elements comprise variables and functions; determining target subcode data to be processed in the original code data; in response to determining that the execution of the target subcode data is dependent on the execution of other code data in the original code data, determining at least one target code element on which the target subcode data is dependent from at least one code element included in the other code data; determining first conversion data corresponding to target subcode data based on a preset conversion rule; generating a translated code segment comprising at least one object code element; obtaining second conversion data by inserting conversion code fragments into the first conversion data; and determining executable code data corresponding to the second conversion data.

Description

Code data processing method, device, equipment and medium
Technical Field
The present disclosure relates to the field of computer technology, and in particular, to the field of code data processing and compiling, and in particular, to a code data processing method, apparatus, electronic device, computer readable storage medium, and computer program product.
Background
With the continuous development of computer and internet technologies, code data needs to be executed in various environments, such as the internet of things or the internet of vehicles. When code data needs to be executed in an untrusted environment, the original code data needs to be secured against hacking or attack.
The approaches described in this section are not necessarily approaches that have been previously conceived or pursued. Unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section. Similarly, the problems mentioned in this section should not be considered as having been recognized in any prior art unless otherwise indicated.
Disclosure of Invention
The present disclosure provides a code data processing method, apparatus, electronic device, computer readable storage medium, and computer program product.
According to an aspect of the present disclosure, there is provided a code data processing method including: acquiring original code data, wherein the original code data comprises a plurality of code elements, and the code elements comprise variables and functions; determining target subcode data to be processed in the original code data; in response to determining that execution of the target subcode data is dependent on execution of other code data in the original code data, determining at least one target code element from among at least one code element included in the other code data on which the target subcode data is dependent; determining first conversion data corresponding to the target subcode data based on a preset conversion rule; generating a translated code segment comprising the at least one object code element; obtaining second conversion data by inserting the conversion code fragments into the first conversion data; and determining executable code data corresponding to the second conversion data.
According to another aspect of the present disclosure, there is provided a code data processing apparatus including: an acquisition unit configured to acquire original code data including a plurality of code elements including variables and functions; a first determination unit configured to determine target subcode data to be processed in the original code data; a second determination unit configured to determine, in response to determining that the execution of the target subcode data depends on the execution of other code data in the original code data, at least one target code element on which the target subcode data depends from among at least one code element included in the other code data; a third determining unit configured to determine first conversion data corresponding to the target subcode data based on a preset conversion rule; a first generation unit configured to generate a translated code segment including the at least one object code element; an inserting unit configured to obtain second conversion data by inserting the conversion code segment in the first conversion data; and a fourth determination unit configured to determine executable code data corresponding to the second conversion data.
According to another aspect of the present disclosure, there is provided an electronic device including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the code data processing method described above.
According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute the above-described code data processing method.
According to another aspect of the present disclosure, there is provided a computer program product comprising a computer program, wherein the computer program is capable of implementing the above-mentioned code data processing method when being executed by a processor.
According to one or more embodiments of the present disclosure, the security of code running may be improved.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The accompanying drawings illustrate exemplary embodiments and, together with the description, serve to explain exemplary implementations of the embodiments. The illustrated embodiments are for exemplary purposes only and do not limit the scope of the claims. Throughout the drawings, identical reference numerals designate similar, but not necessarily identical, elements.
FIG. 1 illustrates a schematic diagram of an exemplary system in which various methods described herein may be implemented, according to an exemplary embodiment of the present disclosure;
FIG. 2 illustrates a flow chart of a code data processing method according to an exemplary embodiment of the present disclosure;
FIG. 3 illustrates a flow chart of a code data processing method according to an exemplary embodiment of the present disclosure;
FIG. 4 illustrates a schematic diagram of a code data execution process according to an exemplary embodiment of the present disclosure;
FIG. 5 illustrates a block diagram of a code data processing apparatus according to an exemplary embodiment of the present disclosure;
fig. 6 illustrates a block diagram of an exemplary electronic device that can be used to implement embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
In the present disclosure, the use of the terms "first," "second," and the like to describe various elements is not intended to limit the positional relationship, timing relationship, or importance relationship of the elements, unless otherwise indicated, and such terms are merely used to distinguish one element from another. In some examples, a first element and a second element may refer to the same instance of the element, and in some cases, they may also refer to different instances based on the description of the context.
The terminology used in the description of the various illustrated examples in this disclosure is for the purpose of describing particular examples only and is not intended to be limiting. Unless the context clearly indicates otherwise, the elements may be one or more if the number of the elements is not specifically limited. Furthermore, the term "and/or" as used in this disclosure encompasses any and all possible combinations of the listed items.
In a practical application scenario, key content of original code data may often be determined by reversely analyzing executable code data. In the related art, the original code data can be converted based on the customized rule, and then executable data is obtained based on the converted data, so that the original code data is protected by utilizing the converted data, and the attack of a reverse analysis means is avoided. However, there are often a large number of dependencies (e.g., variable dependencies, function dependencies) in code data, and when the code fragment to be protected is converted, the dependency information cannot be completely and correctly preserved, resulting in code execution errors.
Based on the above, the present disclosure provides a code data processing method, which converts target subcode data to be processed in original code data into conversion data, inserts conversion code fragments for obtaining dependent target code elements in the conversion data, so that the conversion data can correctly indicate dependent information in a complete code, determines executable code data based on the dependency information, and can effectively protect the safety of the original code data.
Embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.
Fig. 1 illustrates a schematic diagram of an exemplary system 100 in which various methods and apparatus described herein may be implemented, in accordance with an embodiment of the present disclosure. Referring to fig. 1, the system 100 includes one or more client devices 101, 102, 103, 104, 105, and 106, a server 120, and one or more communication networks 110 coupling the one or more client devices to the server 120. Client devices 101, 102, 103, 104, 105, and 106 may be configured to execute one or more applications.
In an embodiment of the present disclosure, the server 120 may run one or more services or software applications that enable execution of the code data processing method.
In some embodiments, server 120 may also provide other services or software applications, which may include non-virtual environments and virtual environments. In some embodiments, these services may be provided as web-based services or cloud services, for example, provided to users of client devices 101, 102, 103, 104, 105, and/or 106 under a software as a service (SaaS) model.
In the configuration shown in fig. 1, server 120 may include one or more components that implement the functions performed by server 120. These components may include software components, hardware components, or a combination thereof that are executable by one or more processors. A user operating client devices 101, 102, 103, 104, 105, and/or 106 may in turn utilize one or more client applications to interact with server 120 to utilize the services provided by these components. It should be appreciated that a variety of different system configurations are possible, which may differ from system 100. Accordingly, FIG. 1 is one example of a system for implementing the various methods described herein and is not intended to be limiting.
The user may send raw code data using client devices 101, 102, 103, 104, 105, and/or 106. The client device may provide an interface that enables a user of the client device to interact with the client device. The client device may also output information to the user via the interface. Although fig. 1 depicts only six client devices, those skilled in the art will appreciate that the present disclosure may support any number of client devices.
Client devices 101, 102, 103, 104, 105, and/or 106 may include various types of computer devices, such as portable handheld devices, general purpose computers (such as personal computers and laptop computers), workstation computers, wearable devices, smart screen devices, self-service terminal devices, service robots, gaming systems, thin clients, various messaging devices, sensors or other sensing devices, and the like. These computer devices may run various classes and versions of software applications and operating systems, such as MICROSOFT Windows, APPLE iOS, UNIX-like operating systems, linux, or Linux-like operating systems (e.g., GOOGLE Chrome OS); or include various mobile operating systems such as MICROSOFT Windows Mobile OS, iOS, windows Phone, android. Portable handheld devices may include cellular telephones, smart phones, tablet computers, personal Digital Assistants (PDAs), and the like. Wearable devices may include head mounted displays (such as smart glasses) and other devices. The gaming system may include various handheld gaming devices, internet-enabled gaming devices, and the like. The client device is capable of executing a variety of different applications, such as various Internet-related applications, communication applications (e.g., email applications), short Message Service (SMS) applications, and may use a variety of communication protocols.
Network 110 may be any of a variety of networks known to those skilled in the art that may support data communications using any of a variety of available protocols, including but not limited to TCP/IP, SNA, IPX, etc. For example only, the one or more networks 110 may be a Local Area Network (LAN), an ethernet-based network, a token ring, a Wide Area Network (WAN), the internet, a virtual network, a Virtual Private Network (VPN), an intranet, an extranet, a blockchain network, a Public Switched Telephone Network (PSTN), an infrared network, a wireless network (e.g., bluetooth, WIFI), and/or any combination of these and/or other networks.
The server 120 may include one or more general purpose computers, special purpose server computers (e.g., PC (personal computer) servers, UNIX servers, mid-end servers), blade servers, mainframe computers, server clusters, or any other suitable arrangement and/or combination. The server 120 may include one or more virtual machines running a virtual operating system, or other computing architecture that involves virtualization (e.g., one or more flexible pools of logical storage devices that may be virtualized to maintain virtual storage devices of the server). In various embodiments, server 120 may run one or more services or software applications that provide the functionality described below.
The computing units in server 120 may run one or more operating systems including any of the operating systems described above as well as any commercially available server operating systems. Server 120 may also run any of a variety of additional server applications and/or middle tier applications, including HTTP servers, FTP servers, CGI servers, JAVA servers, database servers, etc.
In some implementations, server 120 may include one or more applications to analyze and consolidate data feeds and/or event updates received from users of client devices 101, 102, 103, 104, 105, and 106. Server 120 may also include one or more applications to display data feeds and/or real-time events via one or more display devices of client devices 101, 102, 103, 104, 105, and 106.
In some implementations, the server 120 may be a server of a distributed system or a server that incorporates a blockchain. The server 120 may also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology. The cloud server is a host product in a cloud computing service system, so as to solve the defects of large management difficulty and weak service expansibility in the traditional physical host and virtual private server (VPS, virtual Private Server) service.
The system 100 may also include one or more databases 130. In some embodiments, these databases may be used to store data and other information. For example, one or more of databases 130 may be used to store information such as audio files and video files. Database 130 may reside in various locations. For example, the database used by the server 120 may be local to the server 120, or may be remote from the server 120 and may communicate with the server 120 via a network-based or dedicated connection. Database 130 may be of different categories. In some embodiments, the database used by server 120 may be, for example, a relational database. One or more of these databases may store, update, and retrieve the databases and data from the databases in response to the commands.
In some embodiments, one or more of databases 130 may also be used by applications to store application data. The databases used by the application may be different types of databases, such as key value stores, object stores, or conventional stores supported by the file system.
The system 100 of fig. 1 may be configured and operated in various ways to enable application of the various methods and apparatus described in accordance with the present disclosure.
Fig. 2 shows a flow chart of a code data processing method 200 according to an exemplary embodiment of the present disclosure. As shown in fig. 2, the method 200 includes:
step S201, acquiring original code data, wherein the original code data comprises a plurality of code elements, and the code elements comprise variables and functions;
step S202, determining target subcode data to be processed in the original code data;
step S203, in response to determining that the execution of the target subcode data depends on the execution of other code data in the original code data, determining at least one target code element on which the target subcode data depends from at least one code element included in the other code data;
step S204, determining first conversion data corresponding to the target subcode data based on a preset conversion rule;
step S205, generating a translated code segment including the at least one object code element;
step S206, obtaining second conversion data by inserting the conversion code fragments into the first conversion data; and
step S207, determining executable code data corresponding to the second conversion data.
By applying the method 200, the target sub-code data to be processed in the original code data can be converted into the conversion data according to the preset conversion rule, particularly the conversion data is determined according to the self-defined conversion rule, and the conversion data is utilized to avoid the attack of the reverse analysis means. Meanwhile, a conversion code segment is generated based on the dependency relationship of the target subcode data on target code elements in the original code data and is inserted into the original conversion data, so that the conversion data can correctly indicate the dependency information in the complete original code, executable code data is determined based on the dependency information, and the correctness of code compiling and executing is ensured while the safety of the original code data is effectively protected.
In some examples, the raw code data may include various types, such as raw code that may be written based on various programming languages, such as C language, java, python, and the like. In some examples, the raw code data may also be intermediate code (Intermediate Representation, IR) generated by a compiler after preprocessing based on source code of a programming language. Generally, after obtaining the intermediate code through the preprocessing process, the compiler continues to perform post-processing based on the intermediate code to obtain an executable file corresponding to a code execution environment (for example, an X86 architecture, an ARM architecture, etc.). It will be appreciated that different code execution environments typically correspond to different sets of assembler instructions, i.e., to different executable files, and thus, the code execution environment is merely a post-processing process that affects code compilation.
In the related art, one implementation way is to define different virtual instruction sets for different code execution environments, and then use a corresponding custom virtual interpretation module to realize the running of code data in the execution process, however, the complexity of the way is higher, and the code data conversion process based on the virtual instruction sets does not have cross-platform generality.
By applying the method 200 based on the intermediate code, code protection can be realized in the intermediate code link, so that conversion processing of code data is not required to be performed respectively for different code execution environments, universality can be improved, and efficiency of code protection processing can be improved.
In some examples, determining the target subcode data to be processed in the original code data in step S202 includes: and acquiring configuration information of code data processing, and extracting target subcode data to be processed in the original code data based on the configuration information.
The configuration information can be set and saved manually according to actual requirements in advance, and the configuration information can comprise granularity information of code data conversion, wherein the granularity can comprise file granularity, function granularity and code fragment granularity in the function. When the configuration information indicates that conversion is performed based on the granularity of the function, target subcode data of a specified function in the original code data is extracted. The function specification method may include, for example, function attribute declarations, function signature matches, function code feature matches, and the like. When the configuration information indicates that conversion is performed based on the granularity of the specified code fragment, then target subcode data of the specified fragment in the original code data needs to be extracted. The fragment specification method may include, for example, a tag for specifying a code fragment.
In some examples, the determination in step S203 of the at least one object code element on which the object subcode data depends may be implemented by traversing a use-def linked list of the original code data. The use-def linked list is created by a compiler in the code compiling process, is used for tracking the use and definition conditions of variables in the code in the program, and is used for analysis and optimization in the compiling process so as to improve the execution efficiency of the program. By checking the variable definition content (def) corresponding to the use operation in the target subcode data, the dependency of the target subcode data on the variable or function can be determined.
For example, when the target subcode data has invoked the custom function a, and the target subcode data does not include the declaration content of the custom function a, the function a may be determined to be the target code element. For another example, when variable B is used in the target subcode data and the assignment statement for variable B is not included in the target subcode data, variable B may be determined to be the target code element.
In some examples, the original code data or target subcode data may be divided into atomic execution blocks, each of which is equivalent to an indivisible code segment whose execution is atomic, i.e., is executed by a single thread and cannot be interrupted or disturbed. Based on this, each atom may be determined to execute a block-dependent object code element.
In some examples, the step S204 may be to translate the target sub-code data into the first conversion data based on a mapping relationship between the preset original code content and the conversion content. In some examples, the content of the target subcode data may also be dynamically adjusted based on a preset dynamic change rule, such as implementing out-of-order operations on the content of the target subcode data, to obtain the first conversion data. The specific rules of transcoding the code data are not limited by the present disclosure as long as the original code data in the plaintext can be hidden.
According to some embodiments, generating a translated code segment including the at least one object code element in step S205 includes: generating a first statement for creating the at least one translated code element corresponding to the first object code element; and determining the transcoding segment based on the first statement. Therefore, the dependency of the target sub-code data on the target code element can be converted into the dependency on the conversion code element by creating the conversion code element in the conversion code segment, and the method is simpler, more convenient and quicker.
According to some embodiments, the generating a first statement for creating at least one translated code element corresponding to the at least one target code element comprises: in response to determining that a first object code element of the at least one object code element is a local variable, a first statement is generated for creating a global variable corresponding to the first object code element. Thus, dependencies of target subcode data on local variables in other code fragments can be readily eliminated by creating global variables.
In one example, the original target subcode data may include the following statements: add 1, x, in which case the target subcode data has a dependency on variable x. The dependency of the instruction on the variable x can be converted into a dependency on a new global variable x ' by generating a statement that creates the global variable x ' and modifying the call statement as add 1, x '.
According to some embodiments, the generating a first statement for creating at least one translated code element corresponding to the at least one target code element comprises: generating a second statement for creating an object retrieval function, the object retrieval function being for retrieving the at least one object code element; generating a third statement for calling the target acquisition function; and determining the first sentence based on the second sentence and the third sentence. Thus, the target code element can be acquired by utilizing the target acquisition function, and the method can be suitable for various types of target code elements and has better universality.
In the above example, for the variable x on which the target subcode data depends, the target acquisition function get_x () may be created to return the address of the variable x. By inserting the call instruction x_ptr=call get_x () and the load instruction x '=load x_ptr of the target acquisition function into the first conversion data and modifying the call statement into add 1 and x', the dependence of the instruction on the variable x can be converted into the dependence on the target acquisition function.
As described above, the conversion data is processed based on the preset conversion rule, in which case the conversion data needs to be compiled based on the parsing rule corresponding to the conversion rule to obtain the executable code data. In some examples, step S207 may be to determine executable code data using a custom parsing engine corresponding to custom conversion rules. In one example, the custom parsing engine may further include an execution engine to directly execute the corresponding program after parsing and compiling the second conversion data, thereby further improving the security of code execution.
In one example, the custom parsing engine may be a pre-written and packaged software package to which the code compilation and/or code execution process may be triggered by passing the second transformation data.
According to some embodiments, determining the first conversion data corresponding to the target subcode data based on the preset conversion rule in step S204 includes: converting the target subcode data into virtual machine bytecodes to obtain the first converted data, wherein the converted code segments in step S205 are determined based on the virtual machine bytecodes, and determining executable code data corresponding to the second converted data in step S207 includes: and determining at least one instruction corresponding to the second conversion data based on a mapping relation between the preset virtual machine byte code and the instruction set so as to obtain the executable code data. Therefore, the virtual machine byte codes can be utilized to carry out the virtualized conversion of the target subcode data, so that compiling and executing can be carried out based on the mapping relation between the customized virtual machine byte codes and the instruction set, the code data is prevented from being attacked by a general reverse analysis means, and the safety is improved.
According to some embodiments, determining executable code data corresponding to the second conversion data in step S207 further comprises: acquiring a dependency relationship between the target subcode data and the at least one target code element; and constructing a virtual stack in a memory of the virtual machine based on the dependency relationship, so that the virtual machine can execute the at least one instruction based on the virtual stack. When the code data to be executed is complex, the dependency relationship can be directly transferred to the virtual machine to construct a memory virtual stack, so that the program can more effectively utilize memory resources, and the execution efficiency is improved.
In some examples, the at least one virtual instruction corresponding to the second conversion data may be determined based on a mapping relationship between a preset virtual machine byte code and a virtual instruction set, and executed by using a virtual machine, so as to improve security.
It should be understood that the above manner is merely an example of a specific embodiment of step S207. In some examples, compiling the second conversion data may also be accomplished based on other means. For example, when the conversion data is obtained by dynamically adjusting the content of the target subcode data, in step S207, compiling may be performed based on the parsing rules corresponding to the preset dynamic change rules, and the process may be performed by the pre-packaged custom parsing engine to improve security.
According to some embodiments, the method 200 further comprises: storing the second translation data to a target storage address; and generating a calling code segment for reading the second translation data from the target storage address, wherein determining executable code data corresponding to the second translation data in step S207 includes: executing the calling code segment to obtain the second conversion data. By storing the conversion data in the target storage address and reading the conversion data by executing the calling code segment in the execution process, the direct acquisition of the plaintext of the conversion data through reverse analysis can be avoided, and the safety is further improved.
Fig. 3 shows a flow chart of a code data processing method 300 according to an exemplary embodiment of the present disclosure. As shown in fig. 3, the method 300 includes:
step S301, acquiring original code data, wherein the original code data comprises a plurality of code elements, and the code elements comprise variables and functions;
step S302, determining target subcode data to be processed in the original code data;
step S303, in response to determining that the execution of the target subcode data depends on the execution of other code data in the original code data, determining at least one target code element on which the target subcode data depends from at least one code element included in the other code data;
Step S304, converting the target sub-code data into virtual machine byte codes to obtain first converted data;
step S305, generating a first sentence for creating the at least one converted code element corresponding to the first target code element;
step S306, determining a conversion code segment based on the first statement and the virtual machine byte code;
step S307, obtaining second conversion data by inserting the conversion code segment into the first conversion data;
step S308, storing the second conversion data to a target storage address, and generating a calling code segment for reading the second conversion data from the target storage address;
step S309, executing the calling code segment to acquire the second conversion data;
step S310, determining at least one virtual instruction corresponding to the second conversion data based on a mapping relationship between a preset virtual machine byte code and a virtual instruction set, and executing the virtual instruction by using the virtual machine.
By applying the method 300, the original code data to be protected can be converted according to the customized virtual machine byte code, and the converted data can correctly indicate the dependency information in the complete original code, so that the code security is protected while the execution accuracy of the code is ensured.
Fig. 4 shows a schematic diagram of a code data execution process according to an exemplary embodiment of the present disclosure. Referring to fig. 4, the execution process of the code data invokes a preprocessing module, a preprocessing analysis module, a dependency analysis module, a translation module, a replacement module, and a virtual machine, where the preprocessing analysis module, the dependency analysis module, the translation module, and the replacement module implement a conversion stage for performing virtualization protection on the code data, that is, an implementation means corresponding to step S201 to step S206 in the method 200.
In this example, intermediate code may be generated by performing preprocessing after the source code is acquired, and conversion is performed with the intermediate code as original code data. The preprocessing analysis module is configured to implement the process of extracting the target subcode data to be processed in step S202, for example, may be extracting based on the configuration information, and then transmit the extraction result to the dependency analysis module. The process of determining the dependency information of the target subcode data in the step S203 may be implemented by, for example, splitting an atomic execution block and traversing a use-def linked list, and further, transmitting the analysis result including the atomic execution block and the dependency information to the translation module. The translation module is used to implement the process of determining the second translation data in the above steps S204-S206, for example, by translating the target subcode data into a custom virtual machine bytecode, and a code segment for eliminating the dependency can be inserted into the translation data by the means as described above. After the second conversion data is determined, a replacement module can be used for executing replacement operation of each atomic execution block in the conversion data, specifically, the second conversion data is stored to a target storage address, a calling code segment for reading the second conversion data is generated, and the atomic execution block is replaced by the calling code segment, so that the atomic execution block can be obtained by the calling code segment in the program execution process, and protection of the atomic execution block is realized. On this basis, the calling code segment may further include information related to calling execution of the virtual machine, such as dynamic parameters, dependency information, etc., so that the virtual machine can call the second conversion data and parse the second conversion data to implement execution of the program.
According to an aspect of the present disclosure, there is also provided a code data processing apparatus. Fig. 5 shows a block diagram of a code data processing apparatus 500 according to an exemplary embodiment of the present disclosure, as shown in fig. 5, the apparatus 500 includes:
an acquisition unit 501 configured to acquire original code data including a plurality of code elements including variables and functions;
a first determining unit 502 configured to determine target subcode data to be processed in the original code data;
a second determining unit 503 configured to determine, in response to determining that the execution of the target subcode data depends on the execution of other code data in the original code data, at least one target code element on which the target subcode data depends from at least one code element included in the other code data;
a third determining unit 504 configured to determine first conversion data corresponding to the target subcode data based on a preset conversion rule;
a first generation unit 505 configured to generate a translated code segment comprising the at least one target code element;
an inserting unit 506 configured to obtain second conversion data by inserting the conversion code segment in the first conversion data; and
A fourth determination unit 507 configured to determine executable code data corresponding to the second conversion data.
According to some embodiments, the first generating unit 505 comprises: a generation subunit configured to generate a first statement for creating the at least one translated code element corresponding to the first target code element; and a determining subunit configured to determine the transcoding segment based on the first statement.
According to some embodiments, the generating subunit is configured to: in response to determining that a first object code element of the at least one object code element is a local variable, a first statement is generated for creating a global variable corresponding to the first object code element.
According to some embodiments, the generating subunit is configured to: generating a second statement for creating an object retrieval function, the object retrieval function being for retrieving the at least one object code element; generating a third statement for calling the target acquisition function; and determining the first sentence based on the second sentence and the third sentence.
According to some embodiments, the apparatus 500 further comprises: a storage unit configured to store the second conversion data to a target storage address; and a second generation unit configured to generate a calling code segment for reading the second conversion data from the target storage address, wherein the fourth determination unit 507 is configured to: executing the calling code segment to obtain the second conversion data.
According to some embodiments, the third determining unit 505 is configured to convert the target subcode data into virtual machine bytecodes to obtain the first converted data, wherein the converted code segments are determined based on the virtual machine bytecodes, and wherein the fourth determining unit 507 is configured to determine at least one instruction corresponding to the second converted data based on a preset mapping relation of virtual machine bytecodes to instruction sets to obtain the executable code data.
According to some embodiments, the fourth determination unit 507 is further configured to: acquiring a dependency relationship between the target subcode data and the at least one target code element; and constructing a virtual stack in a memory of the virtual machine based on the dependency relationship, so that the virtual machine can execute the at least one instruction based on the virtual stack.
According to another aspect of the present disclosure, there is also provided an electronic apparatus including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the code data processing method described above.
According to another aspect of the present disclosure, there is also provided a non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute the above-described code data processing method.
According to another aspect of the present disclosure, there is also provided a computer program product comprising a computer program, wherein the computer program, when executed by a processor, implements the above-mentioned code data processing method.
Referring to fig. 6, a block diagram of an electronic device 600 that may be a server or a client of the present disclosure, which is an example of a hardware device that may be applied to aspects of the present disclosure, will now be described. Electronic devices are intended to represent various forms of digital electronic computer devices, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 6, the apparatus 600 includes a computing unit 601 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 602 or a computer program loaded from a storage unit 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 may also be stored. The computing unit 601, ROM 602, and RAM 603 are connected to each other by a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Various components in the device 600 are connected to the I/O interface 605, including: an input unit 606, an output unit 607, a storage unit 608, and a communication unit 609. The input unit 606 may be any type of device capable of inputting information to the device 600, the input unit 606 may receive input numeric or character information and generate key signal inputs related to user settings and/or function control of the electronic device, and may include, but is not limited to, a mouse, a keyboard, a touch screen, a trackpad, a trackball, a joystick, a microphone, and/or a remote control. The output unit 607 may be any type of device capable of presenting information and may include, but is not limited to, a display, speakers, video/audio output terminals, vibrators, and/or printers. Storage unit 608 may include, but is not limited to, magnetic disks, optical disks. The communication unit 609 allows the device 600 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunications networks, and may include, but is not limited to, modems, network cards, infrared communication devices, wireless communication transceivers and/or chipsets, such as bluetooth (TM) devices, 802.11 devices, wiFi devices, wiMax devices, cellular communication devices, and/or the like.
The computing unit 601 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 601 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the respective methods and processes described above, for example, a code data processing method. For example, in some embodiments, the code data processing method may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program may be loaded and/or installed onto the device 600 via the ROM 602 and/or the communication unit 609. When a computer program is loaded into the RAM 603 and executed by the computing unit 601, one or more steps of the code data processing method described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the code data processing method in any other suitable way (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), complex Programmable Logic Devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), the internet, and blockchain networks.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel, sequentially or in a different order, provided that the desired results of the disclosed aspects are achieved, and are not limited herein.
While embodiments or examples of the present disclosure have been described with reference to the accompanying drawings, it is to be understood that the methods, systems, and apparatus described above are merely illustrative embodiments or examples and that the scope of the present disclosure is not limited by these embodiments or examples. Various elements of the embodiments or examples may be omitted or replaced with equivalent elements thereof. Furthermore, the steps may be performed in a different order than described in the present disclosure. Further, various elements of the embodiments or examples may be combined in various ways. It is important that as technology evolves, many of the elements described herein may be replaced by equivalent elements that appear after the disclosure.

Claims (17)

1. A code data processing method, comprising:
acquiring original code data, wherein the original code data comprises a plurality of code elements, and the code elements comprise variables and functions;
Determining target subcode data to be processed in the original code data;
in response to determining that execution of the target subcode data is dependent on execution of other code data in the original code data, determining at least one target code element from among at least one code element included in the other code data on which the target subcode data is dependent;
determining first conversion data corresponding to the target subcode data based on a preset conversion rule;
generating a translated code segment comprising the at least one object code element;
obtaining second conversion data by inserting the conversion code fragments into the first conversion data; and
executable code data corresponding to the second conversion data is determined.
2. The method of claim 1, wherein the generating a translated code segment comprising the at least one object code element comprises:
generating a first statement for creating the at least one translated code element corresponding to the first object code element; and
the transcode segment is determined based on the first statement.
3. The method of claim 2, wherein the generating a first statement for creating at least one translated code element corresponding to the at least one object code element comprises:
In response to determining that a first object code element of the at least one object code element is a local variable, a first statement is generated for creating a global variable corresponding to the first object code element.
4. The method of claim 2, wherein the generating a first statement for creating at least one translated code element corresponding to the at least one object code element comprises:
generating a second statement for creating an object retrieval function, the object retrieval function being for retrieving the at least one object code element;
generating a third statement for calling the target acquisition function; and
the first sentence is determined based on the second sentence and the third sentence.
5. The method of any one of claims 1-4, further comprising:
storing the second translation data to a target storage address; and
generating a calling code segment for reading said second translation data from said target memory address,
wherein the determining executable code data corresponding to the second conversion data includes:
executing the calling code segment to obtain the second conversion data.
6. The method of any of claims 1-5, wherein the determining first conversion data corresponding to the target subcode data based on a preset conversion rule comprises:
Converting the target subcode data into virtual machine bytecode to obtain the first converted data,
wherein the translation code segment is determined based on the virtual machine bytecode,
and wherein said determining executable code data corresponding to said second conversion data comprises:
and determining at least one instruction corresponding to the second conversion data based on a mapping relation between the preset virtual machine byte code and the instruction set so as to obtain the executable code data.
7. The method of claim 6, wherein the determining executable code data corresponding to the second conversion data further comprises:
acquiring a dependency relationship between the target subcode data and the at least one target code element; and
based on the dependency, a virtual stack is built in a memory of a virtual machine, such that the virtual machine is capable of executing the at least one instruction based on the virtual stack.
8. A code data processing apparatus comprising:
an acquisition unit configured to acquire original code data including a plurality of code elements including variables and functions;
a first determination unit configured to determine target subcode data to be processed in the original code data;
A second determination unit configured to determine, in response to determining that the execution of the target subcode data depends on the execution of other code data in the original code data, at least one target code element on which the target subcode data depends from among at least one code element included in the other code data;
a third determining unit configured to determine first conversion data corresponding to the target subcode data based on a preset conversion rule;
a first generation unit configured to generate a translated code segment including the at least one object code element;
an inserting unit configured to obtain second conversion data by inserting the conversion code segment in the first conversion data; and
and a fourth determination unit configured to determine executable code data corresponding to the second conversion data.
9. The apparatus of claim 8, wherein the first generation unit comprises:
a generation subunit configured to generate a first statement for creating the at least one translated code element corresponding to the first target code element; and
a determination subunit configured to determine the translated code segment based on the first statement.
10. The apparatus of claim 9, wherein the generation subunit is configured to:
in response to determining that a first object code element of the at least one object code element is a local variable, a first statement is generated for creating a global variable corresponding to the first object code element.
11. The apparatus of claim 9, wherein the generation subunit is configured to:
generating a second statement for creating an object retrieval function, the object retrieval function being for retrieving the at least one object code element;
generating a third statement for calling the target acquisition function; and
the first sentence is determined based on the second sentence and the third sentence.
12. The apparatus of any of claims 8-11, further comprising:
a storage unit configured to store the second conversion data to a target storage address; and
a second generation unit configured to generate a calling code segment for reading the second translation data from the target storage address,
wherein the fourth determination unit is configured to:
executing the calling code segment to obtain the second conversion data.
13. The apparatus of any of claims 8-12, wherein the third determination unit is configured to translate the target subcode data into virtual machine bytecodes to obtain the first translation data,
wherein the translation code segment is determined based on the virtual machine bytecode,
and wherein the fourth determining unit is configured to determine at least one instruction corresponding to the second conversion data based on a mapping relation of a preset virtual machine bytecode and an instruction set to obtain the executable code data.
14. The apparatus of claim 13, wherein the fourth determination unit is further configured to:
acquiring a dependency relationship between the target subcode data and the at least one target code element; and
based on the dependency, a virtual stack is built in a memory of a virtual machine, such that the virtual machine is capable of executing the at least one instruction based on the virtual stack.
15. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the method comprises the steps of
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.
16. A non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the method of any one of claims 1-7.
17. A computer program product comprising a computer program, wherein the computer program, when executed by a processor, implements the method according to any of claims 1-7.
CN202311775547.4A 2023-12-21 2023-12-21 Code data processing method, device, equipment and medium Pending CN117668824A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311775547.4A CN117668824A (en) 2023-12-21 2023-12-21 Code data processing method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311775547.4A CN117668824A (en) 2023-12-21 2023-12-21 Code data processing method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN117668824A true CN117668824A (en) 2024-03-08

Family

ID=90084576

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311775547.4A Pending CN117668824A (en) 2023-12-21 2023-12-21 Code data processing method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN117668824A (en)

Similar Documents

Publication Publication Date Title
CN113010181B (en) Deployment method and device of operators in deep learning framework and electronic equipment
CN116306396A (en) Chip verification method and device, equipment and medium
US11842726B2 (en) Method, apparatus, electronic device and storage medium for speech recognition
CN112860566B (en) Applet detection method, device, electronic equipment and readable medium
CN116737928B (en) Text mining method and system for platform user requirements and cloud platform
CN114035829A (en) Page component updating method and device, electronic equipment and storage medium
CN114047921A (en) Inference engine development platform, method, electronic equipment and storage medium
CN109408057B (en) Method, device, medium and computing equipment for automatically generating codes
CN114881235A (en) Inference service calling method and device, electronic equipment and storage medium
CN114510308B (en) Method, device, equipment and medium for storing application page by mobile terminal
CN113839944B (en) Method, device, electronic equipment and medium for coping with network attack
CN117668824A (en) Code data processing method, device, equipment and medium
US11429358B2 (en) Representing asynchronous state machine in intermediate code
CN113849785B (en) Mobile terminal information asset use behavior identification method for application program
US20210342538A1 (en) Processing word segmentation ambiguity
CN113568797B (en) Testing method and device of intelligent interaction system, electronic equipment and medium
CN115951894A (en) Data processing method, device, electronic equipment and medium
CN113741887B (en) Model production method, system, device and electronic equipment
US20230012881A1 (en) Method and apparatus for reading data, electronic device and storage medium
CN114398653A (en) Data processing method, device, electronic equipment and medium
CN116700791A (en) Method, apparatus, device and medium for caching instructions
CN117196932A (en) Image processing method, device, equipment and medium
CN116662475A (en) Text storage method and device, electronic equipment and medium
CN115145654A (en) Object creating method, data processing method and device, electronic device and medium
CN113961633A (en) Data processing method, system, electronic device and computer storage medium

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