An operating system updating method, device, equipment and storage medium
By pre-embedding no-operation instructions in the real-time operating system and replacing them with patch jump instructions, an incremental patching scheme is generated, which solves the problem that traditional real-time operating system updates require a shutdown and restart. This enables operating system kernel patching without a restart, reducing costs and risks, and is suitable for MCU devices with smaller Flash/RAM.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI LIXIANG AUTOMOBILE CO LTD
- Filing Date
- 2024-12-26
- Publication Date
- 2026-06-26
AI Technical Summary
Traditional real-time operating system updates require system shutdown and restart, resulting in high risk for mission-critical systems, poor user experience, and limited patching frequency. Existing redundant system solutions are costly and have high switching risks, making them unsuitable for resource-constrained embedded systems.
An incremental patching scheme is adopted, which replaces no-operation instructions with patch jump instructions in the operating system image to generate an operating system update method, device, equipment and storage medium.
It enables operating system kernel patching without rebooting, reducing downtime and cost. It is suitable for MCU devices with small Flash/RAM and embedded systems.
Smart Images

Figure CN122285031A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and specifically to a method, apparatus, device, and storage medium for updating an operating system. Background Technology
[0002] A Real-Time Operating System (RTOS) is an operating system designed for real-time computing applications that can handle data and events with strictly defined time constraints.
[0003] In traditional real-time operating systems, patching the operating system kernel typically requires a system shutdown, with the new kernel version loaded upon system restart. The process involves downloading the patch, applying it to the operating system, and then rebooting the device. Because the operating system must be stopped to update, all running processes must be interrupted, which poses significant risks and losses, especially in mission-critical systems. In end-user services, such as vehicle control and intelligent driving MCU (Microcontroller Unit) systems, downtime renders the system unusable, impacting business continuity and user experience. Furthermore, the overhead of rebooting and the complexity of the operation limit the frequency of patch application, potentially forcing the system to operate with vulnerabilities for extended periods, increasing security risks. Summary of the Invention
[0004] In view of this, embodiments of this application provide an operating system update method, apparatus, device, and storage medium to achieve operating system kernel patching without restarting.
[0005] To address the above problems, the technical solutions provided in this application are as follows:
[0006] In a first aspect, embodiments of this application provide a method for updating an operating system, the method comprising:
[0007] When executing the target function in the operating system image, read the jump address corresponding to the target function;
[0008] Read the target value corresponding to the jump address of the target function in the jump address table;
[0009] If the target value is empty, continue executing the target function;
[0010] If the target value is the address of the patch function, execute the patch function in the space corresponding to the address of the patch function in the patch function partition.
[0011] In one possible implementation, the method further includes:
[0012] In response to the operating system's update command, obtain the patch function and the address of the patch function for the function to be updated in the operating system image;
[0013] Write the address of the patch function of the function to be updated into the first target space of the jump address table, where the first target space is the space corresponding to the jump address of the function to be updated;
[0014] The patch function of the function to be updated is written into the second target space in the patch function partition, where the second target space is the space corresponding to the address of the patch function of the function to be updated.
[0015] In one possible implementation, the method further includes:
[0016] When the patch function partition space is full, an update failure message is triggered.
[0017] In one possible implementation, the method further includes, before executing the target function in the operating system image:
[0018] Obtain the operating system image and jump address table;
[0019] The operating system image is stored in flash memory or random access memory, and the jump address table is stored in the random access memory.
[0020] In one possible implementation, the process of generating the operating system image includes:
[0021] Obtain the initial operating system image; embed no-operation instructions for each objective function in the initial operating system image;
[0022] The operating system image is generated by modifying the no-operation instructions of each objective function in the initial operating system image into patch jump instructions using a script.
[0023] In one possible implementation, the patch jump instruction is used to achieve:
[0024] Read the jump address of the target function containing the patch jump instruction from the jump address table;
[0025] Read the value corresponding to the jump address of the target function where the patch jump instruction is located;
[0026] Determine if the value is null. If it is, jump to the target function where the patch jump instruction is located and execute. If not, jump to the space corresponding to the value in the patch function partition and execute.
[0027] In one possible implementation, the jump address table includes the jump addresses of each objective function in the operating system image and the corresponding values for each objective function's jump address. The jump addresses of each objective function in the operating system image are pre-allocated, and the initial values corresponding to the jump addresses of each objective function in the operating system image in the jump address table are null values.
[0028] Secondly, embodiments of this application provide an operating system update apparatus, the apparatus comprising:
[0029] The first reading unit is used to read the jump address corresponding to the target function when executing the target function in the operating system image;
[0030] The second reading unit is used to read the target value corresponding to the jump address of the target function in the jump address table;
[0031] The first execution unit is configured to continue executing the target function if the target value is null.
[0032] The second execution unit is used to execute the patch function in the space corresponding to the patch function address in the patch function partition if the target value is the patch function address.
[0033] Thirdly, embodiments of this application provide an operating system update device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it implements the operating system update method as described in any of the preceding claims.
[0034] Fourthly, embodiments of this application provide a computer-readable storage medium, characterized in that the computer-readable storage medium stores instructions that, when executed on a terminal device, cause the terminal device to perform an operating system update method as described in any of the preceding claims.
[0035] Therefore, the embodiments of this application have the following beneficial effects:
[0036] In this embodiment, when the operating system image executes the target function, the jump address corresponding to the target function is read. The jump address table contains the space corresponding to the jump address of the target function. When the target function needs to be updated, the address of the patch function can be written into this space. The target value corresponding to the jump address of the target function in the jump address table is read. If the target value is not empty, then the target value is the address of the patch function. The updated patch function in the space corresponding to the patch function address in the patch function partition can be executed without executing the original target function. In this way, certain functions in the operating system kernel can be dynamically replaced with corresponding patch functions, achieving operating system kernel patching without a reboot. Attached Figure Description
[0037] Figure 1 A schematic diagram illustrating an exemplary application scenario provided in this application embodiment;
[0038] Figure 2 This is a schematic diagram illustrating the replacement of the nop instruction with a patch jump instruction in an embodiment of this application;
[0039] Figure 3 A flowchart illustrating an operating system update method provided in this application embodiment;
[0040] Figure 4 This is a schematic diagram illustrating the execution of a patch jump instruction in an embodiment of this application;
[0041] Figure 5 This is a schematic diagram of an operating system update device provided in an embodiment of this application. Detailed Implementation
[0042] To make the above-mentioned objectives, features and advantages of the embodiments of this application more apparent and understandable, the embodiments of this application will be further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0043] To facilitate understanding and explanation of the technical solutions provided in the embodiments of this application, the background technology of the embodiments of this application will be described first below.
[0044] RTOS differs from time-sharing operating systems (such as Unix), which manage system resources and share schedulers, data buffers, or fixed task priorities in a multitasking or multiprogramming environment. All operations in an RTOS must be verifiable within given time and resource constraints; otherwise, safety cannot be guaranteed. RTOS is typically used on hardware devices with limited resources.
[0045] Traditional real-time operating systems (RTOS) require a reboot-based update method. This means patching the operating system kernel typically requires system downtime, with the new kernel version loaded upon system reboot. The process involves downloading the patch, applying it to the operating system, and then restarting the device. However, this method has several drawbacks: 1. Long downtime: The operating system must be stopped for updates. This means all running processes must be interrupted, which can pose significant risks and losses, especially in mission-critical systems. 2. Poor user experience: In end-user services (e.g., vehicle control, intelligent driving MCU systems), downtime prevents users from using the operating system, impacting business continuity and user experience. 3. Limited patching frequency: Due to the overhead and complexity of rebooting, the frequency of patch application is limited. The operating system may have to run for longer periods with vulnerabilities, increasing security risks.
[0046] In existing technologies, redundant systems can be used to address the technical challenges of system downtime and restarts required for operating system updates. Specifically, this is achieved through dual-system (Active / Standby) or multi-system redundancy (Cluster). For example, while one operating system is being patched, another redundant operating system continues to run and provide services. After the update is complete, the system can switch to the new operating system. However, this approach has drawbacks: 1. High hardware and cost overhead: It requires multiple sets of hardware and more resources, significantly increasing costs, especially in large-scale deployments. 2. Switching risks: The operating system switching process may still result in service interruptions or data inconsistencies. 3. Unsuitable for embedded systems: Many embedded devices or resource-constrained systems cannot support redundant designs, making this method impractical.
[0047] Based on this, embodiments of this application provide an operating system update method, apparatus, device, and storage medium, which is an incremental patching scheme based on a real-time operating system. The loading and application process of this incremental patching scheme does not require modification of the original operating system image code and data partitions, and can simultaneously support differential images with multiple patches, thereby providing more software patching mechanism options for scenarios such as OTA (Over-the-Air) upgrades and ELF (Executable and Linkable Format) dynamic loading.
[0048] To facilitate understanding of the operating system update method provided in the embodiments of this application, the following is combined with... Figure 1 The example scenario is shown below. See also... Figure 1 As shown in the figure, this figure is a schematic diagram of an exemplary application scenario provided in the embodiments of this application.
[0049] To avoid incremental modifications to the original operating system image after it has been burned to the device, this application embodiment requires two stages to implement the incremental patching function in order to update the operating system.
[0050] The first stage requires generating an operating system image. In practical applications, no-op instructions (NOP instructions) can be pre-embedded in various functions of the initial operating system image. Then, a script can process the initial operating system, replacing the pre-embedded NOP instructions with patch jump instructions to generate the operating system image. The generated operating system image is then uploaded to a server for distribution to various user devices.
[0051] In the second stage, the operating system image is downloaded and burned to the user device. Before the operating system starts, a pre-allocated jump address table needs to be copied into the user device's RAM (Random Access Memory). The user device can then execute the operating system image to start the operating system. After the operating system starts, the jump address table is loaded, which includes the jump addresses and corresponding values of each function in the operating system image.
[0052] When executing a target function in the operating system image, the jump address corresponding to the target function is read, and the target value corresponding to the jump address of the target function is read from the jump address table. If the target value is not empty, it is the address of the patch function, and the patch function corresponding to the address of the patch function in the patch function partition is executed.
[0053] Those skilled in the art will understand that Figure 1 The schematic diagram shown is merely one example in which embodiments of this application can be implemented. The scope of application of the embodiments of this application is not limited by any aspect of this framework.
[0054] To facilitate understanding of the embodiments of this application, the following description, in conjunction with the accompanying drawings, illustrates an operating system update method provided by the embodiments of this application.
[0055] To facilitate subsequent explanations, the process of generating an operating system image will first be described. In one possible implementation, the process of generating an operating system image includes:
[0056] A1: Obtain the initial operating system image; embed no-operation instructions for each target function in the initial operating system image.
[0057] An operating system image contains multiple functions. First, no-op instructions (nop) are pre-embedded for each target function in the initial operating system image that has the potential to be updated. In practice, this can be achieved by executing the `-fpatchable-function-entry` compilation option to pre-embed function entry point nop instructions in the initial image. For example, the code for function 1 is shown below; in the initial operating system image, code 10000000... <func1>This means that function 1 starts at position 10000000. After the beginning of this function, N lines of nop instructions are added, where N can be set according to the actual situation. For example, in function 1, 6 lines of nop instructions are added first (bf00 nop at positions 10000000-1000000a). After the nop instructions, the original content of function 1 (starting at position 1000000c) is added:
[0058] 10000000 <func1>
[0059] 10000000:bf00 nop
[0060] 10000002:bf00 nop
[0061] 10000004:bf00 nop
[0062] 10000006:bf00 nop
[0063] 10000008:bf00 nop
[0064] 1000000a:bf00 nop
[0065] 1000000c:b508 push{r3,lr}
[0066] 1000000e:4802ldr r0,[pc,#8]
[0067] ...
[0068] Similarly, the same nop instruction is pre-embedded for each target function in the initial operating system image that has the potential to be updated.
[0069] A2: Use a script to modify the no-operation instructions of each objective function in the initial operating system image into patch jump instructions to generate the operating system image.
[0070] Then, a script is used to replace the pre-embedded nop instructions in the initial operating system image with patch jump instructions. See also Figure 2 The diagram illustrates the replacement of nop instructions with patch jump instructions. The reserved nop instruction portion in each objective function is replaced with a set of instructions, which are patch jump instructions.
[0071] By pre-embedding the nop instruction in the initial operating system image, a script can be used to replace the pre-embedded nop with patch jump instructions, thus enabling the rapid generation of the operating system image.
[0072] In one possible implementation, the patch jump instruction performs the following functions:
[0073] Read the jump address of the target function where the patch jump instruction is located in the jump address table; read the value corresponding to the jump address of the target function where the patch jump instruction is located; determine whether the value is null. If it is, jump to the space corresponding to the patch jump instruction in the target function where the patch jump instruction is located and execute. If not, jump to the space corresponding to the value in the patch function partition and execute.
[0074] After the `nop` instruction replaces a function, it reserves instructions for all patched functions. Once the operating system is running normally, a null pointer check is performed on the jump addresses of the functions in the jump address table. The addresses of the patched functions are updated in the jump address table after the patch functions are created. This allows for dynamic replacement of certain functions in the operating system kernel using patch functions, enabling kernel patching without a reboot. In one possible implementation, the jump address table includes the jump addresses of each target function in the operating system image and the corresponding values. The jump addresses of each target function in the operating system image are pre-allocated, and the initial values corresponding to the jump addresses of each target function in the jump address table are null.
[0075] Along with generating the operating system image, a jump address table corresponding to the operating system image also needs to be generated. This table includes preset jump addresses for each target function in the operating system image, along with the corresponding values. Initially, all jump addresses in the table have empty values (0). The values corresponding to the jump addresses correspond to the patch function addresses in the patch function partition. The jump address table allows for quick lookup of the patch function addresses corresponding to the target functions.
[0076] See also Figure 2 As shown, for example, in the patch jump instruction corresponding to function 1 (func1), mov.wr3,#536870912; 0x20000000 means reading the jump address 0x20000000 from the jump address table into register r3. Jump address 0x20000000 is a jump address pre-allocated for function 1, that is, reading the jump address of function 1 where the patch jump instruction is located. ldr r4,[r3,#0] means loading the value corresponding to the jump address in register r3 into register r4, that is, reading the value corresponding to the jump address of function 1 where the patch jump instruction is located. The initial values corresponding to the jump addresses are all 0. cbz r4,1000000c<func1+0x12> This means that if the value of register r4 is 0, the content starting from 1000000c will be executed, that is, the part of the original function after the patch jump instruction will continue to be executed. Otherwise, the jump will be executed to the value corresponding to the jump address in register r3, that is, the corresponding patch function in the patch function partition will be executed.
[0077] After generating the operating system image and jump address table, the operating system image and jump address table of this version need to be distributed to each user device through a server. The operating system update method provided in this application embodiment can be applied to user devices. In one possible implementation, the operating system update method provided in this application embodiment may further include:
[0078] Obtain the operating system image and jump address table;
[0079] The operating system image is stored in Flash or RAM, and the jump address table is stored in RAM.
[0080] After the user equipment obtains the operating system image and jump address table, the operating system image can be stored in Flash. After the operating system image boots, it can be executed based on XIP (Extended-In-Place) or loaded into RAM for execution. XIP is a technology that allows execution in-place without moving the program from Flash to memory. XIP doesn't mean the program runs directly in Flash; rather, it allows the CPU to fetch instructions directly from Flash, just like fetching from memory. Program execution still occurs within the CPU; XIP simply treats Flash as read-only memory. Before booting the operating system image, the jump address table must be loaded into RAM.
[0081] Based on the above explanation, see Figure 3 As shown, this figure is a flowchart of an operating system update method provided in an embodiment of this application. Figure 3 As shown, the method may include S301-S304:
[0082] S301: When executing the target function in the operating system image, read the jump address corresponding to the target function.
[0083] After the operating system image boots, each function in the operating system image is executed sequentially. When executing a specific target function, the patch jump instruction within the target function is executed first. The jump address corresponding to the target function is read through the patch jump instruction.
[0084] S302: Read the target value corresponding to the jump address of the target function in the jump address table.
[0085] The target value corresponding to the jump address of the target function can be read from the jump address table. See also... Figure 4 The diagram illustrates the execution of a patch jump instruction. For example, if the target function is function 1 (func1), the jump address in the Hook Table is 0x20000000. The target value corresponding to jump address 0x20000000 can be 0, or it can be the address of the patch function.
[0086] S303: If the target value is null, continue executing the target function.
[0087] If the target value is empty, it means that the target function has not been updated. In this case, the patch jump instruction is skipped and the original content of the target function is continued to be executed. For example, the content starting from 1000000c is continued to be executed.
[0088] S304: If the target value is the address of the patch function, execute the patch function in the space corresponding to the address of the patch function in the patch function partition.
[0089] If the target value is not null, it means the target function has been updated. The updated target function is the patch function, stored in the Patched Section. This non-null value is the address of the patch function, which is the address of the patch function corresponding to the target function stored in the Patched Section. For example, if the target value is 0x1f000000, the system will jump to the Patched Section and execute the code starting at address 0x1f000000, thus updating the target function.
[0090] In this embodiment, when the operating system image executes the target function, the jump address corresponding to the target function is read. The jump address table contains the space corresponding to the jump address of the target function. When the target function needs to be updated, the address of the patch function can be written into this space. The target value corresponding to the jump address of the target function in the jump address table is read. If the target value is not empty, then the target value is the address of the patch function. The updated patch function in the space corresponding to the patch function address in the patch function partition can be executed without executing the original target function. In this way, certain functions in the operating system kernel can be dynamically replaced with corresponding patch functions, achieving operating system kernel patching without a reboot.
[0091] One possible implementation may also include:
[0092] B1: In response to the operating system's update command, obtain the patch function and the address of the function to be updated in the operating system image.
[0093] B2: Write the address of the patch function of the function to be updated into the first target space in the jump address table. The first target space is the space corresponding to the jump address of the function to be updated.
[0094] B3: Write the patch function of the function to be updated into the second target space in the patch function partition. The second target space is the space corresponding to the address of the patch function of the function to be updated.
[0095] Based on the above explanation, when the operating system needs to be updated, the patch function and its address are obtained from the distributed operating system image. The jump address of the function to be updated is retrieved from the jump address table, and the patch function address is written into the first target space corresponding to that jump address in the jump address table. Then, the patch function is written into the second target space corresponding to that patch function address in the patch function partition. For example, based on... Figure 4 For example, the function to be updated is function 1 (func1), the address of the patch function is 0x1f000000, the jump address in the jump address table is 0x20000000, and 0x1f000000 is written at the jump address 0x20000000 in the jump address table. Then, the corresponding patch function is written to the space corresponding to 0x1f000000 in the patch function partition (the space starting at 0x1f000000).
[0096] Unlike traditional OTA and dynamic loading solutions, the incremental patch function in this application only has a differential size and does not require dynamic parsing or incremental updates to the original operating system image code. The entire repair process is fast, and it consumes minimal Flash and RAM space. This application's embodiment can directly replace the patch function while the system is running, without affecting the operating system.
[0097] Alternatively, one possible implementation could include triggering an update failure message when the patch function's partition space is full.
[0098] When the number of updates for each objective function is large and the patch function partition space is full, an update failure message can be displayed to promptly indicate the update failure. In this case, after the overall operating system image is updated, the operating system image and jump address table can be retrieved again before executing the operating system update method provided in this embodiment.
[0099] Based on the above description, the software incremental patching scheme based on a real-time operating system in this application solves the technical problems existing in the prior art and can have the following beneficial effects:
[0100] (1) No downtime patching: Incremental patches achieve operating system kernel patching without restarting by dynamically replacing operating system kernel functions, which significantly reduces downtime.
[0101] (2) Smaller size: The incremental patching scheme only applies the corresponding patch functions that need to be replaced. Compared with the traditional differential upgrade and AB partition upgrade schemes, the incremental patching scheme has the advantage of smaller code size, which is suitable for MCU devices with smaller Flash / Ram.
[0102] (3) High security: The operating system kernel supports signature verification and security checks for patch functions, ensuring that only certified patch functions can be applied, thus preventing malicious attacks.
[0103] (4) No impact on running tasks: When the patch function is applied, the operating system kernel guarantees the atomicity of the update process to avoid inconsistent states. In other words, the operating system's tasks will not be affected during the update process.
[0104] (5) Wide applicability: Incremental patching functions can be applied to most real-time operating systems and embedded systems.
[0105] Based on the operating system update method provided in the above-described method embodiments, this application also provides an operating system update apparatus, which will be described below with reference to the accompanying drawings.
[0106] See Figure 5 As shown in the figure, this figure is a structural schematic diagram of an operating system update device provided in an embodiment of this application.
[0107] like Figure 5 As shown, the operating system update device includes:
[0108] The first reading unit 501 is used to read the jump address corresponding to the target function when executing the target function in the operating system image;
[0109] The second reading unit 502 is used to read the target value corresponding to the jump address of the target function in the jump address table;
[0110] The first execution unit 503 is configured to continue executing the target function if the target value is null.
[0111] The second execution unit 504 is used to execute the patch function in the space corresponding to the patch function address in the patch function partition if the target value is the patch function address.
[0112] In one possible implementation, the device further includes:
[0113] The first acquisition unit is used to obtain the patch function and the address of the function to be updated in the operating system image in response to the operating system's update command.
[0114] The first writing unit is used to write the address of the patch function of the function to be updated into the first target space of the jump address table, wherein the first target space is the space corresponding to the jump address of the function to be updated;
[0115] The second writing unit is used to write the patch function of the function to be updated into the second target space in the patch function partition, where the second target space is the space corresponding to the address of the patch function of the function to be updated.
[0116] In one possible implementation, the device further includes:
[0117] The prompting unit is used to trigger an update failure prompt message when the patch function partition space is full.
[0118] In one possible implementation, the device further includes:
[0119] The second acquisition unit is used to acquire the operating system image and the jump address table;
[0120] The storage unit is used to store the operating system image in flash memory or random access memory, and to store the jump address table in the random access memory.
[0121] In one possible implementation, the process of generating the operating system image includes:
[0122] Obtain the initial operating system image; embed no-operation instructions for each objective function in the initial operating system image;
[0123] The operating system image is generated by modifying the no-operation instructions of each objective function in the initial operating system image into patch jump instructions using a script.
[0124] In one possible implementation, the patch jump instruction is used to achieve:
[0125] Read the jump address of the target function containing the patch jump instruction from the jump address table;
[0126] Read the value corresponding to the jump address of the target function where the patch jump instruction is located;
[0127] Determine if the value is null. If it is, jump to the target function where the patch jump instruction is located and execute. If not, jump to the space corresponding to the value in the patch function partition and execute.
[0128] In one possible implementation, the jump address table includes the jump addresses of each objective function in the operating system image and the corresponding values for each objective function's jump address. The jump addresses of each objective function in the operating system image are pre-allocated, and the initial values corresponding to the jump addresses of each objective function in the operating system image in the jump address table are null values.
[0129] In addition, embodiments of this application also provide an operating system update device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it implements the operating system update method as described in any of the above claims.
[0130] This application also provides a computer-readable storage medium storing instructions that, when executed on a terminal device, cause the terminal device to perform an operating system update method as described in any of the preceding embodiments.
[0131] This application also provides a computer program product, including computer program instructions that, when executed on a computer, cause the computer to perform an operating system update method as described in any of the preceding embodiments.
[0132] In this embodiment, when the operating system image executes the target function, the jump address corresponding to the target function is read. The jump address table contains the space corresponding to the jump address of the target function. When the target function needs to be updated, the address of the patch function can be written into this space. The target value corresponding to the jump address of the target function in the jump address table is read. If the target value is not empty, then the target value is the address of the patch function. The updated patch function in the space corresponding to the patch function address in the patch function partition can be executed without executing the original target function. In this way, certain functions in the operating system kernel can be dynamically replaced with corresponding patch functions, achieving operating system kernel patching without a reboot.
[0133] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems or apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and relevant parts can be referred to the method section.
[0134] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0135] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0136] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0137] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for updating an operating system, characterized in that, The method includes: When executing the target function in the operating system image, read the jump address corresponding to the target function; Read the target value corresponding to the jump address of the target function in the jump address table; If the target value is empty, continue executing the target function; If the target value is the address of the patch function, execute the patch function in the space corresponding to the address of the patch function in the patch function partition.
2. The method according to claim 1, characterized in that, The method further includes: In response to the operating system's update command, obtain the patch function and the address of the patch function for the function to be updated in the operating system image; Write the address of the patch function of the function to be updated into the first target space of the jump address table, where the first target space is the space corresponding to the jump address of the function to be updated; The patch function of the function to be updated is written into the second target space in the patch function partition, where the second target space is the space corresponding to the address of the patch function of the function to be updated.
3. The method according to claim 2, characterized in that, The method further includes: When the patch function partition space is full, an update failure message is triggered.
4. The method according to claim 1, characterized in that, Before executing the target function in the operating system image, the method further includes: Obtain the operating system image and jump address table; The operating system image is stored in flash memory or random access memory, and the jump address table is stored in the random access memory.
5. The method according to any one of claims 1-4, characterized in that, The process of generating the operating system image includes: Obtain the initial operating system image; embed no-operation instructions for each objective function in the initial operating system image; The operating system image is generated by modifying the no-operation instructions of each objective function in the initial operating system image into patch jump instructions using a script.
6. The method according to claim 5, characterized in that, The patch jump instruction is used to achieve: Read the jump address of the target function containing the patch jump instruction from the jump address table; Read the value corresponding to the jump address of the target function where the patch jump instruction is located; Determine if the value is null. If it is, jump to the target function where the patch jump instruction is located and execute. If not, jump to the space corresponding to the value in the patch function partition and execute.
7. The method according to any one of claims 1-4, characterized in that, The jump address table includes the jump addresses of each objective function in the operating system image and the corresponding values of each objective function's jump address. The jump addresses of each objective function in the operating system image are pre-allocated, and the initial values corresponding to the jump addresses of each objective function in the operating system image in the jump address table are null values.
8. An operating system update device, characterized in that, The device includes: The first reading unit is used to read the jump address corresponding to the target function when executing the target function in the operating system image; The second reading unit is used to read the target value corresponding to the jump address of the target function in the jump address table; The first execution unit is configured to continue executing the target function if the target value is null. The second execution unit is used to execute the patch function in the space corresponding to the patch function address in the patch function partition if the target value is the patch function address.
9. An operating system update device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the method for updating the operating system as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a terminal device, cause the terminal device to perform the operating system update method as described in any one of claims 1-7.