A symbol translation method, device, equipment and computer-readable storage medium
By intercepting and replacing the preset entry function, symbol translation is implemented using the value of the link register, which solves the problem of unresolved symbol tables in real machine debugging and Release mode, ensuring that symbol translation can be performed when the application crashes.
Patent Information
- Application Number
- CN202011120493.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-19
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2040-10-19
AI Technical Summary
Existing symbol translation methods cannot implement symbol translation when debugging real machines or using Release mode, because some dSYM files stored on disk in the symbol table cannot be parsed at runtime.
By intercepting the preset entry function, replace it with a new function. Before calling the original system function in the new function, pass in the object pointer, method name and link register, obtain function symbols, and use the value of the link register to achieve symbol translation.
Symbol translation can be implemented when the application crashes, solving the problem that the existing technology cannot implement symbol translation in real machine debugging or Release mode.
Smart Images

Figure CN112232027B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer software, and in particular to a symbol translation method, device, equipment and computer-readable storage medium. Background Art
[0002] Applications, such as mobile terminal App crashes, usually refer to the phenomenon that some unauthorized operations are performed, which triggers the system to throw an exception, but the exception is not handled in time, resulting in the killing of the application. In order to locate the crash exception, it is necessary to obtain the return address of the stack frame, which is hexadecimal memory data and needs to be converted into readable symbols, i.e. symbol translation.
[0003] The existing symbol translation method is to confirm the image file to which the stack address belongs, and then query the symbol name corresponding to the function call address through the symbol table of the image file to complete the symbol translation. However, when debugging on a real machine or using the Release mode of the application, in order to optimize the solution, some symbol tables are stored in the dSYM file on the disk, which cannot be parsed at runtime, so the above existing symbol translation method cannot be executed. Summary of the invention
[0004] The embodiments of the present application provide a symbol translation method, apparatus, device and computer-readable storage medium, so as to realize symbol translation during real machine debugging or when the application uses the Release mode. The technical solution is as follows:
[0005] In one aspect, a symbol translation method is provided, the method comprising:
[0006] When the application calls the first object method through a preset entry function, intercepting the preset entry function;
[0007] Replace the preset entry function with the newly created function;
[0008] Before calling the original system function in the newly created function, calling the first predefined function by passing a pointer to the second object, a second object method name corresponding to the second object, and a current link register to the first predefined function;
[0009] The function symbol corresponding to the first object method is obtained by calling the original system function and the second object method corresponding to the second object and according to the returned value of the link register.
[0010] In one aspect, a symbol translation device is provided, the device comprising:
[0011] An interception module, used for intercepting the preset entry function when the application calls the first object method through the preset entry function;
[0012] A replacement module, used to replace the preset entry function with a newly created function;
[0013] A first calling module is used to call the first predefined function by passing a pointer of a second object, a second object method name corresponding to the second object, and a current link register to the first predefined function before calling the original system function in the newly created function;
[0014] The function symbol acquisition module is used to acquire the function symbol corresponding to the first object method by calling the original system function and the second object method corresponding to the second object and according to the returned value of the link register.
[0015] On the one hand, a computer device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program code is loaded and executed by the one or more processors to implement the operations performed by the symbolic translation method.
[0016] In one aspect, a computer-readable storage medium is provided, which stores a computer program that is loaded and executed by a processor to implement the operations performed by the symbol translation method.
[0017] From the technical solution provided by the present application, it can be seen that since the value of the link register can be mapped to obtain the function symbol by intercepting the preset entry function, and the link register belongs to a storage unit in the memory, which is a dynamically saved value, therefore, compared with the prior art that stores certain symbol tables in dSYM files on the disk and cannot achieve symbol translation when real machine debugging or application using Release mode, the technical solution provided by the present application enables symbol translation to be achieved even when the application crashes. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be 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 creative work.
[0019] Figure 1 It is a schematic diagram of an application scenario of the device for symbol translation provided in an embodiment of the present application;
[0020] Figure 2 is a flowchart of a symbol translation method provided in an embodiment of the present application;
[0021] Figure 3 This is a schematic diagram of a link register-based method stack backtracking provided in an embodiment of the present application;
[0022] Figure 4 is a schematic diagram of the structure of a symbol translation device provided in an embodiment of the present application;
[0023] Figure 5 It is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0025] The embodiments of the present application are introduced based on computer devices as the execution subject. The computer device here can be a server or a terminal, wherein the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms, and the terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The above-mentioned terminal and server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.
[0026] The carrier implemented in the embodiment of the present application is a cloud server, which specifically refers to a server of a hosting technology that unifies a series of resources such as hardware, software, and network in a wide area network or a local area network to realize the calculation, storage, processing, and sharing of data. Among them, cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. applied based on the cloud computing business model, which can form a resource pool and be used on demand, flexibly and conveniently. Cloud technology requires a large amount of computing and storage resources, such as video websites, picture websites, and more portal websites. With the high development and application of the Internet industry, each item has its own identification mark, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately, and all kinds of industry data require a strong system backing, which is achieved through cloud computing.
[0027] As mentioned earlier, cloud technology requires a large amount of data resources and computing power based on a large amount of data resources, which inevitably involves big data and artificial intelligence cloud services as a supporting foundation. Big data refers to data sets that cannot be captured, managed and processed by conventional software tools within a certain time frame. It is a massive, high-growth and diversified information asset that requires new processing models to have stronger decision-making power, insight discovery and process optimization capabilities. With the advent of the cloud technology era, big data has also attracted more and more attention. Big data requires special technologies to effectively process large amounts of data within a tolerable time. Technologies suitable for big data include massively parallel processing databases, data mining, distributed file systems, distributed databases, cloud computing platforms, the Internet and scalable storage systems.
[0028] On the other hand, artificial intelligence (AI) combined with the above-mentioned big data and / or cloud technology has produced artificial intelligence cloud services, namely AIaaS (AI as a Service). AIaaS is currently a mainstream service mode of an artificial intelligence platform. Specifically, the AIaaS platform splits several common AI services and provides independent or packaged services in the cloud. AI is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science. It attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. In addition, AI is to study the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making. It involves a wide range of fields, including both hardware-level technology and software-level technology. Among them, the software-level technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning. AIaaS is similar to opening an AI theme mall: all developers can access and use one or more artificial intelligence services provided by the platform through the API interface. Some senior developers can also use the AI framework and AI infrastructure provided by the platform to deploy and operate their own cloud artificial intelligence services.
[0029] See also Figure 1 , Figure 1Schematic diagram of application scenarios of the device for symbol translation provided by the embodiment of the present application. The system may include at least one terminal 1000, at least one server 2000, at least one database 3000, and a network 4000. The terminal 1000 held by the user can be connected to different servers through the network 4000. The terminal 1000 is any device with computing hardware that can support and execute the corresponding product. In addition, the terminal 1000 has one or more multi-touch screens for sensing and obtaining the input of the user through the touch or sliding operation performed at multiple points of one or more touch-sensitive display screens. In addition, when the system includes multiple terminals 1000, multiple servers 2000, and multiple networks 4000, different terminals 1000 can be connected to each other through different networks 4000 and different servers 2000. The network 4000 can be a wireless network or a wired network, such as a wireless network for a wireless local area network (WLAN), a local area network (LAN), a cellular network, a 2G network, a 3G network, a 4G network, a 5G network, etc. In addition, different terminals 1000 can also use their own Bluetooth network or hotspot network to connect to other terminals or to servers, etc. For example, multiple users can be online through different terminals 1000 and thus connected and synchronized with each other through appropriate networks to support multiple users to operate simultaneously. In addition, the system may include multiple databases 3000, multiple databases 3000 are coupled to different servers 2000, and relevant information can be continuously stored in the databases 3000 when different users operate online.
[0030] The existing symbol translation method is to first confirm the image file to which the stack address belongs, and then, through the symbol table of the image file, query the symbol name corresponding to the function call address to complete the symbol translation. However, when debugging on a real machine or using the Release mode, in order to optimize the solution, some symbol tables are stored in the dSYM file on the disk, which cannot be parsed at runtime, and thus the above existing symbol translation method cannot be executed. In view of this, the present application provides a symbol translation method to solve the problem of how to achieve symbol translation when debugging on a real machine or using the Release mode. See Figure 2 , is a symbol translation method provided in an embodiment of the present application, the method mainly includes the following steps S201 to S204, which are described in detail as follows:
[0031] Step S201: When an application calls a first object method through a preset entry function, the preset entry function is intercepted.
[0032] The technical solution of the present application can be illustrated by taking the Apple operating system iOS as an example. Objective-C, which is used in application development based on the iOS system, is a dynamic language that provides class definitions, methods and properties. All of its method calls are converted into calls to functions of the objc_msgSend series after being processed by the compiler, that is, all method calls are attributed to a unified entry. Therefore, in an embodiment of the present application, the preset entry function may be objc_msgSend. When an application calls any object method through the preset entry function objc_msgSend, the preset entry function may be intercepted by a hook function, wherein the hook function executes the set function before the system or third-party function is called by jumping or modifying the function table, or replaces the preset entry function by rebinding the binary dynamic symbol address. Assume that the Demo class is defined, and its instantiated objects include A and B, and the object methods corresponding to object A and object B are A.test-a() and B.test-b(), respectively. In the following description, object A is referred to as the first object, and its corresponding object method A.test-a() is referred to as the first object method, object B is referred to as the second object, and its corresponding object method B.test-a() is referred to as the second object method. When the application calls the first object method A.test-a() through the preset entry function, the preset entry function objc_msgSend is intercepted.
[0033] Step S202: Replace the preset entry function with the newly created function.
[0034] In the embodiment of the present invention, after the preset entry function is captured by the hook function described above, the entire program process to be called by the preset entry function is suspended in the system, and the preset entry function is replaced by a newly created function, wherein the newly created function is a custom implementation of new_objc_msgSend, and the hook function can be completed by rebinding the binary dynamic symbol address. In this way, each call of the object method will enter the implementation of new_objc_msgSend.
[0035] Step S203: before calling the original system function in the newly created function, calling the first predefined function by passing the pointer of the second object, the second object method name corresponding to the second object and the current link register to the first predefined function.
[0036] In the embodiment of the present application, the first predefined function is called in the newly created function, and is called by the newly created function before the original system function. Generally speaking, the purpose of using a hook to "hook" a preset function (for example, the original system function objc_msgSend in the above embodiment) is to record the context information of the method. For example, to measure the time of a slow function, its method name, class, upper-level calling method, and history stack are required, or the recording and processing of some events can be customized. In the embodiment of the present application, this can be achieved by customizing a function, namely the first predefined function pre_objc_msgSend. The pseudo code is as follows:
[0037] A.test-a(){
[0038] …
[0039] new_objc_msgSend(){
[0040] …
[0041] pre_objc_msgSend(id self,SEL_cmd,uintptr_t lr){}
[0042] …
[0043] objc_msgSend(){}
[0044] …
[0045] }
[0046] }.
[0047] In the above-mentioned first predefined function pre_objc_msgSend, the parameters self, SEL_cmd and lr respectively represent the pointer of the second object, the second object method name corresponding to the second object and the current link register.
[0048] As mentioned above, the first predefined function pre_objc_msgSend is used to implement the customized recording and processing of some events before calling the original system function objc_msgSend. In the embodiment of the present application, in addition to knowing the first object method name corresponding to the first function symbol, it is also necessary to obtain the second object method name corresponding to the second function symbol. This can be achieved in the first predefined function after calling the first predefined function, that is, in the first predefined function, the identifier of the second object and the second object method name are combined into a second function symbol, and the correspondence between the value of the link register and the second function symbol is saved.
[0049] In the above process of calling the first predefined function, the context may be recorded by calling a save function before calling the first predefined function, and the context may be restored by calling a load function after calling the first predefined function.
[0050] Step S204: by calling the original system function and the second object method corresponding to the second object, and according to the value of the returned link register, the function symbol corresponding to the first object method is obtained.
[0051] Since the calling of the first object method and the second object method is arbitrary, that is, the first object method is any method called by the application, and the second object method is any method called by the first object method, therefore, when the application crashes, finding the function symbols corresponding to the calling and called methods is the first step to locate the problem. In iOS, any method calling another method will be attributed to the calling and being called of the original system function objc_msgSend.
[0052] As an embodiment of the present application, by calling the original system function and the second object method corresponding to the second object, and according to the value of the returned link register, obtaining the function symbol corresponding to the first object method can be: by calling the second object method, the value of the returned link register is obtained, and the value of the returned register is mapped to the function symbol corresponding to the first method object, wherein the value of the returned link register is the address of the next instruction to be executed after the second object method is called. It should be noted here that iOS is an OS real machine written using ARM64 assembly. ARM64 has 32 general registers with a length of 64 bits: x0~x30 and sp, and only 32 bits of them can be used: w0~w30, among which the first 8 registers x0~x7 are used to pass parameters when calling a function. At the same time, the x0 register can also be used as a register for the function return value. The x8 register is used for indirect addressing (when the content returned by the function is greater than 16Bytes, the returned content will be placed in the memory, and then the memory address will be stored in the x8 register). The meanings of several special registers are explained as follows:
[0053] sp register: points to the top of the current stack frame (low address), and can allocate or release memory space for the stack by moving the position of sp;
[0054] Register x29: usually used as the fp register, pointing to the bottom of the current stack frame (high address);
[0055] Register x30: Usually used as a link register (lr), which is mainly used to save the return address of a subroutine, or when an exception occurs, to save the return address of the exception;
[0056] PC is the program counter: it points to the next instruction.
[0057] It should be noted that the value of the link register (lr) is the address of the next instruction to be executed after calling an object method. In other words, lr always points to the address of the upper method returned at the end of the method call. For example, there is a calling relationship between three methods A, B and C, where A calls B and B calls C. The method stack backtracking is shown in the attached figure. Figure 3 As shown. Figure 3 It can be seen that after the call of method B is completed, the link register pair it returns points to the link register of method A.
[0058] As mentioned above, since the value of the returned link register is the address of the next instruction to be executed after the call to the second object method is completed, the returned register value is mapped to the function symbol corresponding to the first method object. Specifically, after the application crashes, a sequential list of lr will be obtained through the system API, and the returned register value is used to match the entire sequential list of lr. In the entire sequential list of lr, if an lr is matched, the function symbol corresponding to the previous address of the lr is the function symbol corresponding to the first method object.
[0059] In one embodiment of the present application, the value of the link register returned by calling the second object method may be obtained by: calling the original system function, calling the second object method in the original system function, and returning the value of the link register.
[0060] As mentioned above, the link register (lr) is mainly used to save the return address of the subroutine, or when an exception occurs, it is used to save the return address of the exception. In other words, the link register records the return address when the function call is completed. However, after multiple calls to other methods, it is unknown whether the value of the link register is correct. Therefore, at the end of the new function new_objc_msgSend method, the value of the link register needs to be restored, that is, after calling the original system function in the new function, call the second predefined function to restore the value of the link register.
[0061] Similar to the fact that the context can be recorded and restored when the first predefined function is called, in an embodiment of the present application, in the above-mentioned calling process of the second predefined function, the context can be recorded by calling a save function before calling the second predefined function, and the context can be restored by calling a load function after calling the second predefined function.
[0062] From the above attached Figure 1It can be seen from the technical solution of the example that the function symbol can be obtained by mapping the value of the link register through intercepting the preset entry function, and the link register belongs to a storage unit in the memory, which is a dynamically saved value. Therefore, compared with the prior art that stores certain symbol tables in dSYM files on the disk during real machine debugging or application using Release mode and cannot achieve symbol translation, the technical solution provided by the present application enables symbol translation to be achieved even when the application crashes.
[0063] Please see attached Figure 4 , is a schematic diagram of the structure of a symbol translation device provided in an embodiment of the present application, the device can be integrated in a computer device such as a terminal, the device includes an interception module 401, a replacement module 402, a first calling module 403 and a function symbol acquisition module 404, wherein:
[0064] The interception module 401 is used to intercept the preset entry function when the application calls the first object method through the preset entry function;
[0065] A replacement module 402, used to replace the preset entry function with a newly created function;
[0066] The first calling module 403 is used to call the first predefined function by passing the pointer of the second object, the second object method name corresponding to the second object and the current link register to the first predefined function before calling the original system function in the newly created function;
[0067] The function symbol acquisition module 404 is used to acquire the function symbol corresponding to the first object method by calling the original system function and the second object method corresponding to the second object and according to the value of the returned link register.
[0068] In a possible implementation, the function symbol acquisition module 404 may further include a subject first calling unit unit and a mapping unit, wherein:
[0069] A first calling unit, configured to obtain the returned value of the link register by calling the second object method, wherein the returned value of the link register is the address of the next instruction to be executed after the calling of the second object method is completed;
[0070] A mapping unit is used to map the returned register value to a function symbol corresponding to the first method object.
[0071] In a possible implementation, the first calling unit in the above embodiment may further include a second calling unit, a third calling unit and a returning unit, wherein:
[0072] The second calling unit is used to call the original system function;
[0073] A third calling unit is used to call the second object method in the original system function;
[0074] Return unit, used to return the value of the link register.
[0075] The above-mentioned Figure 4 The exemplary apparatus may further include a combining module and a saving module, wherein:
[0076] A combining module, used for combining the identifier of the second object and the method name of the second object into a second function symbol in the first predefined function;
[0077] The storage module is used to store the corresponding relationship between the value of the link register and the second function symbol.
[0078] In one possible implementation, Figure 4 The exemplary apparatus may further include a second calling module, configured to call a second predefined function after calling the original system function in the newly created function to restore the value of the link register.
[0079] In one possible implementation, Figure 4 The exemplary apparatus may further include a third calling module and a fourth calling module, wherein:
[0080] A third calling module is used to record the context by calling the saved function before calling the second predefined function;
[0081] The fourth calling module is used to restore the context by calling the loading function after calling the second predefined function.
[0082] In one possible implementation, Figure 4 The exemplary apparatus may further include a fifth calling module and a sixth calling module, wherein:
[0083] A fifth calling module, used for recording a context by calling a saved function before calling the first predefined function;
[0084] The sixth calling module is used to restore the context by calling the loading function after calling the first predefined function.
[0085] It should be noted that the symbol translation device provided in the above embodiment only uses the division of the above functional modules as an example when extracting text keywords. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the symbol translation device and the symbol translation method embodiment provided in the above embodiment belong to the same concept. The specific implementation process and technical effects are detailed in the method embodiment, which will not be repeated here.
[0086] The present application also provides a computer device, which may be a terminal or a server. Figure 5 As shown, it shows a schematic diagram of the structure of the computer device involved in the embodiment of the present application, specifically:
[0087] The computer device may include one or more processing core processors 501, one or more computer-readable storage media memories 502, a power supply 503, an input unit 504 and other components. Those skilled in the art will appreciate that Figure 5 The computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:
[0088] The processor 501 is the control center of the computer device. It uses various interfaces and lines to connect various parts of the entire computer device. By running or executing software programs and / or modules stored in the memory 502 and calling data stored in the memory 502, it executes various functions of the computer device and processes data, thereby performing overall detection of the computer device. Optionally, the processor 501 may include one or more processing cores; preferably, the processor 501 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 501.
[0089] The memory 502 can be used to store software programs and modules. The processor 501 executes various functional applications and data processing by running the software programs and modules stored in the memory 502. The memory 502 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 502 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 502 may also include a memory controller to provide the processor 501 with access to the memory 502.
[0090] The computer device also includes a power supply 503 for supplying power to various components. Optionally, the power supply 503 can be logically connected to the processor 501 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 503 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.
[0091] The computer device may further include an input unit 504, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0092] Although not shown, the computer device may also include a display unit, etc., which will not be described in detail here. Specifically in this embodiment, the processor 501 in the computer device will load the executable file corresponding to the process of one or more applications into the memory 502 according to the following instructions, and the processor 501 will run the application stored in the memory 502, so as to realize various functions, as follows: when the application calls the first object method through the preset entry function, intercept the preset entry function; replace the preset entry function with a newly created function; before calling the original system function in the newly created function, call the first predefined function by passing the pointer of the second object, the second object method name corresponding to the second object, and the current link register to the first predefined function; by calling the original system function and the second object method corresponding to the second object, and according to the value of the returned link register, obtain the function symbol corresponding to the first object method.
[0093] The specific implementation of the above operation can refer to the previous implementation, which will not be described again here.
[0094] From the above, it can be seen that since the value of the link register can be mapped to obtain the function symbol by intercepting the preset entry function, and the link register belongs to a storage unit in the memory, it is a dynamically saved value. Therefore, compared with the prior art that stores certain symbol tables in dSYM files on the disk and cannot realize symbol translation when real machine debugging or application using Release mode, the technical solution provided by the present application enables symbol translation to be realized even when the application crashes.
[0095] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0096] To this end, an embodiment of the present application provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any one of the symbol translation methods provided in the embodiment of the present application. For example, the instruction can execute the following steps: when an application calls a first object method through a preset entry function, intercept the preset entry function; replace the preset entry function with a newly created function; before calling the original system function in the newly created function, call the first predefined function by passing a pointer to the second object, a second object method name corresponding to the second object, and a current link register to the first predefined function; obtain the function symbol corresponding to the first object method by calling the original system function and the second object method corresponding to the second object, and according to the value of the returned link register.
[0097] The specific implementation of each of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0098] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0099] Since the instructions stored in the computer-readable storage medium can execute the steps in any symbol translation method provided in the embodiments of the present application, the beneficial effects that can be achieved by any symbol translation method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0100] The above is a detailed introduction to a symbol translation method, device, equipment and computer-readable storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A symbol translation method, characterized in that: The method comprises: When the application calls the first object method through a preset entry function, intercepting the preset entry function; Replace the preset entry function with the newly created function; Before calling the original system function in the newly created function, calling the first predefined function by passing a pointer to the second object, a second object method name corresponding to the second object, and a current link register to the first predefined function; By calling the original system function and the second object method corresponding to the second object, and according to the returned value of the link register, obtaining the function symbol corresponding to the first object method; According to the returned value of the link register, obtaining the function symbol corresponding to the first object method, including: matching the value of the link register with a predetermined link register sequence list, and using the function symbol corresponding to the previous address of the matched link register as the function symbol corresponding to the first object method, wherein the predetermined link register sequence list is obtained through a system API; After calling the first predefined function, the method further includes: In the first predefined function, the identifier of the second object and the method name of the second object are combined into a second function symbol; The correspondence between the value of the link register and the second function symbol is saved.
2. The symbol translation method according to claim 1, characterized in that: The method of calling the original system function and the second object method corresponding to the second object and acquiring the function symbol corresponding to the first object method according to the returned value of the link register includes: By calling the second object method, the value of the link register is obtained, and the value of the link register is returned, wherein the value of the link register is the address of the next instruction to be executed after the calling of the second object method is completed; The returned link register value is mapped to a function symbol corresponding to the first object method.
3. The symbol translation method as claimed in claim 2, characterized in that: The step of obtaining the returned value of the link register by calling the second object method comprises: Calling the original system function; Calling the second object method in the original system function; Returns the value of the link register.
4. The symbol translation method according to any one of claims 1 to 3, characterized in that: The method further comprises: After calling the original system function in the newly created function, the second predefined function is called to restore the value of the link register.
5. The symbol translation method as claimed in claim 4, characterized in that: The method further comprises: Before calling the second predefined function, recording the context by calling a saving function; After calling the second predefined function, the context is restored by calling the load function.
6. The symbol translation method according to any one of claims 1 to 3, characterized in that: The method further comprises: Before calling the first predefined function, recording the context by calling a saving function; After calling the first predefined function, the context is restored by calling a load function.
7. A symbol translation device, characterized in that: The device comprises: An interception module, used for intercepting the preset entry function when the application calls the first object method through the preset entry function; A replacement module, used to replace the preset entry function with a newly created function; A first calling module is used to call the first predefined function by passing a pointer of a second object, a second object method name corresponding to the second object, and a current link register to the first predefined function before calling the original system function in the newly created function; A function symbol acquisition module, used for acquiring the function symbol corresponding to the first object method by calling the original system function and the second object method corresponding to the second object and according to the returned value of the link register; According to the returned value of the link register, obtaining the function symbol corresponding to the first object method, including: matching the value of the link register with a predetermined link register sequence list, and using the function symbol corresponding to the previous address of the matched link register as the function symbol corresponding to the first object method, wherein the predetermined link register sequence list is obtained through a system API; After calling the first predefined function, the method further includes: In the first predefined function, the identifier of the second object and the method name of the second object are combined into a second function symbol; The correspondence between the value of the link register and the second function symbol is saved.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
