mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-17 15:34:34 +00:00
The Git repository of the Libabigail Project
fadfa1a6f6
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> |
||
---|---|---|
autoconf-archive | ||
bash-completion | ||
doc | ||
include | ||
m4 | ||
scripts | ||
src | ||
tests | ||
tools | ||
.gitignore | ||
abigail.m4 | ||
AUTHORS | ||
ChangeLog | ||
COMMIT-LOG-GUIDELINES | ||
COMPILING | ||
configure.ac | ||
CONTRIBUTING | ||
COPYING | ||
COPYING-GPLV3 | ||
COPYING-LGPLV2 | ||
COPYING-LGPLV3 | ||
default.abignore | ||
gen-changelog.py | ||
install-sh | ||
libabigail.pc.in | ||
ltmain.sh | ||
Makefile.am | ||
NEWS | ||
README | ||
release-text-template.txt | ||
VISIBILITY |
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.