kmod/patch: export patched functions information via sysfs

This feature is implemented as:
```
[root@localhost kpatch]# insmod ./kpatch-meminfo.ko
[root@localhost kpatch]# ls /sys/kernel/kpatch/patches/kpatch_meminfo/functions/meminfo_proc_show/
new_addr  old_addr
[root@localhost kpatch]# cat /sys/kernel/kpatch/patches/kpatch_meminfo/functions/meminfo_proc_show/new_addr
0xffffffffa05211e0
[root@localhost kpatch]# cat /sys/kernel/kpatch/patches/kpatch_meminfo/functions/meminfo_proc_show/old_addr
0xffffffff8125d0e0
```

The patch module init function will allocate and init kpatch_func_obj with
customized kobj_type func_ktype. The attribute new_addr and old_addr of
kpatch_func_obj is attached to this func_ktype, so that these files could
be created by kobject_add automatically.

Signed-off-by: Jincheng Miao <jincheng.miao@gmail.com>
correlate symbols also by type

Both unpatched and patched objects may contain FILE
symbol with empty name. This is unexpected for
create-diff-object and could correlate 2 symbols
with same (empty) name but different types:
  sym 00, type 0, bind 0, ndx 00, name  (SAME)
  ...
  sym 425, type 4, bind 0, ndx 65521, name  (SAME)
  ...
  signal.o: changed function: do_rt_tgsigqueueinfo
  signal.o: changed function: do_rt_sigqueueinfo
  signal.o: changed function: get_signal_to_deliver
  signal.o: signal.o: changed section .rela__jump_table not selected for inclusion
  signal.o: 1 unsupported section change(s)
  /root/kpatch/kpatch-build/create-diff-object: unreconcilable difference

Introduce condition to match symbols also by type.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
fix vmlinux parameter for kpatch-build

It was missing in getopt arguments.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Merge pull request #216 from jstancek/issue203

fix vmlinux parameter for kpatch-build
create-diff-object: percpu support

The -fdata-sections gcc flag doesn't work with objects in the
.data..percpu section.  Any function which uses a percpu variable
references this section, causing the section to get incorrectly included
in the patch module.

Manually convert these section references to object symbol references so
that the needed symbol can be found in vmlinux.

Also, the core module symbol verification code will fail when looking up
a percpu variable, because sprint_symbol doesn't think a percpu address
is a valid kernel address.  So rewrite the symbol verification code to
use kallsyms_on_each_symbol() instead.  It's not ideal performance-wise:
it seems to cost about 1ms per symbol lookup.  I think that's acceptable
for now.  In the future we may want to try to get a better upstream
kallsyms interface.
create-diff-object: fix symbol section indexes

For a local non-included function or object which is needed by an
included function, its symbol table entry will still refer to a local
section index.  Instead it should be changed to SHN_UNDEF.
create-diff-object: improve error message
create-diff-object: generic special section support

Abstract out the common functionality for dealing with special sections
into a new kpatch_process_special_sections() function.

The base sections are partitioned into "groups".  Only those groups
whose relas reference a changed function are kept.  The only difference
in the logic for handling each special section is determining the size
of a given group.  Each section has its own group_size() callback for
this.  It's a callback instead of an integer because one of the
soon-to-be-supported special sections requires that its group sizes be
dynamically determined.
create-diff-object: support fixup and related sections

Add support for the following sections:

- .fixup
- __ex_table
- .altinstructions
- .altinstr_replacement

Fixes #187.
create-diff-object: support tracepoints and related sections

Add support for the following special sections:

- __jump_table
- __tracepoints
- __tracepoints_ptrs
- __tracepoints_strings

Fixes #157.
Merge pull request #215 from jstancek/issue202

correlate symbols also by type
Merge pull request #214 from jpoimboe/special-sections

generic support for special sections
kmod/core: move dynamic relocation writes to new function

Unclutter kpatch_register a little bit.
kmod/core: make loc variable a u64

So less casting is needed.
kmod/core: ensure page is RO before changing its permissions

Make sure we leave the page's execution permissions in the same state we
found them.
Merge pull request #217 from jpoimboe/check-page-rw

kmod/core: ensure page is RO before changing its permissions
Merge pull request #180 from ryanmiao/print_funcs

export funcs via sysfs
kpatch-build: better error message for struct def change

Fixes #109.
Merge pull request #218 from jpoimboe/struct-def-change-error

kpatch-build: better error message for struct def change
create-diff-object: ensure no data sections are included

When a changed function needs relocations for special data sections like
.data..percpu or .data..read_mostly, it's possible for those sections to
get included.  We try to avoid that situation by converting section
references to data symbol references in kpatch_replace_sections_syms(),
but the conversion success rate isn't 100%, and we could be forgetting
about some other sections, so ensure that it never happens in
kpatch_verify_patchability().