From patchwork Tue Jun 20 19:55:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1797569 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=e2gFTpPi; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qly6Z3FhYz20Wk for ; Wed, 21 Jun 2023 05:55:34 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2D3BB3858C41 for ; Tue, 20 Jun 2023 19:55:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D3BB3858C41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687290932; bh=gCQw33RH52SMsM4GUut57ZymdvDqAeChGXkMZtALI4w=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=e2gFTpPiP9OZoVO0vf2XK7yXGSrgqXIRcpQXigWFXBql+Yi70rCJ6ru0qNheA4c44 dtFl1AvNUtXTFbqHAOi0ZsQ5JT2LAXPd81bH/dAWyxZRFMOxIptm10sUqkOvbl9cnI CWT7Jl+rHS0vFPRCCL+2B8GFA837XQOqtypS2eSs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by sourceware.org (Postfix) with ESMTPS id 3F5603858D28 for ; Tue, 20 Jun 2023 19:55:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F5603858D28 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-1a1fa977667so5145139fac.1 for ; Tue, 20 Jun 2023 12:55:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687290915; x=1689882915; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gCQw33RH52SMsM4GUut57ZymdvDqAeChGXkMZtALI4w=; b=XrhT4i5SPvtPOK86dRJIL+nHWkiykihckoj8wwzq+BrDaa08TMDWvqcSDKX4Oj+phQ 2wwF1Jr6Mp3qBS1Pb8g9ikQIoeAFrUrWoUzjzQ6sGZZ1Rlc3ws54bTb3mVSoAd/fmm3U fEuieh20lQflxgSokoPXTF1bqraXwyIDthe0oHe9N7xOkY88U/7/AqIXFowu3pUs6cyB lCJ/kjmS6BegDTL9zrsvbGI9vemhNW9fNe2d8ryipgeh/GX/lv7kUXZrpxiRPJSbcdWC 4+BciRJKMhLbE2rUFSerFIAvFLEj24n26ClMW5rpixJQQqsupyrgrXh4+yMeXK6CQie5 FHBw== X-Gm-Message-State: AC+VfDxi4EvOw+4SCp+HF66/NorCzHkNWCMTpO413Lq4C4L2Nyp5pb4V p8sG+Vxkdn3t7I2SZn/VuK+QgjySjqf6oXsZp0j/gQ== X-Google-Smtp-Source: ACHHUZ5G4/taS/72xtky/FZ+JFJINxwoR4s2x9CCYnlyEcW1ObQ6un2cIzZAP9CP88ix8NQDzNrwcw== X-Received: by 2002:a05:6870:1a87:b0:19f:af14:9e60 with SMTP id ef7-20020a0568701a8700b0019faf149e60mr10234490oab.8.1687290915076; Tue, 20 Jun 2023 12:55:15 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:a14c:8683:1fa3:da2c:c7dc]) by smtp.gmail.com with ESMTPSA id kw41-20020a056870ac2900b001a6a3f99691sm1815413oab.27.2023.06.20.12.55.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 12:55:14 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] scripts: Add fortify checks on installed headers Date: Tue, 20 Jun 2023 16:55:10 -0300 Message-Id: <20230620195510.2274938-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" The _FORTIFY_SOURCE is used as default by some system compilers, and there is no way to check if some fortify extension does not trigger any conformance issue. Checked on x86_64-linux-gnu. Reviewed-by: Carlos O'Donell --- scripts/check-installed-headers.sh | 36 +++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/scripts/check-installed-headers.sh b/scripts/check-installed-headers.sh index 5a50a491ca..23506a2514 100644 --- a/scripts/check-installed-headers.sh +++ b/scripts/check-installed-headers.sh @@ -29,6 +29,9 @@ cxx_modes="-std=c++98 -std=gnu++98 -std=c++11 -std=gnu++11" # These are probably the most commonly used three. lib_modes="-D_DEFAULT_SOURCE=1 -D_GNU_SOURCE=1 -D_XOPEN_SOURCE=700" +# Also check for fortify modes, since it might be enabled as default. +fortify_modes="1 2 3" + if [ $# -lt 3 ]; then echo "usage: $0 c|c++ \"compile command\" header header header..." >&2 exit 2 @@ -100,29 +103,36 @@ EOF echo :: "$header" for lang_mode in "" $lang_modes; do for lib_mode in "" $lib_modes; do - echo :::: $lang_mode $lib_mode - if [ -z "$lib_mode" ]; then - expanded_lib_mode='/* default library mode */' - else - expanded_lib_mode=$(echo : $lib_mode | \ - sed 's/^: -D/#define /; s/=/ /') - fi - cat >"$cih_test_c" <"$cih_test_c" < int avoid_empty_translation_unit; EOF - if $cc_cmd -finput-charset=ascii -fsyntax-only $lang_mode \ - "$cih_test_c" 2>&1 - then : - else failed=1 - fi + if $cc_cmd -finput-charset=ascii -fsyntax-only $lang_mode \ + "$cih_test_c" 2>&1 + then : + else failed=1 + fi + done done done done