From patchwork Tue Jan 23 12:28:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 190884 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp297140dyi; Tue, 23 Jan 2024 04:28:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IEBIbBoQ6ybnaWJtlpreqf7kqVmYva9UD+FuxFI8ubxVIyDrun00KAf7m8RfxY+qT5VKIga X-Received: by 2002:a05:6902:154a:b0:dbe:a0e2:c637 with SMTP id r10-20020a056902154a00b00dbea0e2c637mr3961455ybu.65.1706012912414; Tue, 23 Jan 2024 04:28:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706012912; cv=pass; d=google.com; s=arc-20160816; b=Sc3A1+SGwbC2Nj8RSRJ7Ry1DXtuIfzPG1fyTrWudLCdocQ0JL1d3gTPHTD73STKBoa HWRWGmqLgW04zbTPBHfKpRwmAiCEBWS2N+d0CWNueLUbejcVZBxlBW70yKPs56nRoNH2 WozweMmwMP1Gz82yQmvNI/CPvjevq09HBZxGqcznSRmLcaHl8Qz3XPI8Sfl6ffWW/Uz9 LIgLUWk0nIfSMq9h6eiiUtE83vGj9NjkY1I1IS/4R8NIJO6sAPzGSqKSZXbdvkMN0i1p SNsY5AQwQ5vrxh2NEvox7vPZa9PgYF8hdEbz0Il445hmqKMUA5kqs6DTbl3uQSMdQ4nY voEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:message-id:date :subject:cc:to:from:dkim-signature:arc-filter:dmarc-filter :delivered-to; bh=PHQwzII7wwWINp+fGsE8cn6+Rn0beUD9le7DFSdNJm8=; fh=7tBu42zZknJYuMqHv/bn6CyFAIfuy9XpxPr/uDwqMQs=; b=gSyXhxEFouVG3AZexTdxYUdj5YZvFL5mv/pWPYpGb0+imxiU0lC9Yksx0g+YN2y/ae hBKSkUqR6F9L8WV8TS2coQLZgy5EwjG23ML9T0oIu9kRkOuY1FoPc9MX0qdjDu/DnoER Vn+bWEjcL1IBjtcAr4a30kLqRwU7dSpjtHQtMaZ9jP6CGWiCNBtUn31VcJHtNWkYa8yy OBN5uaN4mQZ72jgO0DPWJjq3mqO8LOSVRPXvBSQFzbApO4Dx9419i1TbFZQmJ2QSuYny 1Y4VbboF7/3ieagSPwDx7z/tlorbNJY+pRF7V0JE/zZlMaRtkRNpK5mP/DCsVY9qqMWk mzew== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sgn0oLJ+; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i22-20020a0cab56000000b006819b136471si7885743qvb.426.2024.01.23.04.28.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 04:28:32 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sgn0oLJ+; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A2E3385840C for ; Tue, 23 Jan 2024 12:28:32 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 22B293858C54 for ; Tue, 23 Jan 2024 12:28:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 22B293858C54 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 22B293858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706012902; cv=none; b=pFA7Vh7TCKtpybuv7yFH8ROzyRsnGtpiIVCNWXgJRiMbeh2ZkHG7HXkXORagNRVJEWpSx9286xP7JqlN07ACEs1rxWIibTHZhktGkmSI+wcZupT9fS0V63RIdulsZvb9SBX505ivqowglW9KHOx5Pf0aqyFl8X12Dy86S2l9HYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706012902; c=relaxed/simple; bh=NBK+K8lAyixszerQGriDTbU9dB2bd48KajmwOYww3/o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gdNUBbS7r8dzlPxAcEBKwFGs+EhLACVjd6FGyn8nMJAl1BPeorOpAd5Ktv1jFbvYqsMd4zdaYoz7hsdiKil80cAUzI5MdhBw89AUSviuES+mGbmqynH8Gb5rxa3CxD3gOtubOvXQ2Tp50ZuCf3xWcGRwqnSy/LA5U6lxec4+B4c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706012900; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=PHQwzII7wwWINp+fGsE8cn6+Rn0beUD9le7DFSdNJm8=; b=Sgn0oLJ+T+J2puSrMF3y1rp/1RSbwNgNriwM3aFjhW9yvXfUV2B33gGcOU51MVGP0C5IRg MMPoHBTAZt4HwV3fOjawYLb7KY4h5CKVZ5Z/QYMQcuH2y2mxxOgvaIK8Rydxg42s6SE9vY 6HJ8bGjCuKd9wkUszHsJOJAgkLiq3zk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-332-KJJpgKD7PV6hkL7LjrueCg-1; Tue, 23 Jan 2024 07:28:19 -0500 X-MC-Unique: KJJpgKD7PV6hkL7LjrueCg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2722210AF98A; Tue, 23 Jan 2024 12:28:19 +0000 (UTC) Received: from prancer.redhat.com (unknown [10.42.28.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A6BFBC15E61; Tue, 23 Jan 2024 12:28:18 +0000 (UTC) From: Nick Clifton To: binutils@sourceware.org Cc: serge.guelton@telecom-bretagne.eu Subject: RFC: Document unexpected behaviour of --fatal-warnings Date: Tue, 23 Jan 2024 12:28:17 +0000 Message-ID: <87fryomdy6.fsf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788884195759288181 X-GMAIL-MSGID: 1788884195759288181 Hi Guys, It was recently pointed out to me that the bfd linker's --fatal-warnings option can behave in an unexpected manner. For example: $ ld.bfd -z bad-option --fatal-warnings -e 0/dev/null ld.bfd: warning: -z bad-option ignored $ echo $? 0 ie the warning about the ignored option is not being treated as an error. This happens because the --fatal-warnings option only takes affect after it has been processed, and we process the options in a linear order. So the following works: $ ld.bfd --fatal-warnings -z bad-option -e 0 /dev/null ld.bfd: warning: -z bad-option ignored $ echo $? 1 This behaviour differs from gold and lld, both of which honour --fatal-warnings no matter where it occurs on the command line. So we could fix the linker, create a two pass argument scan and the problem would be solved. But a) I am lazy and b) we already have a precedent for options on the command line only affecting options that come after it. (I am thinking of the -L option here, although there are probably several others). So instead I am considering documenting the current behaviour as expected. (See the patch below). What do people think ? Cheers Nick diff --git a/ld/ld.texi b/ld/ld.texi index 4fda259a552..16ab08e03f2 100644 --- a/ld/ld.texi +++ b/ld/ld.texi @@ -1993,7 +1993,20 @@ in filename invoked by -R or --just-symbols @item --fatal-warnings @itemx --no-fatal-warnings Treat all warnings as errors. The default behaviour can be restored -with the option @option{--no-fatal-warnings}. +with the option @option{--no-fatal-warnings}. Note: this option does +not affects warnings generated by other command line options that are +placed before it on the command line. So for example: + +@smallexample +$ ld -z bad-option --fatal-warnings -e 0/dev/null +ld: warning: -z bad-option ignored +$ echo $? +0 +$ ld --fatal-warnings -z bad-option -e 0 /dev/null +ld: warning: -z bad-option ignored +$ echo $? +1 +@end smallexample @kindex -w @kindex --no-warnings