REAME.md: add g++ package to the Debian Wheezy procedure
add difftest.sh test

The purpose of this test script is to determine if create-diff-object
can properly recognize object file equivalence when passed the same file
for both the original and patched objects.  This verifies that
create-diff-object is correctly parsing, correlating, and comparing the
different elements of the object file.  In practice, a situation similar
to the test case occurs when a commonly included header file changes,
causing Make to rebuild many objects that have no functional change.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
Merge pull request #354 from spartacus06/diff-tree-tests

add difftest.sh test
kpatch-gcc: fix for .tmp_* objects on RHEL 7

On RHEL 7 I see the following error when trying to patch meminfo.o:

    cp: cannot stat ‘/home/user/.kpatch/obj/fs/proc/.tmp_meminfo.o’: No such file or directory

It turns out that on RHEL 7, a given object foo.o is compiled as
.tmp_foo.o before then being linked as foo.o.  I have no idea why.  The
fix is to record .tmp_foo.o as foo.o in the changed_objs file.
Merge pull request #355 from jpoimboe/rhel7-tmp-obj-fix

kpatch-gcc: fix for .tmp_* objects on RHEL 7
allow patches that only contains hook functions

Fixes #357

Signed-off-by: Seth Jennings <sjenning@redhat.com>
Merge pull request #361 from spartacus06/issue-357

allow patches that only contains hook functions
fix dynrela corruption in load/unload hooks

In kpatch_create_dynamic_rela_sections() the dest field is filled in
with either the function symbol or the section symbol that contains the
function depending on whether or not the sym field of the base section
is NULL or not (around line 2153).

In the case of the hook functions, we strip the FUNC symbol to prevent
it from being added to the kpatch.funcs section as a patched function.
However we weren't unbundling the stripped symbol from the section.
This resulted in the sym field pointing to the null symbol (index 0),
corrupting the dynrelas rela section.

Before:

Relocation section [14] '.rela.kpatch.dynrelas' for section [13] '.kpatch.dynrelas' at offset 0x8b8 contains 6 entries:
  Offset              Type            Value               Addend Name
  000000000000000000  X86_64_64       000000000000000000      +9
  0x0000000000000018  X86_64_64       000000000000000000      +8 .kpatch.strings
  0x0000000000000020  X86_64_64       000000000000000000      +0 .kpatch.strings
  0x0000000000000030  X86_64_64       000000000000000000      +9
  0x0000000000000048  X86_64_64       000000000000000000      +8 .kpatch.strings
  0x0000000000000050  X86_64_64       000000000000000000      +0 .kpatch.strings

This commit unbundles the stripped symbol from the section so that the
section symbol is used in the dynrelas rela section.

After:

Relocation section [14] '.rela.kpatch.dynrelas' for section [13] '.kpatch.dynrelas' at offset 0x8b8 contains 6 entries:
  Offset              Type            Value               Addend Name
  000000000000000000  X86_64_64       000000000000000000      +9 .text.kpatch_load_aio_max_nr
  0x0000000000000018  X86_64_64       000000000000000000      +8 .kpatch.strings
  0x0000000000000020  X86_64_64       000000000000000000      +0 .kpatch.strings
  0x0000000000000030  X86_64_64       000000000000000000      +9 .text.kpatch_unload_aio_max_nr
  0x0000000000000048  X86_64_64       000000000000000000      +8 .kpatch.strings
  0x0000000000000050  X86_64_64       000000000000000000      +0 .kpatch.strings

Signed-off-by: Seth Jennings <sjenning@redhat.com>
Merge pull request #362 from spartacus06/fix-dynrela-corruption-in-hooks

fix dynrela corruption in load/unload hooks
test: add hook macro test

From issue #357.
Merge pull request #363 from jpoimboe/add-hook-test

test: add hook macro test
fix use-after-free error

Don't use rela after you just freed it!

Signed-off-by: Seth Jennings <sjenning@redhat.com>
always include .rodata.str1.* sections

Signed-off-by: Seth Jennings <sjenning@redhat.com>
Merge pull request #365 from spartacus06/issue-359-v2

always include .rodata.str1.* sections
create-diff-object: allow new data to be included

Allow the inclusion of new global variables.
Merge pull request #366 from jpoimboe/allow-new-data

create-diff-object: allow new data to be included
kpatch-patch-hook: fix incorrect old_offsets for loadable modules

Fix incorrect old_offsets for loadable modules during sysfs
initialization in patch_init.

sysfs will be initialized on patch module init regardless of whether
or not the module is loaded. func_old_addr_show() will read from func->old_addr,
which is initially set to 0; it'll be eventually filled in by the core module.
consolidate variables func->old_offset and func->old_addr to just old_addr

To reduce redundancy, remove/change the old_offset fields in the
kpatch_func and kpatch_patch_func structs to just old_addr. Since
old_offset is being used as a placeholder for old_addr, might as well
consolidate it to just one variable.
Merge pull request #360 from flaming-toast/func-sysfs-fix

kpatch-patch-hook: fix incorrect old_offsets for loadable modules
kpatch-build: add Oracle Linux 7 and CentOS 7 support