Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp684189iob; Thu, 12 May 2022 02:24:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVakdcEjywd3FtxOCopPdB7jAajsFYF8/Aq6cMeb3sbiVndaKt5YO/sHFtUFCRI0/akHnb X-Received: by 2002:a17:907:2da0:b0:6f4:e536:3771 with SMTP id gt32-20020a1709072da000b006f4e5363771mr30243189ejc.55.1652347447281; Thu, 12 May 2022 02:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652347447; cv=none; d=google.com; s=arc-20160816; b=AiYx7aI6XK/RIxQwssbdla7x2K8HOz/ImxZPNjTxXnJT0g2icvST3MgHdYzqbAdp9A 5XEAXh3jTSZmvx6WZoB/9Lwa22fNqqbgZnUWDvbAtyPc+3YgY+nZuaEkKexF9MiFjivL Hz3qWRGV7a+dwDUCv9S0TX6758KClMmjUYLZ1tKLQrdqwIaq509v6J0wlMcsPqiLg5eZ OV2qUOcS3PitcgHQdDKBdYPGczw5MoKjX68VPVirmq9HCI5gEay6zFGHbwqK44hZ1mmi srjju9s0Ff3mkcgSgYB9MxnrJ19qqC7uR7lJkED5MkALrZ5D6U5A4LHpY+9z8NhVzvyc Ryaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=JZpzKLhkBXkccpwxuxe0rmOv0UldbZIhUDSP5FUigIM=; b=RNksXf32ciTf3TxHdhJicyNvdZDsTvu8d6NLMi+oPdkjzJLmBBIcIFtq2FqcdCOrIV 2xVRSug6qy/Q/RVtbUUjoAhYWsu84QVu+yusnq1zFa39nJe3i71nvPKniagEtT/TUGC1 SO0Yh18M/Sed5LhK6axQBc91C9VNXRXDXlAbyO3Os9Vma8HSwjFkroy0NtmXArwkiP+u CTX0Bafa204iVkM08/LBSBscev2UNWSjs/nZKx87mx7ize/E0LMioss6qBQYD7m2uSfQ 5bFD06o0hfifE+OSsYTl/fsRZZQjpT+bf0uCKwyC6kleqA/XffdforrETzRY+dZqDhs7 1DqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i28-20020a0564020f1c00b0041d82c21030si5696669eda.607.2022.05.12.02.23.32; Thu, 12 May 2022 02:24:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345468AbiEKRVo (ORCPT + 99 others); Wed, 11 May 2022 13:21:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345454AbiEKRVi (ORCPT ); Wed, 11 May 2022 13:21:38 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BDC5320CA48; Wed, 11 May 2022 10:21:35 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 338961042; Wed, 11 May 2022 10:21:35 -0700 (PDT) Received: from donnerap.arm.com (donnerap.cambridge.arm.com [10.1.197.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0D2D73F73D; Wed, 11 May 2022 10:21:33 -0700 (PDT) From: Andre Przywara To: Catalin Marinas , Will Deacon , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, Mark Brown , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] kselftest/arm64: bti: force static linking Date: Wed, 11 May 2022 18:21:29 +0100 Message-Id: <20220511172129.2078337-1-andre.przywara@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The "bti" selftests are built with -nostdlib, which apparently automatically creates a statically linked binary, which is what we want and need for BTI (to avoid interactions with the dynamic linker). However this is not true when building a PIE binary, which some toolchains (Ubuntu) configure as the default. When compiling btitest with such a toolchain, it will create a dynamically linked binary, which will probably fail some tests, as the dynamic linker might not support BTI: =================== TAP version 13 1..18 not ok 1 nohint_func/call_using_br_x0 not ok 2 nohint_func/call_using_br_x16 not ok 3 nohint_func/call_using_blr .... =================== To make sure we create static binaries, add an explicit -static on the linker command line. This forces static linking even if the toolchain defaults to PIE builds, and fixes btitest runs on BTI enabled machines. Signed-off-by: Andre Przywara --- tools/testing/selftests/arm64/bti/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/arm64/bti/Makefile b/tools/testing/selftests/arm64/bti/Makefile index 73e013c082a65..dafa1c2aa5c47 100644 --- a/tools/testing/selftests/arm64/bti/Makefile +++ b/tools/testing/selftests/arm64/bti/Makefile @@ -39,7 +39,7 @@ BTI_OBJS = \ teststubs-bti.o \ trampoline-bti.o gen/btitest: $(BTI_OBJS) - $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -o $@ $^ + $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -static -o $@ $^ NOBTI_OBJS = \ test-nobti.o \ @@ -50,7 +50,7 @@ NOBTI_OBJS = \ teststubs-nobti.o \ trampoline-nobti.o gen/nobtitest: $(NOBTI_OBJS) - $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -o $@ $^ + $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -static -o $@ $^ # Including KSFT lib.mk here will also mangle the TEST_GEN_PROGS list # to account for any OUTPUT target-dirs optionally provided by -- 2.25.1