allow user-defined LIBDIR in install paths

User reported cases where libraries are in lib32/64 directories, not
lib.

Allow the user to override by setting LIBDIR.

Fixes #167

Signed-off-by: Seth Jennings <sjenning@redhat.com>
replace section symbols before correlating

The correlation logic could get confused if it compares two relas whose
symbols haven't been converted from section symbols to object or
function symbols.  So we should replace section symbols for both the
base and the patched object before correlating, so that it can compare
the function and object symbols rather than the section symbols.

This is also a prerequisite for dealing properly with gcc's renaming of
static local variables, because relas which reference static locals
usually use section symbols.
support for gcc static local variable renaming

gcc renames static local variables by appending a period and a number.
For example, __key could be renamed to __key.31452.  Unfortunately this
number can arbitrarily change.  Try to rename the patched version of the
symbol to match the base version and then correlate them.

Fixes #313.
Merge pull request #328 from jpoimboe/static-local-vars

support for gcc static local variable naming
kpatch: update the kpatch version and the man
remove sh_link from section comparison

This sh_link line currently has a bug with both operands being sec1; the
second should be sec2.  However the bug is masking a logical flaw; that
is that the sh_link is the index of either the symtab or the strtab and
that can change if sections have been added or removed by the patch.

This commit removes the comparison.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
Merge pull request #331 from spartacus06/dont-check-shlink

remove sh_link from section comparison
s/funcs/functions/g

Signed-off-by: Seth Jennings <sjenning@redhat.com>
mark mcount sections as SAME

Right now, in the case that the mcount sections have changed, we get a
"changed section not included" error on them.  Since we rebuild them
from scratch, just mark them as SAME even if they are different so that
we don't cause an error.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
Merge pull request #330 from goldyfruit/master

kpatch: update the kpatch version and the man and the kmod/core/Makefile
kmod/core/Makefile: update the Makefile for Debian Like
Merge pull request #333 from goldyfruit/master

kmod/core/Makefile: update the Makefile for Debian Like
add KPATCH_IGNORE_SECTION support

This macro is for ignoring sections that may change as a side effect of
another change or might be a non-bundlable section; that is one that
does not honor -ffunction-section and create a one-to-one relation from
function symbol to section.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
add support for replacing section syms for unbundled sections

Right now, the test patch unnecessarily includes hrtimer_nanosleep()
because the call to do_nanosleep() generates a rela the references the
unbundled .sched.text section.  This section symbol is not currently
replaced by kpatch_replace_sections_syms() as it only replaces bundled
sections symbols.

This commit adds logic to kpatch_replace_sections_syms() to replace
unbundled section symbols as well by scanning the symbol table for
symbols that start at the rela entry's offset within the matching
section.

This allows for properly rela section correlation when the functions
have moved from an unbundled section to a bundled section.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
make symbol section change an error

make symbol section change an error, except when moving out of an
ignored section

Signed-off-by: Seth Jennings <sjenning@redhat.com>
Merge pull request #332 from spartacus06/ignore-sections

add KPATCH_IGNORE_SECTION support (plus fixups)
Revert "add KPATCH_WARN_*_LINE macros"

This reverts commit 57b51d0bdce53a928bde6c3370fcd0f06cfa0ad4.

Probably no longer needed now that we have KPATCH_IGNORE_FUNCTION and
KPATCH_IGNORE_SECTION.
Merge pull request #334 from jpoimboe/revert-warn-macros

Revert "add KPATCH_WARN_*_LINE macros"
Merge pull request #335 from spartacus06/user-libdir

allow user-defined LIBDIR in install paths
kpatch: change core module path again

On RHEL I'm seeing issues with putting the core module in the "extra"
path.  On the next depmod run, it gets added to modules.dep, and on a
subsequent kpatch install I see the following errors:

    /usr/lib/dracut/modules.d/50drm/module-setup.sh: line 26: /lib/modules/3.10.0-123.4.4.el7.x86_64//weak-updates/kpatch/kpatch.ko: No such file or directory
    /usr/lib/dracut/modules.d/90kernel-modules/module-setup.sh: line 14: /lib/modules/3.10.0-123.4.4.el7.x86_64//weak-updates/kpatch/kpatch.ko: No such file or directory
    modinfo: ERROR: Module /lib/modules/3.10.0-123.4.4.el7.x86_64/weak-updates/kpatch/kpatch.ko not found.

Until the core module gets merged into Linux, I think we can put it in
/usr/lib/kpatch, which is also where the patch modules are going to be
delivered in the RHEL RPM.

Making sure the other options still work with the kpatch utility for
now, so as to keep backwards compatibility between a newer kpatch
utility and older core modules.  We can break this compatibility for
kpatch 0.2.0.