libabigail/tests/data/test-abicompat/test7-fn-changed-app.c

18 lines
457 B
C
Raw Permalink Normal View History

Fix computing the set of exported functions and varible symbols Sinny Kumari reported that abicompat is failing to report ABI changes on a library linked to a small test program. It turned out that the code that compute if a given exported function is to be kept by looking at the white list of symbols to keep has a bug in which the versions of the symbols of the white list were not being reset as they should. Fixed thus. * src/abg-ir.cc (elf_symbol::get_name_and_version_from_id): Always set the version and name of the symbol. * src/abg-corpus.cc (corpus::exported_decls_builder::{keep_wrt_id_of_fns_to_keep, keep_wrt_id_of_vars_to_keep}): Reset the symbol name *and* version before passing it. This is redundant with the fix in elf_symbol::get_name_and_version_from_id() that always set the symbol name and version now, but I felt it makes it easier to understand the fix overall. * tests/data/test-abicompat/libtest7-fn-changed-libapp-v{0,1}.so: New test input binaries. * tests/data/test-abicompat/test7-fn-changed-app: Likewise. * tests/data/test-abicompat/test7-fn-changed-{app, libapp-v0, libapp-v1}.c: Source code of the binary test inputs above. * * tests/data/test-abicompat/test7-fn-changed-{libapp-v0, libapp-v1}.h: Likewise. * tests/data/test-abicompat/test7-fn-changed-report-0.txt: Test input. * tests/data/Makefile.am: Add the new test material above to source distribution. * tests/test-abicompat.cc (int_out_specs): Add the test inputs above to the set of inputs this test harness has to run over. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-20 10:31:03 +00:00
// Compile this with:
// gcc -g -o test7-fn-changed-app -L. -ltest7-fn-changed-libapp-v0 test7-fn-changed-app.c
Add support for undefined symbols in the BTF reader This patch teaches the BTF reader how to construct an IR for undefined interfaces. The patch also updates the abicompat tool for BTF support. * doc/manuals/abicompat.rst: Update documentation for the --btf option of abicompat. * include/abg-elf-reader.h (elf::reader::{function,variable}_symbol_is_undefined): Declare new member functions. * src/abg-btf-reader.cc (reader::read_debug_info_into_corpus): Sort functions & variables after canonicalization. (reader::build_ir_node_from_btf_type): Always call fe_iface::add_{fn,var}_to_exported_or_undefined_decls with the decl that was constructed. (reader::build_function_decl): Support setting an undefined symbol to the function decl. (reader::build_var_decl): Likewise, support setting undefined symbol the variable decl. * src/abg-elf-reader.cc ((elf::reader::{function,variable}_symbol_is_undefined): Declare new member functions.): Define new member functions. * src/abg-symtab-reader.cc (symtab::{function,variable}_symbol_is_undefined): Return the undefined symbol that was found. * src/abg-symtab-reader.h (symtab::{function,variable}_symbol_is_undefined): Return an undefined symbol rather than just a boolean value. * tools/abicompat.cc: Add support for BTF here. (options::use_btf): Define new data member ... (options::options): ... and initialize it. (display_usage): Add a help string for the --btf option. (parse_command_line): Parse the --btf option. * tests/data/test-abicompat/test7-fn-changed-report-0.1.txt: New reference test output file. * tests/data/test-abicompat/test7-fn-changed-report-2.1.txt: Likewise. * tests/data/test-abicompat/libtest7-fn-changed-libapp-btf-v0.so: New binary input file. * tests/data/test-abicompat/libtest7-fn-changed-libapp-btf-v1.so: Likewise. * tests/data/test-abicompat/test7-fn-changed-app.btf: Likewise. * tests/data/Makefile.am: Add the new test material to source distribution. * tests/test-abicompat.cc (in_out_specs): Add the new test input to the test harness. * tests/data/test-abicompat/test7-fn-changed-app.c: Adjust. * tests/data/test-abicompat/test7-fn-changed-libapp-v0.c: Likewise. * tests/data/test-abicompat/test7-fn-changed-libapp-v1.c: Likewise Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2024-03-12 16:17:16 +00:00
// Or, for BTF debug info, with:
// gcc -gbtf -o test7-fn-changed-app.btf -L. -ltest7-fn-changed-libapp-v0 test7-fn-changed-app.c
Fix computing the set of exported functions and varible symbols Sinny Kumari reported that abicompat is failing to report ABI changes on a library linked to a small test program. It turned out that the code that compute if a given exported function is to be kept by looking at the white list of symbols to keep has a bug in which the versions of the symbols of the white list were not being reset as they should. Fixed thus. * src/abg-ir.cc (elf_symbol::get_name_and_version_from_id): Always set the version and name of the symbol. * src/abg-corpus.cc (corpus::exported_decls_builder::{keep_wrt_id_of_fns_to_keep, keep_wrt_id_of_vars_to_keep}): Reset the symbol name *and* version before passing it. This is redundant with the fix in elf_symbol::get_name_and_version_from_id() that always set the symbol name and version now, but I felt it makes it easier to understand the fix overall. * tests/data/test-abicompat/libtest7-fn-changed-libapp-v{0,1}.so: New test input binaries. * tests/data/test-abicompat/test7-fn-changed-app: Likewise. * tests/data/test-abicompat/test7-fn-changed-{app, libapp-v0, libapp-v1}.c: Source code of the binary test inputs above. * * tests/data/test-abicompat/test7-fn-changed-{libapp-v0, libapp-v1}.h: Likewise. * tests/data/test-abicompat/test7-fn-changed-report-0.txt: Test input. * tests/data/Makefile.am: Add the new test material above to source distribution. * tests/test-abicompat.cc (int_out_specs): Add the test inputs above to the set of inputs this test harness has to run over. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-20 10:31:03 +00:00
#include <stdio.h>
#include "test7-fn-changed-libapp-v0.h"
int main()
{
struct Student s = {7, "foo"};
float a = 3.5, b = 2.0;
printf ("Addition of a and b = %f\n",add(a,b));
print(s);
return 0;
}