From patchwork Mon Apr 17 16:01:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 674288 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2D61C77B7E for ; Mon, 17 Apr 2023 16:02:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230399AbjDQQB7 (ORCPT ); Mon, 17 Apr 2023 12:01:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230281AbjDQQBy (ORCPT ); Mon, 17 Apr 2023 12:01:54 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E56AC145; Mon, 17 Apr 2023 09:01:43 -0700 (PDT) From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1681747301; bh=zekhJ4z4Fnh6i2mXqzVImhLPZlMmwOwIMhaSEAjmj+Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WZbPbKyk+rj+hBkRR5sTSTkN0rQT/zZf+GHgkgo/bmZ7lIPBo11nhYswBsXhJGW9B /yZzLi7J046wb1qbtaFFmYd2eKUhqH711skdOqCMcDHvs2u9mo2LQXLevJZ4a0yAoj K4SVMyc+EQXAStROIqJkxS1gbzVPFzrKq+puN06E= Date: Mon, 17 Apr 2023 18:01:33 +0200 Subject: [PATCH 3/6] tools/nolibc: aarch64: add stackprotector support MIME-Version: 1.0 Message-Id: <20230408-nolibc-stackprotector-archs-v1-3-271f5c859c71@weissschuh.net> References: <20230408-nolibc-stackprotector-archs-v1-0-271f5c859c71@weissschuh.net> In-Reply-To: <20230408-nolibc-stackprotector-archs-v1-0-271f5c859c71@weissschuh.net> To: Willy Tarreau , Shuah Khan , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1681747300; l=1861; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=zekhJ4z4Fnh6i2mXqzVImhLPZlMmwOwIMhaSEAjmj+Q=; b=CbAIungh96eUcyDkNCJ3jKLI0AkYfxTl/MiL8raeBi+oIAFJ69Jem8xlgVdBGDgQD0j+0UXiF 5uGK0wWz+qgDiXIfrmZXdg+p8/8onx3kP1oW++a65k3fQzfhySFeoWE X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/arch-aarch64.h | 7 ++++++- tools/testing/selftests/nolibc/Makefile | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h index 76ef26520c85..6a859131c530 100644 --- a/tools/include/nolibc/arch-aarch64.h +++ b/tools/include/nolibc/arch-aarch64.h @@ -172,10 +172,15 @@ struct sys_stat_struct { char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); +#define __ARCH_SUPPORTS_STACK_PROTECTOR + /* startup code */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) { __asm__ volatile ( +#ifdef NOLIBC_STACKPROTECTOR + "bl __stack_chk_init\n" /* initialize stack protector */ +#endif "ldr x0, [sp]\n" /* argc (x0) was in the stack */ "add x1, sp, 8\n" /* argv (x1) = sp */ "lsl x2, x0, 3\n" /* envp (x2) = 8*argc ... */ diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 0a83ad388a16..d68e96afea80 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -82,6 +82,7 @@ CFLAGS_STACKPROTECTOR = -DNOLIBC_STACKPROTECTOR \ CFLAGS_STKP_i386 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_x86_64 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_x86 = $(CFLAGS_STACKPROTECTOR) +CFLAGS_STKP_arm64 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_riscv = $(CFLAGS_STACKPROTECTOR) CFLAGS_s390 = -m64 CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \