From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com [IPv6:2607:f8b0:4864:20::b2e]) by sourceware.org (Postfix) with ESMTPS id 6460D3858409 for ; Tue, 23 Jan 2024 13:16:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6460D3858409 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6460D3858409 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b2e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706015781; cv=none; b=annLw4DwLvJzumhPuzgCYS9b7TPngPC5yDan4rog3jshmMDiH6cZPUYB2G/hGJagy7zRGsieyEVdmF0Rvh2AIRq/p5uyI9lAAt2LnjQrdIBE+eQiPGGJ7RNY3pm0FCrvda2xTopgtUZPw7HlLGDd1sd+9P6e70DzopzGLq/kokc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706015781; c=relaxed/simple; bh=6qn9jeRMHxO3ZiXHrFyYLzAWgYHZmHW8WhBtDjfEQNU=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=qzHFI+K5M3IpA2kaZIQGl5xNqTa6e4BtqI3LVWbKWp0A7Rd4FPVw/BdY4FVEk1EtTK8dfXPfpIOBx3FS2jdpioHT1JLBETOho4khm92qdevz/mp2b/IHu1BiJlj9kwRbaWo8sjCUNq37sGym0aHYknnVKH1H3hDXtps6NLXznX0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yb1-xb2e.google.com with SMTP id 3f1490d57ef6-dbed179f0faso3958475276.1 for ; Tue, 23 Jan 2024 05:16:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706015779; x=1706620579; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=XxFgyEnmRqjWFkrQt0pEhgeJhGm1M5Ic+oGyBvM9k18=; b=aOpUvJD6FUGSvMit0osgpJSakXyDAgHVUxPpSrXA0/kPvNUxcAioxfihZU5q7O8RBU jxxr9oT+zc7SsYUhOcZkrRHMgQ0TvhfyxMC76pzp84UwQ6dgBkOe24/1slFrj26i27mF tTAr2LciDVa++6QPeERMmZvAqGFTMJGR1RUwZCM0C8djGIzQZy1JfsJezBkGN+ZhoJC2 uf5guXNCiwRldpUuvNDUbU0rOjj3Umlx0skFGuxdcEIILEgdc3quSRx2159ON9lWIJIu dSQ9wEIGwCk6BKjUoQfYu5JwivlArIwZpWpLxWUSdXerT/cl5GUxW2Uo532tm4J/voUL lxVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706015779; x=1706620579; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XxFgyEnmRqjWFkrQt0pEhgeJhGm1M5Ic+oGyBvM9k18=; b=wTjlonrEqBVB33oNhncrE+B6IlR4KUnMPZLzbx4xIN4HBCSdEr4WBvCWXPDCikJX/n yXLgEXEi95o01qJv9khh8boddCPv+hB9CcvzTgx8gujQRIw9C6KuqZNrTgxeTI2m7S2K yziXuAIyeHc58WB1FYCyeCqU4EwD1XvA/WLPYuvShdFZ/eBxWLBec/u12+rt28bekYCS LwVixFl03UI5gGxP88meemoGvNOd5PgVtx+Z1/+y3JzGpQQgyHfhJZ4ZBDNInQZE+uC7 J0yTv3wm/0rVqC29xWPNPckyQPw4/3BkipW7swRXFO2pApS6/on2fTRqbAzYvjka0oM8 qABw== X-Gm-Message-State: AOJu0YyJ4JsEsXPcCnNpFSivTW5NjMtxl1RUX38LbFZa77KCZZF+kTiV BepiXSFGNjN+PCxmGE2Pz+U+Gxe7aODNgzq4tLNGP/jYU2IWsBZBnLvEz++IFYiqmVGQ5E30RzQ 5tp0u7/ShkPoFFW29pOmrQCz+i3E= X-Google-Smtp-Source: AGHT+IFasd3u0K+JWX8V0gOyoEaPtyxsurin0Dfw3M0xMXQcglgc27rrkwIT/CQ+J8+x1kfzXXjnZ59eDlhcZM5y/Qs= X-Received: by 2002:a81:8411:0:b0:5ff:b07b:e534 with SMTP id u17-20020a818411000000b005ffb07be534mr2926634ywf.9.1706015778722; Tue, 23 Jan 2024 05:16:18 -0800 (PST) MIME-Version: 1.0 References: <87fryomdy6.fsf@redhat.com> In-Reply-To: From: "H.J. Lu" Date: Tue, 23 Jan 2024 05:15:42 -0800 Message-ID: Subject: Re: RFC: Document unexpected behaviour of --fatal-warnings To: Jan Beulich Cc: Nick Clifton , serge.guelton@telecom-bretagne.eu, binutils@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3014.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 List-Id: On Tue, Jan 23, 2024 at 4:50=E2=80=AFAM H.J. Lu wrote= : > > On Tue, Jan 23, 2024 at 4:39=E2=80=AFAM Jan Beulich w= rote: > > > > On 23.01.2024 13:28, Nick Clifton wrote: > > > 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 th= at > > > come after it. (I am thinking of the -L option here, although ther= e > > > are probably several others). So instead I am considering document= ing > > > the current behaviour as expected. (See the patch below). > > > > > > What do people think ? > > > > I'd be fine either way, and I agree documenting is cheaper and sufficie= nt. > > > > Jan > > We should give a warning or an error if --fatal-warnings isn't the first > command-line option. > I ran into a similar issue with --text-section-ordering-file. My patch issues an error if --text-section-ordering-file is placed after -T/--script= . @@ -670,6 +673,7 @@ parse_args (unsigned argc, char **argv) dynamic_list } opt_dynamic_list =3D dynamic_list_unset; struct bfd_elf_dynamic_list *export_list =3D NULL; + bool seen_linker_script =3D false; shortopts =3D (char *) xmalloc (OPTION_COUNT * 3 + 2); longopts =3D (struct option *) @@ -1394,6 +1398,12 @@ parse_args (unsigned argc, char **argv) einfo (_("%F%P: invalid section sorting option: %s\n"), optarg); break; + case OPTION_TEXT_SECTION_ORDERING_FILE: + if (seen_linker_script) + einfo (_("%F%P: --text-section-ordering-file must be placed" + " before -T/--script\n")); + config.text_section_ordering_file =3D optarg; + break; case OPTION_STATS: config.stats =3D true; break; @@ -1410,6 +1420,7 @@ parse_args (unsigned argc, char **argv) ++trace_files; break; case 'T': + seen_linker_script =3D true; previous_script_handle =3D saved_script_handle; ldfile_open_script_file (optarg); parser_input =3D input_script; --=20 H.J.