libabigail/tools/abisym.cc

165 lines
3.9 KiB
C++
Raw Normal View History

Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
// -*- Mode: C++ -*-
//
Update copyright years * include/abg-comp-filter.h: Update copyright years. * include/abg-comparison.h: Likewise. * include/abg-config.h: Likewise. * include/abg-corpus.h: Likewise. * include/abg-diff-utils.h: Likewise. * include/abg-dwarf-reader.h: Likewise. * include/abg-fwd.h: Likewise. * include/abg-hash.h: Likewise. * include/abg-ini.h: Likewise. * include/abg-ir.h: Likewise. * include/abg-libxml-utils.h: Likewise. * include/abg-libzip-utils.h: Likewise. * include/abg-reader.h: Likewise. * include/abg-sptr-utils.h: Likewise. * include/abg-traverse.h: Likewise. * include/abg-viz-common.h: Likewise. * include/abg-viz-dot.h: Likewise. * include/abg-viz-svg.h: Likewise. * include/abg-writer.h: Likewise. * src/abg-comp-filter.cc: Likewise. * src/abg-comparison.cc: Likewise. * src/abg-config.cc: Likewise. * src/abg-corpus.cc: Likewise. * src/abg-diff-utils.cc: Likewise. * src/abg-dwarf-reader.cc: Likewise. * src/abg-hash.cc: Likewise. * src/abg-ini.cc: Likewise. * src/abg-ir.cc: Likewise. * src/abg-libxml-utils.cc: Likewise. * src/abg-libzip-utils.cc: Likewise. * src/abg-reader.cc: Likewise. * src/abg-traverse.cc: Likewise. * src/abg-viz-common.cc: Likewise. * src/abg-viz-dot.cc: Likewise. * src/abg-viz-svg.cc: Likewise. * src/abg-writer.cc: Likewise. * tests/print-diff-tree.cc: Likewise. * tests/test-abidiff.cc: Likewise. * tests/test-alt-dwarf-file.cc: Likewise. * tests/test-core-diff.cc: Likewise. * tests/test-diff-dwarf.cc: Likewise. * tests/test-diff-filter.cc: Likewise. * tests/test-diff-suppr.cc: Likewise. * tests/test-diff2.cc: Likewise. * tests/test-ir-walker.cc: Likewise. * tests/test-lookup-syms.cc: Likewise. * tests/test-read-dwarf.cc: Likewise. * tests/test-read-write.cc: Likewise. * tests/test-utils.cc: Likewise. * tests/test-utils.h: Likewise. * tests/test-write-read-archive.cc: Likewise. * tools/abg-tools-utils.cc: Likewise. * tools/abg-tools-utils.h: Likewise. * tools/abiar.cc: Likewise. * tools/abidiff.cc: Likewise. * tools/abidw.cc: Likewise. * tools/abilint.cc: Likewise. * tools/abisym.cc: Likewise. * tools/binilint.cc: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-01-07 12:53:58 +00:00
// Copyright (C) 2013-2015 Red Hat, Inc.
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
//
// This file is part of the GNU Application Binary Interface Generic
// Analysis and Instrumentation Library (libabigail). This library is
// free software; you can redistribute it and/or modify it under the
// terms of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 3, or (at your option) any
// later version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this program; see the file COPYING-LGPLV3. If
// not, see <http://www.gnu.org/licenses/>.
// Author: Dodji Seketeli
/// @file
///
/// This program takes parameters to open an elf file, lookup a symbol
/// in its symbol tables and report what it sees.
#include <elf.h>
#include <cstring>
#include <iostream>
#include <sstream>
#include "abg-dwarf-reader.h"
Initial support for elf symbol (versionning) during decl comparison * include/abg-fwd.h (get_linkage_name): Remove. * include/abg-dwarf-reader.h (enum symbol_type) (enum symbol_binding): Move these into abg-ir.h. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr): Declare this before using it. (die_address_attribute, die_location_address) (stt_to_elf_symbol_type, stb_to_elf_symbol_binding) (find_hash_table_section_index, find_symbol_table_section) (find_symbol_table_section_index, find_text_section) (find_bss_section, compare_symbol_name) (get_symbol_versionning_sections get_version_for_symbol) (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes) (bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, maybe_adjust_fn_sym_address) (maybe_adjust_var_sym_address): New static functions. (enum hash_table_kind): New enum. (struct gnu_ht): New struct. (read_context::var_decls_to_add_): Renamed var_decls_to_add into this. (read_context::{fun, var}_sym_addr_sym_index_map_): New member. (read_context::{lookup_symbol_from_elf, lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address, lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map, var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps, get_function_address, get_variable_address}): New member functions. (read_context::lookup_public_{variable, function}_symbol_from_elf): Adjust. (op_pushes_constant_value): Fix a bug here. (lookup_symbol_from_elf): Adjust. Support cases where there is no elf hash table, e.g, for relocatable files. (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (build_var_decl): Allow updating the var_decl to associate it with its underlying symbol. In that case, if the linkage name is not set, set it to the symbol name. (build_function_decl): Likewise for function_decl. (operator<<(std::ostream&, symbol_type)): (operator<<(std::ostream&, symbol_binding)): Move these do abg-ir.cc. * include/abg-ir.h (class elf_symbol): Declare new class. Move enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to elf_symbol::binding and elf_symbol::type here. (operator<<(std::ostream&, elf_symbol::type)) (operator<<(std::ostream&, elf_symbol::binding)) (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New operators. (class elf_symbol::version): Declare new class. (class var_decl): Make this pimpl, and add ... (var_decl::{g,s}et_symbol): ... new member functions. (class function_decl): Likewise, make this pimpl and add ... (function_decl::{g,s}et_symbol): ... new member functions. * src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New types. (elf_symbol::*): Lots of new members and member functions. (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New. (operator<<(std::ostream&, elf_symbol::type)): New. (operator<<(std::ostream&, elf_symbol::binding)): New. (elf_symbol::version::priv): New type. (elf_symbol::version::*): Lots of member functions. (get_linkage_name): Removed. (var_decl::priv): New type. Pimplify the thing. (var_decl::{s,g}et_symbol): New. (var_decl::operator==): Take symbols in account in the comparison. (function_decl::priv): New type. (function_decl::*): Pimplify. (function_decl::{s,g}et_symbol): New. (function_decl::operator==): Take symbols in account in the comparison. * include/abg-comparison.h (diff_context::show_linkage_name): New member function. * src/abg-comparison.cc (diff_context::priv::show_linkage_name_): New member. (diff_context::priv::priv): Initialize it. (diff_context::show_linkage_names): New member function. (corpus_diff::report): If the user used --show-linkage-names, display the linkage name after the name of the functions. Add missing "'" in the some spots. * tools/bidiff.cc (options.show_linkage_names): New member. (display_usage, parse_command_line): Support --linkage-names. * tools/bisym.cc (show_help): Add '\n' at the end of help string for --demangle. Add --no-absolute-path option. (parse_command_line): Support --no-absolute-path. (main): Adjust for symbol (versionning) support. Consider that the program successfully completed even when the symbol wasn't found. Support --no-absolute-path. * tests/data/test-lookup-syms/test0-report.txt: New. * tests/data/test-lookup-syms/test01-report.txt: New. * tests/data/test-lookup-syms/test02-report.txt: New. * tests/data/test-read-dwarf/test0.abi: Adjust. * tests/data/test-read-dwarf/test1.abi: Adjust. * tests/data/test-diff-dwarf/test7-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test12-report.txt: Adjust. * tests/data/test-lookup-syms/test1-[123]-report.txt: New. * tests/data/test-lookup-syms/test1.c: New. * tests/data/test-lookup-syms/test1.version-script: New. * tests/test-lookup-syms.cc: Adjust for new tests. * test/Makefile.am: Adjust makefile. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
#include "abg-ir.h"
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
using std::cout;
using std::cerr;
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
using std::string;
using std::ostream;
using std::ostringstream;
Initial support for elf symbol (versionning) during decl comparison * include/abg-fwd.h (get_linkage_name): Remove. * include/abg-dwarf-reader.h (enum symbol_type) (enum symbol_binding): Move these into abg-ir.h. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr): Declare this before using it. (die_address_attribute, die_location_address) (stt_to_elf_symbol_type, stb_to_elf_symbol_binding) (find_hash_table_section_index, find_symbol_table_section) (find_symbol_table_section_index, find_text_section) (find_bss_section, compare_symbol_name) (get_symbol_versionning_sections get_version_for_symbol) (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes) (bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, maybe_adjust_fn_sym_address) (maybe_adjust_var_sym_address): New static functions. (enum hash_table_kind): New enum. (struct gnu_ht): New struct. (read_context::var_decls_to_add_): Renamed var_decls_to_add into this. (read_context::{fun, var}_sym_addr_sym_index_map_): New member. (read_context::{lookup_symbol_from_elf, lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address, lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map, var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps, get_function_address, get_variable_address}): New member functions. (read_context::lookup_public_{variable, function}_symbol_from_elf): Adjust. (op_pushes_constant_value): Fix a bug here. (lookup_symbol_from_elf): Adjust. Support cases where there is no elf hash table, e.g, for relocatable files. (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (build_var_decl): Allow updating the var_decl to associate it with its underlying symbol. In that case, if the linkage name is not set, set it to the symbol name. (build_function_decl): Likewise for function_decl. (operator<<(std::ostream&, symbol_type)): (operator<<(std::ostream&, symbol_binding)): Move these do abg-ir.cc. * include/abg-ir.h (class elf_symbol): Declare new class. Move enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to elf_symbol::binding and elf_symbol::type here. (operator<<(std::ostream&, elf_symbol::type)) (operator<<(std::ostream&, elf_symbol::binding)) (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New operators. (class elf_symbol::version): Declare new class. (class var_decl): Make this pimpl, and add ... (var_decl::{g,s}et_symbol): ... new member functions. (class function_decl): Likewise, make this pimpl and add ... (function_decl::{g,s}et_symbol): ... new member functions. * src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New types. (elf_symbol::*): Lots of new members and member functions. (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New. (operator<<(std::ostream&, elf_symbol::type)): New. (operator<<(std::ostream&, elf_symbol::binding)): New. (elf_symbol::version::priv): New type. (elf_symbol::version::*): Lots of member functions. (get_linkage_name): Removed. (var_decl::priv): New type. Pimplify the thing. (var_decl::{s,g}et_symbol): New. (var_decl::operator==): Take symbols in account in the comparison. (function_decl::priv): New type. (function_decl::*): Pimplify. (function_decl::{s,g}et_symbol): New. (function_decl::operator==): Take symbols in account in the comparison. * include/abg-comparison.h (diff_context::show_linkage_name): New member function. * src/abg-comparison.cc (diff_context::priv::show_linkage_name_): New member. (diff_context::priv::priv): Initialize it. (diff_context::show_linkage_names): New member function. (corpus_diff::report): If the user used --show-linkage-names, display the linkage name after the name of the functions. Add missing "'" in the some spots. * tools/bidiff.cc (options.show_linkage_names): New member. (display_usage, parse_command_line): Support --linkage-names. * tools/bisym.cc (show_help): Add '\n' at the end of help string for --demangle. Add --no-absolute-path option. (parse_command_line): Support --no-absolute-path. (main): Adjust for symbol (versionning) support. Consider that the program successfully completed even when the symbol wasn't found. Support --no-absolute-path. * tests/data/test-lookup-syms/test0-report.txt: New. * tests/data/test-lookup-syms/test01-report.txt: New. * tests/data/test-lookup-syms/test02-report.txt: New. * tests/data/test-read-dwarf/test0.abi: Adjust. * tests/data/test-read-dwarf/test1.abi: Adjust. * tests/data/test-diff-dwarf/test7-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test12-report.txt: Adjust. * tests/data/test-lookup-syms/test1-[123]-report.txt: New. * tests/data/test-lookup-syms/test1.c: New. * tests/data/test-lookup-syms/test1.version-script: New. * tests/test-lookup-syms.cc: Adjust for new tests. * test/Makefile.am: Adjust makefile. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
using std::vector;
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
using abigail::dwarf_reader::lookup_symbol_from_elf;
Initial support for elf symbol (versionning) during decl comparison * include/abg-fwd.h (get_linkage_name): Remove. * include/abg-dwarf-reader.h (enum symbol_type) (enum symbol_binding): Move these into abg-ir.h. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr): Declare this before using it. (die_address_attribute, die_location_address) (stt_to_elf_symbol_type, stb_to_elf_symbol_binding) (find_hash_table_section_index, find_symbol_table_section) (find_symbol_table_section_index, find_text_section) (find_bss_section, compare_symbol_name) (get_symbol_versionning_sections get_version_for_symbol) (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes) (bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, maybe_adjust_fn_sym_address) (maybe_adjust_var_sym_address): New static functions. (enum hash_table_kind): New enum. (struct gnu_ht): New struct. (read_context::var_decls_to_add_): Renamed var_decls_to_add into this. (read_context::{fun, var}_sym_addr_sym_index_map_): New member. (read_context::{lookup_symbol_from_elf, lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address, lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map, var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps, get_function_address, get_variable_address}): New member functions. (read_context::lookup_public_{variable, function}_symbol_from_elf): Adjust. (op_pushes_constant_value): Fix a bug here. (lookup_symbol_from_elf): Adjust. Support cases where there is no elf hash table, e.g, for relocatable files. (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (build_var_decl): Allow updating the var_decl to associate it with its underlying symbol. In that case, if the linkage name is not set, set it to the symbol name. (build_function_decl): Likewise for function_decl. (operator<<(std::ostream&, symbol_type)): (operator<<(std::ostream&, symbol_binding)): Move these do abg-ir.cc. * include/abg-ir.h (class elf_symbol): Declare new class. Move enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to elf_symbol::binding and elf_symbol::type here. (operator<<(std::ostream&, elf_symbol::type)) (operator<<(std::ostream&, elf_symbol::binding)) (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New operators. (class elf_symbol::version): Declare new class. (class var_decl): Make this pimpl, and add ... (var_decl::{g,s}et_symbol): ... new member functions. (class function_decl): Likewise, make this pimpl and add ... (function_decl::{g,s}et_symbol): ... new member functions. * src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New types. (elf_symbol::*): Lots of new members and member functions. (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New. (operator<<(std::ostream&, elf_symbol::type)): New. (operator<<(std::ostream&, elf_symbol::binding)): New. (elf_symbol::version::priv): New type. (elf_symbol::version::*): Lots of member functions. (get_linkage_name): Removed. (var_decl::priv): New type. Pimplify the thing. (var_decl::{s,g}et_symbol): New. (var_decl::operator==): Take symbols in account in the comparison. (function_decl::priv): New type. (function_decl::*): Pimplify. (function_decl::{s,g}et_symbol): New. (function_decl::operator==): Take symbols in account in the comparison. * include/abg-comparison.h (diff_context::show_linkage_name): New member function. * src/abg-comparison.cc (diff_context::priv::show_linkage_name_): New member. (diff_context::priv::priv): Initialize it. (diff_context::show_linkage_names): New member function. (corpus_diff::report): If the user used --show-linkage-names, display the linkage name after the name of the functions. Add missing "'" in the some spots. * tools/bidiff.cc (options.show_linkage_names): New member. (display_usage, parse_command_line): Support --linkage-names. * tools/bisym.cc (show_help): Add '\n' at the end of help string for --demangle. Add --no-absolute-path option. (parse_command_line): Support --no-absolute-path. (main): Adjust for symbol (versionning) support. Consider that the program successfully completed even when the symbol wasn't found. Support --no-absolute-path. * tests/data/test-lookup-syms/test0-report.txt: New. * tests/data/test-lookup-syms/test01-report.txt: New. * tests/data/test-lookup-syms/test02-report.txt: New. * tests/data/test-read-dwarf/test0.abi: Adjust. * tests/data/test-read-dwarf/test1.abi: Adjust. * tests/data/test-diff-dwarf/test7-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test12-report.txt: Adjust. * tests/data/test-lookup-syms/test1-[123]-report.txt: New. * tests/data/test-lookup-syms/test1.c: New. * tests/data/test-lookup-syms/test1.version-script: New. * tests/test-lookup-syms.cc: Adjust for new tests. * test/Makefile.am: Adjust makefile. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
using abigail::elf_symbol;
Fix symbols comparison While working on something else, I noticed that the code for handling copying symbols (and their aliases) was broken, and so comparing two symbols which main name were different by which had aliases that were equal was wrongly resulting in the two symbol being different. I think we shouldn't actually copy symbols and their aliases. Once a symbol is allocated, interested code should just manipulate that symbol by address rather than by value an thus do away with the copying. The patch does that, essentially. In the implementation of a symbol, the aliases as well as the main symbol are now weak pointers, rather than naked pointers. Numerous API entry points that were taking containers of elf_symbol (and were copying elf_symbols over) are not taking containers of smart pointers to elf_symbol. Copying of instances of elf_symbol is now thus disabled. As a result many tests that were exercising elf_symbols (with alias) comparison have been updated. As a result, many empty sub-result of PR libabigail/PR17948 are now fixed. * include/abg-ir.h (elf_symbol_wptr): New typedef. (elf_symbol): Make the constructors and assignment operator private. The type can neither be copied nor created with the new operator. (elf_symbol::create): New static member function. (elf_symbol::{get_main_symbol, get_next_alias, add_alias}): Adjust. ( compute_aliases_for_elf_symbol): Likewise. (elf_symbol::operator=): Make this private. (elf_symbol::get_alias_which_equals): Declare new member function. * src/abg-comp-filter.cc (function_name_changed_but_not_symbol): Adjust. * src/abg-comparison.cc (class_diff::ensure_lookup_tables_populated): Adjust. * src/abg-corpus.cc (corpus::priv::build_unreferenced_symbols_tables): Likewise. * include/abg-dwarf-reader.h (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (read_context::lookup_elf_symbol_from_index): Likewise. (read_context::lookup_elf_fn_symbol_from_address): Likewise. (read_context::lookup_elf_var_symbol_from_address): Likewise. (read_context::lookup_public_function_symbol_from_elf): Likewise. (read_context::lookup_public_variable_symbol_from_elf): Likewise. (read_context::load_symbol_maps): Likewise. (build_var_decl, build_function_decl): Likewise. * src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}): Change the type of these from elf_symbol* to elf_symbol_wptr. (elf_symbol::priv::priv): Adjust. (elf_symbol::{create, get_alias_which_equals}): Define new functions. (textually_equals): Likewise. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, add_alias}): Adjust to return or take elf_symbol_sptr type, rather than a elf_symbol* one. (elf_symbol::{get_aliases_id_string, does_alias}): Adjust. (compute_alias_for_elf_symbol): Likewise. (elf_symbol::operator==): Two symbols A and B are now equal if A has at least one alias that is textually equal to B. (equals): In the overload for function_decls, in the part where we compare the decl_base part of the functions without considering their decl names, we now also omit considering their linkage names, because we compared they symbols before. * tools/abisym.cc (main): Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust. * tests/data/test-diff-dwarf/test8-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test13-report.txt: Adjust. * tests/data/test-diff-filter/test2-report.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust. * tests/data/test-diff-filter/test9-report.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-01 22:07:02 +00:00
using abigail::elf_symbol_sptr;
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
struct options
{
bool show_help;
char* elf_path;
char* symbol_name;
bool demangle;
Initial support for elf symbol (versionning) during decl comparison * include/abg-fwd.h (get_linkage_name): Remove. * include/abg-dwarf-reader.h (enum symbol_type) (enum symbol_binding): Move these into abg-ir.h. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr): Declare this before using it. (die_address_attribute, die_location_address) (stt_to_elf_symbol_type, stb_to_elf_symbol_binding) (find_hash_table_section_index, find_symbol_table_section) (find_symbol_table_section_index, find_text_section) (find_bss_section, compare_symbol_name) (get_symbol_versionning_sections get_version_for_symbol) (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes) (bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, maybe_adjust_fn_sym_address) (maybe_adjust_var_sym_address): New static functions. (enum hash_table_kind): New enum. (struct gnu_ht): New struct. (read_context::var_decls_to_add_): Renamed var_decls_to_add into this. (read_context::{fun, var}_sym_addr_sym_index_map_): New member. (read_context::{lookup_symbol_from_elf, lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address, lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map, var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps, get_function_address, get_variable_address}): New member functions. (read_context::lookup_public_{variable, function}_symbol_from_elf): Adjust. (op_pushes_constant_value): Fix a bug here. (lookup_symbol_from_elf): Adjust. Support cases where there is no elf hash table, e.g, for relocatable files. (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (build_var_decl): Allow updating the var_decl to associate it with its underlying symbol. In that case, if the linkage name is not set, set it to the symbol name. (build_function_decl): Likewise for function_decl. (operator<<(std::ostream&, symbol_type)): (operator<<(std::ostream&, symbol_binding)): Move these do abg-ir.cc. * include/abg-ir.h (class elf_symbol): Declare new class. Move enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to elf_symbol::binding and elf_symbol::type here. (operator<<(std::ostream&, elf_symbol::type)) (operator<<(std::ostream&, elf_symbol::binding)) (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New operators. (class elf_symbol::version): Declare new class. (class var_decl): Make this pimpl, and add ... (var_decl::{g,s}et_symbol): ... new member functions. (class function_decl): Likewise, make this pimpl and add ... (function_decl::{g,s}et_symbol): ... new member functions. * src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New types. (elf_symbol::*): Lots of new members and member functions. (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New. (operator<<(std::ostream&, elf_symbol::type)): New. (operator<<(std::ostream&, elf_symbol::binding)): New. (elf_symbol::version::priv): New type. (elf_symbol::version::*): Lots of member functions. (get_linkage_name): Removed. (var_decl::priv): New type. Pimplify the thing. (var_decl::{s,g}et_symbol): New. (var_decl::operator==): Take symbols in account in the comparison. (function_decl::priv): New type. (function_decl::*): Pimplify. (function_decl::{s,g}et_symbol): New. (function_decl::operator==): Take symbols in account in the comparison. * include/abg-comparison.h (diff_context::show_linkage_name): New member function. * src/abg-comparison.cc (diff_context::priv::show_linkage_name_): New member. (diff_context::priv::priv): Initialize it. (diff_context::show_linkage_names): New member function. (corpus_diff::report): If the user used --show-linkage-names, display the linkage name after the name of the functions. Add missing "'" in the some spots. * tools/bidiff.cc (options.show_linkage_names): New member. (display_usage, parse_command_line): Support --linkage-names. * tools/bisym.cc (show_help): Add '\n' at the end of help string for --demangle. Add --no-absolute-path option. (parse_command_line): Support --no-absolute-path. (main): Adjust for symbol (versionning) support. Consider that the program successfully completed even when the symbol wasn't found. Support --no-absolute-path. * tests/data/test-lookup-syms/test0-report.txt: New. * tests/data/test-lookup-syms/test01-report.txt: New. * tests/data/test-lookup-syms/test02-report.txt: New. * tests/data/test-read-dwarf/test0.abi: Adjust. * tests/data/test-read-dwarf/test1.abi: Adjust. * tests/data/test-diff-dwarf/test7-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test12-report.txt: Adjust. * tests/data/test-lookup-syms/test1-[123]-report.txt: New. * tests/data/test-lookup-syms/test1.c: New. * tests/data/test-lookup-syms/test1.version-script: New. * tests/test-lookup-syms.cc: Adjust for new tests. * test/Makefile.am: Adjust makefile. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
bool absolute_path;
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
options()
: show_help(false),
elf_path(0),
symbol_name(0),
Initial support for elf symbol (versionning) during decl comparison * include/abg-fwd.h (get_linkage_name): Remove. * include/abg-dwarf-reader.h (enum symbol_type) (enum symbol_binding): Move these into abg-ir.h. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr): Declare this before using it. (die_address_attribute, die_location_address) (stt_to_elf_symbol_type, stb_to_elf_symbol_binding) (find_hash_table_section_index, find_symbol_table_section) (find_symbol_table_section_index, find_text_section) (find_bss_section, compare_symbol_name) (get_symbol_versionning_sections get_version_for_symbol) (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes) (bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, maybe_adjust_fn_sym_address) (maybe_adjust_var_sym_address): New static functions. (enum hash_table_kind): New enum. (struct gnu_ht): New struct. (read_context::var_decls_to_add_): Renamed var_decls_to_add into this. (read_context::{fun, var}_sym_addr_sym_index_map_): New member. (read_context::{lookup_symbol_from_elf, lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address, lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map, var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps, get_function_address, get_variable_address}): New member functions. (read_context::lookup_public_{variable, function}_symbol_from_elf): Adjust. (op_pushes_constant_value): Fix a bug here. (lookup_symbol_from_elf): Adjust. Support cases where there is no elf hash table, e.g, for relocatable files. (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (build_var_decl): Allow updating the var_decl to associate it with its underlying symbol. In that case, if the linkage name is not set, set it to the symbol name. (build_function_decl): Likewise for function_decl. (operator<<(std::ostream&, symbol_type)): (operator<<(std::ostream&, symbol_binding)): Move these do abg-ir.cc. * include/abg-ir.h (class elf_symbol): Declare new class. Move enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to elf_symbol::binding and elf_symbol::type here. (operator<<(std::ostream&, elf_symbol::type)) (operator<<(std::ostream&, elf_symbol::binding)) (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New operators. (class elf_symbol::version): Declare new class. (class var_decl): Make this pimpl, and add ... (var_decl::{g,s}et_symbol): ... new member functions. (class function_decl): Likewise, make this pimpl and add ... (function_decl::{g,s}et_symbol): ... new member functions. * src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New types. (elf_symbol::*): Lots of new members and member functions. (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New. (operator<<(std::ostream&, elf_symbol::type)): New. (operator<<(std::ostream&, elf_symbol::binding)): New. (elf_symbol::version::priv): New type. (elf_symbol::version::*): Lots of member functions. (get_linkage_name): Removed. (var_decl::priv): New type. Pimplify the thing. (var_decl::{s,g}et_symbol): New. (var_decl::operator==): Take symbols in account in the comparison. (function_decl::priv): New type. (function_decl::*): Pimplify. (function_decl::{s,g}et_symbol): New. (function_decl::operator==): Take symbols in account in the comparison. * include/abg-comparison.h (diff_context::show_linkage_name): New member function. * src/abg-comparison.cc (diff_context::priv::show_linkage_name_): New member. (diff_context::priv::priv): Initialize it. (diff_context::show_linkage_names): New member function. (corpus_diff::report): If the user used --show-linkage-names, display the linkage name after the name of the functions. Add missing "'" in the some spots. * tools/bidiff.cc (options.show_linkage_names): New member. (display_usage, parse_command_line): Support --linkage-names. * tools/bisym.cc (show_help): Add '\n' at the end of help string for --demangle. Add --no-absolute-path option. (parse_command_line): Support --no-absolute-path. (main): Adjust for symbol (versionning) support. Consider that the program successfully completed even when the symbol wasn't found. Support --no-absolute-path. * tests/data/test-lookup-syms/test0-report.txt: New. * tests/data/test-lookup-syms/test01-report.txt: New. * tests/data/test-lookup-syms/test02-report.txt: New. * tests/data/test-read-dwarf/test0.abi: Adjust. * tests/data/test-read-dwarf/test1.abi: Adjust. * tests/data/test-diff-dwarf/test7-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test12-report.txt: Adjust. * tests/data/test-lookup-syms/test1-[123]-report.txt: New. * tests/data/test-lookup-syms/test1.c: New. * tests/data/test-lookup-syms/test1.version-script: New. * tests/test-lookup-syms.cc: Adjust for new tests. * test/Makefile.am: Adjust makefile. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
demangle(false),
absolute_path(true)
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
{}
};
static void
display_usage(const string& prog_name, ostream &out)
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
{
out << "usage: " << prog_name << " [options] <elf file> <symbol-name>\n"
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
<< "where [options] can be:\n"
<< " --help display this help string\n"
Initial support for elf symbol (versionning) during decl comparison * include/abg-fwd.h (get_linkage_name): Remove. * include/abg-dwarf-reader.h (enum symbol_type) (enum symbol_binding): Move these into abg-ir.h. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr): Declare this before using it. (die_address_attribute, die_location_address) (stt_to_elf_symbol_type, stb_to_elf_symbol_binding) (find_hash_table_section_index, find_symbol_table_section) (find_symbol_table_section_index, find_text_section) (find_bss_section, compare_symbol_name) (get_symbol_versionning_sections get_version_for_symbol) (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes) (bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, maybe_adjust_fn_sym_address) (maybe_adjust_var_sym_address): New static functions. (enum hash_table_kind): New enum. (struct gnu_ht): New struct. (read_context::var_decls_to_add_): Renamed var_decls_to_add into this. (read_context::{fun, var}_sym_addr_sym_index_map_): New member. (read_context::{lookup_symbol_from_elf, lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address, lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map, var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps, get_function_address, get_variable_address}): New member functions. (read_context::lookup_public_{variable, function}_symbol_from_elf): Adjust. (op_pushes_constant_value): Fix a bug here. (lookup_symbol_from_elf): Adjust. Support cases where there is no elf hash table, e.g, for relocatable files. (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (build_var_decl): Allow updating the var_decl to associate it with its underlying symbol. In that case, if the linkage name is not set, set it to the symbol name. (build_function_decl): Likewise for function_decl. (operator<<(std::ostream&, symbol_type)): (operator<<(std::ostream&, symbol_binding)): Move these do abg-ir.cc. * include/abg-ir.h (class elf_symbol): Declare new class. Move enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to elf_symbol::binding and elf_symbol::type here. (operator<<(std::ostream&, elf_symbol::type)) (operator<<(std::ostream&, elf_symbol::binding)) (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New operators. (class elf_symbol::version): Declare new class. (class var_decl): Make this pimpl, and add ... (var_decl::{g,s}et_symbol): ... new member functions. (class function_decl): Likewise, make this pimpl and add ... (function_decl::{g,s}et_symbol): ... new member functions. * src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New types. (elf_symbol::*): Lots of new members and member functions. (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New. (operator<<(std::ostream&, elf_symbol::type)): New. (operator<<(std::ostream&, elf_symbol::binding)): New. (elf_symbol::version::priv): New type. (elf_symbol::version::*): Lots of member functions. (get_linkage_name): Removed. (var_decl::priv): New type. Pimplify the thing. (var_decl::{s,g}et_symbol): New. (var_decl::operator==): Take symbols in account in the comparison. (function_decl::priv): New type. (function_decl::*): Pimplify. (function_decl::{s,g}et_symbol): New. (function_decl::operator==): Take symbols in account in the comparison. * include/abg-comparison.h (diff_context::show_linkage_name): New member function. * src/abg-comparison.cc (diff_context::priv::show_linkage_name_): New member. (diff_context::priv::priv): Initialize it. (diff_context::show_linkage_names): New member function. (corpus_diff::report): If the user used --show-linkage-names, display the linkage name after the name of the functions. Add missing "'" in the some spots. * tools/bidiff.cc (options.show_linkage_names): New member. (display_usage, parse_command_line): Support --linkage-names. * tools/bisym.cc (show_help): Add '\n' at the end of help string for --demangle. Add --no-absolute-path option. (parse_command_line): Support --no-absolute-path. (main): Adjust for symbol (versionning) support. Consider that the program successfully completed even when the symbol wasn't found. Support --no-absolute-path. * tests/data/test-lookup-syms/test0-report.txt: New. * tests/data/test-lookup-syms/test01-report.txt: New. * tests/data/test-lookup-syms/test02-report.txt: New. * tests/data/test-read-dwarf/test0.abi: Adjust. * tests/data/test-read-dwarf/test1.abi: Adjust. * tests/data/test-diff-dwarf/test7-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test12-report.txt: Adjust. * tests/data/test-lookup-syms/test1-[123]-report.txt: New. * tests/data/test-lookup-syms/test1.c: New. * tests/data/test-lookup-syms/test1.version-script: New. * tests/test-lookup-syms.cc: Adjust for new tests. * test/Makefile.am: Adjust makefile. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
<< " --demangle demangle the symbols from the symbol table\n"
<< " --no-absolute-path do not show absolute paths in messages\n";
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
}
static void
parse_command_line(int argc, char* argv[], options& opts)
{
if (argc < 2)
{
opts.show_help = true;
return;
}
for (int i = 1; i < argc; ++i)
{
if (argv[i][0] != '-')
{
if (!opts.elf_path)
opts.elf_path = argv[i];
else if (!opts.symbol_name)
opts.symbol_name = argv[i] ;
else
{
opts.show_help = true;
return;
}
}
else if (!strcmp(argv[i], "--help")
|| !strcmp(argv[i], "-h"))
{
opts.show_help = true;
return;
}
else if (!strcmp(argv[i], "--demangle"))
opts.demangle = true;
Initial support for elf symbol (versionning) during decl comparison * include/abg-fwd.h (get_linkage_name): Remove. * include/abg-dwarf-reader.h (enum symbol_type) (enum symbol_binding): Move these into abg-ir.h. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr): Declare this before using it. (die_address_attribute, die_location_address) (stt_to_elf_symbol_type, stb_to_elf_symbol_binding) (find_hash_table_section_index, find_symbol_table_section) (find_symbol_table_section_index, find_text_section) (find_bss_section, compare_symbol_name) (get_symbol_versionning_sections get_version_for_symbol) (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes) (bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, maybe_adjust_fn_sym_address) (maybe_adjust_var_sym_address): New static functions. (enum hash_table_kind): New enum. (struct gnu_ht): New struct. (read_context::var_decls_to_add_): Renamed var_decls_to_add into this. (read_context::{fun, var}_sym_addr_sym_index_map_): New member. (read_context::{lookup_symbol_from_elf, lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address, lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map, var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps, get_function_address, get_variable_address}): New member functions. (read_context::lookup_public_{variable, function}_symbol_from_elf): Adjust. (op_pushes_constant_value): Fix a bug here. (lookup_symbol_from_elf): Adjust. Support cases where there is no elf hash table, e.g, for relocatable files. (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (build_var_decl): Allow updating the var_decl to associate it with its underlying symbol. In that case, if the linkage name is not set, set it to the symbol name. (build_function_decl): Likewise for function_decl. (operator<<(std::ostream&, symbol_type)): (operator<<(std::ostream&, symbol_binding)): Move these do abg-ir.cc. * include/abg-ir.h (class elf_symbol): Declare new class. Move enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to elf_symbol::binding and elf_symbol::type here. (operator<<(std::ostream&, elf_symbol::type)) (operator<<(std::ostream&, elf_symbol::binding)) (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New operators. (class elf_symbol::version): Declare new class. (class var_decl): Make this pimpl, and add ... (var_decl::{g,s}et_symbol): ... new member functions. (class function_decl): Likewise, make this pimpl and add ... (function_decl::{g,s}et_symbol): ... new member functions. * src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New types. (elf_symbol::*): Lots of new members and member functions. (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New. (operator<<(std::ostream&, elf_symbol::type)): New. (operator<<(std::ostream&, elf_symbol::binding)): New. (elf_symbol::version::priv): New type. (elf_symbol::version::*): Lots of member functions. (get_linkage_name): Removed. (var_decl::priv): New type. Pimplify the thing. (var_decl::{s,g}et_symbol): New. (var_decl::operator==): Take symbols in account in the comparison. (function_decl::priv): New type. (function_decl::*): Pimplify. (function_decl::{s,g}et_symbol): New. (function_decl::operator==): Take symbols in account in the comparison. * include/abg-comparison.h (diff_context::show_linkage_name): New member function. * src/abg-comparison.cc (diff_context::priv::show_linkage_name_): New member. (diff_context::priv::priv): Initialize it. (diff_context::show_linkage_names): New member function. (corpus_diff::report): If the user used --show-linkage-names, display the linkage name after the name of the functions. Add missing "'" in the some spots. * tools/bidiff.cc (options.show_linkage_names): New member. (display_usage, parse_command_line): Support --linkage-names. * tools/bisym.cc (show_help): Add '\n' at the end of help string for --demangle. Add --no-absolute-path option. (parse_command_line): Support --no-absolute-path. (main): Adjust for symbol (versionning) support. Consider that the program successfully completed even when the symbol wasn't found. Support --no-absolute-path. * tests/data/test-lookup-syms/test0-report.txt: New. * tests/data/test-lookup-syms/test01-report.txt: New. * tests/data/test-lookup-syms/test02-report.txt: New. * tests/data/test-read-dwarf/test0.abi: Adjust. * tests/data/test-read-dwarf/test1.abi: Adjust. * tests/data/test-diff-dwarf/test7-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test12-report.txt: Adjust. * tests/data/test-lookup-syms/test1-[123]-report.txt: New. * tests/data/test-lookup-syms/test1.c: New. * tests/data/test-lookup-syms/test1.version-script: New. * tests/test-lookup-syms.cc: Adjust for new tests. * test/Makefile.am: Adjust makefile. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
else if (!strcmp(argv[i], "--no-absolute-path"))
opts.absolute_path = false;
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
else
opts.show_help = true;
}
}
int
main(int argc, char* argv[])
{
options opts;
parse_command_line(argc, argv, opts);
if (opts.show_help)
{
display_usage(argv[0], cout);
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
return 1;
}
assert(opts.elf_path != 0
&& opts.symbol_name != 0);
Initial support for elf symbol (versionning) during decl comparison * include/abg-fwd.h (get_linkage_name): Remove. * include/abg-dwarf-reader.h (enum symbol_type) (enum symbol_binding): Move these into abg-ir.h. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr): Declare this before using it. (die_address_attribute, die_location_address) (stt_to_elf_symbol_type, stb_to_elf_symbol_binding) (find_hash_table_section_index, find_symbol_table_section) (find_symbol_table_section_index, find_text_section) (find_bss_section, compare_symbol_name) (get_symbol_versionning_sections get_version_for_symbol) (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes) (bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, maybe_adjust_fn_sym_address) (maybe_adjust_var_sym_address): New static functions. (enum hash_table_kind): New enum. (struct gnu_ht): New struct. (read_context::var_decls_to_add_): Renamed var_decls_to_add into this. (read_context::{fun, var}_sym_addr_sym_index_map_): New member. (read_context::{lookup_symbol_from_elf, lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address, lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map, var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps, get_function_address, get_variable_address}): New member functions. (read_context::lookup_public_{variable, function}_symbol_from_elf): Adjust. (op_pushes_constant_value): Fix a bug here. (lookup_symbol_from_elf): Adjust. Support cases where there is no elf hash table, e.g, for relocatable files. (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (build_var_decl): Allow updating the var_decl to associate it with its underlying symbol. In that case, if the linkage name is not set, set it to the symbol name. (build_function_decl): Likewise for function_decl. (operator<<(std::ostream&, symbol_type)): (operator<<(std::ostream&, symbol_binding)): Move these do abg-ir.cc. * include/abg-ir.h (class elf_symbol): Declare new class. Move enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to elf_symbol::binding and elf_symbol::type here. (operator<<(std::ostream&, elf_symbol::type)) (operator<<(std::ostream&, elf_symbol::binding)) (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New operators. (class elf_symbol::version): Declare new class. (class var_decl): Make this pimpl, and add ... (var_decl::{g,s}et_symbol): ... new member functions. (class function_decl): Likewise, make this pimpl and add ... (function_decl::{g,s}et_symbol): ... new member functions. * src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New types. (elf_symbol::*): Lots of new members and member functions. (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New. (operator<<(std::ostream&, elf_symbol::type)): New. (operator<<(std::ostream&, elf_symbol::binding)): New. (elf_symbol::version::priv): New type. (elf_symbol::version::*): Lots of member functions. (get_linkage_name): Removed. (var_decl::priv): New type. Pimplify the thing. (var_decl::{s,g}et_symbol): New. (var_decl::operator==): Take symbols in account in the comparison. (function_decl::priv): New type. (function_decl::*): Pimplify. (function_decl::{s,g}et_symbol): New. (function_decl::operator==): Take symbols in account in the comparison. * include/abg-comparison.h (diff_context::show_linkage_name): New member function. * src/abg-comparison.cc (diff_context::priv::show_linkage_name_): New member. (diff_context::priv::priv): Initialize it. (diff_context::show_linkage_names): New member function. (corpus_diff::report): If the user used --show-linkage-names, display the linkage name after the name of the functions. Add missing "'" in the some spots. * tools/bidiff.cc (options.show_linkage_names): New member. (display_usage, parse_command_line): Support --linkage-names. * tools/bisym.cc (show_help): Add '\n' at the end of help string for --demangle. Add --no-absolute-path option. (parse_command_line): Support --no-absolute-path. (main): Adjust for symbol (versionning) support. Consider that the program successfully completed even when the symbol wasn't found. Support --no-absolute-path. * tests/data/test-lookup-syms/test0-report.txt: New. * tests/data/test-lookup-syms/test01-report.txt: New. * tests/data/test-lookup-syms/test02-report.txt: New. * tests/data/test-read-dwarf/test0.abi: Adjust. * tests/data/test-read-dwarf/test1.abi: Adjust. * tests/data/test-diff-dwarf/test7-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test12-report.txt: Adjust. * tests/data/test-lookup-syms/test1-[123]-report.txt: New. * tests/data/test-lookup-syms/test1.c: New. * tests/data/test-lookup-syms/test1.version-script: New. * tests/test-lookup-syms.cc: Adjust for new tests. * test/Makefile.am: Adjust makefile. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
string p = opts.elf_path, n = opts.symbol_name;
Fix symbols comparison While working on something else, I noticed that the code for handling copying symbols (and their aliases) was broken, and so comparing two symbols which main name were different by which had aliases that were equal was wrongly resulting in the two symbol being different. I think we shouldn't actually copy symbols and their aliases. Once a symbol is allocated, interested code should just manipulate that symbol by address rather than by value an thus do away with the copying. The patch does that, essentially. In the implementation of a symbol, the aliases as well as the main symbol are now weak pointers, rather than naked pointers. Numerous API entry points that were taking containers of elf_symbol (and were copying elf_symbols over) are not taking containers of smart pointers to elf_symbol. Copying of instances of elf_symbol is now thus disabled. As a result many tests that were exercising elf_symbols (with alias) comparison have been updated. As a result, many empty sub-result of PR libabigail/PR17948 are now fixed. * include/abg-ir.h (elf_symbol_wptr): New typedef. (elf_symbol): Make the constructors and assignment operator private. The type can neither be copied nor created with the new operator. (elf_symbol::create): New static member function. (elf_symbol::{get_main_symbol, get_next_alias, add_alias}): Adjust. ( compute_aliases_for_elf_symbol): Likewise. (elf_symbol::operator=): Make this private. (elf_symbol::get_alias_which_equals): Declare new member function. * src/abg-comp-filter.cc (function_name_changed_but_not_symbol): Adjust. * src/abg-comparison.cc (class_diff::ensure_lookup_tables_populated): Adjust. * src/abg-corpus.cc (corpus::priv::build_unreferenced_symbols_tables): Likewise. * include/abg-dwarf-reader.h (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (read_context::lookup_elf_symbol_from_index): Likewise. (read_context::lookup_elf_fn_symbol_from_address): Likewise. (read_context::lookup_elf_var_symbol_from_address): Likewise. (read_context::lookup_public_function_symbol_from_elf): Likewise. (read_context::lookup_public_variable_symbol_from_elf): Likewise. (read_context::load_symbol_maps): Likewise. (build_var_decl, build_function_decl): Likewise. * src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}): Change the type of these from elf_symbol* to elf_symbol_wptr. (elf_symbol::priv::priv): Adjust. (elf_symbol::{create, get_alias_which_equals}): Define new functions. (textually_equals): Likewise. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, add_alias}): Adjust to return or take elf_symbol_sptr type, rather than a elf_symbol* one. (elf_symbol::{get_aliases_id_string, does_alias}): Adjust. (compute_alias_for_elf_symbol): Likewise. (elf_symbol::operator==): Two symbols A and B are now equal if A has at least one alias that is textually equal to B. (equals): In the overload for function_decls, in the part where we compare the decl_base part of the functions without considering their decl names, we now also omit considering their linkage names, because we compared they symbols before. * tools/abisym.cc (main): Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust. * tests/data/test-diff-dwarf/test8-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test13-report.txt: Adjust. * tests/data/test-diff-filter/test2-report.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust. * tests/data/test-diff-filter/test9-report.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-01 22:07:02 +00:00
vector<elf_symbol_sptr> syms;
Initial support for elf symbol (versionning) during decl comparison * include/abg-fwd.h (get_linkage_name): Remove. * include/abg-dwarf-reader.h (enum symbol_type) (enum symbol_binding): Move these into abg-ir.h. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr): Declare this before using it. (die_address_attribute, die_location_address) (stt_to_elf_symbol_type, stb_to_elf_symbol_binding) (find_hash_table_section_index, find_symbol_table_section) (find_symbol_table_section_index, find_text_section) (find_bss_section, compare_symbol_name) (get_symbol_versionning_sections get_version_for_symbol) (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes) (bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, maybe_adjust_fn_sym_address) (maybe_adjust_var_sym_address): New static functions. (enum hash_table_kind): New enum. (struct gnu_ht): New struct. (read_context::var_decls_to_add_): Renamed var_decls_to_add into this. (read_context::{fun, var}_sym_addr_sym_index_map_): New member. (read_context::{lookup_symbol_from_elf, lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address, lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map, var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps, get_function_address, get_variable_address}): New member functions. (read_context::lookup_public_{variable, function}_symbol_from_elf): Adjust. (op_pushes_constant_value): Fix a bug here. (lookup_symbol_from_elf): Adjust. Support cases where there is no elf hash table, e.g, for relocatable files. (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (build_var_decl): Allow updating the var_decl to associate it with its underlying symbol. In that case, if the linkage name is not set, set it to the symbol name. (build_function_decl): Likewise for function_decl. (operator<<(std::ostream&, symbol_type)): (operator<<(std::ostream&, symbol_binding)): Move these do abg-ir.cc. * include/abg-ir.h (class elf_symbol): Declare new class. Move enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to elf_symbol::binding and elf_symbol::type here. (operator<<(std::ostream&, elf_symbol::type)) (operator<<(std::ostream&, elf_symbol::binding)) (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New operators. (class elf_symbol::version): Declare new class. (class var_decl): Make this pimpl, and add ... (var_decl::{g,s}et_symbol): ... new member functions. (class function_decl): Likewise, make this pimpl and add ... (function_decl::{g,s}et_symbol): ... new member functions. * src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New types. (elf_symbol::*): Lots of new members and member functions. (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New. (operator<<(std::ostream&, elf_symbol::type)): New. (operator<<(std::ostream&, elf_symbol::binding)): New. (elf_symbol::version::priv): New type. (elf_symbol::version::*): Lots of member functions. (get_linkage_name): Removed. (var_decl::priv): New type. Pimplify the thing. (var_decl::{s,g}et_symbol): New. (var_decl::operator==): Take symbols in account in the comparison. (function_decl::priv): New type. (function_decl::*): Pimplify. (function_decl::{s,g}et_symbol): New. (function_decl::operator==): Take symbols in account in the comparison. * include/abg-comparison.h (diff_context::show_linkage_name): New member function. * src/abg-comparison.cc (diff_context::priv::show_linkage_name_): New member. (diff_context::priv::priv): Initialize it. (diff_context::show_linkage_names): New member function. (corpus_diff::report): If the user used --show-linkage-names, display the linkage name after the name of the functions. Add missing "'" in the some spots. * tools/bidiff.cc (options.show_linkage_names): New member. (display_usage, parse_command_line): Support --linkage-names. * tools/bisym.cc (show_help): Add '\n' at the end of help string for --demangle. Add --no-absolute-path option. (parse_command_line): Support --no-absolute-path. (main): Adjust for symbol (versionning) support. Consider that the program successfully completed even when the symbol wasn't found. Support --no-absolute-path. * tests/data/test-lookup-syms/test0-report.txt: New. * tests/data/test-lookup-syms/test01-report.txt: New. * tests/data/test-lookup-syms/test02-report.txt: New. * tests/data/test-read-dwarf/test0.abi: Adjust. * tests/data/test-read-dwarf/test1.abi: Adjust. * tests/data/test-diff-dwarf/test7-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test12-report.txt: Adjust. * tests/data/test-lookup-syms/test1-[123]-report.txt: New. * tests/data/test-lookup-syms/test1.c: New. * tests/data/test-lookup-syms/test1.version-script: New. * tests/test-lookup-syms.cc: Adjust for new tests. * test/Makefile.am: Adjust makefile. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
if (!lookup_symbol_from_elf(p, n, opts.demangle, syms))
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
{
cout << "could not find symbol '"
<< opts.symbol_name
Initial support for elf symbol (versionning) during decl comparison * include/abg-fwd.h (get_linkage_name): Remove. * include/abg-dwarf-reader.h (enum symbol_type) (enum symbol_binding): Move these into abg-ir.h. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr): Declare this before using it. (die_address_attribute, die_location_address) (stt_to_elf_symbol_type, stb_to_elf_symbol_binding) (find_hash_table_section_index, find_symbol_table_section) (find_symbol_table_section_index, find_text_section) (find_bss_section, compare_symbol_name) (get_symbol_versionning_sections get_version_for_symbol) (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes) (bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, maybe_adjust_fn_sym_address) (maybe_adjust_var_sym_address): New static functions. (enum hash_table_kind): New enum. (struct gnu_ht): New struct. (read_context::var_decls_to_add_): Renamed var_decls_to_add into this. (read_context::{fun, var}_sym_addr_sym_index_map_): New member. (read_context::{lookup_symbol_from_elf, lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address, lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map, var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps, get_function_address, get_variable_address}): New member functions. (read_context::lookup_public_{variable, function}_symbol_from_elf): Adjust. (op_pushes_constant_value): Fix a bug here. (lookup_symbol_from_elf): Adjust. Support cases where there is no elf hash table, e.g, for relocatable files. (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (build_var_decl): Allow updating the var_decl to associate it with its underlying symbol. In that case, if the linkage name is not set, set it to the symbol name. (build_function_decl): Likewise for function_decl. (operator<<(std::ostream&, symbol_type)): (operator<<(std::ostream&, symbol_binding)): Move these do abg-ir.cc. * include/abg-ir.h (class elf_symbol): Declare new class. Move enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to elf_symbol::binding and elf_symbol::type here. (operator<<(std::ostream&, elf_symbol::type)) (operator<<(std::ostream&, elf_symbol::binding)) (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New operators. (class elf_symbol::version): Declare new class. (class var_decl): Make this pimpl, and add ... (var_decl::{g,s}et_symbol): ... new member functions. (class function_decl): Likewise, make this pimpl and add ... (function_decl::{g,s}et_symbol): ... new member functions. * src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New types. (elf_symbol::*): Lots of new members and member functions. (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New. (operator<<(std::ostream&, elf_symbol::type)): New. (operator<<(std::ostream&, elf_symbol::binding)): New. (elf_symbol::version::priv): New type. (elf_symbol::version::*): Lots of member functions. (get_linkage_name): Removed. (var_decl::priv): New type. Pimplify the thing. (var_decl::{s,g}et_symbol): New. (var_decl::operator==): Take symbols in account in the comparison. (function_decl::priv): New type. (function_decl::*): Pimplify. (function_decl::{s,g}et_symbol): New. (function_decl::operator==): Take symbols in account in the comparison. * include/abg-comparison.h (diff_context::show_linkage_name): New member function. * src/abg-comparison.cc (diff_context::priv::show_linkage_name_): New member. (diff_context::priv::priv): Initialize it. (diff_context::show_linkage_names): New member function. (corpus_diff::report): If the user used --show-linkage-names, display the linkage name after the name of the functions. Add missing "'" in the some spots. * tools/bidiff.cc (options.show_linkage_names): New member. (display_usage, parse_command_line): Support --linkage-names. * tools/bisym.cc (show_help): Add '\n' at the end of help string for --demangle. Add --no-absolute-path option. (parse_command_line): Support --no-absolute-path. (main): Adjust for symbol (versionning) support. Consider that the program successfully completed even when the symbol wasn't found. Support --no-absolute-path. * tests/data/test-lookup-syms/test0-report.txt: New. * tests/data/test-lookup-syms/test01-report.txt: New. * tests/data/test-lookup-syms/test02-report.txt: New. * tests/data/test-read-dwarf/test0.abi: Adjust. * tests/data/test-read-dwarf/test1.abi: Adjust. * tests/data/test-diff-dwarf/test7-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test12-report.txt: Adjust. * tests/data/test-lookup-syms/test1-[123]-report.txt: New. * tests/data/test-lookup-syms/test1.c: New. * tests/data/test-lookup-syms/test1.version-script: New. * tests/test-lookup-syms.cc: Adjust for new tests. * test/Makefile.am: Adjust makefile. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
<< "' in file '";
if (opts.absolute_path)
cout << opts.elf_path << "'\n";
else
cout << basename(opts.elf_path);
return 0;
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
}
Fix symbols comparison While working on something else, I noticed that the code for handling copying symbols (and their aliases) was broken, and so comparing two symbols which main name were different by which had aliases that were equal was wrongly resulting in the two symbol being different. I think we shouldn't actually copy symbols and their aliases. Once a symbol is allocated, interested code should just manipulate that symbol by address rather than by value an thus do away with the copying. The patch does that, essentially. In the implementation of a symbol, the aliases as well as the main symbol are now weak pointers, rather than naked pointers. Numerous API entry points that were taking containers of elf_symbol (and were copying elf_symbols over) are not taking containers of smart pointers to elf_symbol. Copying of instances of elf_symbol is now thus disabled. As a result many tests that were exercising elf_symbols (with alias) comparison have been updated. As a result, many empty sub-result of PR libabigail/PR17948 are now fixed. * include/abg-ir.h (elf_symbol_wptr): New typedef. (elf_symbol): Make the constructors and assignment operator private. The type can neither be copied nor created with the new operator. (elf_symbol::create): New static member function. (elf_symbol::{get_main_symbol, get_next_alias, add_alias}): Adjust. ( compute_aliases_for_elf_symbol): Likewise. (elf_symbol::operator=): Make this private. (elf_symbol::get_alias_which_equals): Declare new member function. * src/abg-comp-filter.cc (function_name_changed_but_not_symbol): Adjust. * src/abg-comparison.cc (class_diff::ensure_lookup_tables_populated): Adjust. * src/abg-corpus.cc (corpus::priv::build_unreferenced_symbols_tables): Likewise. * include/abg-dwarf-reader.h (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (read_context::lookup_elf_symbol_from_index): Likewise. (read_context::lookup_elf_fn_symbol_from_address): Likewise. (read_context::lookup_elf_var_symbol_from_address): Likewise. (read_context::lookup_public_function_symbol_from_elf): Likewise. (read_context::lookup_public_variable_symbol_from_elf): Likewise. (read_context::load_symbol_maps): Likewise. (build_var_decl, build_function_decl): Likewise. * src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}): Change the type of these from elf_symbol* to elf_symbol_wptr. (elf_symbol::priv::priv): Adjust. (elf_symbol::{create, get_alias_which_equals}): Define new functions. (textually_equals): Likewise. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, add_alias}): Adjust to return or take elf_symbol_sptr type, rather than a elf_symbol* one. (elf_symbol::{get_aliases_id_string, does_alias}): Adjust. (compute_alias_for_elf_symbol): Likewise. (elf_symbol::operator==): Two symbols A and B are now equal if A has at least one alias that is textually equal to B. (equals): In the overload for function_decls, in the part where we compare the decl_base part of the functions without considering their decl names, we now also omit considering their linkage names, because we compared they symbols before. * tools/abisym.cc (main): Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust. * tests/data/test-diff-dwarf/test8-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test13-report.txt: Adjust. * tests/data/test-diff-filter/test2-report.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust. * tests/data/test-diff-filter/test9-report.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-01 22:07:02 +00:00
elf_symbol_sptr sym = syms[0];
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
cout << " found symbol '" << n << "'";
Fix symbols comparison While working on something else, I noticed that the code for handling copying symbols (and their aliases) was broken, and so comparing two symbols which main name were different by which had aliases that were equal was wrongly resulting in the two symbol being different. I think we shouldn't actually copy symbols and their aliases. Once a symbol is allocated, interested code should just manipulate that symbol by address rather than by value an thus do away with the copying. The patch does that, essentially. In the implementation of a symbol, the aliases as well as the main symbol are now weak pointers, rather than naked pointers. Numerous API entry points that were taking containers of elf_symbol (and were copying elf_symbols over) are not taking containers of smart pointers to elf_symbol. Copying of instances of elf_symbol is now thus disabled. As a result many tests that were exercising elf_symbols (with alias) comparison have been updated. As a result, many empty sub-result of PR libabigail/PR17948 are now fixed. * include/abg-ir.h (elf_symbol_wptr): New typedef. (elf_symbol): Make the constructors and assignment operator private. The type can neither be copied nor created with the new operator. (elf_symbol::create): New static member function. (elf_symbol::{get_main_symbol, get_next_alias, add_alias}): Adjust. ( compute_aliases_for_elf_symbol): Likewise. (elf_symbol::operator=): Make this private. (elf_symbol::get_alias_which_equals): Declare new member function. * src/abg-comp-filter.cc (function_name_changed_but_not_symbol): Adjust. * src/abg-comparison.cc (class_diff::ensure_lookup_tables_populated): Adjust. * src/abg-corpus.cc (corpus::priv::build_unreferenced_symbols_tables): Likewise. * include/abg-dwarf-reader.h (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (read_context::lookup_elf_symbol_from_index): Likewise. (read_context::lookup_elf_fn_symbol_from_address): Likewise. (read_context::lookup_elf_var_symbol_from_address): Likewise. (read_context::lookup_public_function_symbol_from_elf): Likewise. (read_context::lookup_public_variable_symbol_from_elf): Likewise. (read_context::load_symbol_maps): Likewise. (build_var_decl, build_function_decl): Likewise. * src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}): Change the type of these from elf_symbol* to elf_symbol_wptr. (elf_symbol::priv::priv): Adjust. (elf_symbol::{create, get_alias_which_equals}): Define new functions. (textually_equals): Likewise. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, add_alias}): Adjust to return or take elf_symbol_sptr type, rather than a elf_symbol* one. (elf_symbol::{get_aliases_id_string, does_alias}): Adjust. (compute_alias_for_elf_symbol): Likewise. (elf_symbol::operator==): Two symbols A and B are now equal if A has at least one alias that is textually equal to B. (equals): In the overload for function_decls, in the part where we compare the decl_base part of the functions without considering their decl names, we now also omit considering their linkage names, because we compared they symbols before. * tools/abisym.cc (main): Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust. * tests/data/test-diff-dwarf/test8-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test13-report.txt: Adjust. * tests/data/test-diff-filter/test2-report.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust. * tests/data/test-diff-filter/test9-report.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-01 22:07:02 +00:00
if (n != sym->get_name())
cout << " (" << sym->get_name() << ")";
Initial support for elf symbol (versionning) during decl comparison * include/abg-fwd.h (get_linkage_name): Remove. * include/abg-dwarf-reader.h (enum symbol_type) (enum symbol_binding): Move these into abg-ir.h. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr): Declare this before using it. (die_address_attribute, die_location_address) (stt_to_elf_symbol_type, stb_to_elf_symbol_binding) (find_hash_table_section_index, find_symbol_table_section) (find_symbol_table_section_index, find_text_section) (find_bss_section, compare_symbol_name) (get_symbol_versionning_sections get_version_for_symbol) (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes) (bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, maybe_adjust_fn_sym_address) (maybe_adjust_var_sym_address): New static functions. (enum hash_table_kind): New enum. (struct gnu_ht): New struct. (read_context::var_decls_to_add_): Renamed var_decls_to_add into this. (read_context::{fun, var}_sym_addr_sym_index_map_): New member. (read_context::{lookup_symbol_from_elf, lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address, lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map, var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps, get_function_address, get_variable_address}): New member functions. (read_context::lookup_public_{variable, function}_symbol_from_elf): Adjust. (op_pushes_constant_value): Fix a bug here. (lookup_symbol_from_elf): Adjust. Support cases where there is no elf hash table, e.g, for relocatable files. (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (build_var_decl): Allow updating the var_decl to associate it with its underlying symbol. In that case, if the linkage name is not set, set it to the symbol name. (build_function_decl): Likewise for function_decl. (operator<<(std::ostream&, symbol_type)): (operator<<(std::ostream&, symbol_binding)): Move these do abg-ir.cc. * include/abg-ir.h (class elf_symbol): Declare new class. Move enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to elf_symbol::binding and elf_symbol::type here. (operator<<(std::ostream&, elf_symbol::type)) (operator<<(std::ostream&, elf_symbol::binding)) (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New operators. (class elf_symbol::version): Declare new class. (class var_decl): Make this pimpl, and add ... (var_decl::{g,s}et_symbol): ... new member functions. (class function_decl): Likewise, make this pimpl and add ... (function_decl::{g,s}et_symbol): ... new member functions. * src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New types. (elf_symbol::*): Lots of new members and member functions. (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New. (operator<<(std::ostream&, elf_symbol::type)): New. (operator<<(std::ostream&, elf_symbol::binding)): New. (elf_symbol::version::priv): New type. (elf_symbol::version::*): Lots of member functions. (get_linkage_name): Removed. (var_decl::priv): New type. Pimplify the thing. (var_decl::{s,g}et_symbol): New. (var_decl::operator==): Take symbols in account in the comparison. (function_decl::priv): New type. (function_decl::*): Pimplify. (function_decl::{s,g}et_symbol): New. (function_decl::operator==): Take symbols in account in the comparison. * include/abg-comparison.h (diff_context::show_linkage_name): New member function. * src/abg-comparison.cc (diff_context::priv::show_linkage_name_): New member. (diff_context::priv::priv): Initialize it. (diff_context::show_linkage_names): New member function. (corpus_diff::report): If the user used --show-linkage-names, display the linkage name after the name of the functions. Add missing "'" in the some spots. * tools/bidiff.cc (options.show_linkage_names): New member. (display_usage, parse_command_line): Support --linkage-names. * tools/bisym.cc (show_help): Add '\n' at the end of help string for --demangle. Add --no-absolute-path option. (parse_command_line): Support --no-absolute-path. (main): Adjust for symbol (versionning) support. Consider that the program successfully completed even when the symbol wasn't found. Support --no-absolute-path. * tests/data/test-lookup-syms/test0-report.txt: New. * tests/data/test-lookup-syms/test01-report.txt: New. * tests/data/test-lookup-syms/test02-report.txt: New. * tests/data/test-read-dwarf/test0.abi: Adjust. * tests/data/test-read-dwarf/test1.abi: Adjust. * tests/data/test-diff-dwarf/test7-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test12-report.txt: Adjust. * tests/data/test-lookup-syms/test1-[123]-report.txt: New. * tests/data/test-lookup-syms/test1.c: New. * tests/data/test-lookup-syms/test1.version-script: New. * tests/test-lookup-syms.cc: Adjust for new tests. * test/Makefile.am: Adjust makefile. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
cout << ", an instance of "
Fix symbols comparison While working on something else, I noticed that the code for handling copying symbols (and their aliases) was broken, and so comparing two symbols which main name were different by which had aliases that were equal was wrongly resulting in the two symbol being different. I think we shouldn't actually copy symbols and their aliases. Once a symbol is allocated, interested code should just manipulate that symbol by address rather than by value an thus do away with the copying. The patch does that, essentially. In the implementation of a symbol, the aliases as well as the main symbol are now weak pointers, rather than naked pointers. Numerous API entry points that were taking containers of elf_symbol (and were copying elf_symbols over) are not taking containers of smart pointers to elf_symbol. Copying of instances of elf_symbol is now thus disabled. As a result many tests that were exercising elf_symbols (with alias) comparison have been updated. As a result, many empty sub-result of PR libabigail/PR17948 are now fixed. * include/abg-ir.h (elf_symbol_wptr): New typedef. (elf_symbol): Make the constructors and assignment operator private. The type can neither be copied nor created with the new operator. (elf_symbol::create): New static member function. (elf_symbol::{get_main_symbol, get_next_alias, add_alias}): Adjust. ( compute_aliases_for_elf_symbol): Likewise. (elf_symbol::operator=): Make this private. (elf_symbol::get_alias_which_equals): Declare new member function. * src/abg-comp-filter.cc (function_name_changed_but_not_symbol): Adjust. * src/abg-comparison.cc (class_diff::ensure_lookup_tables_populated): Adjust. * src/abg-corpus.cc (corpus::priv::build_unreferenced_symbols_tables): Likewise. * include/abg-dwarf-reader.h (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (read_context::lookup_elf_symbol_from_index): Likewise. (read_context::lookup_elf_fn_symbol_from_address): Likewise. (read_context::lookup_elf_var_symbol_from_address): Likewise. (read_context::lookup_public_function_symbol_from_elf): Likewise. (read_context::lookup_public_variable_symbol_from_elf): Likewise. (read_context::load_symbol_maps): Likewise. (build_var_decl, build_function_decl): Likewise. * src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}): Change the type of these from elf_symbol* to elf_symbol_wptr. (elf_symbol::priv::priv): Adjust. (elf_symbol::{create, get_alias_which_equals}): Define new functions. (textually_equals): Likewise. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, add_alias}): Adjust to return or take elf_symbol_sptr type, rather than a elf_symbol* one. (elf_symbol::{get_aliases_id_string, does_alias}): Adjust. (compute_alias_for_elf_symbol): Likewise. (elf_symbol::operator==): Two symbols A and B are now equal if A has at least one alias that is textually equal to B. (equals): In the overload for function_decls, in the part where we compare the decl_base part of the functions without considering their decl names, we now also omit considering their linkage names, because we compared they symbols before. * tools/abisym.cc (main): Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust. * tests/data/test-diff-dwarf/test8-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test13-report.txt: Adjust. * tests/data/test-diff-filter/test2-report.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust. * tests/data/test-diff-filter/test9-report.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-01 22:07:02 +00:00
<< (elf_symbol::type) sym->get_type()
<< " of " << sym->get_binding();
if (syms.size() > 1 || !sym->get_version().is_empty())
Initial support for elf symbol (versionning) during decl comparison * include/abg-fwd.h (get_linkage_name): Remove. * include/abg-dwarf-reader.h (enum symbol_type) (enum symbol_binding): Move these into abg-ir.h. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr): Declare this before using it. (die_address_attribute, die_location_address) (stt_to_elf_symbol_type, stb_to_elf_symbol_binding) (find_hash_table_section_index, find_symbol_table_section) (find_symbol_table_section_index, find_text_section) (find_bss_section, compare_symbol_name) (get_symbol_versionning_sections get_version_for_symbol) (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes) (bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, maybe_adjust_fn_sym_address) (maybe_adjust_var_sym_address): New static functions. (enum hash_table_kind): New enum. (struct gnu_ht): New struct. (read_context::var_decls_to_add_): Renamed var_decls_to_add into this. (read_context::{fun, var}_sym_addr_sym_index_map_): New member. (read_context::{lookup_symbol_from_elf, lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address, lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map, var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps, get_function_address, get_variable_address}): New member functions. (read_context::lookup_public_{variable, function}_symbol_from_elf): Adjust. (op_pushes_constant_value): Fix a bug here. (lookup_symbol_from_elf): Adjust. Support cases where there is no elf hash table, e.g, for relocatable files. (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (build_var_decl): Allow updating the var_decl to associate it with its underlying symbol. In that case, if the linkage name is not set, set it to the symbol name. (build_function_decl): Likewise for function_decl. (operator<<(std::ostream&, symbol_type)): (operator<<(std::ostream&, symbol_binding)): Move these do abg-ir.cc. * include/abg-ir.h (class elf_symbol): Declare new class. Move enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to elf_symbol::binding and elf_symbol::type here. (operator<<(std::ostream&, elf_symbol::type)) (operator<<(std::ostream&, elf_symbol::binding)) (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New operators. (class elf_symbol::version): Declare new class. (class var_decl): Make this pimpl, and add ... (var_decl::{g,s}et_symbol): ... new member functions. (class function_decl): Likewise, make this pimpl and add ... (function_decl::{g,s}et_symbol): ... new member functions. * src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New types. (elf_symbol::*): Lots of new members and member functions. (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New. (operator<<(std::ostream&, elf_symbol::type)): New. (operator<<(std::ostream&, elf_symbol::binding)): New. (elf_symbol::version::priv): New type. (elf_symbol::version::*): Lots of member functions. (get_linkage_name): Removed. (var_decl::priv): New type. Pimplify the thing. (var_decl::{s,g}et_symbol): New. (var_decl::operator==): Take symbols in account in the comparison. (function_decl::priv): New type. (function_decl::*): Pimplify. (function_decl::{s,g}et_symbol): New. (function_decl::operator==): Take symbols in account in the comparison. * include/abg-comparison.h (diff_context::show_linkage_name): New member function. * src/abg-comparison.cc (diff_context::priv::show_linkage_name_): New member. (diff_context::priv::priv): Initialize it. (diff_context::show_linkage_names): New member function. (corpus_diff::report): If the user used --show-linkage-names, display the linkage name after the name of the functions. Add missing "'" in the some spots. * tools/bidiff.cc (options.show_linkage_names): New member. (display_usage, parse_command_line): Support --linkage-names. * tools/bisym.cc (show_help): Add '\n' at the end of help string for --demangle. Add --no-absolute-path option. (parse_command_line): Support --no-absolute-path. (main): Adjust for symbol (versionning) support. Consider that the program successfully completed even when the symbol wasn't found. Support --no-absolute-path. * tests/data/test-lookup-syms/test0-report.txt: New. * tests/data/test-lookup-syms/test01-report.txt: New. * tests/data/test-lookup-syms/test02-report.txt: New. * tests/data/test-read-dwarf/test0.abi: Adjust. * tests/data/test-read-dwarf/test1.abi: Adjust. * tests/data/test-diff-dwarf/test7-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test12-report.txt: Adjust. * tests/data/test-lookup-syms/test1-[123]-report.txt: New. * tests/data/test-lookup-syms/test1.c: New. * tests/data/test-lookup-syms/test1.version-script: New. * tests/test-lookup-syms.cc: Adjust for new tests. * test/Makefile.am: Adjust makefile. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
{
cout << ", of version";
if (syms.size () > 1)
cout << "s";
cout << " ";
Fix symbols comparison While working on something else, I noticed that the code for handling copying symbols (and their aliases) was broken, and so comparing two symbols which main name were different by which had aliases that were equal was wrongly resulting in the two symbol being different. I think we shouldn't actually copy symbols and their aliases. Once a symbol is allocated, interested code should just manipulate that symbol by address rather than by value an thus do away with the copying. The patch does that, essentially. In the implementation of a symbol, the aliases as well as the main symbol are now weak pointers, rather than naked pointers. Numerous API entry points that were taking containers of elf_symbol (and were copying elf_symbols over) are not taking containers of smart pointers to elf_symbol. Copying of instances of elf_symbol is now thus disabled. As a result many tests that were exercising elf_symbols (with alias) comparison have been updated. As a result, many empty sub-result of PR libabigail/PR17948 are now fixed. * include/abg-ir.h (elf_symbol_wptr): New typedef. (elf_symbol): Make the constructors and assignment operator private. The type can neither be copied nor created with the new operator. (elf_symbol::create): New static member function. (elf_symbol::{get_main_symbol, get_next_alias, add_alias}): Adjust. ( compute_aliases_for_elf_symbol): Likewise. (elf_symbol::operator=): Make this private. (elf_symbol::get_alias_which_equals): Declare new member function. * src/abg-comp-filter.cc (function_name_changed_but_not_symbol): Adjust. * src/abg-comparison.cc (class_diff::ensure_lookup_tables_populated): Adjust. * src/abg-corpus.cc (corpus::priv::build_unreferenced_symbols_tables): Likewise. * include/abg-dwarf-reader.h (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (read_context::lookup_elf_symbol_from_index): Likewise. (read_context::lookup_elf_fn_symbol_from_address): Likewise. (read_context::lookup_elf_var_symbol_from_address): Likewise. (read_context::lookup_public_function_symbol_from_elf): Likewise. (read_context::lookup_public_variable_symbol_from_elf): Likewise. (read_context::load_symbol_maps): Likewise. (build_var_decl, build_function_decl): Likewise. * src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}): Change the type of these from elf_symbol* to elf_symbol_wptr. (elf_symbol::priv::priv): Adjust. (elf_symbol::{create, get_alias_which_equals}): Define new functions. (textually_equals): Likewise. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, add_alias}): Adjust to return or take elf_symbol_sptr type, rather than a elf_symbol* one. (elf_symbol::{get_aliases_id_string, does_alias}): Adjust. (compute_alias_for_elf_symbol): Likewise. (elf_symbol::operator==): Two symbols A and B are now equal if A has at least one alias that is textually equal to B. (equals): In the overload for function_decls, in the part where we compare the decl_base part of the functions without considering their decl names, we now also omit considering their linkage names, because we compared they symbols before. * tools/abisym.cc (main): Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust. * tests/data/test-diff-dwarf/test8-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test13-report.txt: Adjust. * tests/data/test-diff-filter/test2-report.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust. * tests/data/test-diff-filter/test9-report.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-01 22:07:02 +00:00
for (vector<elf_symbol_sptr>::const_iterator i = syms.begin();
Initial support for elf symbol (versionning) during decl comparison * include/abg-fwd.h (get_linkage_name): Remove. * include/abg-dwarf-reader.h (enum symbol_type) (enum symbol_binding): Move these into abg-ir.h. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr): Declare this before using it. (die_address_attribute, die_location_address) (stt_to_elf_symbol_type, stb_to_elf_symbol_binding) (find_hash_table_section_index, find_symbol_table_section) (find_symbol_table_section_index, find_text_section) (find_bss_section, compare_symbol_name) (get_symbol_versionning_sections get_version_for_symbol) (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes) (bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, maybe_adjust_fn_sym_address) (maybe_adjust_var_sym_address): New static functions. (enum hash_table_kind): New enum. (struct gnu_ht): New struct. (read_context::var_decls_to_add_): Renamed var_decls_to_add into this. (read_context::{fun, var}_sym_addr_sym_index_map_): New member. (read_context::{lookup_symbol_from_elf, lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address, lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map, var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps, get_function_address, get_variable_address}): New member functions. (read_context::lookup_public_{variable, function}_symbol_from_elf): Adjust. (op_pushes_constant_value): Fix a bug here. (lookup_symbol_from_elf): Adjust. Support cases where there is no elf hash table, e.g, for relocatable files. (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (build_var_decl): Allow updating the var_decl to associate it with its underlying symbol. In that case, if the linkage name is not set, set it to the symbol name. (build_function_decl): Likewise for function_decl. (operator<<(std::ostream&, symbol_type)): (operator<<(std::ostream&, symbol_binding)): Move these do abg-ir.cc. * include/abg-ir.h (class elf_symbol): Declare new class. Move enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to elf_symbol::binding and elf_symbol::type here. (operator<<(std::ostream&, elf_symbol::type)) (operator<<(std::ostream&, elf_symbol::binding)) (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New operators. (class elf_symbol::version): Declare new class. (class var_decl): Make this pimpl, and add ... (var_decl::{g,s}et_symbol): ... new member functions. (class function_decl): Likewise, make this pimpl and add ... (function_decl::{g,s}et_symbol): ... new member functions. * src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New types. (elf_symbol::*): Lots of new members and member functions. (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New. (operator<<(std::ostream&, elf_symbol::type)): New. (operator<<(std::ostream&, elf_symbol::binding)): New. (elf_symbol::version::priv): New type. (elf_symbol::version::*): Lots of member functions. (get_linkage_name): Removed. (var_decl::priv): New type. Pimplify the thing. (var_decl::{s,g}et_symbol): New. (var_decl::operator==): Take symbols in account in the comparison. (function_decl::priv): New type. (function_decl::*): Pimplify. (function_decl::{s,g}et_symbol): New. (function_decl::operator==): Take symbols in account in the comparison. * include/abg-comparison.h (diff_context::show_linkage_name): New member function. * src/abg-comparison.cc (diff_context::priv::show_linkage_name_): New member. (diff_context::priv::priv): Initialize it. (diff_context::show_linkage_names): New member function. (corpus_diff::report): If the user used --show-linkage-names, display the linkage name after the name of the functions. Add missing "'" in the some spots. * tools/bidiff.cc (options.show_linkage_names): New member. (display_usage, parse_command_line): Support --linkage-names. * tools/bisym.cc (show_help): Add '\n' at the end of help string for --demangle. Add --no-absolute-path option. (parse_command_line): Support --no-absolute-path. (main): Adjust for symbol (versionning) support. Consider that the program successfully completed even when the symbol wasn't found. Support --no-absolute-path. * tests/data/test-lookup-syms/test0-report.txt: New. * tests/data/test-lookup-syms/test01-report.txt: New. * tests/data/test-lookup-syms/test02-report.txt: New. * tests/data/test-read-dwarf/test0.abi: Adjust. * tests/data/test-read-dwarf/test1.abi: Adjust. * tests/data/test-diff-dwarf/test7-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test12-report.txt: Adjust. * tests/data/test-lookup-syms/test1-[123]-report.txt: New. * tests/data/test-lookup-syms/test1.c: New. * tests/data/test-lookup-syms/test1.version-script: New. * tests/test-lookup-syms.cc: Adjust for new tests. * test/Makefile.am: Adjust makefile. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
i != syms.end();
++i)
{
if (i != syms.begin())
cout << ", ";
Fix symbols comparison While working on something else, I noticed that the code for handling copying symbols (and their aliases) was broken, and so comparing two symbols which main name were different by which had aliases that were equal was wrongly resulting in the two symbol being different. I think we shouldn't actually copy symbols and their aliases. Once a symbol is allocated, interested code should just manipulate that symbol by address rather than by value an thus do away with the copying. The patch does that, essentially. In the implementation of a symbol, the aliases as well as the main symbol are now weak pointers, rather than naked pointers. Numerous API entry points that were taking containers of elf_symbol (and were copying elf_symbols over) are not taking containers of smart pointers to elf_symbol. Copying of instances of elf_symbol is now thus disabled. As a result many tests that were exercising elf_symbols (with alias) comparison have been updated. As a result, many empty sub-result of PR libabigail/PR17948 are now fixed. * include/abg-ir.h (elf_symbol_wptr): New typedef. (elf_symbol): Make the constructors and assignment operator private. The type can neither be copied nor created with the new operator. (elf_symbol::create): New static member function. (elf_symbol::{get_main_symbol, get_next_alias, add_alias}): Adjust. ( compute_aliases_for_elf_symbol): Likewise. (elf_symbol::operator=): Make this private. (elf_symbol::get_alias_which_equals): Declare new member function. * src/abg-comp-filter.cc (function_name_changed_but_not_symbol): Adjust. * src/abg-comparison.cc (class_diff::ensure_lookup_tables_populated): Adjust. * src/abg-corpus.cc (corpus::priv::build_unreferenced_symbols_tables): Likewise. * include/abg-dwarf-reader.h (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (read_context::lookup_elf_symbol_from_index): Likewise. (read_context::lookup_elf_fn_symbol_from_address): Likewise. (read_context::lookup_elf_var_symbol_from_address): Likewise. (read_context::lookup_public_function_symbol_from_elf): Likewise. (read_context::lookup_public_variable_symbol_from_elf): Likewise. (read_context::load_symbol_maps): Likewise. (build_var_decl, build_function_decl): Likewise. * src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}): Change the type of these from elf_symbol* to elf_symbol_wptr. (elf_symbol::priv::priv): Adjust. (elf_symbol::{create, get_alias_which_equals}): Define new functions. (textually_equals): Likewise. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, add_alias}): Adjust to return or take elf_symbol_sptr type, rather than a elf_symbol* one. (elf_symbol::{get_aliases_id_string, does_alias}): Adjust. (compute_alias_for_elf_symbol): Likewise. (elf_symbol::operator==): Two symbols A and B are now equal if A has at least one alias that is textually equal to B. (equals): In the overload for function_decls, in the part where we compare the decl_base part of the functions without considering their decl names, we now also omit considering their linkage names, because we compared they symbols before. * tools/abisym.cc (main): Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust. * tests/data/test-diff-dwarf/test8-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test13-report.txt: Adjust. * tests/data/test-diff-filter/test2-report.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust. * tests/data/test-diff-filter/test9-report.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-01 22:07:02 +00:00
cout << "'" << (*i)->get_version().str() << "'";
Initial support for elf symbol (versionning) during decl comparison * include/abg-fwd.h (get_linkage_name): Remove. * include/abg-dwarf-reader.h (enum symbol_type) (enum symbol_binding): Move these into abg-ir.h. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr): Declare this before using it. (die_address_attribute, die_location_address) (stt_to_elf_symbol_type, stb_to_elf_symbol_binding) (find_hash_table_section_index, find_symbol_table_section) (find_symbol_table_section_index, find_text_section) (find_bss_section, compare_symbol_name) (get_symbol_versionning_sections get_version_for_symbol) (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes) (bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, maybe_adjust_fn_sym_address) (maybe_adjust_var_sym_address): New static functions. (enum hash_table_kind): New enum. (struct gnu_ht): New struct. (read_context::var_decls_to_add_): Renamed var_decls_to_add into this. (read_context::{fun, var}_sym_addr_sym_index_map_): New member. (read_context::{lookup_symbol_from_elf, lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address, lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map, var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps, get_function_address, get_variable_address}): New member functions. (read_context::lookup_public_{variable, function}_symbol_from_elf): Adjust. (op_pushes_constant_value): Fix a bug here. (lookup_symbol_from_elf): Adjust. Support cases where there is no elf hash table, e.g, for relocatable files. (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (build_var_decl): Allow updating the var_decl to associate it with its underlying symbol. In that case, if the linkage name is not set, set it to the symbol name. (build_function_decl): Likewise for function_decl. (operator<<(std::ostream&, symbol_type)): (operator<<(std::ostream&, symbol_binding)): Move these do abg-ir.cc. * include/abg-ir.h (class elf_symbol): Declare new class. Move enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to elf_symbol::binding and elf_symbol::type here. (operator<<(std::ostream&, elf_symbol::type)) (operator<<(std::ostream&, elf_symbol::binding)) (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New operators. (class elf_symbol::version): Declare new class. (class var_decl): Make this pimpl, and add ... (var_decl::{g,s}et_symbol): ... new member functions. (class function_decl): Likewise, make this pimpl and add ... (function_decl::{g,s}et_symbol): ... new member functions. * src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New types. (elf_symbol::*): Lots of new members and member functions. (operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New. (operator<<(std::ostream&, elf_symbol::type)): New. (operator<<(std::ostream&, elf_symbol::binding)): New. (elf_symbol::version::priv): New type. (elf_symbol::version::*): Lots of member functions. (get_linkage_name): Removed. (var_decl::priv): New type. Pimplify the thing. (var_decl::{s,g}et_symbol): New. (var_decl::operator==): Take symbols in account in the comparison. (function_decl::priv): New type. (function_decl::*): Pimplify. (function_decl::{s,g}et_symbol): New. (function_decl::operator==): Take symbols in account in the comparison. * include/abg-comparison.h (diff_context::show_linkage_name): New member function. * src/abg-comparison.cc (diff_context::priv::show_linkage_name_): New member. (diff_context::priv::priv): Initialize it. (diff_context::show_linkage_names): New member function. (corpus_diff::report): If the user used --show-linkage-names, display the linkage name after the name of the functions. Add missing "'" in the some spots. * tools/bidiff.cc (options.show_linkage_names): New member. (display_usage, parse_command_line): Support --linkage-names. * tools/bisym.cc (show_help): Add '\n' at the end of help string for --demangle. Add --no-absolute-path option. (parse_command_line): Support --no-absolute-path. (main): Adjust for symbol (versionning) support. Consider that the program successfully completed even when the symbol wasn't found. Support --no-absolute-path. * tests/data/test-lookup-syms/test0-report.txt: New. * tests/data/test-lookup-syms/test01-report.txt: New. * tests/data/test-lookup-syms/test02-report.txt: New. * tests/data/test-read-dwarf/test0.abi: Adjust. * tests/data/test-read-dwarf/test1.abi: Adjust. * tests/data/test-diff-dwarf/test7-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test12-report.txt: Adjust. * tests/data/test-lookup-syms/test1-[123]-report.txt: New. * tests/data/test-lookup-syms/test1.c: New. * tests/data/test-lookup-syms/test1.version-script: New. * tests/test-lookup-syms.cc: Adjust for new tests. * test/Makefile.am: Adjust makefile. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
}
}
cout << '\n';
Support symbol lookups from ELF * include/abg-dwarf-reader.h (symbol_type, symbol_binding): New enums. (operator<<): Declare new overloads for the new enums above. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf): Declare new entry points. * src/abg-dwarf-reader.cc (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Define new static functions. (read_context::elf_{module_, handle}_): New data members. (read_context::{elf_module, elf_handle}): New accessors. (read_context::load_debug_info): Store the elf module into read_context::_elf_module_. Adjust. (read_context::{lookup_symbol_from_elf, lookup_public_function_symbol_from_elf, lookup_public_variable_symbol_from_elf}): New member functions. (lookup_symbol_from_elf, lookup_public_function_symbol_from_elf) (operator<<): Define public entry points. * tools/bisym.cc: New tool to lookup a symbol in an elf file. * tools/Makefile.am: Add the bisym.cc source file to the distribution and arrange to compile it into a 'bisym' executable. * tests/test-lookup-syms.cc: New test harness. * tests/data/test-lookup-syms/test0-report.txt: New test input for the harness above. * tests/data/test-lookup-syms/test0.cc: Likewise. * tests/data/test-lookup-syms/test0.o: Likewise * tests/data/test-lookup-syms/test01-report.txt: Likewise. * tests/data/test-lookup-syms/test02-report.txt: Likewise. * tests/Makefile.am: Build the new runtestlookupsyms test and add the new files to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 15:43:15 +00:00
return 0;
}