From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id CE54E3858C33 for ; Fri, 27 Jan 2023 07:01:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE54E3858C33 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-pg1-x535.google.com with SMTP id 36so2646276pgp.10 for ; Thu, 26 Jan 2023 23:01:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=y9vNxk7qd0Y6OSYKQTTX3pbRxC5KE58R3R9UAlcWBjc=; b=WnLyk+siHDqO99dIPo9GqBML3EZMi/Yuxp6Jf7osjtvet1mDxijq5woa8ybOzf/g9k 136FSGq/UMEyHjOO4beV+lnxyZUkLY1h0aIamPi8i3I7VXthQHWBEF4jjm0KNziD4CKW 8fu1kWtR1M0VlWbNGn7HncXsCCCbrq54rTaPTzauZBFzR/zIofk5z4fEwrcNkbY637q+ hdWbfMyW994wetQZPU3i9MkgUV4S+tEO6JRFEcpZxsoUDis6dhc7FzmUsx5yG84SqIV+ fGV/l96EK3Ccm9375eJ6XBOuaZEsLw0OtxQltIrv4Vu2ErteqX62nbFZmWW7xZUvfUu1 nQnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=y9vNxk7qd0Y6OSYKQTTX3pbRxC5KE58R3R9UAlcWBjc=; b=XhBIxVUntDYdlZDettEfP/cMwTyq70nnhwCVV1TRjtX/OTgP4siubD9WisZ/IPUHOu 799wxX101RnMl1SvFr+D9x7X9oC7ye8okkLRhty5iFxF8FoMJ8uGw6EtSp5If7UkzN8x pks6aMKtdNHKf65Iy5mbuyFhIkRVhsSDmd1j2NIbYycd0pVj5cBNMnOcRuhrd4XU4RrP LtBx5LhWdB3RrtkMJnsI2Wzr8PTG6fSfOA40MMZvSgq+vmAMEPC5nQbTHMQnElRZ9QTr KQN3sok+LU0/m3lldxnZHj4d9t3PzO5fdqRA0J9VHs86U297dzSvn5zfiAYSdsPsAH60 CK9g== X-Gm-Message-State: AFqh2kpFKfR0nnIWIpBv4TxIfMYDyn1vjYKqRii/dsB/vFFUs3Ykk/48 eOckfv/TkjKMlvAvSwK/AeOqHVQRpZI= X-Google-Smtp-Source: AMrXdXvR1tScsMRJUL5BIURuLvYlHPecs0B5ylSC/SVIqJbRq3OC/XdrQ4Y6l2abigSpxmoWtBP/PQ== X-Received: by 2002:a05:6a00:1d23:b0:58d:a91d:e9f8 with SMTP id a35-20020a056a001d2300b0058da91de9f8mr32210345pfx.18.1674802918613; Thu, 26 Jan 2023 23:01:58 -0800 (PST) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:fb44:1882:a135:67f]) by smtp.gmail.com with ESMTPSA id i9-20020a628709000000b005893f281d43sm1681959pfe.27.2023.01.26.23.01.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 23:01:58 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 258211142E33; Fri, 27 Jan 2023 17:31:56 +1030 (ACDT) Date: Fri, 27 Jan 2023 17:31:56 +1030 From: Alan Modra To: binutils@sourceware.org Subject: Perform cleanup in bfd_close after errors Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3035.1 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: It seems reasonable to continue after errors in bfd_close_all_done, particularly since bfd_close_all_done is typically called on an output file after we've hit some sort of error elsewhere. The iovec test is necessary if bfd_close_all_done is to work on odd bfd's opened by bfd_create. * opncls.c (bfd_close): Call bfd_close_all_done after errors from _bfd_write_contents. (bfd_close_all_done): Call _bfd_delete_bfd after errors. Don't call iovec->bclose when iovec is NULL. diff --git a/bfd/opncls.c b/bfd/opncls.c index 9241cd1c537..6ae3af054e4 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -805,13 +805,10 @@ RETURNS bool bfd_close (bfd *abfd) { - if (bfd_write_p (abfd)) - { - if (! BFD_SEND_FMT (abfd, _bfd_write_contents, (abfd))) - return false; - } + bool ret = (!bfd_write_p (abfd) + || BFD_SEND_FMT (abfd, _bfd_write_contents, (abfd))); - return bfd_close_all_done (abfd); + return bfd_close_all_done (abfd) && ret; } /* @@ -839,15 +836,15 @@ RETURNS bool bfd_close_all_done (bfd *abfd) { - bool ret; + bool ret = BFD_SEND (abfd, _close_and_cleanup, (abfd)); - if (! BFD_SEND (abfd, _close_and_cleanup, (abfd))) - return false; - - ret = abfd->iovec->bclose (abfd) == 0; + if (ret && abfd->iovec != NULL) + { + ret = abfd->iovec->bclose (abfd) == 0; - if (ret) - _maybe_make_executable (abfd); + if (ret) + _maybe_make_executable (abfd); + } _bfd_delete_bfd (abfd); -- Alan Modra Australia Development Lab, IBM