From patchwork Tue Feb 7 00:16:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_M=C3=BCllner?= X-Patchwork-Id: 64385 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7737D3864814 for ; Tue, 7 Feb 2023 00:18:00 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id 164923858D35 for ; Tue, 7 Feb 2023 00:16:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 164923858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu Received: by mail-wm1-x32f.google.com with SMTP id bg26so9932492wmb.0 for ; Mon, 06 Feb 2023 16:16:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8iDBnWQl9q8DHc5u8j+HZPVJRKs/uVA6CFhCy0D+JC0=; b=D1Nq7xuvOFJQdZtlLUqqSEkLjh1T0BpdtneMDuuqBzrzJZd8ELENHUFgXMzu4CZeVq tp5LExVO7Cdg0kwm+/ZmLNcD7VFgqCHWYyfmiQyZzGGKD6WYo/y7kPSD5Cd2usdHTUUq cy1sn5VXp24VkDEr5eOsF44YoSVi/wTgQlna+uhWvcJiXofv/jkhsM1GNy6QOYTH4UKZ noo4uyabcQKVCZ2mARvZNKymPaaezW641SmSRoqK2Wup0WwFi6U0R0lsBGiZsxeElvAx RDmTSviRFjLgdIxCgrYyIOwfswvLfImkJgMsZTrly5yYFhD9378Ozt51ylrmOOVjqvyH KFmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8iDBnWQl9q8DHc5u8j+HZPVJRKs/uVA6CFhCy0D+JC0=; b=pSKHM02T1/R4nd6dsqoAd95c4hFY4aLLxUkWGtyPiryIRWzyvFc06Sli8g2O8f7vSd QUuCUjt+qto1fRpeLqkkjtmRJMr4SdccWBo6m9E473S0m1fOQtuWVNaQkV2B1ImbCnur CnIwzFEAeYExxrw+PXqELdfAvZcZCFXPl7UAroM9pSYxbnc0qrYgFhGPVM4X4a98aIcz h7ML9dNfm9HtGS8fmGezR9YhXnYyA69dEQZlHTJrXT2wlU81ODuKz3ciiosih12gBs4Q ULX860SBEZGfsY+mCt6oHXAP/Kf+dsb2IsVcYepCdU3EbmOTIJtyoldDT+kiyp5QzeLX /3pA== X-Gm-Message-State: AO0yUKUBRg5PQQ5fiZXSwii47xPCFQvCczcr7HqnaaCNL602U4Uj3B0u AUvAYF82ny4w7qf8U5Mvjn/3WtuLHrGSgA1w X-Google-Smtp-Source: AK7set8WBoW7WsPNi2OldKZOI8Y2EB2bdyxmagA1aKjImtIjdbuz+RNghqGi9BhZJ/zQs4SFLOjcrQ== X-Received: by 2002:a05:600c:3317:b0:3e0:111:28a9 with SMTP id q23-20020a05600c331700b003e0011128a9mr1300861wmp.22.1675728992272; Mon, 06 Feb 2023 16:16:32 -0800 (PST) Received: from beast.fritz.box (62-178-148-172.cable.dynamic.surfer.at. [62.178.148.172]) by smtp.gmail.com with ESMTPSA id f1-20020a1cc901000000b003df14531724sm16862050wmb.21.2023.02.06.16.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 16:16:31 -0800 (PST) From: Christoph Muellner To: libc-alpha@sourceware.org, Palmer Dabbelt , Darius Rad , Andrew Waterman , DJ Delorie , Vineet Gupta , Kito Cheng , Jeff Law , Philipp Tomsich , Heiko Stuebner Cc: =?utf-8?q?Christoph_M=C3=BCllner?= Subject: [RFC PATCH 01/19] Inhibit early libcalls before ifunc support is ready Date: Tue, 7 Feb 2023 01:16:00 +0100 Message-Id: <20230207001618.458947-2-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207001618.458947-1-christoph.muellner@vrull.eu> References: <20230207001618.458947-1-christoph.muellner@vrull.eu> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_MANYTO, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 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: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" From: Christoph Müllner One of the few tasks in __libc_start_main_impl, before ifunc support is ready on many architectures is to process the AUX vector. GCC is able to detect libcall routines in this code, which will result in invocations of uninitialized ifunc pointers. Let's set the proper attributes to these early functions to avoid avoid libcalls. This was observed to be an issue (endless loop) in combination with: - GCC upstream/master - glibc upstream/master - glibc built with -O3 - target arch RISC-V (RV64) - experimental RISC-V ifunc support patches Other combinations/architectures might be affected as well. Signed-off-by: Christoph Müllner --- csu/libc-start.c | 1 + elf/dl-support.c | 1 + 2 files changed, 2 insertions(+) diff --git a/csu/libc-start.c b/csu/libc-start.c index c3bb6d09bc..8566a54df5 100644 --- a/csu/libc-start.c +++ b/csu/libc-start.c @@ -231,6 +231,7 @@ STATIC int LIBC_START_MAIN (int (*main) (int, char **, char ** locate constructors and destructors. For statically linked executables, the relevant symbols are access directly. */ STATIC int +inhibit_loop_to_libcall LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), int argc, char **argv, #ifdef LIBC_START_MAIN_AUXVEC_ARG diff --git a/elf/dl-support.c b/elf/dl-support.c index 9714f75db0..b0e9e1636a 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -242,6 +242,7 @@ __rtld_lock_define_initialized_recursive (, _dl_load_tls_lock) int _dl_clktck; void +inhibit_loop_to_libcall _dl_aux_init (ElfW(auxv_t) *av) { #ifdef NEED_DL_SYSINFO