mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-23 10:03:47 +08:00
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.
This commit is contained in:
parent
dc86962bf1
commit
bf2dd8d7cf
@ -1,3 +1,10 @@
|
||||
2018-10-15 Alan Modra <amodra@gmail.com>
|
||||
|
||||
PR 23534
|
||||
* init.c (BFD_INIT_MAGIC): Define.
|
||||
(bfd_init): Return BFD_INIT_MAGIC.
|
||||
bfd-in2.h: Regenerate.
|
||||
|
||||
2018-10-13 Alan Modra <amodra@gmail.com>
|
||||
|
||||
PR 23770
|
||||
|
@ -1080,8 +1080,12 @@ extern void elf32_csky_next_input_section
|
||||
extern int elf32_csky_setup_section_lists
|
||||
(bfd *, struct bfd_link_info *);
|
||||
/* Extracted from init.c. */
|
||||
void bfd_init (void);
|
||||
size_t bfd_init (void);
|
||||
|
||||
|
||||
/* Value returned by bfd_init. */
|
||||
|
||||
#define BFD_INIT_MAGIC (sizeof (struct bfd_section))
|
||||
/* Extracted from opncls.c. */
|
||||
/* Set to N to open the next N BFDs using an alternate id space. */
|
||||
extern unsigned int bfd_use_reserved_id;
|
||||
|
11
bfd/init.c
11
bfd/init.c
@ -38,17 +38,24 @@ FUNCTION
|
||||
bfd_init
|
||||
|
||||
SYNOPSIS
|
||||
void bfd_init (void);
|
||||
size_t bfd_init (void);
|
||||
|
||||
DESCRIPTION
|
||||
This routine must be called before any other BFD function to
|
||||
initialize magical internal data structures.
|
||||
Returns a magic number, which may be used to check
|
||||
that the bfd library is configured as expected by users.
|
||||
.
|
||||
.{* Value returned by bfd_init. *}
|
||||
.
|
||||
.#define BFD_INIT_MAGIC (sizeof (struct bfd_section))
|
||||
*/
|
||||
|
||||
/* Actually, there is currently nothing for this function to do.
|
||||
However, someday it may be needed, so keep it around. */
|
||||
|
||||
void
|
||||
size_t
|
||||
bfd_init (void)
|
||||
{
|
||||
return BFD_INIT_MAGIC;
|
||||
}
|
||||
|
@ -1,3 +1,18 @@
|
||||
2018-10-15 Alan Modra <amodra@gmail.com>
|
||||
|
||||
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.
|
||||
|
||||
2018-10-11 Jordan Rupprecht <rupprecht@google.com>
|
||||
Nick Clifton <nickc@redhat.com>
|
||||
|
||||
|
@ -435,7 +435,8 @@ main (int argc, char **argv)
|
||||
|
||||
expandargv (&argc, &argv);
|
||||
|
||||
bfd_init ();
|
||||
if (bfd_init () != BFD_INIT_MAGIC)
|
||||
fatal (_("fatal error: libbfd ABI mismatch"));
|
||||
set_default_bfd_target ();
|
||||
|
||||
file_name = NULL;
|
||||
|
@ -718,7 +718,8 @@ main (int argc, char **argv)
|
||||
|
||||
START_PROGRESS (program_name, 0);
|
||||
|
||||
bfd_init ();
|
||||
if (bfd_init () != BFD_INIT_MAGIC)
|
||||
fatal (_("fatal error: libbfd ABI mismatch"));
|
||||
set_default_bfd_target ();
|
||||
|
||||
xatexit (remove_output);
|
||||
|
@ -3504,7 +3504,8 @@ identify_dll_for_implib (void)
|
||||
search_data.symname = "__NULL_IMPORT_DESCRIPTOR";
|
||||
search_data.found = FALSE;
|
||||
|
||||
bfd_init ();
|
||||
if (bfd_init () != BFD_INIT_MAGIC)
|
||||
fatal (_("fatal error: libbfd ABI mismatch"));
|
||||
|
||||
abfd = bfd_openr (identify_imp_name, 0);
|
||||
if (abfd == NULL)
|
||||
|
@ -1654,7 +1654,8 @@ main (int argc, char **argv)
|
||||
|
||||
expandargv (&argc, &argv);
|
||||
|
||||
bfd_init ();
|
||||
if (bfd_init () != BFD_INIT_MAGIC)
|
||||
fatal (_("fatal error: libbfd ABI mismatch"));
|
||||
set_default_bfd_target ();
|
||||
|
||||
while ((c = getopt_long (argc, argv, "aABCDef:gHhlnopPrSst:uvVvX:",
|
||||
|
@ -5659,7 +5659,8 @@ main (int argc, char *argv[])
|
||||
strip_symbols = STRIP_UNDEF;
|
||||
discard_locals = LOCALS_UNDEF;
|
||||
|
||||
bfd_init ();
|
||||
if (bfd_init () != BFD_INIT_MAGIC)
|
||||
fatal (_("fatal error: libbfd ABI mismatch"));
|
||||
set_default_bfd_target ();
|
||||
|
||||
if (is_strip < 0)
|
||||
|
@ -3842,7 +3842,8 @@ main (int argc, char **argv)
|
||||
|
||||
expandargv (&argc, &argv);
|
||||
|
||||
bfd_init ();
|
||||
if (bfd_init () != BFD_INIT_MAGIC)
|
||||
fatal (_("fatal error: libbfd ABI mismatch"));
|
||||
set_default_bfd_target ();
|
||||
|
||||
while ((c = getopt_long (argc, argv,
|
||||
|
@ -137,7 +137,8 @@ main (int argc, char **argv)
|
||||
|
||||
expandargv (&argc, &argv);
|
||||
|
||||
bfd_init ();
|
||||
if (bfd_init () != BFD_INIT_MAGIC)
|
||||
fatal (_("fatal error: libbfd ABI mismatch"));
|
||||
set_default_bfd_target ();
|
||||
|
||||
while ((c = getopt_long (argc, argv, "ABHhVvdfotx", long_options,
|
||||
|
@ -287,7 +287,8 @@ main (int argc, char **argv)
|
||||
usage (stderr, 1);
|
||||
}
|
||||
|
||||
bfd_init ();
|
||||
if (bfd_init () != BFD_INIT_MAGIC)
|
||||
fatal (_("fatal error: libbfd ABI mismatch"));
|
||||
set_default_bfd_target ();
|
||||
|
||||
if (optind >= argc)
|
||||
|
@ -956,7 +956,8 @@ main (int argc, char **argv)
|
||||
|
||||
expandargv (&argc, &argv);
|
||||
|
||||
bfd_init ();
|
||||
if (bfd_init () != BFD_INIT_MAGIC)
|
||||
fatal (_("fatal error: libbfd ABI mismatch"));
|
||||
set_default_bfd_target ();
|
||||
|
||||
target = NULL;
|
||||
|
@ -812,7 +812,8 @@ main (int argc, char **argv)
|
||||
|
||||
expandargv (&argc, &argv);
|
||||
|
||||
bfd_init ();
|
||||
if (bfd_init () != BFD_INIT_MAGIC)
|
||||
fatal (_("fatal error: libbfd ABI mismatch"));
|
||||
set_default_bfd_target ();
|
||||
|
||||
res_init ();
|
||||
|
@ -1,3 +1,9 @@
|
||||
2018-10-15 Alan Modra <amodra@gmail.com>
|
||||
|
||||
PR 23534
|
||||
* as.c (main): Exit with fatal error if bfd_init returns an
|
||||
unexpected value.
|
||||
|
||||
2018-10-11 Jan Beulich <jbeulich@suse.com>
|
||||
|
||||
* testsuite/gas/i386/xmmword.s: Add MOVQ / VMOVQ cases.
|
||||
|
3
gas/as.c
3
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
|
||||
|
@ -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),
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user