Browse Prior Art Database

Generic Methodology for Code Patching in Binary File

IP.com Disclosure Number: IPCOM000123163D
Original Publication Date: 1998-Jun-01
Included in the Prior Art Database: 2005-Apr-04
Document File: 4 page(s) / 120K

Publishing Venue

IBM

Related People

Chang, DM: AUTHOR [+1]

Abstract

Disclosed is a procedure used to fix the Year 2000 problem in a program for all shipped countries. This solution can solve the problem without re-compiling the source code for all the countries. We can provide one utility program to patch the code for all the countries.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 53% of the total text.

Generic Methodology for Code Patching in Binary File

   Disclosed is a procedure used to fix the Year 2000 problem
in a program for all shipped countries.  This solution can solve the
problem without re-compiling the source code for all the countries.
We can provide one utility program to patch the code for all the
countries.

   Problem:

   There are times when code needs to be modified in the field,
and patching the code is the only viable solution.  This may be
because it is impractical to replace the entire module with a new
build, or the original level of source code in the field is
unreproduceable.  If the code being patched needs additional
instructions to be added or the code is going to grow in any way,
the binary patch may not be possible.

   Overview:

   In software, there is a need for software to be able to be
fixed or updated in the field, and this sometimes may be in the form
of a patch.  However, if the code being patched is being replaced by
code that is larger than the original, this can pose problems for
standard binary patch methods.  This will present a method to solve
such situations.  We assume a few basic patching requirements:
  1.  Special care should be taken to ensure that the patched
       code is limited as much as possible.  This is especially
       important if the code being patched gets CALL/JMPed into
       at several locations, as well as CALL/JMPs that address
       external functions (.DLLs).  To patch code that is
       CALL/JMPed into will require more extensive manipulations
       of the System Programming Interface (SPI), Application
       Programming Interface (API), or internal functions.
  2.  Need to know what code to change, and where to apply the
       change.

   Methodology:

   Put the patching code at the end of CODE segment (code
object session).  Change the first instruction of the original code
into a CALL instruction to call the patching code.  After the CALL
instruction, replace all of the original code instructions with NOPs
(no operation instructions).  Update the pointer and length in
segment table (code object table) to locate the new code segment
(code object session).

   Possible implementation:
  1.  Copying patched segment to the end of the file.
        This implementation is simpler than the following one
       because it requires much less data structures to be
       modified and traversed.  Basically the segment...