WO2015018302A1 - 一种热补丁方法及设备 - Google Patents
一种热补丁方法及设备 Download PDFInfo
- Publication number
- WO2015018302A1 WO2015018302A1 PCT/CN2014/083616 CN2014083616W WO2015018302A1 WO 2015018302 A1 WO2015018302 A1 WO 2015018302A1 CN 2014083616 W CN2014083616 W CN 2014083616W WO 2015018302 A1 WO2015018302 A1 WO 2015018302A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- instruction
- function
- jump
- custom
- instruction sequence
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 35
- 238000012545 processing Methods 0.000 claims abstract description 19
- 238000004891 communication Methods 0.000 abstract description 7
- 230000007246 mechanism Effects 0.000 abstract description 2
- 230000006870 function Effects 0.000 description 57
- 230000008569 process Effects 0.000 description 10
- 238000005516 engineering process Methods 0.000 description 7
- 230000003111 delayed effect Effects 0.000 description 3
- 238000010586 diagram Methods 0.000 description 3
- 238000003780 insertion Methods 0.000 description 2
- 230000037431 insertion Effects 0.000 description 2
- 230000009471 action Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 230000001934 delay Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000009191 jumping Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000011022 operating instruction Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000008439 repair process Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
- G06F8/656—Updates while running
Definitions
- the present invention relates to the field of communications, and in particular, to a hot patch method and device. Background technique
- Hot patch technology is a technology that can complete product software defect repair without interrupting business operations.
- Jump instructions commonly used in hot patches have short jump instructions, short jump instructions can complete jump operations, but short jump instruction jumps can span space storage locations less than 32 megabytes, with short jumps Relatively long jump instructions, long jump instructions need to use the register to assist the jump action, long jump instructions require multiple instructions to complete.
- the replacement of the instruction refers to replacing the instruction at the beginning of the function with the jump instruction and jumping to the patch area.
- the replacement of the instruction is followed by the operating system and the CPU. ( Central Processing Unit) The architecture of the central processing unit is closely related.
- PowerPC A single-core processor that simplifies the instruction set computer microprocessor architecture. When performing hot patch processing under such hardware conditions, it is not necessary to consider the difference between concurrency and different software and hardware architectures.
- operating systems such as LINUX have begun to be applied more.
- Processors have also evolved from single core to multi-core, including MIPS (Microprocessor without Interlocked Pipeline Stages), reduced instruction set processor architecture, X86, etc. Multiple instruction set architectures.
- MIPS Microprocessor without Interlocked Pipeline Stages
- X86 Reduce instruction set processor architecture
- hot patch processing faces the problem of multiple operating systems, multiple hardware system architectures, and concurrent processing of a large number of tasks. Summary of the invention
- the purpose of the embodiments of the present invention is to provide a hot patching method, which is to solve the problem that the existing technical solution cannot provide a unified hot patch solution under various processor architectures and different operating systems.
- the present invention provides a hot patch method, the method comprising:
- the inserting the custom instruction sequence into the function by the extension compiler includes:
- the custom instruction sequence is inserted at the function header.
- the custom instruction sequence includes:
- the modifying the short jump instruction includes:
- the present invention provides a hot patch device, the device comprising:
- a compiler extension unit for extending the compiler
- a hot patch unit configured to: when performing hot patch processing, first modify a long jump instruction of the custom instruction sequence, point the long jump instruction to a patch area of the jump, and then modify the short jump instruction to make the The short jump instruction points to the modified long jump instruction.
- the compiling unit inserting the custom instruction sequence includes:
- the custom instruction sequence is inserted at the function header.
- the custom instruction sequence inserted by the coding unit includes:
- modifying the short jump instruction includes modifying
- a custom instruction sequence is inserted into a function by an extension compiler to implement a general hot patch mechanism of a software and hardware architecture, and is also compatible with the existing mature jump island hot patch method, and It can effectively control the existence of concurrent processing.
- FIG. 1 is a flowchart of a hot patch method according to Embodiment 1 of the present invention
- 2 is a flowchart of a hot patching method according to Embodiment 2 of the present invention
- FIG. 3 is a structural block diagram of a hot patching apparatus according to Embodiment 3 of the present invention
- a structural diagram of a hot patch device A structural diagram of a hot patch device. detailed description
- Embodiment 1 is a diagrammatic representation of Embodiment 1:
- a hot patch method provided in Embodiment 1 of the present invention is as follows:
- the insertion of the custom instruction sequence can be flexibly defined according to the needs of the application scenario, such as: automatically inserting the customization immediately before the function header
- the instruction sequence can be specifically inserted into the custom instruction sequence by compiling the foo function by the extended compiler, and inserting a long jump instruction before the function header:
- foo-opt.S is a custom inserted custom instruction sequence, where the instructions to be inserted are as follows: L.lisr rll,0 assigns the upper 16 bits of the rll register
- the inserted custom instruction sequence is before the function header, that is, before the fifth instruction. Normally, the first four instructions are not executed during the function operation.
- the modified first and second instructions constitute a long jump instruction pointing to the patch area of the jump, and finally the first instruction of the modified function header is a short jump instruction. Jump to a custom long jump instruction, where the short jump instruction is set outside the custom instruction sequence in the function.
- the fifth instruction is directed to the first instruction, and then the long jump instruction in the custom instruction sequence is executed.
- the above embodiment is based on the function inserting a custom instruction sequence immediately before the function header.
- the hot patch since the hot patch operation is always performed in one thread, even if the concurrent situation occurs, the process will only be delayed.
- Implementation in this case, modifying a single instruction one by one to ensure its atomicity, independent of system concurrency, and because the inserted custom instruction sequence will not be executed during normal operation, only the short jump instruction is modified at the end. In the case of the case, it will jump to the custom instruction sequence, and finally jump to the patch area through the custom instruction sequence, thus solving the problem of the atomicity of the hot patch for the system concurrently, because the hot patch can be expanded by the extended compiler.
- Processor architectures such as PPC, MIPS, X86, etc. can also be performed on different operating systems such as linux and vxworks, thus providing a unified hot patching technology. Solution. And can achieve compatibility with the original mature jump island hot patch method.
- Embodiment 2 is a diagrammatic representation of Embodiment 1:
- a hot patch method provided in Embodiment 2 of the present invention is as follows:
- the custom instruction sequence inserted into the function is inserted into the custom instruction sequence at the function header, and the foo function is compiled and inserted into the custom instruction sequence by the extended compiler. Insert a long jump instruction at the function header:
- the inserted custom instruction sequence is in the function header, that is, the first six instructions. Under normal circumstances, the first instruction jumps to the seventh instruction, so the subsequent five instructions are not executed. Empty instructions, such as the second and sixth instructions, can also be inserted into the inserted custom instruction sequence.
- the first instruction that modifies the function header is a short jump instruction, which jumps to the long jump instruction area in the custom instruction.
- the short jump instruction is set in the custom instruction sequence in the function.
- the first instruction is directed to the third instruction, and then the long jump instruction in the custom instruction sequence is executed, and finally jumps to the patch area.
- the above embodiment is based on the function inserting a custom instruction sequence in the immediate function function.
- the hot patch since the hot patch operation is always performed in one thread, even if the concurrent situation occurs, the implementation of the process is delayed. In this case, modifying a single instruction one by one can guarantee its atomicity, and is not interfered by the system concurrently.
- the inserted custom instruction sequence will not be executed during normal operation, only the short jump instruction is modified at the end. In this case, it will jump to the custom instruction sequence, and finally jump to the patch area through the custom instruction sequence, thus solving the problem of the atomicity of the hot patch for the system concurrently, because the hot patch can be performed in various ways by expanding the compiler.
- Processor architectures such as PPC, MIPS, X86, etc. can also be performed on different operating systems such as linux and vxworks, thus providing a unified hot patch technology solution. And can achieve compatibility with the original mature jump island hot patch method.
- Embodiment 3 is a diagrammatic representation of Embodiment 3
- a hot patch device provided in Embodiment 3 of the present invention is described in detail as follows:
- a compiler extension unit 31 is configured to expand a compiler and add a compile option.
- the compiler extension unit extends the compiler to add extended compilation options to the compiler. New compilation options for compiled functions after compiling the extended compiler.
- the compiling unit 32 is configured to insert a custom instruction sequence into the function by the new compile option of the extended compiler when compiling.
- the new instruction sequence inserted by the compiler is a custom instruction sequence inserted into the function, and the insertion of the custom instruction sequence can be flexibly defined according to the needs of the application scenario. Insert a custom instruction sequence immediately before the function header; or insert a custom instruction sequence at the function header.
- the inserted custom instruction sequence specifically includes: a null instruction or a long jump instruction.
- the hot patch unit 33 is configured to: when performing the hot patch processing, first modify the long jump instruction of the custom instruction sequence, so that the long jump instruction points to the patch area of the jump, and then modify the short jump instruction to make the short The jump instruction points to the modified long jump instruction.
- the hot patch unit modifies the short jump instruction to make the short jump instruction point to the modified short jump instruction.
- the short jump instruction includes: setting a short jump instruction in the custom instruction sequence in the function; or setting in A short jump instruction outside the custom instruction sequence in the function.
- the hot patch device of the above embodiment inserts a custom instruction sequence based on a function.
- the hot patch device can modify the single instruction one by one to ensure its atomicity, and is not interfered by the hot patch device system concurrently.
- the hot patch through the extended compiler can be carried out on a variety of processor architectures such as: PPC, MIPS, X86, etc., can also be carried out on different operating systems such as: linux, vxworks, so Provide a unified hot patch technology solution. And can achieve compatibility with the original mature jump island hot patch method.
- Embodiment 4 is a diagrammatic representation of Embodiment 4:
- FIG. 4 A structural diagram of a hot patch device provided in Embodiment 3 of the present invention is as shown in FIG. 4, and is as follows:
- Hot patch devices include:
- a processor (English: rocessor) 41, a communication interface (Communications Interface) 42, a memory 43 (memory) 43, a bus 44.
- the processor 41, the communication interface 42, and the memory 43 complete communication with each other via the bus 44.
- a communication interface 42 configured to communicate with a routing processing server;
- the processor 41 is configured to execute a program.
- the program can include program code, the program code including computer operating instructions.
- the processor 41 may be a central processing unit (English: central processing unit), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the invention.
- the memory 43 is used to store a program.
- the memory 43 may be a volatile memory (English: volatile memory), such as random access memory (English: random-access memory, abbreviation: RAM), or non-volatile memory (English: non-volatile memory), for example only Read memory (English: read-only memory, abbreviation: ROM), flash memory (English: flash memory), hard disk (English: hard disk drive, abbreviation: HDD) or solid state drive (English: solid-state drive, abbreviation: SSD).
- the processor 41 executes the following methods based on the program instructions stored in the memory 43:
- the hot patch device of the above embodiment performs the hot patch operation by the processor, and stores the data information of the hot patch operation through the memory.
- the processor performing the hot patch operation is always performed in one thread during execution. At this time, even if the concurrent situation only delays the implementation of this process, in this case, the processor of the hot patch device can modify the single instruction one by one to ensure its atomicity, which is not interfered by the hot patch device processor, and Insert
- the short jump instruction When the short jump instruction is modified, it will jump to the long jump instruction of the custom instruction sequence, and finally jump to the patch area by the long jump instruction in the custom instruction sequence, thereby solving the concurrency for the processor.
- the hot patch atomic problem it can be implemented under a variety of processor architectures such as: PPC, MIPS, X86, etc., also on different operating system platforms such as: linux, vxworks This is done, so a unified hot patch technology solution can be provided. And can achieve compatibility with the original mature jump island hot patch method.
- the functions, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium.
- the technical solution of the present invention which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including
- the instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention.
- the foregoing storage medium includes: a USB flash drive, a removable hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and the like.
- the medium of the code is only the preferred embodiment of the present invention, and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection of the present invention. Within the scope.
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
Abstract
一种热补丁方法及设备,属于通信领域,该方法包括:对编译器进行扩展,新增编译选项;当进行编译时,通过扩展编译器的所述新增编译选项为函数插入自定义指令序列;当进行热补丁处理时,先修改所述自定义指令序列的长跳转指令,使长跳转指令指向跳转的补丁区,之后修改短跳转指令使所述短跳转指令指向修改后的所述长跳转指令。提供的技术方案通过扩展编译器对函数插桩自定义指令序列,以实现软、硬件架构通用的热补丁机制,同时也与现有成熟的跳转岛热补丁方式实现兼容,并能对存在并发处理情况进行有效的控制。
Description
一种热补丁方法及设备 本申请要求于 2013年 08月 05 日提交中国专利局、 申请号为 CN 201310337461.3、 发明名称为 "一种热补丁方法及设备" 的中国专利申请 的优先权, 其全部内容通过引用结合在本申请中。
技术领域 本发明实施例属于通信领域, 尤其涉及一种热补丁方法及设备。 背景技术
热补丁技术是一种能够在不中断业务运行的情况下, 完成产品软件缺 陷修复的技术。 在热补丁中常用的跳转指令有短跳转指令, 短跳转指令一 条指令能够完成跳转动作, 但是短跳转指令跳转的可跨越空间存储位置小 于 32兆字节, 与短跳转相对的有 长跳转指令, 长跳转指令需要借助寄存 器辅助完成跳转动作, 长跳转指令需要多条指令来完成。
由于热补丁的实现需要进行指令的替换, 指令的替换是指将位于函数 开头的指令替换成跳转指令, 跳转到补丁区, 而在具体的指令替换中, 指 令的替换跟操作系统、 CPU ( Central Processing Unit ) 中央处理器的体系 结构强密切相关。
早期的设备主要选型 VXWORKS嵌入式实时操作系统, PPC
( PowerPC )精简指令集计算机微处理器架构的单核处理器。 在这种硬件 条件下进行热补丁处理时, 不需要过多的考虑并发性及不同软、 硬件架构 带来的差异。 然而随着软、硬件技术的发展, LINUX等操作系统更多的开 始应用, 处理器也从单核发展到多核, 同时包含如 MIPS ( Microprocessor without Interlocked Pipeline Stages )精简指令集处理器架构、 X86等多种指 令集架构。 这时候, 热补丁处理面临多操作系统、 多硬件系统架构、 大量 任务并发处理的问题。
发明内容
本发明实施例的目的在于提供一种热补丁方法, 旨在解决现有的技术 方案在多种处理器架构、 不同操作系统情况下无法提供统一的热补丁解决 方案的问题。
第一方面, 本发明提供了一种热补丁方法, 所述方法包括:
对编译器进行扩展, 新增编译选项;
当进行编译时, 通过扩展编译器的新增编译选项为函数插入自定义指 令序列;
当进行热补丁处理时, 先修改自定义指令序列的长跳转指令, 使长跳 转指令指向跳转的补丁区, 之后修改短跳转指令使短跳转指令指向修改后 的长跳转指令。
在第一方面的第一种实现方式中, 所述通过扩展编译器为函数插入自 定义指令序列包括:
在紧临所述函数头部之前插入自定义指令序列; 或
在所述函数头部插入所述自定义指令序列。
结合第一方面, 在第一方面的第二种实现方式中, 所述自定义指令序 列包括:
空指令或所述长跳转指令。
结合第一方面, 在第一方面的第三种实现方式中, 所述修改短跳转指 令包括:
修改在所述函数中所述自定义指令序列内的短跳转指令; 或
修改在所述函数中所述自定义指令序列外的短跳转指令。
第二方面, 本发明提供了一种热补丁设备, 所述设备包括:
编译器扩展单元, 用于对编译器进行扩展;
编译单元, 用于当进行编译时, 通过扩展的所述编译器为函数插入自
定义指令序列;
热补丁单元, 用于当进行热补丁处理时, 先修改所述自定义指令序列 的长跳转指令, 使所述长跳转指令指向跳转的补丁区, 之后修改短跳转指 令使所述短跳转指令指向修改后的所述长跳转指令。
在第二方面的第一种实现方式中, 所述编译单元插入自定义指令序列 包括:
在紧临所述函数头部之前插入所述自定义指令序列; 或
在所述函数头部插入所述自定义指令序列。
结合第二方面, 在第二方面的第二种实现方式中, 所述编译单元插入 的自定义指令序列包括:
空指令或所述长跳转指令。
结合第二方面, 在第二方面的第三种实现方式中, 修改短跳转指令具 体包括修改;
修改在所述函数中自定义指令序列内的短跳转指令; 或
修改在所述函数中自定义指令序列外的短跳转指令。
在本发明提供的技术方案中, 通过扩展编译器对函数插入自定义指令 序列, 以实现软、 硬件架构通用的热补丁机制, 同时也与现有成熟的跳转 岛热补丁方式实现兼容, 并能对存在并发处理情况进行有效的控制。
附图说明
为了更清楚地说明本发明实施例的技术方案, 下面将对实施例或现有 技术描述中所需要使用的附图作简单地介绍, 显而易见地, 下面描述中的 附图是本发明的一些实施例, 对于本领域普通技术人员来讲, 在不付出创 造性劳动的前提下, 还可以根据这些附图获得其他的附图。
图 1是本发明实施例一提供的一种热补丁方法的流程图;
图 2是本发明实施例二提供的一种热补丁方法的流程图; 图 3是本发明实施例三提供的一种热补丁设备的结构框图; 图 4是本发明实施例四提供的一种热补丁设备的结构图。 具体实施方式
为了使本发明的目的、 技术方案及优点更加清楚明白, 以下结合附图 及实施例, 对本发明进行进一步详细说明。 应当理解, 此处所描述的具体 实施例仅仅用以解释本发明, 并不用于限定本发明。
实施例一:
本发明实施例一提供的一种热补丁方法, 如图 1所示, 详述如下:
5101 , 对编译器进行扩展, 新增编译选项。
对编译器进行扩展, 为编译器增加扩展的编译选项。 如: gcc -02 -c foo.c -ffunc— entry— insns=function— entry.S , 其中 ffunc— entry— insns为编 译器扩展后新增的编译选项,其中 function— entry. S为自定义插入的汇编指 令, 汇编指令既不控制机器的操作也不被汇编成机器代码, 只能为汇编程 序所识别并指导汇编如何进行。
5102 , 当进行编译时, 通过扩展编译器的所述新增编译选项为函数插 入自定义指令序列。
具体实施过程中通过扩展编译器的新增编译选项为函数插入的自定 义指令序列, 插入自定义指令序列可以根据应用场景的需要灵活进行定 义, 如: 在紧临函数头部之前自动插入自定义指令序列, 具体的可以为通 过扩展的编译器对 foo函数进行编译插入自定义指令序列, 在函数头之前 插入一段长跳转指令:
gcc -02 -c foo.c -ffunc— entry— insns=foo— opt. S
其中 foo— opt.S为自定义插入的自定义指令序列, 其中需要插入的指 令如下:
l.lis rll,0 给 rll寄存器的高 16位赋值
2.ori rll,rll,0 给 rll寄存器的低 16位赋值
3. mtctr rll 把 rll寄存器的值赋值给 ctr寄存器
4. bctr 根据 ctr寄存器的值跳转到指定地 址执行
对 foo函数编译后的指令如下:
l.lis rll,0
2.ori rll,rll,0
3. mtctr rll
4. bctr
5. stwu rl,-160(rl) foo 函数入口
6. mflr rO
7. bcl- 20,4*cr7
8. li r4,0
需要说明的是, 插入的自定义指令序列在函数头之前, 即第 5条指令 之前, 正常情况下函数运行中插入前 4条指令是不进行执行的。
S103, 当进行热补丁处理时, 先修改所述自定义指令序列的长跳转指 令, 使所述长跳转指令指向跳转的补丁区, 之后修改短跳转指令使所述短 跳转指令指向修改后的所述长跳转指令。
在具体的实施过程中即可以先短跳转到自定义指令序列中再通过自 定义指令序列中的长跳转指令进行跳转, 具体如下:
进行热补丁时, 先修改自定义指令序列中的前两条指令, 让其指向目 的补丁区
l.lis rll, 19068
2.ori rll,rl 1,40960
3. mtctr rll
4. bctr
5. stwu rl,-160(rl) foo 函数入口
6. mflr rO
7. bcl- 20,4*cr7
8. li r4,0
此时已将函数前两条指令进行修改, 修改后的第一条和第二条指令构 成长跳转指令指向跳转的补丁区, 最后修改函数头的第一条指令为短跳转 指令, 跳转到自定义的长跳转指令, 此时短跳转指令设置在函数中自定义 指令序列外。
l . lis rl l, 19068
2. ori rl l,rl 1,40960
3. mtctr rl l
4. bctr
5. b 1 foo函数入口, 跳转到第 1条指令执行
6. mflr r0
7. bcl- 20,4*cr7
8. li r4,0
通过修改第五跳指令为短跳转指令, 使第五条指令指向第一条指令, 然后执行自定义指令序列中的长跳转指令。
上述实施例基于函数在紧临函数头部之前插入自定义指令序列, 在进 行热补丁时, 由于进行热补丁操作始终是在一个线程中进行, 此时即使出 现并发情况只是会延后此进程的实施, 这种情况下逐个对单条指令进行修 改可以保证其原子性, 不受系统并发的干扰, 同时由于插入的自定义指令 序列在正常运行时不会执行, 只有在最后修改了短跳转指令的情况下才会 跳转到自定义指令序列, 最终通过自定义指令序列跳转到补丁区, 从而解 决了对于系统并发下热补丁原子性的难题, 由于通过扩展编译器进行热补 丁能够在多种处理器架构如: PPC、 MIPS , X86等上进行, 也可以在不同 操作系统上如: linux、 vxworks进行, 因此可以提供一种统一的热补丁技
术解决方案。 并能实现与原有成熟的跳转岛热补丁方式的兼容。
实施例二:
本发明实施例二提供的一种热补丁方法, 如图 2所示, 详述如下:
5201 , 对编译器进行扩展, 新增编译选项。
对编译器进行扩展, 为编译器增加扩展的编译选项。 如: gcc -02 -c foo.c -ffunc— entry— insns=function— entry.S其中 ffunc— entry— insns为编译 9<- 扩展后新增的编译选项, function— entry . S为自定义的插入的汇编指令。
5202 , 当进行编译时, 通过扩展编译器的所述新增编译选项在函数头 部为函数插入自定义指令序列。
具体实施过程中通过扩展编译器的新增编译选项为函数插入的自定 义指令序列, 插入自定义指令序列在函数头部, 具体的通过扩展的编译器 对 foo函数进行编译插入自定义指令序列, 在函数头部插入一段长跳转指 令:
gcc -02 -c foo.c -ffunc— entry— insns=foo— opt. S
其中 foo— opt.S为自定义插入的自定义指令序列, 其中需要插入的指 令如下:
1. j 7 函数入口 跳转到第 7条指令执行
2. nop 空指令
3.1ui tl,0 给 tl寄存器赋值
4.1w tl,0(tl) 获取 tl寄存器地址对应的内存数据, 并赋值 给 tl寄存器
5. jalr tl 根据 tl寄存器跳转到指定地址运行
6. nop 空指令
对 foo函数编译后的指令如下:
l .j 7 函数入口
2. nop
3.1ui tl,0
4.1w tl,0(tl)
5. jalr tl
6. nop
7. Lbu tl, 0(al)
需要说明的是, 插入的自定义指令序列在函数头部, 即前六条指令, 正常情况下第一条指令为跳转到第 7条指令执行, 因此后续的五条指令并 不进行执行, 其中在插入的自定义指令序列中还可以插入空指令, 如第二 条和第六条指令。
S203 , 当进行热补丁处理时, 先修改所述自定义指令序列的长跳转指 令, 使所述长跳转指令指向跳转的补丁区, 之后修改短跳转指令使所述短 跳转指令指向修改后的所述长跳转指令。
在具体的实施过程中即可以直接通过自定义指令序列进行长跳转, 具 体如下:
进行热补丁时, 先修改自定义指令序列中的 3、 4条指令, 让其指向 目的补丁区
1 j 7 函数入口
2 nop
3 lui tl,0x6e3
4 lw tl,968(tl)
5 jalr tl
6 nop
7 Lbu tl, 0(al)
最后修改函数头的第一条指令为短跳转指令, 跳转到自定义指令中 的长跳转指令区域, 此时短跳转指令设置在函数中自定义指令序列内。
1 j 3 函数入口
2 nop
3 lui tl,0x6e3
4 lw tl,968(tl)
5 jalr tl
6 nop
7 Lbu tl, 0(al)
通过修改第一跳指令为短跳转指令, 使第一条指令指向第三条指令, 然后执行自定义指令序列中的长跳转指令, 最终跳转到补丁区。
上述实施例基于函数在紧临函数头部插入自定义指令序列, 在进行热 补丁时, 由于进行热补丁操作始终是在一个线程中进行, 此时即使出现并 发情况只是会延后此进程的实施, 这种情况下逐个对单条指令进行修改可 以保证其原子性, 不受系统并发的干扰, 同时由于插入的自定义指令序列 在正常运行时不会执行, 只有在最后修改了短跳转指令的情况下才会跳转 到自定义指令序列, 最终通过自定义指令序列跳转到补丁区, 从而解决了 对于系统并发下热补丁原子性的难题, 由于通过扩展编译器进行热补丁能 够在多种处理器架构如: PPC、 MIPS , X86等上进行, 也可以在不同操作 系统上如: linux、 vxworks进行, 因此可以提供一种统一的热补丁技术解 决方案。 并能实现与原有成熟的跳转岛热补丁方式的兼容。
实施例三:
本发明实施例三提供的一种热补丁设备, 如图 3所示, 详述如下: 编译器扩展单元 31 , 用于对编译器进行扩展, 新增编译选项。
编译器扩展单元对编译器进行扩展, 为编译器增加扩展的编译选项。 使扩展后的编译器进行编译以后对编译的函数新增的编译选项。
编译单元 32 , 用于当进行编译时, 通过扩展编译器的所述新增编译选 项为函数插入自定义指令序列。
具体实施过程中通过编译器的新增编译选项为函数插入的自定义指 令序列, 插入自定义指令序列可以根据应用场景的需要灵活进行定义, 在
紧临函数头部之前插入自定义指令序列; 或在函数头部插入自定义指令序 歹^ 插入的自定义指令序列具体包括: 空指令或长跳转指令。
热补丁单元 33 , 用于当进行热补丁处理时, 先修改所述自定义指令序 列的长跳转指令, 使所述长跳转指令指向跳转的补丁区, 之后修改短跳转 指令使短跳转指令指向修改后的所述长跳转指令。
具体实施过程中热补丁单元修改短跳转指令使短跳转指令指向修改 后的长跳转指令的短跳转指令包括: 设置在函数中自定义指令序列内的短 跳转指令; 或设置在函数中自定义指令序列外的短跳转指令。
上述实施例的热补丁设备基于函数插入自定义指令序列, 在进行热补 丁时, 由于进行热补丁操作始终是在一个线程中进行, 此时即使出现并发 情况只是会延后此进程的实施, 这种情况下热补丁设备逐个对单条指令进 行修改可以保证其原子性, 不受热补丁设备系统并发的干扰, 同时由于插
后修改了短跳转指令的情况下才会跳转到自定义指令序列的长跳转指令 上, 最终通过自定义指令序列中的长跳转指令跳转到补丁区, 从而解决了 对于系统并发下热补丁原子性的难题, 由于通过扩展编译器进行热补丁能 够在多种处理器架构如: PPC、 MIPS , X86等上进行, 也可以在不同操作 系统上如: linux、 vxworks进行, 因此可以提供一种统一的热补丁技术解 决方案。 并能实现与原有成熟的跳转岛热补丁方式的兼容。
实施例四:
本发明实施例三提供的一种热补丁设备的结构图, 如图 4所示, 详述 下:
热补丁设备包括:
处理器 (英文: rocessor)41 , 通信接口 (Communications Interface)42 , 存储器 (memory)43 , 总线 44。
处理器 41 , 通信接口 42 , 存储器 43通过总线 44完成相互间的通信。
通信接口 42 , 用于与路由处理服务器进行通信;
处理器 41 , 用于执行程序。
具体地,程序可以包括程序代码,所述程序代码包括计算机操作指令。 处理器 41可能是一个中央处理器 (英文: central processing unit, 缩 写: CPU ) , 或者是特定集成电路 ASIC ( Application Specific Integrated Circuit ) , 或者是被配置成本发明实施例的一个或多个集成电路。
存储器 43 , 用于存储程序。 存储器 43可以是易失性存储器 (英文: volatile memory ) , 例如随机存取存储器 (英文: random-access memory, 缩写: RAM ) , 或者非易失性存储器 (英文: non-volatile memory ) , 例 如只读存储器(英文: read-only memory, 缩写: ROM ) , 快闪存储器(英 文: flash memory ) , 硬盘 (英文: hard disk drive , 缩写: HDD ) 或固态 硬盘 (英文: solid-state drive , 缩写: SSD ) 。 处理器 41根据存储器 43 存储的程序指令, 执行以下方法:
对编译器进行扩展, 新增编译选项;
当进行编译时, 通过扩展编译器的新增编译选项为函数插入自定义指 令序列;
当进行热补丁处理时, 先修改自定义指令序列的长跳转指令, 使长跳转 指令指向跳转的补丁区, 之后修改短跳转指令使短跳转指令指向修改后的长 跳转指令。
上述实施例的热补丁设备通过处理器执行热补丁操作, 通过存储器存 储热补丁操作的数据信息, 在进行热补丁时, 由于进行热补丁操作的处理 器在执行时始终是在一个线程中进行, 此时即使出现并发情况只是会延后 此进程的实施, 这种情况下热补丁设备的处理器逐个对单条指令进行修改 也可以保证其原子性, 不受热补丁设备处理器并发的干扰, 同时由于插入
修改了短跳转指令的情况下才会跳转到自定义指令序列的长跳转指令上, 最终通过自定义指令序列中的长跳转指令跳转到补丁区, 从而解决了对于 处理器并发下热补丁原子性的难题, 实现了在多种处理器架构下如: PPC、 MIPS , X86等的进行, 也可以在不同操作系统平台如: linux、 vxworks上
进行, 因此可以提供一种统一的热补丁技术解决方案。 并能实现与原有成 熟的跳转岛热补丁方式的兼容。
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或 使用时, 可以存储在一个计算机可读取存储介质中。 基于这样的理解, 本 发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方 案的部分可以以软件产品的形式体现出来, 该计算机软件产品存储在一个 存储介质中, 包括若干指令用以使得一台计算机设备(可以是个人计算机, 服务器, 或者网络设备等)执行本发明各个实施例所述方法的全部或部分 步骤。 而前述的存储介质包括: U盘、 移动硬盘、 只读存储器 (ROM, Read-Only Memory )、 随机存取存 4诸器 ( RAM, Random Access Memory ) 、 磁碟或者光盘等各种可以存储程序代码的介质。 以上所述仅为本发明的较佳实施例而已, 并不用以限制本发明, 凡 在本发明的精神和原则之内所作的任何修改、 等同替换和改进等, 均应 包含在本发明的保护范围之内。
Claims
1、 一种热补丁方法, 其特征在于, 所述方法包括:
对编译器进行扩展, 新增编译选项;
当进行编译时, 通过扩展编译器的所述新增编译选项为函数插入自定 义指令序列;
当进行热补丁处理时, 先修改所述自定义指令序列的长跳转指令, 使 所述长跳转指令指向跳转的补丁区, 之后修改短跳转指令, 使所述短跳转 指令指向修改后的所述长跳转指令。
2、 根据权利要求 1所述的方法, 其特征在于, 所述通过扩展编译器 为函数插入自定义指令序列包括:
在紧临所述函数头部之前插入所述自定义指令序列; 或
在所述函数头部插入所述自定义指令序列。
3、 根据权利要求 1或 2所述的方法, 其特征在于, 所述自定义指令 序列包括:
空指令或所述长跳转指令。
4、 根据权利要求 1至 3任一权利要求所述的方法, 其特征在于, 所 述修改短跳转指令包括:
修改在所述函数中所述自定义指令序列内的短跳转指令; 或 修改在所述函数中自定义指令序列外的短跳转指令。
5、 一种热补丁设备, 其特征在于, 所述设备包括:
编译器扩展单元, 用于对编译器进行扩展, 新增编译选项; 编译单元, 用于当进行编译时, 通过扩展编译器的所述新增编译选项 为函数插入自定义指令序列;
热补丁单元, 用于当进行热补丁处理时, 先修改所述自定义指令序列 的长跳转指令, 使所述长跳转指令指向跳转的补丁区, 之后修改短跳转指 令使所述短跳转指令指向修改后的所述长跳转指令。
6、 根据权利要求 5所述的热补丁设备, 其特征在于, 所述编译单元 为函数插入自定义指令序列包括:
在紧临所述函数头部之前插入所述自定义指令序列; 或
在所述函数头部插入所述自定义指令序列。
7、 根据权利要求 5或 6所述的热补丁设备, 其特征在于, 所述编译 单元插入的自定义指令序列包括:
空指令或所述长跳转指令。
8、 根据权利要求 5至 7任一权利要求所述的热补丁设备, 其特征在 于, 所述修改短跳转指令包括:
修改在所述函数中所述自定义指令序列内的短跳转指令; 或 修改在所述函数中自定义指令序列外的短跳转指令。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2013103374613A CN103399775A (zh) | 2013-08-05 | 2013-08-05 | 一种热补丁方法及设备 |
CN201310337461.3 | 2013-08-05 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2015018302A1 true WO2015018302A1 (zh) | 2015-02-12 |
Family
ID=49563409
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2014/083616 WO2015018302A1 (zh) | 2013-08-05 | 2014-08-04 | 一种热补丁方法及设备 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN103399775A (zh) |
WO (1) | WO2015018302A1 (zh) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104809018A (zh) * | 2015-05-18 | 2015-07-29 | 烽火通信科技股份有限公司 | 一种嵌入式系统软件注入热补丁的方法及系统 |
US20230016250A1 (en) * | 2019-12-13 | 2023-01-19 | Zte Corporation | Method for implementing linux kernel hot patch, electronic device, and computer readable medium |
US12131145B2 (en) * | 2021-09-28 | 2024-10-29 | Hill-Rom Services, Inc. | Systems and methods for peer-to-peer automatic software updates |
Families Citing this family (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103399775A (zh) * | 2013-08-05 | 2013-11-20 | 北京华为数字技术有限公司 | 一种热补丁方法及设备 |
CN103955354B (zh) * | 2014-05-09 | 2017-03-15 | 龙芯中科技术有限公司 | 重定位方法和装置 |
CN104461625A (zh) * | 2014-12-04 | 2015-03-25 | 上海斐讯数据通信技术有限公司 | 一种热补丁实现方法和系统 |
CN105868094A (zh) * | 2015-01-20 | 2016-08-17 | 中兴通讯股份有限公司 | 一种用于mips架构cpu的热补丁的方法和设备 |
CN105138341A (zh) * | 2015-09-24 | 2015-12-09 | 上海斐讯数据通信技术有限公司 | 基于MIPS架构和vxworks系统实现热补丁长跳转的方法 |
CN105630557B (zh) * | 2015-12-24 | 2018-12-28 | 迈普通信技术股份有限公司 | 热补丁方法和装置 |
CN107239309B (zh) * | 2017-06-06 | 2021-03-02 | 网易(杭州)网络有限公司 | 补丁生成方法及装置、更新方法、电子设备、存储介质 |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102156661A (zh) * | 2010-02-11 | 2011-08-17 | 华为技术有限公司 | 在线补丁的激活方法、装置及系统 |
CN102609241A (zh) * | 2012-01-19 | 2012-07-25 | 中兴通讯股份有限公司 | 热补丁方法及装置 |
CN103218262A (zh) * | 2010-02-11 | 2013-07-24 | 华为技术有限公司 | 在线补丁的激活方法、装置及系统 |
CN103399775A (zh) * | 2013-08-05 | 2013-11-20 | 北京华为数字技术有限公司 | 一种热补丁方法及设备 |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN100432931C (zh) * | 2006-12-22 | 2008-11-12 | 中兴通讯股份有限公司 | 嵌入式系统动态补丁长跳转的实现方法 |
CN101799763B (zh) * | 2009-02-10 | 2013-01-30 | 华为技术有限公司 | 内核在线补丁的方法、装置和系统 |
-
2013
- 2013-08-05 CN CN2013103374613A patent/CN103399775A/zh active Pending
-
2014
- 2014-08-04 WO PCT/CN2014/083616 patent/WO2015018302A1/zh active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102156661A (zh) * | 2010-02-11 | 2011-08-17 | 华为技术有限公司 | 在线补丁的激活方法、装置及系统 |
CN103218262A (zh) * | 2010-02-11 | 2013-07-24 | 华为技术有限公司 | 在线补丁的激活方法、装置及系统 |
CN102609241A (zh) * | 2012-01-19 | 2012-07-25 | 中兴通讯股份有限公司 | 热补丁方法及装置 |
CN103399775A (zh) * | 2013-08-05 | 2013-11-20 | 北京华为数字技术有限公司 | 一种热补丁方法及设备 |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104809018A (zh) * | 2015-05-18 | 2015-07-29 | 烽火通信科技股份有限公司 | 一种嵌入式系统软件注入热补丁的方法及系统 |
US20230016250A1 (en) * | 2019-12-13 | 2023-01-19 | Zte Corporation | Method for implementing linux kernel hot patch, electronic device, and computer readable medium |
US11868763B2 (en) * | 2019-12-13 | 2024-01-09 | Zte Corporation | Method for implementing Linux kernel hot patch, electronic device, and computer readable medium |
US12131145B2 (en) * | 2021-09-28 | 2024-10-29 | Hill-Rom Services, Inc. | Systems and methods for peer-to-peer automatic software updates |
Also Published As
Publication number | Publication date |
---|---|
CN103399775A (zh) | 2013-11-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2015018302A1 (zh) | 一种热补丁方法及设备 | |
US10169013B2 (en) | Arranging binary code based on call graph partitioning | |
US9075692B2 (en) | Method, device and system for activating on-line patch | |
JP7090657B2 (ja) | アプリケーションをアップグレードするための方法、装置、デバイスならびに記憶媒体 | |
CN104239082B (zh) | 嵌入式系统的热补丁实现方法 | |
US9696989B1 (en) | Systems and methods for generating and applying operating system live updates | |
US8499289B2 (en) | Method, device and system for realizing kernel online patching | |
EP2557498B1 (en) | Updating method and computer system for hypervisor components | |
CN104111848B (zh) | 一种基于异步检查点的多线程软件动态升级方法 | |
US8522225B2 (en) | Rewriting branch instructions using branch stubs | |
TWI566180B (zh) | 一種動態創建可附加和可拆除二進位檔案的系統和方法 | |
US20180089422A1 (en) | Technologies for deterministic code flow integrity protection | |
US20120198431A1 (en) | Method for upgrading hypervisor component and computer system | |
JP4754004B2 (ja) | マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換するための方法、並びにそのコンピュータ・プログラム及びコンピュータ・システム | |
US10083125B2 (en) | Method to efficiently implement synchronization using software managed address translation | |
US10310871B2 (en) | Non-transitory computer-readable recording medium storing control program, control device and control method | |
JP4931711B2 (ja) | カーネル更新方法、情報処理装置、プログラムおよび記憶媒体 | |
US11055202B1 (en) | Compilation scheme for tagged global variables | |
Ma et al. | Efficient Scheduler Live Update for Linux Kernel with Modularization | |
CN105808269A (zh) | 一种将应用安装到虚拟sd卡的方法及装置 | |
US20170277552A1 (en) | Tracing method, computer-readable recording medium, and information processing apparatus | |
US20120266150A1 (en) | Method and framework for invisible code rewriting | |
JP5845788B2 (ja) | 実行制御プログラム、実行制御装置および実行制御方法 | |
JP5402595B2 (ja) | ネイティブ型icカード、icカードos、及び方法 | |
JP6668638B2 (ja) | 情報処理装置、コンパイル方法及びコンパイラ |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 14835309 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 14835309 Country of ref document: EP Kind code of ref document: A1 |