diff options
author | Alan Modra <amodra@gmail.com> | 2023-01-06 21:15:31 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-01-10 09:15:51 +1030 |
commit | b1c95bc4dd737d3d0a6c9a1b6e022e3ef85110bc (patch) | |
tree | df905a16b08b2e250e5d8adb4d79c149556531a7 /bfd/bfd.c | |
parent | bf716a53bd8f725975979397b3c6b9d4bd4434ef (diff) | |
download | gdb-b1c95bc4dd737d3d0a6c9a1b6e022e3ef85110bc.zip gdb-b1c95bc4dd737d3d0a6c9a1b6e022e3ef85110bc.tar.gz gdb-b1c95bc4dd737d3d0a6c9a1b6e022e3ef85110bc.tar.bz2 |
Move bfd_init to bfd.c
init.c contains just one function that doesn't do much. Move it to
bfd.c and give it something to do, initialising static state. So far
the only initialisation is for bfd.c static variables.
The idea behind reinitialising state is to see whether some set of
flaky oss-fuzz crashes go away. oss-fuzz stresses binutils in ways
that can't occur in reality, feeding multiple testcases into the
internals of binutils. So one testcase may affect the result of the
next testcase.
* init.c: Delete file. Move bfd_init to..
* bfd.c (bfd_init): ..here. Init static variables.
* Makefile.am (BFD32_LIBS): Remove init.lo.
(BFD32_LIBS_CFILES, BFD_H_FILES): Remove init.c.
* doc/local.mk: Remove mention of init.texi and init.c.
* Makefile.in: Regenerate.
* bfd-in2.h: Regenerate.
* po/SRC-POTFILES.in: Regenerate.
Diffstat (limited to 'bfd/bfd.c')
-rw-r--r-- | bfd/bfd.c | 37 |
1 files changed, 34 insertions, 3 deletions
@@ -696,9 +696,9 @@ CODE_FRAGMENT . */ -static bfd_error_type bfd_error = bfd_error_no_error; -static bfd *input_bfd = NULL; -static bfd_error_type input_error = bfd_error_no_error; +static bfd_error_type bfd_error; +static bfd *input_bfd; +static bfd_error_type input_error; const char *const bfd_errmsgs[] = { @@ -2605,3 +2605,34 @@ _bfd_get_link_info (bfd *abfd) return elf_link_info (abfd); } + +/* +FUNCTION + bfd_init + +SYNOPSIS + unsigned int 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)) +. +*/ + +unsigned int +bfd_init (void) +{ + bfd_error = bfd_error_no_error; + input_bfd = NULL; + input_error = bfd_error_no_error; + _bfd_error_program_name = NULL; + _bfd_error_internal = error_handler_fprintf; + _bfd_assert_handler = _bfd_default_assert_handler; + + return BFD_INIT_MAGIC; +} |