The Git repository of the Libabigail Project
Go to file
Dodji Seketeli fadfa1a6f6 Support Linux Kernel binaries
This patch teaches the ELF/DWARF reader of libabigail to load special
ELF sections that are specific to Linux Kernel binaries (either
vmlinux or linux kernel modules).

The patch creates a new flag that tells the ELF reader that it needs
to consider the input binary as a Linux Kernel binary.  This is the
new 'Linux Kernel mode'.

In this linux kernel mode, the reader expects sections that are named
__ksymtab and/or __ksymtab_gpl sections.  Those sections contain
indexes (of ELF symbols described in the normal ELF symbol table) of
exported ELF symbols that are specifically marked by developers using
EXPORT_SYMBOL or EXPORT_SYMBOL_GPL macros.  These are symbols of
global variables and functions defined and meant to be used by kernel
modules.  They constitute the interface exported by the Linux Kernel
to its modules.  So the patch only exports the publicly defined and
exported ELF symbols that are also listed in __ksymtab and
__ksymtab_gpl sections.

The patch also fixes and re-organizes things left and right so that
this new mode works in a well integrated manner with the other parts
of the reader:

  - The load address of the binary is no more assumed to be the load
    address specified by the program header that is at offset zero.
    This is usually the case for user-space programs.  To handle Linux
    Kernel binaries, the load address is now the one specified by the
    program header that is at the smallest offset.

  - The patch now tries to populate the various symbol maps only when
    necessary.  That way, the new symbol maps defined for the ksymtab
    and ksymtab_gpl section are also loaded only when necessary; that
    is, when in Linux Kernel mode.

  - The patch (more) agressively suppresses non-member functions or
    variables that are not declarations and that have no associated
    ELF symbol.

The patch knows how to recognize and read relevant ELF symbol
information from __ksymtab and __ksymtab_gpl sections.

The patch makes abidiff and abidw detect that a binary is a
Linux Kernel binary (either a vmlinux or a module).  It does this by
detecting the presence of the speciall __ksymtab_strings section.

If it detects that a binary is a Linux Kernel binary then it only
considers functions and variables which are defined and exported in
the sense of ELF *AND* which ELF symbols are listed in the __ksymtab
and __ksymtab_gpl sections.

If users want abidiff and abidw to consider their input binaries as
normal ELF binaries then they can use the option --no-linux-kernel-mode.

	* include/abg-dwarf-reader.h (create_read_context): Take a new
	flag to say if the context is to read an ELF binary in linux
	kernel mode.
	* src/abg-dwarf-reader.cc (typedef address_set_type)
	(address_set_sptr): New typedefs.
	(get_binary_load_address):  The load address of the binary is
	the load address specified by the program header that is at the
	smallest offset; not by the program header that is at offset zero.
	(read_context::{ksymtab_section_, ksymtab_gpl_section_,
	linux_exported_fn_syms_, linux_exported_var_syms_,
	linux_exported_gpl_fn_syms_, linux_exported_gpl_var_syms_,
	load_in_linux_kernel_mode_}): New data members.
	(read_context::read_context): Initialize ksymtab_section_,
	ksymtab_gpl_section_ and load_in_linux_kernel_mode_.
	(read_context::{find_symbol_table_section, find_opd_section,
	lookup_elf_fn_symbol_from_address,
	lookup_elf_var_symbol_from_address, get_function_address,
	get_variable_address}): Make these const.
	(read_context::{find_ksymtab_section, find_ksymtab_gpl_section,
	lookup_elf_symbol_from_address, function_symbol_is_exported,
	variable_symbol_is_exported, linux_exported_fn_syms,
	create_or_get_linux_exported_fn_syms, linux_exported_var_syms,
	create_or_get_linux_exported_var_syms, linux_exported_gpl_fn_syms,
	linux_exported_gpl_var_syms,
	create_or_get_linux_exported_gpl_fn_syms,
	linux_exported_gpl_var_syms,
	create_or_get_linux_exported_gpl_var_syms, architecture_word_size,
	load_kernel_symbol_table, load_ksymtab_symbols,
	load_ksymtab_gpl_symbols,
	load_linux_specific_exported_symbol_maps,
	load_in_linux_kernel_mode}): New member functions.
	(read_context::read_int_from_array_of_bytes): Factorize this
	new member function out of ...
	(read_context::{lookup_ppc64_elf_fn_entry_point_address}):
	... this.  Make this function const too.
	(read_context::read_uint64_from_array_of_bytes): New function.
	Uses read_int_from_array_of_bytes above.
	(read_context::{fun_entry_addr_sym_map_sptr}): Try to load symbol
	maps only when it's necessary.
	(read_context::elf_architecture_is_big_endian): Fix logic.
	(read_context::{var_addr_sym_map}):  Express the const variant in
	terms of the non-const one.  In the non-const one, load the map
	only when necessary.
	(read_context::load_symbol_maps_from_symtab_section): Renamed
	load_symbol_maps into this.
	(read_context::is_linux_kernel_binary): Define new member
	function.
	(read_context::{function, variable}_symbol_is_exported): If we are
	not prevented from considering loading in linux kernel mode, then
	just looking at a linux kernel binary makes us consider the
	special kernel sections.
	(read_debug_info_into_corpus): Likewise.
	(build_ir_node_from_die): Take a new flag that says if the ir node
	is a declaration required by another concrete IR node.
	(enum read_context::kernel_symbol_table_kind): New enum.
	(read_context::load_symbol_maps): Support loading linux kernel
	specific sections too.
	(build_var_decl): Use the new
	read_context::variable_symbol_is_exported.
	(function_is_suppressed): Suppress non-member functions or
	variables that are not declarations and that have no symbol.
	(variable_is_suppressed, build_var_decl_if_not_suppressed): Take a
	new flag that says if the variable is a declaration required by a
	concrete variable.  If non member variable that is a declaration
	is not the specification of another concrete variable, then it's
	suppressed.
	(add_fn_symbols_to_map, add_var_symbols_to_map): New function
	definitions.
	(read_debug_info_into_corpus): If we are reading linux kernel or
	linux kernel modules, only set explicitely exported symbols (in
	the linux kernel binary sense) as exported function or variable
	symbols.
	(create_read_context): Take a new flag to say if the context is to
	read an ELF binary in linux kernel mode.
	* tools/abidiff.cc (options::options): Initialize
	options::linux_kernel_mode to true.
	(display_usage): Display usage of the --no-linux-kernel-mode option.
	(parse_command_line): Parse the --no-linux-kernel-mode option.
	* tools/abidw.cc (options::options): Initialize
	options::linux_kernel_mode to true.
	(display_usage): Display usage of --no-linux-kernel-mode option.
	(parse_command_line): Parse the --no-linux-kernel-mode option.
	* doc/manuals/abidiff.rst: Document the new --no-linux-kernel-mode
	options.
	* doc/manuals/abidw.rst: Likewise.
	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
	Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise.
	* tests/data/test-read-dwarf/libtest23.so.abi: Adjust.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi: Adjust.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-06 12:35:22 +01:00
autoconf-archive Improve python modules detection 2016-06-03 17:53:11 +02:00
bash-completion Make bash completion files non-executable 2016-11-26 12:29:12 +01:00
doc Support Linux Kernel binaries 2017-01-06 12:35:22 +01:00
include Support Linux Kernel binaries 2017-01-06 12:35:22 +01:00
m4 Delete ltsugar.m4 and pkg.m4 files from m4/ 2015-01-06 09:54:45 +01:00
scripts Initial DOT work. 2013-07-23 23:13:55 +02:00
src Support Linux Kernel binaries 2017-01-06 12:35:22 +01:00
tests Support Linux Kernel binaries 2017-01-06 12:35:22 +01:00
tools Support Linux Kernel binaries 2017-01-06 12:35:22 +01:00
.gitignore Bug 19428 - New fedabipkgdiff utility 2016-05-13 00:42:36 +02:00
abigail.m4 For usage from within GCC set header path to $includedir/libabigail 2013-08-14 16:10:15 +02:00
AUTHORS Initial AUTHORS and README 2013-02-28 13:25:20 +01:00
ChangeLog Update NEWS and ChangeLog for 1.0.rc6 2016-11-24 15:28:29 +01:00
COMMIT-LOG-GUIDELINES Update the COMMIT-LOG-GUIDELINES file 2016-05-22 23:20:12 +02:00
COMPILING Update documentation to require doxygen and python-sphinx for building 2016-04-27 15:53:40 +02:00
configure.ac Check --enable-rpm dependencies more rigorously 2016-12-13 20:55:00 +01:00
CONTRIBUTING Control symbols exported from libabigail.so 2016-07-27 12:51:02 +02:00
COPYING Use a better wording for the COPYING file 2015-04-22 09:53:18 +02:00
COPYING-GPLV3 Update licence texts 2015-04-20 13:51:21 +02:00
COPYING-LGPLV2 Initial import of gen-changelog.py 2014-11-18 23:18:06 +01:00
COPYING-LGPLV3 LGPLv3 License the library 2013-07-23 23:13:55 +02:00
default.abignore Add default suppression specifications for C++ binaries 2016-09-21 18:35:08 +02:00
gen-changelog.py [gen-changelog] Make subject line always come first 2014-11-18 23:18:06 +01:00
install-sh Add missing autoconfiscation files into version control 2013-03-01 00:47:49 +01:00
libabigail.pc.in Make libxml2 a private dependency wrt pkconfig 2013-08-22 17:41:29 +02:00
ltmain.sh Add missing autoconfiscation files into version control 2013-03-01 00:47:49 +01:00
Makefile.am Control symbols exported from libabigail.so 2016-07-27 12:51:02 +02:00
NEWS Update NEWS and ChangeLog for 1.0.rc6 2016-11-24 15:28:29 +01:00
README Fix wording in README 2015-09-05 10:30:00 +02:00
release-text-template.txt Add a release announcement text pattern 2016-01-08 12:15:30 +01:00
VISIBILITY Control symbols exported from libabigail.so 2016-07-27 12:51:02 +02:00

This is the Application Binary Interface Generic Analysis and
Instrumentation Library.

It aims at constructing, manipulating, serializing and de-serializing
ABI-relevant artifacts.

The set of artifacts that we are intersted is made of quantities like
types, variable, fonctions and declarations of a given library or
program.  For a given library or program this set of quantities is
called an ABI corpus.

This library aims at (among other things) providing a way to compare
two ABI Corpora (apparently the plural of corpus is copora, heh,
that's cool), provide detailed information about their differences,
and help build tools to infer interesting conclusions about these
differences.

You are welcome to contribute to this project after reading the files
CONTRIBUTING and COMMIT-LOG-GUIDELINES files in the source tree.

Communicating with the maintainers of this project -- including
sending patches to be include to the source code -- happens via email
at libabigail@sourceware.org.