The dynamic software update patch produced by the patch generator, which is in source code format, is compiled using the hcucc.pl compiler to produce a dynamic software update patch in binary format, which is a dynamically loadable shared object library. This binary dynamic software update patch is later used to apply a live update.
Figure 5-9 shows an example of preparing a binary dynamic software update patch that will update vsFTPd from version 2.0.4 to version 2.0.5. The compilation is carried out in two steps.
First, the patch is compiled to also be updateable itself. The "--update-version=205" argument is used to indicate that the patch will update the original version to the new version 2.0.5.
Note that compilation is executed with the -fPIC flag which produces position-independent code. Position-independent code is required when building shared object libraries.
The output of this first compilation step is an updateable object file named vsftpd_comb.c_v204_to_v205.hcupatch.o.
![]() | To manage the versionining complexity of applying multiple dynamic software updates during the lifetime of an application, compiling the patch to be updateable appends to many datatypes, variables and functions the postfix _vXXX, where XXX is the version number. For example, for an update from vsFTPd 2.0.4 to vsFTPd 2.0.5, the compilation appends the postfix _v205. The datatypes, variables and functions that have their names changed are all datatypes, variables and functions that differ between the two versions, all functions defined in the mappings file, and all automatically generated datatype and stack transformers. |
Second, this updatable object file is re-linked to create a dynamically loadable shared object library file. Creating a loadable shared object library file is necessary for the runtime to be able to load the patch into the address space of an already running process using dlopen().
Note that the name of this library is supplied with the -soname linker parameter and it is vsftpd_v205_to_v205.so. Also note that the linker by default adds the prefix lib to all library names passed to it. Hence lib + vsftpd_v205_to_v205.so = libvsftpd_v205_to_v205.so.
The output of this re-linking process is the binary dynamic software update patch libvsftpd_v205_to_v205.so.205, and this is the file used to apply a live update, as described in Chapter 6.
Figure 5-9. Compiling a dynamic software update patch for vsFTPd from 2.0.4 to 2.0.5.
# Compile the source dynamic software update patch to be dynamically updateable bash$ hcucc.pl -fPIC \ -c vsftpd_comb.c_v204_to_v205.hcupatch.c \ -o vsftpd_comb.c_v204_to_v205.hcupatch.o \ --update-version=205 # Create a binary dynamic software update patch as a dynamically loadable # shared object library bash$ hcucc.pl -shared -Wl,-soname=vsftpd_v205_to_v205.so \ -o libvsftpd_v205_to_v205.so.205 \ vsftpd_comb.c_v204_to_v205.hcupatch.o
![]() | Unlike preparing updateable programs in Section 4.1, no "--base-version" argument is supplied here. The dynamic software update patch is not the original program: it is an update. When the patch is applied the original program is already running. |