libabigail/include
Jessica Yu e6870326e0 Support pre and post v4.19 ksymtabs for Linux kernel modules
As described in commit ad8c2531fb, the format of the Linux kernel
ksymtab changed in v4.19 to use relative references instead of absolute
references. This changes the type of relocations emitted for ksymtab
sections to be place-relative 32-bit relocations instead of absolute
relocations. One side-effect of this is that libdwfl will not relocate
the ksymtab sections due to the PC-relative relocations. This breaks
load_kernel_symbol_table() for kernel modules because it only reads in
zeros from the unrelocated ksymtab section and is subsequently unable to
determine what exported symbols it refers to. Since a vmlinux binary is
already fully linked and relocated (and therefore we can read its
ksymtab section just fine), this problem is only relevant to Linux
kernel modules.

To work around this, we utilize the ksymtab relocation sections to
determine which symbols the ksymtab entries refer to. We do this by
inspecting each relocation's r_info field for the symbol table index and
from there we are able to read each symbol's value and subsequently add
that to the set of exported symbols.

In addition, for Linux kernel modules, we can utilize relocation types
to implement a new heuristic to determine the ksymtab format we have.
The presence of PC-relative relocations suggest the new v4.19 format,
and absolute relocation types suggest the old pre v4.19 format.

        * include/abg-ir.h (elf_symbol::{elf_symbol, create}): Take new
	symbol value and shndx parameters.
        (elf_symbol::{get_value, get_shndx}): Declare new accessors.
        * src/abg-ir.cc (elf_symbol::priv::{value_, shndx_}): New data
	members.
        (elf_symbol::priv::priv): Adjust.
        (elf_symbol::elf_symbol): Take new value and is_linux_string_cst
	parameters.
        (elf_symbol::create): Likewise.
        (elf_symbol::{get_value, get_is_linux_string_cst}): Define new
	accessors.
        * src/abg-reader.cc (build_elf_symbol): Adjust.
        * src/abg-dwarf-reader.cc (binary_is_linux_kernel)
	(binary_is_linux_kernel): New static functions.
	(lookup_symbol_from_sysv_hash_tab)
        (lookup_symbol_from_gnu_hash_tab)
        (lookup_symbol_from_symtab): Adjust.
        (read_context::{ksymtab_reloc_section_,
	ksymtab_gpl_reloc_section_, ksymtab_strings_section_}): New data
	members.
        (read_context::read_context): Initialize ksymtab_reloc_section_,
	ksymtab_gpl_reloc_section_, ksymtab_strings_section_.
        (read_context::{find_ksymtab_reloc_section,
	find_ksymtab_gpl_reloc_section, find_ksymtab_strings_section,
	find_any_ksymtab_reloc_section, get_ksymtab_format_module,
	populate_symbol_map_from_ksymtab,
	populate_symbol_map_from_ksymtab_reloc, is_linux_kernel_module}):
	New member functions.
        (read_context::load_kernel_symbol_table): Adjust to call either
	populate_symbol_map_from_ksymtab{_reloc,} depending on ksymtab
	format.
        (read_context::get_ksymtab_format): Adjust to call
	get_ksymtab_format_module for linux kernel modules.
        (read_context::lookup_elf_symbol_from_index): Adjust.
        (create_default_var_sym, create_default_fn_sym): Adjust.

Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-09-17 17:53:12 +02:00
..
abg-comp-filter.h Bug 24731 - Wrongly reporting union members order change 2019-06-26 11:09:43 +02:00
abg-comparison.h Bug 24787 - Filter out enum changes into compatible integer types 2019-07-19 18:22:12 +02:00
abg-config.h Update copyright for 2019 2019-01-07 14:54:47 +01:00
abg-corpus.h Implement fast comparison of Linux Kernel types when applicable 2019-07-17 19:35:38 +02:00
abg-cxx-compat.h Add compatibility layer for C++11 mode 2019-07-09 18:05:28 +02:00
abg-diff-utils.h Add compatibility layer for C++11 mode 2019-07-09 18:05:28 +02:00
abg-dwarf-reader.h Avoid over-suppressing fns & vars when analysing the Kernel 2019-02-19 17:42:56 +01:00
abg-fwd.h Serialize canonical types to avoid testing if types have been emitted 2019-09-17 17:52:26 +02:00
abg-hash.h Update copyright for 2019 2019-01-07 14:54:47 +01:00
abg-ini.h Add compatibility layer for C++11 mode 2019-07-09 18:05:28 +02:00
abg-interned-str.h Add compatibility layer for C++11 mode 2019-07-09 18:05:28 +02:00
abg-ir.h Support pre and post v4.19 ksymtabs for Linux kernel modules 2019-09-17 17:53:12 +02:00
abg-libxml-utils.h Add compatibility layer for C++11 mode 2019-07-09 18:05:28 +02:00
abg-libzip-utils.h Add compatibility layer for C++11 mode 2019-07-09 18:05:28 +02:00
abg-reader.h Separate public types of first binary from those of the second 2019-01-16 12:27:45 +01:00
abg-reporter.h Add compatibility layer for C++11 mode 2019-07-09 18:05:28 +02:00
abg-sptr-utils.h Add compatibility layer for C++11 mode 2019-07-09 18:05:28 +02:00
abg-suppression.h Add compatibility layer for C++11 mode 2019-07-09 18:05:28 +02:00
abg-tools-utils.h Add timing to the verbose logs of abidw 2019-07-19 10:46:42 +02:00
abg-traverse.h add missing virtual destructors 2019-04-16 16:11:01 +02:00
abg-version.h.in Add --version option to several libabigail tools 2015-11-16 12:54:10 +01:00
abg-viz-common.h Update copyright for 2019 2019-01-07 14:54:47 +01:00
abg-viz-dot.h viz-dot: remove unused members from dot 2019-04-16 16:11:01 +02:00
abg-viz-svg.h Update copyright for 2019 2019-01-07 14:54:47 +01:00
abg-workers.h Add compatibility layer for C++11 mode 2019-07-09 18:05:28 +02:00
abg-writer.h abg-writer: drop deprecated API 2019-05-22 14:33:45 +02:00
Makefile.am Add compatibility layer for C++11 mode 2019-07-09 18:05:28 +02:00