From bf2dd8d7cf4114b8a60dbb83b340f76b9b2474d1 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 15 Oct 2018 16:10:27 +1030 Subject: BFD_INIT_MAGIC This patch performs a run-time test that a shared libbfd.so has been compiled with the same size bfd_vma as that of apps using the library. On a 32-bit host it is easily possible to have one libbfd.so compiled to support 64-bit targets (or configured with --enable-64-bit-bfd) while another only supports 32-bit targets. The two libraries will have differently sized bfd_vma types, and if the wrong one is loaded all sorts of weird behaviour might be seen. bfd/ PR 23534 * init.c (BFD_INIT_MAGIC): Define. (bfd_init): Return BFD_INIT_MAGIC. bfd-in2.h: Regenerate. binutils/ PR 23534 * addr2line.c (main): Exit with fatal error if bfd_init returns an unexpected value. * ar.c (main): Likewise. * dlltool.c (identify_dll_for_implib): Likewise. * nm.c (main): Likewise. * objcopy.c (main): Likewise. * objdump.c (main): Likewise. * size.c (main): Likewise. * strings.c (main): Likewise. * windmc.c (main): Likewise. * windres.c (main): Likewise. gas/ PR 23534 * as.c (main): Exit with fatal error if bfd_init returns an unexpected value. ld/ PR 23534 * ldmain.c (main): Exit with fatal error if bfd_init returns an unexpected value. --- gas/as.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gas/as.c') diff --git a/gas/as.c b/gas/as.c index 3105d06..c4de060 100644 --- a/gas/as.c +++ b/gas/as.c @@ -1239,7 +1239,8 @@ main (int argc, char ** argv) out_file_name = OBJ_DEFAULT_OUTPUT_FILE_NAME; hex_init (); - bfd_init (); + if (bfd_init () != BFD_INIT_MAGIC) + as_fatal (_("libbfd ABI mismatch")); bfd_set_error_program_name (myname); #ifdef USE_EMULATIONS -- cgit v1.1