From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 857793858D34 for ; Fri, 5 Apr 2024 18:28:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 857793858D34 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 857793858D34 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=1712341698; cv=none; b=qnem1p79Y/p2v1W3janp1ZztFnKr0HwQr7LzBKQ155FEfkRhHrGZ3a054gG9KJsVhzExcjyyAEIwfV3Cobt9brxlodjEzkztMm0wWoX9NvD+5MagSk0jlZr3Es0xybFHTPblSuN8+0qu0+ivqMBdSZyRttZDjXPx++hEvE08mGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712341698; c=relaxed/simple; bh=h9DP97NYPZJJ0bOL7gsZMAEiy+SLoKr6tDPWI7rDl8g=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=ZwlWYUY5mEW1215W64m2lzXXw/lOMxB2W+V/LMs0G/MbgaeoJwhOWuc0HytSsuy7wEbkpJZsEBaPzj+S0TVahxEOYr3PKJHWRPc+BMM2OayeviwZ+vrhC4xN/XNaOXB3XfZhvgqkvZrmVLdlDwMrfh+VEYZ5HR5eaz68WtM66MI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712341696; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=7FwbGsPIYI1wTpxYpcws7Ey9tLn9KCUTJTZk7pHizqQ=; b=dlO2lhzcOcZV77MeRs2mGqnzgQ2jfqAUZebgFdLGwsfccvfjtfVYoKrokY7bBV6Qyl4m5o YhP54peIQ7ZE8y+3tFJKJPkJquqCMb2HM+AZocewOEQj+nOd3Lk6ZzAjQh2gg5Ej90kKyi b9kRgMoZVNcExKdsaw3vt3Hs2WTyHcY= 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-460-Ve5ZEOfgPQafkThpR_EK6Q-1; Fri, 05 Apr 2024 14:28:14 -0400 X-MC-Unique: Ve5ZEOfgPQafkThpR_EK6Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 701F48F5DA0 for ; Fri, 5 Apr 2024 18:28:14 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 35C601C060A4; Fri, 5 Apr 2024 18:28:13 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 435IS8KI2573498 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 5 Apr 2024 20:28:08 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 435IS8O32573497; Fri, 5 Apr 2024 20:28:08 +0200 Date: Fri, 5 Apr 2024 20:28:08 +0200 From: Jakub Jelinek To: Marek Polacek Cc: GCC Patches Subject: Re: [PATCH] target: missing -Whardened with -fcf-protection=none [PR114606] Message-ID: Reply-To: Jakub Jelinek References: <20240405182218.55288-1-polacek@redhat.com> MIME-Version: 1.0 In-Reply-To: <20240405182218.55288-1-polacek@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 Fri, Apr 05, 2024 at 02:22:18PM -0400, Marek Polacek wrote: > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > -- >8 -- > -Whardened warns when -fhardened couldn't enable a hardening option > because that option was disabled on the command line, e.g.: > > $ ./cc1plus -quiet g.C -fhardened -O2 -fstack-protector > cc1plus: warning: '-fstack-protector-strong' is not enabled by '-fhardened' because it was specified on the command line [-Whardened] > > but it doesn't work as expected with -fcf-protection=none: > > $ ./cc1plus -quiet g.C -fhardened -O2 -fcf-protection=none > > because we're checking == CF_NONE which doesn't distinguish between nothing > and -fcf-protection=none. I should have used OPTION_SET_P, like below. > > PR target/114606 > > gcc/ChangeLog: > > * config/i386/i386-options.cc (ix86_option_override_internal): Use > OPTION_SET_P rather than checking == CF_NONE. > > gcc/testsuite/ChangeLog: > > * gcc.target/i386/fhardened-1.c: New test. > * gcc.target/i386/fhardened-2.c: New test. > --- > gcc/config/i386/i386-options.cc | 2 +- > gcc/testsuite/gcc.target/i386/fhardened-1.c | 8 ++++++++ > gcc/testsuite/gcc.target/i386/fhardened-2.c | 8 ++++++++ > 3 files changed, 17 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.target/i386/fhardened-1.c > create mode 100644 gcc/testsuite/gcc.target/i386/fhardened-2.c > > diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc > index 7896d576977..20c6dc48090 100644 > --- a/gcc/config/i386/i386-options.cc > +++ b/gcc/config/i386/i386-options.cc > @@ -3242,7 +3242,7 @@ ix86_option_override_internal (bool main_args_p, > on the command line. */ > if (opts->x_flag_hardened && cf_okay_p) > { > - if (opts->x_flag_cf_protection == CF_NONE) > + if (!OPTION_SET_P (flag_cf_protection)) This function is passed explicit opts and opts_set arguments, so it shouldn't be using flag_something macros nor OPTION_SET_P, as the former use global_options.x_flag_something rather than opts->x_flag_something and the latter uses global_options_set.x_flag_something. So, I think you want to use if (!opts_set->x_flag_cf_protection) instead. > opts->x_flag_cf_protection = CF_FULL; > else if (opts->x_flag_cf_protection != CF_FULL) > warning_at (UNKNOWN_LOCATION, OPT_Whardened, Otherwise LGTM. Jakub