Hello all, Currently gdb may use mismatched binary without complaining or noticing. This is particularly often the case when debugging remote targets, or multiple of, with multiple versions of libraries. The situation is possible on self hosted as well. For example, consider having: 1) a library called 'libso.so.1', with SONAME 'libso.so.1'; 2) a program linked against it; 3) environment in which program can be executed and library from 1) found by the dynamic linker; 4) modified libso.so.1, different from the one found by the dynamic linker in 3), in the current working directory of gdb; 5) attach to process stared in 3) using gdb. What happens is, gdb will happily use modified libso.so.1 from current working directory without noticing the mismatch. This causes a lot of confusion. (I can elaborate on the example if needed). Change introduces new target_so_ops function dedicated to performing validation. If we have loaded and relocated the object, validation fails, we throw away bfd and loading of the object fails. The gist of the change is in solib-svr4.c and solib.c The rest are mechanical changes to fill-in new field with valid value. (for bonus points, solib-svr4.c now compiles without -Wno-unused) Regression test suite shows no regressions. (tested on x86_64-unknown-linux-gnu). Thanks, Aleksandar ChangeLog: Aleksandar Ristovski * solib-svr4.c (read_program_headers_from_bfd, read_elf_header_from_bfd): Forward declare. (svr4_keep_data_in_core): Remove unused variable. (read_elf_header_from_target, read_program_headers_from_target, svr4_validate_hdrs_match, svr4_validate): New function. (svr4_read_so_list): Remove unused variable. (read_elf_header_from_bfd): New function. (_initialize_svr4_solib): Use svr4_validate. * solib.c (solib_map_sections): Validate loaded SO. (solib_validate): New function. * solib.h (solib_validate): Declare. * solist.h (target_so_ops): New field 'validate'. * mips-linux-tdep.c (mips_linux_init_abi): Assign validate value. * ppc-linux-tdep.c (ppc_linux_init_abi): Ditto. * solib-darwin.c (_initialize_darwin_solib): Ditto. * solib-dsbt.c (_initialize_dsbt_solib): Ditto. * solib-frv.c (_initialize_frv_solib): Ditto. * solib-ia64-hpux.c (ia64_hpux_target_so_ops): Ditto. * solib-irix.c (_initialize_irix_solib): Ditto. * solib-osf.c (_initialize_osf_solib): Ditto. * solib-pa64.c (_initialize_pa64_solib): Ditto. * solib-som.c (_initialize_som_solib): Ditto. * solib-spu.c (set_spu_solib_ops): Ditto. * solib-sunos.c (_initialize_sunos_solib): Ditto. * solib-target.c (solib.h): Include. (_initialize_solib_target): Assign validate value.