mirror of
git://sourceware.org/git/libabigail.git
synced 2025-03-07 23:27:43 +00:00
In this problem report libabigail's DWARF reader wrongly looks up the address of variables (that it got from DWARF) in the .bss section of the ELF file. But then, in these files (generated by the Intel C++ compiler) the variables we are looking at have their addresses in the .data1 section. This patch changes the DWARF/ELF reader to make it look for variable addresses in .data, .data1, .rodata and .bss sections, as it should be. * include/abg-dwarf-reader.h (elf_type::ELF_TYPE_RELOCATABLE): New enumerator. * src/abg-dwarf-reader.cc (find_section): Factorize this from ... (find_text_section, find_bss_section): ... these. (find_rodata_section, find_data_section, find_data1_section): Define new static functions. (elf_file_type): Move this static function definition up. (read_context::{get_elf_file_type, address_is_in_section, get_data_section_for_variable_address}): New member functions. (read_context::maybe_adjust_fn_sym_address): Adjust comment. Adjust to use the new read_context::get_data_section_for_variable_address(). * tests/data/test-types-stability/pr19138-elf0: New test input binary. * tests/data/Makefile.am: Add the new test input binary to the test suite. * tests/test-types-stability.cc (elf_paths): Take it into account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
87 lines
2.6 KiB
C++
87 lines
2.6 KiB
C++
// -*- Mode: C++ -*-
|
|
//
|
|
// Copyright (C) 2013-2015 Red Hat, Inc.
|
|
//
|
|
// 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 tests that the representation of types by the
|
|
/// internal representation of libabigail is stable through reading
|
|
/// from ELF/DWARF, constructing an internal represenation, saving that
|
|
/// internal presentation to the abixml format, reading from that
|
|
/// abixml format and constructing an internal representation from it
|
|
/// again.
|
|
///
|
|
/// This program thus compares the internal representation that is
|
|
/// built from reading from ELF/DWARF and the one that is built from
|
|
/// the abixml (which itself results from the serialization of the
|
|
/// first internal representation to abixml).
|
|
///
|
|
/// The comparison is expected to yield the empty set.
|
|
|
|
|
|
#include <string>
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <cstdlib>
|
|
#include "abg-tools-utils.h"
|
|
#include "test-utils.h"
|
|
#include "abg-dwarf-reader.h"
|
|
#include "abg-comparison.h"
|
|
|
|
using std::string;
|
|
using std::ofstream;
|
|
using std::cerr;
|
|
|
|
// A set of elf files to test type stability for.
|
|
const char* elf_paths[] =
|
|
{
|
|
"data/test-types-stability/pr19139-DomainNeighborMapInst.o",
|
|
"data/test-types-stability/pr19202-libmpi_gpfs.so.5.0",
|
|
"data/test-types-stability/pr19026-libvtkIOSQL-6.1.so.1",
|
|
"data/test-types-stability/pr19138-elf0",
|
|
// The below should always be the last element of array.
|
|
0
|
|
};
|
|
|
|
int
|
|
main()
|
|
{
|
|
using abigail::tests::get_src_dir;
|
|
using abigail::tests::get_build_dir;
|
|
|
|
bool is_ok = true;
|
|
|
|
for (const char** p = elf_paths; p && *p; ++p)
|
|
{
|
|
string abidw = get_build_dir() + "/tools/abidw";
|
|
string elf_path = get_src_dir() + "/tests/" + *p;
|
|
string cmd = abidw + " --abidiff " + elf_path;
|
|
if (system(cmd.c_str()))
|
|
{
|
|
cerr << "IR stability issue detected for binary "
|
|
<< elf_path;
|
|
is_ok = false;
|
|
}
|
|
}
|
|
|
|
return !is_ok;
|
|
}
|