File processing method and device and computer equipment

By identifying and parsing target data segments in executable format files and generating debug files to determine the storage address of structure member variables, the problem of excessive memory consumption in traditional technology is solved, and more efficient memory usage and parsing speed is achieved.

CN119645534APending Publication Date: 2025-03-18CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202411457251.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-18
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

Traditional technology requires a lot of memory when parsing large elf files, which leads to system crashes or performance degradation when memory is insufficient. How to reduce memory consumption during the acquisition of structure member variable storage address has become a technical problem.

Method used

By identifying the target data segments in the executable format file, parsing the target data segments to obtain the storage addresses of the structure member variables, and generating debug files to determine these addresses, avoiding loading the entire large file into memory for parsing.

Benefits of technology

Reduces memory consumption, is suitable for systems with limited memory resources, and is also shortened to resolve large executable format files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645534A_ABST
    Figure CN119645534A_ABST
Patent Text Reader

Abstract

The invention relates to a file processing method and device and computer equipment. The method comprises the following steps: identifying a target data segment in an executable format file according to a target data segment identifier; analyzing the target data segment to obtain a storage address of a structural body variable corresponding to a target structural body member variable; and generating a debugging file according to the executable format file, and determining a storage address of the target structure member variable according to the debugging file. By adopting the method, the memory consumption in the storage address acquisition process of the structural member variables can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a file processing method, device and computer equipment. Background Art

[0002] In the fields of computer software development, compiler theory, and data structure and algorithm, elf (Executable and Linkable Format) files are a widely used executable file format. ELF files contain object code, data, and other necessary information so that the operating system can load and execute the program. In elf files, various structures are used to organize and manage data and code in elf files.

[0003] In traditional technology, the storage address of structure member variables is obtained by loading the entire large elf file into memory for parsing. However, since large elf files contain a large amount of data and code, parsing these data and codes requires a large amount of memory. If the memory is insufficient, it will cause the system to crash or performance degradation. Therefore, how to reduce the memory consumption in the process of obtaining the storage address of structure member variables has become a technical problem that needs to be solved at present. Summary of the invention

[0004] Based on this, it is necessary to provide a file processing method, device and computer equipment that can reduce memory consumption in the process of obtaining the storage address of structure member variables in order to solve the above technical problems.

[0005] In a first aspect, the present application provides a file processing method, comprising:

[0006] identifying a target data segment in the executable format file according to the target data segment identifier;

[0007] Parse the target data segment to obtain the storage address of the structure variable corresponding to the member variable of the target structure;

[0008] Generate a debugging file according to the executable format file, and determine the storage address of the member variables of the target structure according to the debugging file.

[0009] In one embodiment, determining the storage address of the target structure member variable according to the debugging file includes:

[0010] Determine the debug information entry of the structure type corresponding to the structure variable in the debug file;

[0011] The offset address of the target structure member variable is determined according to the debugging information entry of the structure type, and the storage address of the structure member variable is obtained according to the offset address of the structure member variable and the storage address of the structure variable.

[0012] In one embodiment, determining the offset address of a member variable of a target structure according to a debugging information entry of a structure type includes:

[0013] Determine the debug information entry of the target structure member variable according to the debug information entry of the structure type;

[0014] Determine the offset address of the target structure member variable according to the debugging information entry of the target structure member variable.

[0015] In one embodiment, determining the debugging information entry of the structure type corresponding to the structure variable in the debugging file includes:

[0016] In the dictionary corresponding to the debugging file, find the debugging information entry corresponding to the structure variable, and determine the initial type corresponding to the structure variable according to the debugging information entry corresponding to the structure variable;

[0017] When the initial type is a standard type name, the initial type is determined as the structure type corresponding to the structure variable, and the debugging information entry corresponding to the structure variable is determined as the debugging information entry of the structure type corresponding to the structure variable;

[0018] When the initial type is not a standard type name, the debug information entry of the standard type name corresponding to the initial type is recursively searched in the dictionary as the debug information entry of the structure type corresponding to the structure variable.

[0019] In one embodiment, the method comprises:

[0020] Parse the symbol table in the executable format file and determine the symbol information matching the target global variable in the symbol table;

[0021] Extract the storage address corresponding to the target global variable from the symbol information.

[0022] In one embodiment, the method includes: after parsing the executable format file, storing the storage address of the parsed structure variable and the symbol information matching the target global variable in a cache.

[0023] In one embodiment, the method includes: parsing the target data segment and symbol table in the executable format file using multiple threads.

[0024] In one of the embodiments, the method includes: in the process of parsing the executable format file, storing the file information in the executable format file through an optimized data structure; wherein the optimized data structure includes a linked list or a hash table.

[0025] In a second aspect, the present application also provides a file processing device, comprising:

[0026] A segment loading module is used to identify a target data segment in an executable format file according to a target data segment identifier;

[0027] The dynamic parsing module is used to parse the target data segment and obtain the storage address of the structure variable corresponding to the member variable of the target structure;

[0028] The address acquisition module is used to generate a debugging file according to the executable format file and determine the storage address of the member variables of the target structure according to the debugging file.

[0029] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0030] identifying a target data segment in the executable format file according to the target data segment identifier;

[0031] Parse the target data segment to obtain the storage address of the structure variable corresponding to the member variable of the target structure;

[0032] Generate a debugging file according to the executable format file, and determine the storage address of the member variables of the target structure according to the debugging file.

[0033] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the following steps are implemented:

[0034] identifying a target data segment in the executable format file according to the target data segment identifier;

[0035] Parse the target data segment to obtain the storage address of the structure variable corresponding to the member variable of the target structure;

[0036] Generate a debugging file according to the executable format file, and determine the storage address of the member variables of the target structure according to the debugging file.

[0037] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0038] identifying a target data segment in the executable format file according to the target data segment identifier;

[0039] Parse the target data segment to obtain the storage address of the structure variable corresponding to the member variable of the target structure;

[0040] Generate a debugging file according to the executable format file, and determine the storage address of the member variables of the target structure according to the debugging file.

[0041] The above-mentioned file processing method, device, computer equipment, storage medium and computer program product, identify the target data segment in the executable format file according to the target data segment identifier, parse the target data segment, obtain the storage address of the structure variable corresponding to the target structure member variable, then generate a debugging file according to the executable format file, and determine the storage address of the target structure member variable according to the debugging file. Different from the traditional method that requires the entire large executable format file to be loaded into the memory for parsing, this embodiment only needs to load and parse the required information, that is, only needs to load and parse the target data segment, thereby reducing memory consumption, being suitable for systems with limited memory resources, and also reducing the time spent on parsing large executable format files. In addition, in this embodiment, it is also possible to obtain the storage address of the target structure member variable through the storage address of the structure variable corresponding to the target structure member variable and the debugging file, and in the scenario where debugging is not possible, the storage address of the structure member variable can be obtained through the executable format file, which helps to complete the calibration work, and solves the problem that the traditional method cannot obtain the storage address of the structure member variable through the executable format file. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0043] Figure 1 An application environment diagram of a file processing method in an embodiment;

[0044] Figure 2 A schematic diagram of a flow chart of a file processing method in one embodiment;

[0045] Figure 3 A schematic diagram of a flow chart of determining an offset address of a member variable of a target structure according to a debugging information entry of a structure type in one embodiment;

[0046] Figure 4 A schematic diagram of a process for obtaining a target global variable address in one embodiment;

[0047] Figure 5 is a structural block diagram of a file processing device in one embodiment;

[0048] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0049] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0050] The file processing method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The server 104 obtains the target structure member variable address acquisition request sent by the terminal 102, and the target structure member variable address acquisition request carries the target structure member variable. Based on the target structure member variable address acquisition request, the server 104 identifies the target data segment in the executable format file according to the target data segment identifier, parses the target data segment in the executable format file, and obtains the storage address of the structure variable corresponding to the target structure member variable; generates a debugging file according to the executable format file, and determines the storage address of the structure member variable according to the debugging file. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices, and the Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.

[0051] In an exemplary embodiment, Figure 2 As shown, a file processing method is provided, which is applied to Figure 1 The server in the example is used to illustrate, including the following steps 202 to 206. Among them:

[0052] Step 202: Identify the target data segment in the executable format file according to the target data segment identifier.

[0053] Among them, the executable format file refers to the elf file, which is a common executable file format for operating systems. The executable format file usually consists of four parts, including the ELF file header (ELF header), the program header table (Programmeheader table, also known as the segment table), sections (Sections) and the section header table (Section header table). The section stores multiple data segments and symbol tables (SHT_SYMTAB). The data segment stores structure variables and the address information corresponding to the structure variables. The symbol table stores global variables and their address information. The target data segment identifier refers to the unique identifier used for the target data segment. The target data segment refers to the data segment that stores the structure variables corresponding to the target structure member variables. The target structure member variables refer to the member variables in the structure whose storage address needs to be obtained. The structure is a user-defined data type that allows different types of data to be combined together. The structure consists of multiple member variables, namely structure member variables, and each member variable can be a different data type. The structure variable refers to an instance of the structure type, which occupies memory space and is used to store specific data. The structure member variables refer to the various fields defined inside the structure.

[0054] Optionally, the server obtains a target structure member variable address acquisition request sent by the terminal, the target structure member variable address acquisition request carrying the target structure member variable. The server determines the target data segment corresponding to the target structure member variable in the executable format file according to the target data segment identifier based on the target structure member variable address acquisition request.

[0055] Step 204, parse the target data segment to obtain the storage address of the structure variable corresponding to the target structure member variable.

[0056] Optionally, the server loads the target data segment into memory for parsing, and finds the storage address of the structure variable corresponding to the member variable of the target structure.

[0057] Step 206, generating a debugging file according to the executable format file, and determining the storage address of the member variable of the target structure according to the debugging file.

[0058] The debug file refers to a file that stores debug information of an executable format file, including type definitions, variable information, etc. The debug file format may be DWARF (Debugging With Attributed Record Formats). The storage address of the target structure member variable refers to the specific location of the storage address of the structure member variable in the memory.

[0059] Optionally, the server can export a debug file from an executable format file, and determine the offset address of the target structure member variable according to the debug file. The offset address of the target structure member variable refers to the storage address of the target structure member variable relative to the structure variable, that is, the byte offset of the base address. Through the offset address, the position of the member variable in the memory can be accurately located. Thus, the storage address of the structure member variable is obtained according to the offset address of the structure member variable and the storage address of the structure variable.

[0060] In one of the embodiments, determining the offset address of the target structure member variable according to the debugging information entry of the structure type includes: generating a debugging file according to the executable format file, and determining the debugging information entry of the structure type corresponding to the structure variable in the debugging file; determining the offset address of the target structure member variable according to the debugging information entry of the structure type, and obtaining the storage address of the structure member variable according to the offset address of the structure member variable and the storage address of the structure variable.

[0061] The basic unit of debugging information in a DWARF file is a debugging information entry (DIE). Each DIE describes the properties and relationships of a program entity, such as types, variables, functions, etc. The structure type corresponding to a structure variable is represented by a DIE in DWARF, which includes information such as the name, size, and alignment of the structure.

[0062] Since the debug file includes debug information entries, the structure type corresponding to the structure variable is represented by a debug information entry. The server searches for the corresponding debug information entry in the debug file according to the name of the structure variable, and determines the debug information entry as the debug information entry of the structure type corresponding to the structure variable. According to the debug information entry of the structure type, the offset address of the target structure member variable is found, and then the storage address of the structure member variable is obtained according to the sum of the offset address of the structure member variable and the storage address of the structure variable.

[0063] Furthermore, when obtaining the address, because it adopts LEB128 (Little Endian Base 128, based on 128 Little Indian sequence encoding format) encoding, LEB128 is a variable-length encoding format for encoding non-negative integers, so it is also necessary to decode the storage address of the obtained structure variable and the storage address of the target structure member variable to obtain the actual storage address of the structure variable and the actual storage address of the target structure member variable.

[0064] Furthermore, the size of the structure can be obtained from the debug information entry of the structure type. The size of the structure refers to the total number of bytes allocated for the structure in the memory. The size of the target structure member variable is determined according to the debug information entry of the structure type. The size of the target structure member variable refers to the number of bytes occupied by the target structure member variable in the memory, which depends on the data type of the target structure member variable. The storage address of the target structure member variable is verified to be accurate based on the size of the target structure member variable and the size of the structure.

[0065] Exemplarily, when the target structure member variable is Student.grade, to obtain the storage address of the structure member variable Student.grade, it is necessary to first identify the target data segment corresponding to the target data segment identifier symtab in the executable format file, parse the target data segment, and obtain the storage address of the structure variable Student. The storage address of Student can be represented by addr_var_Student. Afterwards, a debug file is generated according to the executable format file, and the debug information entry of the structure type corresponding to Student is determined in the debug file. The offset address of Student.grade is determined through the debug information entry of the structure type corresponding to Student. The storage address of Student.grade is obtained according to the offset address of Student.grade and the storage address of Student. The offset address of Student.grade can be represented by offset_member_grade. Therefore, the storage address Addr of Student.grade can be expressed as: Addr=addr_var_Student+offset_member_grade. Furthermore, the general formula of the structure member variable can be expressed as: Addr=addr_var_Struct+offset_member, where addr_var_Struct represents the storage address of the structure variable corresponding to the target structure member variable, and offset_member represents the offset address corresponding to the target structure member variable.

[0066] In the above-mentioned file processing method, the target data segment is identified in the executable format file according to the target data segment identifier, the target data segment is parsed, and the storage address of the structure variable corresponding to the target structure member variable is obtained. Then, a debugging file is generated according to the executable format file, and the storage address of the target structure member variable is determined according to the debugging file. Different from the traditional method that requires the entire large executable format file to be loaded into the memory for parsing, this embodiment only needs to load and parse the required information, that is, only the target data segment needs to be loaded and parsed, thereby reducing memory consumption, being suitable for systems with limited memory resources, and also reducing the time spent on parsing large executable format files. In addition, in this embodiment, the storage address of the target structure member variable can also be obtained through the storage address of the structure variable corresponding to the target structure member variable and the debugging file. In the scenario where debugging is not possible, the storage address of the structure member variable can be obtained through the executable format file, which helps to complete the calibration work and solves the problem that the traditional method cannot obtain the storage address of the structure member variable through the executable format file.

[0067] In an exemplary embodiment, Figure 3 As shown, determining the offset address of the target structure member variable according to the debugging information entry of the structure type includes steps 302 to 304, wherein:

[0068] Step 302: Determine the debugging information entry of the target structure member variable according to the debugging information entry of the structure type.

[0069] Step 304: determine the offset address of the target structure member variable according to the debugging information entry of the target structure member variable.

[0070] The debug information entry of the target structure member variable refers to the debug information entry used to describe the internal members of the structure.

[0071] Optionally, each member variable of the structure is represented by its own debug information entry, and the debug information entry of each member variable of the structure is a child node of the debug information entry of the structure type, which is used to describe the member's name, type, offset address and other attributes. The debug information entry of the structure type and the debug information entry of the target structure member variable are stored in sequence in the target data segment. The server can determine the debug information entry of the target structure member variable based on the debug information entry of the structure type, and thus find the offset address of the target structure member variable in the debug information entry of the target structure member variable.

[0072] Exemplarily, when the target structure member variable is Student.grade, a debug file is generated according to the executable format file, the debug information entry of the structure type corresponding to the structure member variable Student is determined in the debug file, and the debug information entry of grade is searched downward according to the debug information entry of the structure type corresponding to Student, and the offset address member_location of grade is obtained in the debug information entry of grade, that is, the offset address corresponding to Student.grade is obtained.

[0073] In this embodiment, the debugging information entry of the target structure member variable is first determined according to the debugging information entry of the structure type, and then the offset address of the target structure member variable is determined according to the debugging information entry of the target structure member variable, so that the offset address of the target structure member variable can be accurately obtained.

[0074] In an exemplary embodiment, determining the offset address of a target structure member variable based on a debugging information entry of a structure type includes: when the data structure of a structure corresponding to the target structure member variable is a preset data structure, recursively searching for the offset address of the target structure member variable; when the data structure of the structure corresponding to the target structure member variable is not a preset data structure, obtaining the offset address of the target structure member variable in a non-recursive search manner.

[0075] The preset data structures include arrays, nested structures, and nested structure arrays.

[0076] Optionally, when the structure is a different data structure, the offset address of the target structure member variable may be obtained in a different manner. Therefore, after determining the debug information entry of the structure type corresponding to the structure variable, the server can identify whether the data structure of the structure corresponding to the target structure member variable is a preset data structure. When the data structure of the structure corresponding to the target structure member variable is a preset data structure, there will be multiple levels of structure member variables in the data structure of the structure, so it is necessary to obtain the debug information entry of each level of the structure member variable in turn, that is, it is necessary to repeat the process of obtaining the debug information entry of the structure member variable for multiple times, and at this time, the offset address of the target structure member variable can be found in a recursive search manner. When the data structure of the structure corresponding to the target structure member variable is not a preset data structure, there is only one level of structure member variables in the data structure of the structure, that is, the target structure member variable, and it is only necessary to execute the process of obtaining the debug information entry of the structure member variable once, so the offset address of the target structure member variable can be obtained in a non-recursive search manner.

[0077] Furthermore, when searching for the offset address of the target structure member variable, the debug information entry of the target structure member variable is first determined according to the debug information entry of the structure type, and then the offset address of the target structure member variable is determined according to the debug information entry of the target structure member variable.

[0078] Exemplarily, when the target structure member variable is student.grade.math, since there are multiple levels of structure member variables grade and math, the data structure of the structure corresponding to student.grade.math is a preset data structure, specifically a data structure of nested structures, and a recursive search is performed based on the debug information entry of the structure type corresponding to the structure variable student, and then the debug information entry of grade is searched, and then the debug information entry of math is searched based on the debug information entry of grade, so as to obtain the offset address in the debug information entry of math.

[0079] When the target structure member variable is student.grade, since there is only one level of structure member variable grade, the data structure of the structure corresponding to student.grade is not a preset data structure. The debugging information entry of grade can be searched in a non-recursive manner according to the debugging information entry of the structure type corresponding to the structure variable student, and the offset address of grade can be obtained in the debugging information entry of grade.

[0080] In this embodiment, by parsing the target data segment in the executable format file, not only the storage address of the target structure member variable in the executable format file can be determined, but it is also applicable to various situations, such as array situations, nested structures, and nested structure arrays. It can adapt to different application scenarios and requirements and has good flexibility.

[0081] In an exemplary embodiment, determining the debugging information entry of the structure type corresponding to the structure variable in the debugging file includes: searching the debugging information entry corresponding to the structure variable in the dictionary corresponding to the debugging file, and determining the initial type corresponding to the structure variable according to the debugging information entry corresponding to the structure variable. When the initial type is a standard type name, the initial type is determined as the structure type corresponding to the structure variable, and the debugging information entry corresponding to the structure variable is determined as the debugging information entry of the structure type corresponding to the structure variable. When the initial type is not a standard type name, the debugging information entry of the initial type is recursively searched in the dictionary as the debugging information entry of the structure type corresponding to the structure variable.

[0082] The pre-established dictionary refers to a debug information entry dictionary, in which debug information entry dictionary is stored a plurality of debug information entries corresponding to structure variables. The initial type refers to the type of the structure variable stored in the pre-established dictionary.

[0083] Optionally, a debug information entry dictionary is generated in advance based on the debug file, and the debug information entry corresponding to the structure variable is searched in the dictionary. The debug information entry is also used to indicate the type, so the type indicated by the debug information entry corresponding to the structure variable can be determined as the initial type of the structure variable. Identify whether the initial type is a standard type name. The standard type name refers to a general type name, not a type alias. When the initial type is a standard type name, the initial type can be directly determined as the structure type corresponding to the structure variable, and the debug information entry corresponding to the structure variable can be determined as the debug information entry of the structure type corresponding to the structure variable.

[0084] When the initial type is not a standard type name, it is necessary to find the actual type, that is, the initial type corresponds to the standard type name, and obtain the debugging information entry corresponding to the standard type name. Specifically, recursively search the dictionary for the debugging information entry of the standard type name corresponding to the initial type, and use the debugging information entry of the standard type name as the debugging information entry of the structure type corresponding to the structure variable.

[0085] In this embodiment, by looking up the debug information entry of the structure type corresponding to the structure variable through the dictionary, the search process can be simplified, and the information of the structure type can be quickly located and parsed. By identifying whether the initial type corresponding to the structure variable is a standard type name, the corresponding debug information entry search method can be adopted for the standard type name and the non-standard type name, and the debug information entry of the structure type corresponding to the structure variable can be quickly and accurately determined.

[0086] In an exemplary embodiment, Figure 4 As shown, the above method includes: the step of obtaining the address of the target global variable, including:

[0087] Step 402, parse the symbol table in the executable format file, and determine the symbol information matching the target global variable in the symbol table.

[0088] Step 404: extract the storage address corresponding to the target global variable from the symbol information.

[0089] Optionally, the server can not only obtain the storage address of the target structure member variables from the executable format file, but also obtain the storage address of the target global variable. Specifically, the symbol table in the executable format file is loaded, and the symbol table stores global variables and the storage addresses corresponding to the global variables. Parsing the symbol table in the executable format file refers to traversing the symbol table and searching the symbol table for symbol information matching the target global variable. The symbol information includes the storage address corresponding to the global variable. After finding the matching symbol information, the storage address of the symbol information can be directly read to obtain the storage address corresponding to the target global variable.

[0090] Optionally, symbol information matching the target global variable may be determined by performing a linear search on the symbol table.

[0091] Optionally, in order to further improve the search efficiency, a hash table may be used to store the parsed symbol table related data.

[0092] In this embodiment, unlike the traditional method that requires loading the entire executable format file into the memory for parsing, this embodiment only needs to load and parse the required information, that is, only needs to load and parse the symbol table in the executable format file, thereby reducing memory consumption and being suitable for systems with limited memory resources. It also reduces the time spent on parsing large executable format files.

[0093] In an exemplary embodiment, the method further includes: after parsing the executable format file, storing the parsed storage address of the structure variable and the symbol information matching the target global variable in a cache.

[0094] In the process of parsing executable format files, a cache mechanism can be used to store the storage addresses of structure variables that have been parsed, as well as symbol information that matches the target global variables, to avoid repeated parsing, thereby significantly improving file processing speed, especially in scenarios where variable storage addresses need to be searched multiple times.

[0095] In an exemplary embodiment, the method further includes: using multiple threads to load the executable format file, and parsing the target data segment and symbol table in the executable format file.

[0096] In the process of parsing executable format files, multi-threading technology is used to assign different tasks to different threads for processing. For example, the parsing task of the executable format file and the symbol table search task can be assigned to different threads for processing. It can fully utilize the multi-core processing capabilities of modern computers and improve file processing efficiency.

[0097] In an exemplary embodiment, the method further includes: in the process of parsing the executable format file, storing the file information in the executable format file through an optimized data structure; wherein the optimized data structure includes a linked list or a hash table.

[0098] In the process of parsing an executable format file, an optimized data structure can be used to store file information in the parsed file, and the file information includes data and code. The optimized data structure includes a linked list or a hash table. The optimized data structure can better utilize the computer's cache mechanism, reduce memory consumption, and improve file processing efficiency. For example, a linked list is used to store the symbol table in the executable format file instead of an array, and only the necessary data content is loaded. In addition, when parsing an executable format file, a hash table can also be used to store information such as the symbol table to improve search efficiency. The linked list is more efficient when inserting and deleting, while the hash table can provide constant time complexity when searching.

[0099] Furthermore, the embodiments of the present application can add more optimization algorithms and data structures according to actual needs to improve file processing efficiency, which can greatly facilitate system maintenance and upgrades and have better performance, higher flexibility and better scalability.

[0100] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0101] Based on the same inventive concept, the embodiment of the present application also provides a file processing device for implementing the file processing method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more file processing device embodiments provided below can refer to the limitations on the file processing method above, and will not be repeated here.

[0102] In an exemplary embodiment, Figure 5 As shown, a file processing device is provided, including: a segment loading module 502, a dynamic parsing module 504 and an address acquisition module 506, wherein:

[0103] The segment loading module 502 is used to identify the target data segment in the executable format file according to the target data segment identifier.

[0104] The dynamic parsing module 504 is used to parse the target data segment to obtain the storage address of the structure variable corresponding to the member variable of the target structure.

[0105] The address acquisition module 506 is used to generate a debugging file according to the executable format file, and determine the storage address of the member variable of the target structure according to the debugging file.

[0106] In an exemplary embodiment, the address acquisition module 506 further includes:

[0107] The structure debugging information acquisition unit is used to determine the debugging information entry of the structure type corresponding to the structure variable in the debugging file.

[0108] The member address acquisition unit is used to determine the offset address of the target structure member variable according to the debugging information entry of the structure type, and obtain the storage address of the structure member variable according to the offset address of the structure member variable and the storage address of the structure variable.

[0109] In an exemplary embodiment, the member address acquisition unit is further used to determine the debugging information entry of the target structure member variable according to the debugging information entry of the structure type; and determine the offset address of the target structure member variable according to the debugging information entry of the target structure member variable.

[0110] In an exemplary embodiment, the member address acquisition unit is further used to search for a debugging information entry corresponding to a structure variable in a dictionary corresponding to a debugging file, and determine an initial type corresponding to the structure variable according to the debugging information entry corresponding to the structure variable; when the initial type is a standard type name, the initial type is determined as the structure type corresponding to the structure variable, and the debugging information entry corresponding to the structure variable is determined as the debugging information entry of the structure type corresponding to the structure variable; when the initial type is not a standard type name, recursively search the dictionary for a debugging information entry of a standard type name corresponding to the initial type as the debugging information entry of the structure type corresponding to the structure variable.

[0111] In an exemplary embodiment, the above-mentioned device also includes: a global variable address acquisition module, which is used to parse the symbol table in the executable format file, determine the symbol information matching the target global variable in the symbol table; and extract the storage address corresponding to the target global variable in the symbol information.

[0112] In an exemplary embodiment, the apparatus further includes: a cache module, which is used to store the storage address of the parsed structure variable and the symbol information matching the target global variable in the cache after parsing the executable format file.

[0113] In an exemplary embodiment, the apparatus further includes: a multi-thread module, configured to parse the target data segment and the symbol table in the executable format file using multiple threads.

[0114] In an exemplary embodiment, the above-mentioned device also includes: a storage module, which is used to store file information in the executable format file through an optimized data structure during the process of parsing the executable format file; wherein the optimized data structure includes a linked list or a hash table.

[0115] Each module in the above-mentioned file processing device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module above.

[0116] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 6 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as executable format files, storage addresses of structure variables, and storage addresses of target structure member variables. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a file processing method is implemented.

[0117] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0118] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0119] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0120] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0121] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0122] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0123] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0124] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A file processing method, characterized in that: The method comprises: identifying a target data segment in the executable format file according to the target data segment identifier; Parsing the target data segment to obtain the storage address of the structure variable corresponding to the target structure member variable; A debugging file is generated according to the executable format file, and a storage address of the target structure member variable is determined according to the debugging file.

2. The method according to claim 1, characterized in that Determining the storage address of the target structure member variable according to the debugging file includes: Determine in the debugging file a debugging information entry of a structure type corresponding to the structure variable; The offset address of the target structure member variable is determined according to the debugging information entry of the structure type, and the storage address of the structure member variable is obtained according to the offset address of the structure member variable and the storage address of the structure variable.

3. The method according to claim 2, characterized in that Determining the offset address of the target structure member variable according to the debugging information entry of the structure type includes: Determine the debugging information entry of the target structure member variable according to the debugging information entry of the structure type; The offset address of the target structure member variable is determined according to the debugging information entry of the target structure member variable.

4. The method according to claim 2, characterized in that: The debugging information entry for determining the structure type corresponding to the structure variable in the debugging file includes: In the dictionary corresponding to the debugging file, searching for the debugging information entry corresponding to the structure variable, and determining the initial type corresponding to the structure variable according to the debugging information entry corresponding to the structure variable; When the initial type is a standard type name, determining the initial type as the structure type corresponding to the structure variable, and determining the debugging information entry corresponding to the structure variable as the debugging information entry of the structure type corresponding to the structure variable; When the initial type is not a standard type name, the debugging information entry of the standard type name corresponding to the initial type is recursively searched in the dictionary as the debugging information entry of the structure type corresponding to the structure variable.

5. The method according to claim 1, characterized in that The method comprises: Parsing a symbol table in the executable format file, and determining symbol information matching a target global variable in the symbol table; A storage address corresponding to the target global variable is extracted from the symbol information.

6. The method according to claim 5, characterized in that The method further comprises: After parsing the executable format file, the parsed storage address of the structure variable and the symbol information matching the target global variable are stored in a cache.

7. The method according to claim 5, characterized in that The method further comprises: The target data segment and the symbol table in the executable format file are parsed using multithreading.

8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: In the process of parsing the executable format file, the file information in the executable format file is stored through an optimized data structure; wherein the optimized data structure includes a linked list or a hash table.

9. A file processing device, characterized in that: The device comprises: A segment loading module is used to identify a target data segment in an executable format file according to a target data segment identifier; A dynamic parsing module, used for parsing the target data segment to obtain the storage address of the structure variable corresponding to the member variable of the target structure; The address acquisition module is used to generate a debugging file according to the executable format file, and determine the storage address of the member variable of the target structure according to the debugging file.

10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.

Citation Information

Cited By

  • Variable monitoring method, system and device, computer equipment and storage medium

    CN120256254A

  • Variable monitoring method, system, device, computer equipment and storage medium

    CN120256254B

  • Executable and linkable file analysis method and electronic equipment

    CN120723339A