aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2018-10-15 16:10:27 +1030
committerAlan Modra <amodra@gmail.com>2018-10-15 22:11:58 +1030
commitbf2dd8d7cf4114b8a60dbb83b340f76b9b2474d1 (patch)
tree0ba71a654d503cc47523f3bf878d9e1d9c2c2d58 /ld
parentdc86962bf15e7b8dfdcebc17d83b9b48be0bd9cb (diff)
downloadbinutils-bf2dd8d7cf4114b8a60dbb83b340f76b9b2474d1.zip
binutils-bf2dd8d7cf4114b8a60dbb83b340f76b9b2474d1.tar.gz
binutils-bf2dd8d7cf4114b8a60dbb83b340f76b9b2474d1.tar.bz2
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.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog6
-rw-r--r--ld/ldmain.c3
2 files changed, 8 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 0f28a2e..3043096 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2018-10-15 Alan Modra <amodra@gmail.com>
+
+ PR 23534
+ * ldmain.c (main): Exit with fatal error if bfd_init returns
+ an unexpected value.
+
2018-10-13 Alan Modra <amodra@gmail.com>
* Makefile.am (eelf32btsmip_fbsd.c, eelf32btsmipn32_fbsd.c),
diff --git a/ld/ldmain.c b/ld/ldmain.c
index aca9b1b..4641920 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -209,7 +209,8 @@ main (int argc, char **argv)
expandargv (&argc, &argv);
- bfd_init ();
+ if (bfd_init () != BFD_INIT_MAGIC)
+ einfo (_("%F%P: fatal error: libbfd ABI mismatch\n"));
bfd_set_error_program_name (program_name);