From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id 34EF3385840D; Tue, 10 Jan 2023 10:12:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 34EF3385840D Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: bfd-cvs@sourceware.org Subject: [binutils-gdb] Re: Move bfd_init to bfd.c X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: fd95c73ef5a6c4386b599d4a796377bc065ed6b6 X-Git-Newrev: 56b3aa508cdbabddd4f46357c8382fe7dca35249 Message-Id: <20230110101237.34EF3385840D@sourceware.org> Date: Tue, 10 Jan 2023 10:12:37 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jan 2023 10:12:37 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D56b3aa508cdb= abddd4f46357c8382fe7dca35249 commit 56b3aa508cdbabddd4f46357c8382fe7dca35249 Author: Alan Modra Date: Tue Jan 10 20:28:18 2023 +1030 Re: Move bfd_init to bfd.c =20 Commit b1c95bc4dd73 resulted in ...bfd.texi:246: @include: could not find init.texi which went unnoticed due to not building in a clean directory. =20 This fixes the problem by moving bfd_init earlier, giving it a doc node, and stitching the nodes back together. =20 * bfd.c (bfd_init): Move earlier. Give it a doc inode. Adjust other inodes to suit. * doc/bfd.texi: Don't include init.texi. Adjust nodes to suit. Diff: --- bfd/bfd-in2.h | 10 ++++---- bfd/bfd.c | 69 +++++++++++++++++++++++++++++-----------------------= ---- bfd/doc/bfd.texi | 9 +++----- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index bb2b30200dc..b6e417f26ec 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -7105,6 +7105,11 @@ typedef void (*bfd_assert_handler_type) (const char = *bfd_formatmsg, =20 bfd_assert_handler_type bfd_set_assert_handler (bfd_assert_handler_type); =20 +unsigned int bfd_init (void); + +/* Value returned by bfd_init. */ +#define BFD_INIT_MAGIC (sizeof (struct bfd_section)) + long bfd_get_reloc_upper_bound (bfd *abfd, asection *sect); =20 long bfd_canonicalize_reloc @@ -7256,11 +7261,6 @@ bfd_vma bfd_emul_get_commonpagesize (const char *); =20 char *bfd_demangle (bfd *, const char *, int); =20 -unsigned int bfd_init (void); - -/* Value returned by bfd_init. */ -#define BFD_INIT_MAGIC (sizeof (struct bfd_section)) - /* Extracted from archive.c. */ symindex bfd_get_next_mapent (bfd *abfd, symindex previous, carsym **sym); diff --git a/bfd/bfd.c b/bfd/bfd.c index 1d1c4498938..c59e31d99e2 100644 --- a/bfd/bfd.c +++ b/bfd/bfd.c @@ -643,7 +643,7 @@ CODE_FRAGMENT =0C /* INODE -Error reporting, Miscellaneous, typedef bfd, BFD front end +Error reporting, Initialization, typedef bfd, BFD front end =20 SECTION Error reporting @@ -1628,10 +1628,44 @@ bfd_set_assert_handler (bfd_assert_handler_type pne= w) _bfd_assert_handler =3D pnew; return pold; } + +/* +INODE +Initialization, Miscellaneous, Error reporting, BFD front end + +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 =3D bfd_error_no_error; + input_bfd =3D NULL; + input_error =3D bfd_error_no_error; + _bfd_error_program_name =3D NULL; + _bfd_error_internal =3D error_handler_fprintf; + _bfd_assert_handler =3D _bfd_default_assert_handler; + + return BFD_INIT_MAGIC; +} =0C /* INODE -Miscellaneous, Memory Usage, Error reporting, BFD front end +Miscellaneous, Memory Usage, Initialization, BFD front end =20 SECTION Miscellaneous @@ -2605,34 +2639,3 @@ _bfd_get_link_info (bfd *abfd) =20 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 =3D bfd_error_no_error; - input_bfd =3D NULL; - input_error =3D bfd_error_no_error; - _bfd_error_program_name =3D NULL; - _bfd_error_internal =3D error_handler_fprintf; - _bfd_assert_handler =3D _bfd_default_assert_handler; - - return BFD_INIT_MAGIC; -} diff --git a/bfd/doc/bfd.texi b/bfd/doc/bfd.texi index 7374e37f8cf..f348710845f 100644 --- a/bfd/doc/bfd.texi +++ b/bfd/doc/bfd.texi @@ -198,9 +198,9 @@ IEEE-695. @menu * typedef bfd:: * Error reporting:: +* Initialization:: * Miscellaneous:: * Memory Usage:: -* Initialization:: * Sections:: * Symbols:: * Archives:: @@ -219,7 +219,7 @@ IEEE-695. @include bfdt.texi @include bfdio.texi =20 -@node Memory Usage, Initialization, Miscellaneous, BFD front end +@node Memory Usage, Sections, Miscellaneous, BFD front end @section Memory Usage BFD keeps all of its internal structures in obstacks. There is one obstack per open BFD file, into which the current state is stored. When a BFD is @@ -242,10 +242,7 @@ select the greediest open BFD, close it to reclaim the= memory, perform some operation and reopen the BFD again, to get a fresh copy of the data structures. =20 -@node Initialization, Sections, Memory Usage, BFD front end -@include init.texi - -@node Sections, Symbols, Initialization, BFD front end +@node Sections, Symbols, Memory Usage, BFD front end @include section.texi =20 @node Symbols, Archives, Sections, BFD front end