From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by sourceware.org (Postfix) with ESMTPS id CD1843858CDA for ; Tue, 10 Jan 2023 10:11:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD1843858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x102f.google.com with SMTP id bj3so8617122pjb.0 for ; Tue, 10 Jan 2023 02:11:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=8u6UOP7UqEsg4Smhq+x66EBGzH24gQ2BW9qz056zKps=; b=ay1snAwYtRi3KcyHSEGcyLqO85AF1NDMzJ+L6jYAm1iTDz2NSDo+m5dvljs2jZuT7m UelYXVPV4NssOIygF2+C2fK3rrxNZf7uhjTugmxdNv53MQzm5NCB63chrIVbf+54+6Zw 8WOJ/H2SXELZTOUcElzIXeJMYAe92xJJgvBATdOolYaWKgucUCoE+udsC2EMJ+09feGc x1qjS4kUEK/eSZRXYkvnqo2d0dj1RW9MIpELE3HbCPRRJNSzWlWQNgXvgf6rrd1zYzSE Ysc7YbotDN7dnOtTiUG6crrcLGIwfhaF2DF/Z++QA+ICHkJ6yaP4e7Hv9sGKSE1zFPjF C9eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8u6UOP7UqEsg4Smhq+x66EBGzH24gQ2BW9qz056zKps=; b=RsN944FqwRBDVc1MJz3zQ+Q6k/T4Ewk0BpCxmb9Xf61oWqWJATeLLi0ZgvCqAFLgfP qJ1wVXqfkM0YJBbKqYc19DgJmCIkBf/g8KvNJtDOcnh+NZYMeMMEYJc8XW2aluvnN8ZI zJA5OfyvrAaCTTgl5G3VziGpi0hF932Zf/3h1VbfhEQ7deGdi3wcq89JEOYbfk2q8Njc +Cmy58pPvnVGu9ixDxspu7TMayrzDBTL7f7WdLLSHfI3MPkxklFVMiY31q8v+542UgNX 4dp6w1CNP1DVnK/bPoHcetMNAxbV1OtQ7hRqzri7F8n+sRZw/KlYLXBaUZGg8rwpXlHO WD5Q== X-Gm-Message-State: AFqh2koaA5+UGQjZ+Sl6f76a9h8AWg49qHsVcoTK9qPj3VdnPANgppJw nIS7JrkqbxPzlXDY95/QmGVVZqKf6DQ= X-Google-Smtp-Source: AMrXdXsaFzIxlS/k4kYZgnLfa7TMT79BuDuLIoBwE628gW4aF+zr9S2NtlWFF20ICdu3qlGfGPM+2w== X-Received: by 2002:a05:6a21:3d0e:b0:b2:40a8:abc0 with SMTP id bi14-20020a056a213d0e00b000b240a8abc0mr88538963pzc.40.1673345518114; Tue, 10 Jan 2023 02:11:58 -0800 (PST) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:561d:7c49:65e0:4dc6]) by smtp.gmail.com with ESMTPSA id z24-20020a630a58000000b004790eb3fee1sm6342366pgk.90.2023.01.10.02.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 02:11:57 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id DA14911407C8; Tue, 10 Jan 2023 20:41:54 +1030 (ACDT) Date: Tue, 10 Jan 2023 20:41:54 +1030 From: Alan Modra To: Jan Beulich Cc: binutils@sourceware.org Subject: Re: Move bfd_init to bfd.c Message-ID: References: <6fd40220-6dba-90f3-f31d-9c6859d22a3d@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6fd40220-6dba-90f3-f31d-9c6859d22a3d@suse.com> X-Spam-Status: No, score=-3035.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Jan 10, 2023 at 10:47:25AM +0100, Jan Beulich wrote: > On 10.01.2023 00:18, Alan Modra via Binutils wrote: > > 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. > > If I'm not mistaken this should also have touched bfd.texi to remove > the inclusion of init.texi? Yes, I just found the bad news from the buildbot. Commit b1c95bc4dd73 resulted in ...bfd.texi:246: @include: could not find init.texi which went unnoticed due to not building in a clean directory. This fixes the problem by moving bfd_init earlier, giving it a doc node, and stitching the nodes back together. * 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. * bfd-in2.h: Regenerate. 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, bfd_assert_handler_type bfd_set_assert_handler (bfd_assert_handler_type); +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); long bfd_canonicalize_reloc @@ -7256,11 +7261,6 @@ bfd_vma bfd_emul_get_commonpagesize (const char *); char *bfd_demangle (bfd *, const char *, int); -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 /* INODE -Error reporting, Miscellaneous, typedef bfd, BFD front end +Error reporting, Initialization, typedef bfd, BFD front end SECTION Error reporting @@ -1628,10 +1628,44 @@ bfd_set_assert_handler (bfd_assert_handler_type pnew) _bfd_assert_handler = 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 = 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; +} /* INODE -Miscellaneous, Memory Usage, Error reporting, BFD front end +Miscellaneous, Memory Usage, Initialization, BFD front end SECTION Miscellaneous @@ -2605,34 +2639,3 @@ _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; -} 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 -@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. -@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 @node Symbols, Archives, Sections, BFD front end -- Alan Modra Australia Development Lab, IBM