Method and apparatus for determining reservation structure, terminal and medium
By extracting structures from the existing and new versions of KABI related files to form a difference set and a whitelist of compatible structures, the structures that need to be reserved are automatically determined. This solves the problems of low efficiency and poor accuracy in the existing technology of checking KABI changed structures, and achieves efficient and accurate structure reservation.
Patent Information
- Application Number
- CN202511239883.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-02
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2045-09-02
AI Technical Summary
In existing technologies, it is difficult to identify changes in the binary interface (KABI) structure of different versions of kernel applications, especially in the case of multi-level nested structures. Manual comparison is inefficient and inaccurate.
By extracting structures from the original and new versions of KABI-related files to form first and second sets, and using the difference set and whitelist to adapt the structure set, the structures that need to reserve space are automatically determined, and the application binary interface description file is generated to achieve accurate structure comparison and reservation.
It improves the efficiency and accuracy of checking KABI variable structures, especially in the case of multi-layered nested structures, reducing the workload of manual comparison and improving the automation and accuracy of the check.
Smart Images

Figure CN120743339B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of kernel, and in particular to a method and device for determining a reserved structure, a terminal and a medium. BACKGROUND
[0002] Kernel Application Binary Interface (KABI) is a binary interface specification for kernel modules to interact with the kernel, including function symbols, data structure layout, calling convention, etc. Its core goal is to solve the compatibility problem of driver modules across kernel versions. When the kernel is upgraded, if the KABI remains stable, the old driver can run on the new kernel without recompilation.
[0003] At the time of version release, the KABI has been fixed, and if subsequent support for new features or repair of Common Vulnerabilities & Exposures (CVE) is encountered, some members of the core structure or parameters of the function need to be modified again, which will cause the KABI compatibility to be broken, thereby failing to ensure that the old kernel module and application work normally on the new kernel.
[0004] In the prior art, the space of the structure related to the white list locking stable symbols can be reserved before the version is released, and if the structure needs to be changed later, only the previously reserved space needs to be used, which will not cause the KABI to be broken. However, this method needs to invest a lot of time and manpower to comb and investigate which structures exist in the tens of thousands of code amounts, and since there are also multiple nested structures, it further increases the difficulty of investigating the changed structures. SUMMARY
[0005] Embodiments of the present application provide a method and device for determining a reserved structure, a terminal and a medium to solve the technical problem that it is difficult to investigate the KABI change structure of different versions of the kernel in the prior art.
[0006] In a first aspect, embodiments of the present application provide a method for determining a reserved structure, comprising:
[0007] extracting structures from KABI related files in the original version to obtain a first set;
[0008] extracting structures from KABI related files in the new version to obtain a second set;
[0009] obtaining a difference set using the first set and the second set;
[0010] generating an application binary interface description file based on the function interface whitelist of the original version;
[0011] read the structure from the application binary interface description file to form a whitelist adaptation structure set;
[0012] determine the structure needing to reserve space according to the difference set and the whitelist adaptation structure set.
[0013] In a second aspect, an embodiment of the present application further provides a determination apparatus for reserving structure, comprising:
[0014] a first extraction module, used for extracting the structure from the original version and the KABI related file to obtain a first set;
[0015] a second extraction module, used for extracting the structure from the new version and the KABI related file to obtain a second set;
[0016] a difference set obtaining module, used for obtaining the difference set by using the first set and the second set;
[0017] a generating module, used for generating the application binary interface description file based on the function interface whitelist of the original version;
[0018] a reading module, used for reading the structure from the application binary interface description file to form a whitelist adaptation structure set;
[0019] a determining module, used for determining the structure needing to reserve space according to the difference set and the whitelist adaptation structure set.
[0020] In a third aspect, an embodiment of the present application further provides a terminal, comprising:
[0021] one or more processors;
[0022] a storage device, used for storing one or more programs,
[0023] when the one or more programs are executed by the one or more processors, the one or more processors implement the determination method for reserving structure provided by the above embodiment.
[0024] In a fourth aspect, an embodiment of the present application further provides a storage medium containing computer executable instructions, which are used for executing the determination method for reserving structure provided by the above embodiment when executed by a computer processor.
[0025] The method for determining the reserved structure provided by the embodiment of the application, the device, the terminal and the medium, extracts the structure from the original version and the KABI related file to obtain a first set; extracts the structure from the new version and the KABI related file to obtain a second set; obtains a difference set by using the first set and the second set; generates an application binary interface description file based on the function interface white list of the original version; reads the structure from the application binary interface description file to form a white list adapted structure set; and determines the structure that needs to be reserved according to the difference set and the white list adapted structure set. The structures are extracted from the KABI related files between different versions, and different sets are formed, the structures that change between different versions are determined by comparing different sets, especially the structures with the same name but different attributes. Further, the white list structure in the interface description file of the original version can be read, and the reserved structure in the white list is determined based on the intersection of the comparison result between the sets and the white list structure. Compared with the prior art, the structures that need to be reserved can be obtained without manual comparison and investigation, and the investigation efficiency is improved. Moreover, for the multi-layer nested structure, an accurate judgment result can be given, and the investigation accuracy is also improved. BRIEF DESCRIPTION OF DRAWINGS DETAILED DESCRIPTION OF THE INVENTION BRIEF DESCRIPTION OF DRAWINGS
[0026] Other features, objects, and advantages of the application will become more apparent from the following detailed description of non-limiting embodiments thereof, when read in conjunction with the accompanying drawings:
[0027] Figure 1 is a flowchart of the method for determining the reserved structure provided by the embodiment one of the application;
[0028] Figure 2 is a flowchart of the method for determining the reserved structure provided by the embodiment two of the application;
[0029] Figure 3 is a structural diagram of the device for determining the reserved structure provided by the embodiment three of the application;
[0030] Figure 4 is a structural diagram of the terminal provided by the embodiment four of the application. DETAILED DESCRIPTION
[0031] The application will be further described in conjunction with the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the application, but not to limit the application. In addition, it should be noted that, for the convenience of description, only the parts related to the application are shown in the drawings, but not all the structures.
[0032] Embodiment one
[0033] Figure 1is a flowchart of a method for determining a reserved structure provided by Embodiment One of the present application. The present embodiment can be applied to the case of determining a reserved structure in KABI when the kernel evolves. The method can be performed by a device for determining a reserved structure, and specifically includes the following steps:
[0034] In step 110, structures are extracted from the original version and KABI-related files to obtain a first set.
[0035] In the present embodiment, a pre-release version can be used as the original version. The original version is not limited to the pre-release version, and can also include other official versions. A pre-release version is a test version before the official release of software, and is used for function verification, stability testing, and user feedback collection. KABI is a binary compatibility standard for the Linux kernel layer, and ensures stable operation of kernel modules between different versions. In the original version, there are driver support for hardware, and these may have compatibility problems in subsequent versions. Therefore, structures need to be extracted from the original version and KABI-related files to obtain a first set. The set includes structures related to the driver of specific or all hardware. For example, structures related to the wireless subsystem.
[0036] In step 120, structures are extracted from the new version and KABI-related files to obtain a second set.
[0037] For example, a version of a newer upstream community can be used as the new version. The new version is in a continuous progressive relationship with the original version. The upstream community usually uses Git trunk or rolling branch as the only de facto source, and outputs daily continuous integration. There can be some changes relative to the pre-release version. Therefore, structures, especially structures related to the driver of specific or all hardware, also need to be extracted from the new version to form a second set.
[0038] In step 130, a difference set is obtained using the first set and the second set.
[0039] Each element in the first set represents a related structure in the original version, and correspondingly, each element in the second set represents a related structure in the new version.
[0040] The different structures in the two versions can be determined according to the name and corresponding attributes of each structure, where the different structures include structures with different names and structures with the same name but one or more different attributes. The difference set is constructed based on the different structures obtained above. Each element in the set is a different structure in the first set and the second set.
[0041] Step 140, generating an application binary interface description file based on the function interface whitelist of the original version.
[0042] KABI defines the binary interface specification between the original version of the Linux kernel and external modules (especially drivers). It ensures that modules compiled on a certain kernel version can be directly loaded and run without recompilation on subsequent compatible kernel versions, such as new versions. A KABI whitelist is usually maintained to explicitly specify which kernel interfaces (structures, functions, macros, etc.) are stable and unchanged. In order to avoid KABI being broken and at least meet the needs of the new version, the space for structures related to stable symbols locked by the whitelist is usually reserved before the new version is released. Therefore, it is necessary to first determine which structures in the KABI whitelist of the original version are involved.
[0043] For example, it can include: extracting the corresponding interface using the function interface whitelist of the original version; generating an application binary interface description file based on the interface using the kernel binary file and the kernel debug information file of the original version. For example, the interface name that needs to be focused on can be extracted from the KABI whitelist, that is, the binary interface of the driver involved in the whitelist. Using the abidw command in the libabigail toolkit, the above-mentioned interface that needs to be focused on is extracted from the kernel binary file and the kernel debug information file of the original version, and an application binary interface description file is generated.
[0044] Step 150, reading the structures from the application binary interface description file to form a whitelist adapted structure set.
[0045] Correspondingly, it can include: locating the structure node in the application binary interface description file and recursively parsing the sub-structure; extracting the properties of the structure to form a whitelist adapted structure set. Using the above-mentioned method, the problem of multi-layer nested structures not being easy to troubleshoot can be solved, and all structures and corresponding properties can be obtained.
[0046] Step 160, determining the structures that need to be reserved based on the difference set and the whitelist adapted structure set.
[0047] For example, the difference structure set reflects the structures that are different between the new and old versions of KABI, and the whitelist adapted structure set reflects the structures involved in the whitelist of the original version. Using the intersection of the difference structure set and the whitelist adapted structure set, the structures that will change in the new version of the original version whitelist can be obtained. These structures need to be reserved, which means that the structures that need to be reserved are determined.
[0048] Optionally, after determining the structure of the reserved space, an external structure can be created for each reserved space structure, and an association between the two is established. The space reservation of the reserved space structure is achieved. And it will not damage the KABI.
[0049] The embodiment extracts structures from the KABI-related files in the original version to obtain a first set, extracts structures from the KABI-related files in the new version to obtain a second set, obtains a difference set by using the first set and the second set, generates an application binary interface description file based on the function interface whitelist of the original version, reads structures from the application binary interface description file to form a whitelist adaptation structure set, and determines structures that need to be reserved according to the difference set and the whitelist adaptation structure set. Structures are extracted from the KABI-related files between different versions, and different sets are formed. By comparing different sets, structures that change between different versions are determined, especially structures with the same name but different properties. Further, the whitelist structures in the interface description file in the original version can also be read, and the intersection of the comparison result between the sets and the whitelist structures is used to determine the reserved structures in the whitelist. Compared with the prior art, the structures that need to be reserved can be obtained without manual comparison and investigation, which improves the investigation efficiency. And for multi-layer nested structures, accurate judgment results can be given, which also enhances the accuracy of the investigation.
[0050] Embodiment Two
[0051] Figure 2 is a flowchart of a method for determining a reserved structure provided by Embodiment Two of the application. Based on the above-mentioned embodiment, the embodiment is optimized as follows. The structures are extracted from the KABI-related files in the original version. Specifically, a first abstract syntax tree is created for the original version, and structures are extracted from the driver source code and the corresponding kernel header file of the device of interest in the original version by using the first abstract syntax tree. Correspondingly, the structures are extracted from the KABI-related files in the new version. Specifically, a second abstract syntax tree is created for the new version, and structures are extracted from the driver source code and the corresponding kernel header file of the device of interest in the new version by using the second abstract syntax tree.
[0052] Referring to Figure 2 , the method for determining a reserved structure comprises the following steps.
[0053] In step 210, a first abstract syntax tree is created for the original version, and structures are extracted from the driver source code and the corresponding kernel header file of the device of interest in the original version by using the first abstract syntax tree to obtain a first set.
[0054] An Abstract Syntax Tree (AST) is a tree-like abstract representation of the syntactic structure of source code. It organizes code in the form of nodes and edges, with each node corresponding to a syntactic element in the source code (such as an expression, statement, function, variable, etc.) and edges representing the hierarchical relationships between syntactic elements. AST omits specific details in the source code (such as semicolons, parentheses, spaces, etc.) and only retains structures related to program logic. For example, nested parentheses are implied in the tree structure and do not generate separate nodes.
[0055] In this embodiment, the structure bodies can be extracted from the source code of the driver of the device of interest in the original version and the corresponding kernel header file using an abstract syntax tree, and the nested structure bodies can be processed to obtain the corresponding bottom-level structure bodies. The device of interest can be a device or multiple devices that may be affected by version changes.
[0056] Further, obtaining the first set can include: for each structure body extracted, generating a corresponding MD5 value based on the name, member quantity, and type of the structure body, removing duplicate structure bodies according to the MD5 values, and generating the first set. For example, a hash operation can be used to calculate each structure body, so that each structure body has a unique "fingerprint". The MD5 value can be used to determine whether the extracted structure bodies are identical, i.e., duplicate, and based on the MD5 value, duplicate structure bodies are removed, and the MD5 values of the remaining structure bodies are used to construct the first set.
[0057] Step 220, a second abstract syntax tree is created for the new version, and structure bodies are extracted from the driver source code and the corresponding kernel header file of the device of interest in the new version using the second abstract syntax tree to obtain a second set.
[0058] For example, the method of the foregoing steps can be used to extract structure bodies from the driver source code and the corresponding kernel header file of the same device in the new version, and the MD5 values of each structure body can be used for deduplication, and the deduplicated MD5 values can be used to generate the second set.
[0059] Step 230, a difference set is obtained using the first set and the second set.
[0060] Step 240, an application binary interface description file is generated based on the function interface whitelist of the original version.
[0061] Step 250, structure bodies are read from the application binary interface description file to form a whitelist adaptation structure body set.
[0062] Step 260, structure bodies that need to be reserved are determined based on the difference set and the whitelist adaptation structure body set.
[0063] The embodiment extracts the structure from the KABI related file in the original version, and is specifically optimized as follows: a first abstract syntax tree is created for the original version, and the structure is extracted from the original version of the device driver source code and the corresponding kernel header file by using the first abstract syntax tree; correspondingly, the structure is extracted from the KABI related file in the new version, and is specifically optimized as follows: a second abstract syntax tree is created for the new version, and the structure is extracted from the new version of the device driver source code and the corresponding kernel header file by using the second abstract syntax tree. In the above manner, the structures in different versions can be automatically extracted, and for the nested structures, the corresponding underlying structures can also be extracted. The accuracy and integrity of the extracted structures are guaranteed, and no omission occurs. Moreover, by using the MD5 algorithm, the“fingerprint”information of each structure can be generated, which not only improves the comparison efficiency, but also facilitates manual checking whether there are different structures and the corresponding quantity and other information. This facilitates the user to maintain later.
[0064] Embodiment three
[0065] Figure 3 is a structural schematic diagram of a reserved structure determination device provided by the embodiment three of the present application, referring to Figure 3 The reserved structure determination device comprises:
[0066] A first extraction module 310 is configured to extract the structure from the KABI related file in the original version to obtain a first set.
[0067] A second extraction module 320 is configured to extract the structure from the KABI related file in the new version to obtain a second set.
[0068] A difference set obtaining module 330 is configured to obtain a difference set by using the first set and the second set.
[0069] A generating module 340 is configured to generate an application binary interface description file based on the function interface white list of the original version.
[0070] A reading module 350 is configured to read the structure from the application binary interface description file to form a white list adapted structure set.
[0071] A determining module 360 is configured to determine the structure that needs to be reserved according to the difference set and the white list adapted structure set.
[0072] The determination device of the reserved structure provided by the embodiment extracts the structure from the KABI related files between different versions, forms different sets, compares the different sets, determines the changed structure between different versions, especially the structure with unchanged name but different attributes. Further, the white list structure in the interface description file in the original version can be read, and the reserved structure required in the white list is determined based on the intersection of the comparison result between the sets and the white list structure. Compared with the prior art, the structure required to be reserved can be obtained without manual comparison and investigation, and the investigation efficiency is improved. And for the multi-layer nested structure, accurate judgment result can be given, which also enhances the accuracy of the investigation.
[0073] On the basis of the above embodiments, the generation module comprises:
[0074] The extraction unit is configured to extract the corresponding interface by using the function interface white list of the original version.
[0075] The generation unit is configured to generate an application binary interface description file by using the kernel binary file and the kernel debugging information file of the original version according to the interface.
[0076] On the basis of the above embodiments, the first extraction module is configured to:
[0077] The first abstract syntax tree is created for the original version, and the structure is extracted from the driver source code and the corresponding kernel header file of the device of interest in the original version by using the first abstract syntax tree.
[0078] Correspondingly, the second extraction module is configured to:
[0079] The second abstract syntax tree is created for the new version, and the structure is extracted from the driver source code and the corresponding kernel header file of the device of interest in the new version by using the second abstract syntax tree.
[0080] On the basis of the above embodiments, the first extraction module comprises:
[0081] The first generation unit is configured to generate a corresponding MD5 value based on the name, the number of members and the type of the structure for each extracted structure, remove the duplicate structures according to the MD5 value, and generate a first set.
[0082] On the basis of the above embodiments, the second extraction module comprises:
[0083] The second generation unit is configured to generate a corresponding MD5 value based on the name, the number of members and the type of the structure for each extracted structure, remove the duplicate structures according to the MD5 value, and generate a second set.
[0084] On the basis of the above embodiments, the difference set obtaining module comprises:
[0085] The obtaining unit is configured to determine different elements in the first set and the second set, and obtain the difference set based on the different elements.
[0086] On the basis of the above embodiments, the determining module comprises:
[0087] The calculating unit is configured to calculate an intersection of the difference set and the whitelist adaptation structure set, and take a structure corresponding to each element in the intersection as a structure that needs to be reserved.
[0088] The determination apparatus for reserved structures provided in the embodiments of the present application can perform the determination method for reserved structures provided in any of the embodiments of the present application, and has the corresponding function modules and beneficial effects of performing the method.
[0089] Embodiment four
[0090] Figure 4 A structural schematic diagram of a terminal provided in embodiment four of the present application is shown. Figure 4 A block diagram of an exemplary terminal 12 suitable for use in implementing embodiments of the present application is shown. Figure 4 The terminal 12 shown is merely an example and should not be taken as limiting the functionality or applicability of embodiments of the present application.
[0091] As shown in Figure 4 The terminal 12 is shown in the form of a general-purpose computing device. The components of terminal 12 can include, but are not limited to, one or more processors or processing units 16, a memory 28, and a bus 18 that connects the various system components, including the memory 28 and the processing unit 16.
[0092] The bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration bus, a processor or local bus using any of a variety of bus architectures. By way of example, these architectures include Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA (EISA) bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
[0093] The terminal 12 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by the terminal 12 and includes both volatile and non-volatile media, removable and non-removable media.
[0094] Memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Terminal 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (… Figure 4 Not shown; usually referred to as a "hard drive"). Although Figure 4 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.
[0095] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of the present invention.
[0096] Terminal 12 can also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and with one or more devices that enable a user to interact with terminal 12, and / or with any device that enables terminal 12 to communicate with one or more other computing terminals (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 22. Furthermore, terminal 12 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with other modules of terminal 12 via bus 18. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with terminal 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0097] The processing unit 16 executes various functional applications and data processing by running programs stored in the memory 28, such as implementing the method for determining the reserved structure provided in the embodiments of the present invention.
[0098] Example Five
[0099] The example five of the present application also provides a storage medium containing computer executable instructions, which when executed by a computer processor, are used to perform the method for determining the pre-reserved structure as provided by any of the above examples.
[0100] The computer storage medium of the present application can employ any combination of one or more computer readable medium or media. The computer readable medium can be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium can be, for example, but 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 (a non-exhaustive list) of the computer readable storage medium include an electrical connection having 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. In the present document, a computer readable storage medium can be any tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device.
[0101] A computer readable signal medium can include a propagated data signal with computer readable program code embodied therein, for use by or in connection with an instruction execution system, apparatus, or device. Examples of a computer readable signal medium include but are not limited to electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a propagating wire, cable, or other communication medium that can be used to carry or transport a program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable medium discussed herein also can be titled a computer readable storage medium.
[0102] Program code embodied on a computer readable medium can be transmitted using any appropriate medium, including but not limited to wireless, wire line, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0103] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0104] It is to be understood that the above description is merely a preferred embodiment of the application and the applied technical principles. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, modifications and substitutions can be made without departing from the scope of the present application. Therefore, although the present application has been described in detail through the above embodiments, the present application is not limited to the above embodiments, and can include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.
Claims
1. A method of determining a reservation structure, characterized by, The application comprises the following steps: a first abstract syntax tree is created for the original version, and a first set is obtained by extracting structures from the original version of the concerned device driver source code and the corresponding kernel header file by using the first abstract syntax tree; a second abstract syntax tree is created for the new version, and a second set is obtained by extracting structures from the new version of the concerned device driver source code and the corresponding kernel header file by using the second abstract syntax tree; a difference set is obtained by using the first set and the second set, which comprises the following steps: different structures are determined according to the name and corresponding attributes of each structure, wherein the structures include structures with different names and structures with the same name but one or more different attributes; an application binary interface description file is generated based on the function interface whitelist of the original version; structures are read from the application binary interface description file to form a whitelist adapted structure set; structures that need to be reserved are determined according to the difference set and the whitelist adapted structure set; 2. The method of claim 1, wherein, for each structure that needs to be reserved, a plug-in structure is created, and an association between the two is established. The application binary interface description file is generated based on the function interface whitelist of the original version, which comprises the following steps: interfaces are extracted from the function interface whitelist of the original version; 3. The method of claim 2, wherein, the application binary interface description file is generated based on the kernel binary file and the kernel debugging information file of the original version. The structures are read from the application binary interface description file to form a whitelist adapted structure set, which comprises the following steps: structure nodes are located in the application binary interface description file, and sub-structures are recursively parsed; 4. The method of claim 1, wherein, attributes of the structures are extracted to form the whitelist adapted structure set. The first set is obtained, which comprises the following steps: for each extracted structure, a corresponding MD5 value is generated based on the name, member quantity and type of the structure, and the first set is generated by removing duplicate structures according to the MD5 value. Correspondingly, the second set is obtained, which comprises the following steps:
5. The method of claim 4, wherein, for each extracted structure, a corresponding MD5 value is generated based on the name, member quantity and type of the structure, and the second set is generated by removing duplicate structures according to the MD5 value. The difference set is obtained by using the first set and the second set, which comprises the following steps:
6. The method of claim 5, wherein, different elements in the first set and the second set are determined, and the difference set is obtained based on the different elements. The structures that need to be reserved are determined according to the difference set and the whitelist adapted structure set, which comprises the following steps:
7. A determination apparatus of a reservation structure, characterized by, the intersection of the difference set and the whitelist adapted structure set is calculated, and each element in the intersection is taken as a structure that needs to be reserved. The application comprises the following steps: a first abstract syntax tree is created for the original version, and a first set is obtained by extracting structures from the original version of the concerned device driver source code and the corresponding kernel header file by using the first abstract syntax tree; a second abstract syntax tree is created for the new version, and a second set is obtained by extracting structures from the new version of the concerned device driver source code and the corresponding kernel header file by using the second abstract syntax tree; The difference set obtaining module is configured to obtain a difference set by using the first set and the second set, and determine different structure bodies in the two sets according to the names and corresponding attributes of each structure body, wherein the different structure bodies include structure bodies with different names and structure bodies with the same name but one or more different attributes; The generating module is configured to generate the application binary interface description file based on the function interface whitelist of the original version; The reading module is configured to read the structure bodies from the application binary interface description file to form a whitelist adaptation structure body set; The determining module is configured to determine the structure bodies that need to be reserved according to the difference set and the whitelist adaptation structure body set; The creating module is configured to correspondingly create an external structure body for each reserved structure body, and establish an association relationship between the two.
8. A terminal, characterized by comprising: Comprise: One or more processors; Storage device, for storing one or more programs, When the one or more programs are executed by the plurality of processors, the plurality of processors implement the determination method of the reserved structure body as claimed in any one of claims 1-6.
9. A storage medium containing computer-executable instructions, wherein: The computer executable instructions when executed by the computer processor are configured to perform the determination method of the reserved structure body as claimed in any one of claims 1-6.
Citation Information
Patent Citations
Static code analysis method and device, electronic equipment, readable storage medium and chip
CN115827437A