From patchwork Sun Sep 6 19:06:06 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Turner X-Patchwork-Id: 143015 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CAE214BC7EEC for ; Sun, 6 Sep 2026 19:08:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CAE214BC7EEC Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=nxUPBAMK X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by sourceware.org (Postfix) with ESMTPS id 87BB34BC7EF8 for ; Sun, 6 Sep 2026 19:06:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 87BB34BC7EF8 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 87BB34BC7EF8 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788721572; cv=none; b=ms2J+zxg/KYAL92Sh/QFqGYJ6kq3VYAO0sruZFLBBBbaAgvfql5F5Y9mBXhXL+lbzAG24wiJOeO/z5JY2lZinYNGK9jnleqBpWxZjUdqXJ7Pj3cjZwQu/UA6bcRFJFRXDQbhlNcgjtnSbKCyDJYi/wUrXiKeMGz1AfHbR0kdNy8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788721572; c=relaxed/simple; bh=f6g9XH09PXXOLlOeqOo4+A7UeA1mRNGS2W1YvzolAp4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=ivAnLCcptwQMfiG9auvNaZDoOzG0TBTqItJaORGBLF9SvUuxmgV4lqhg4vDHqWea18OjwhtbbktCzAJtszU7fOrj0Y59UGJmW4ou2poZMFbYLHivZ0UUSpeGEQsxTkTocEY4WpGeZ0onsWrFhgL8RNDx5LNRClGGKpeRzj5WZdY= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=nxUPBAMK DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87BB34BC7EF8 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-85a50f6a7f7so36459517b3.2 for ; Sun, 06 Sep 2026 12:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788721572; x=1789326372; darn=sourceware.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=QLilfjfvp9McyPSHvinIusMh/owF9asIYNGstK2atlM=; b=nxUPBAMKEhhNkthGw4fbbt0mMlLj5S71EiGDMHI4ZoMToenZJeJjIxSRph0rExtaT5 ZfGkBGrGxshhV+dmfvT43OAuWYq6z5bM216Dp/5fzaaI88Wa7cKLYpP699pceXpELbs2 JioKQz+D+RCO2yJDJ0VS4iSFChZEPreLJJVVus2Uxhc9Kp6pb0W3kXBkN1truzvA9mji 8JcBWlg+8Mmzuoy1mqRMkdBAaLjdYLcpA2025PeFZ8rUwEUs47A2JA3nABwKtYOLErm9 0trAjbPO8b9vILck0QIiR1O79ruRYA3OGFcgdVdisbQjaCjCTkuXzIDrBmi1ZtRn9AFj 0W1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788721572; x=1789326372; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=QLilfjfvp9McyPSHvinIusMh/owF9asIYNGstK2atlM=; b=pk9EMhqT6R0LrCYiiLPIwD2YxpjGpeSY8ghXtQrAqYtl5WcNTUdng5m8XXPcmQd/IM Ehqectuzdys8mOTZJvuSI29y0BIwV5BlFCYw+xs3rU05mSLS3yWkI62Y97zfK5W7Fv/p 4XxLQmj1C8k1xntMaNmKci8By6oZbVy406Jju9um+a8ynFfWDOAAHrtZOd2a2DpCKW2L Sv52sLy2/4xeJ/hg1CrXPhsiRsd2tfKM9yqzuM111b/+s9vDw05OPdcz9JIUlDk7QfC6 cYBS3VFr34NtAAZTJ/GKcGEz7htXjgps199P47Qy5ABkX4z0g0xB+eaOymSckUBX0R+F hYlw== X-Gm-Message-State: AFuF++kcBveztApIJ3UiuRlhcDfP5xF/AWwpYEKMgAOEtar8F05YAeI4 1KFOk8JmwBGv0WTJ1BCk90S/rlFe6/qpk/e4CumJCjNMvVFEn+LP0Gl8 X-Gm-Gg: AYBFou20L8eG5wuwwzbn6YwMqjb/EgSDsvkd0wg2x7gajozCxJXzqDO69kXFa7AE05D sKhxztUwlJgBokYVHYh+ucc2MFEz8FkVdQn3oYt6cPeSL+fQFppyxK7tsowTcC9nHbEyesz7FuZ xFHPIesE9LuCKwy+Ot/eMK27i7ytdbctXs6NZvg82K15JBi1jsZtnxnV5HG2pDQQWNKopinoFTC tglh1wH1jTzTk2YcKrVVVMPLaiPP1GZ7csOFU+8rz4UrQsrr4AhhhADmq1J76slj+HF/BLFBjzE f6vZuatJHe9Zxoc+/Utw7IrJT/J2kyk+nx9o1XPGvcOQMZWNQaEZwgVraNjDYIX1Od5i56Hwy70 cmETrm3JY3y39ZULdsid8Gk1Mex2shFEtLdlLoNB+4i68zwHFErGY0lnUN/qHYEAxV47IS+pyel kFwEiKuedQQB6k0+vs7LZl3G0F6LJfBm11Po8mdQsVyD0KloC4SYDKr224y+bK X-Received: by 2002:a05:690c:3683:b0:820:b89:52c6 with SMTP id 00721157ae682-8712a418f03mr70112737b3.33.1788721571838; Sun, 06 Sep 2026 12:06:11 -0700 (PDT) Received: from localhost ([2600:1702:7a90:6f9f:8bc4:8aec:108d:7a04]) by smtp.gmail.com with ESMTPSA id 00721157ae682-87149316356sm58987907b3.9.2026.09.06.12.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Sep 2026 12:06:11 -0700 (PDT) From: Matt Turner Date: Sun, 06 Sep 2026 15:06:06 -0400 Subject: [PATCH 1/4] alpha: treat STO_ALPHA_STD_GPLOAD as a function in abilist.awk MIME-Version: 1.0 Message-Id: <20260906-gm-series1-ifunc-infra-v1-1-d409f053327f@gmail.com> References: <20260906-gm-series1-ifunc-infra-v1-0-d409f053327f@gmail.com> In-Reply-To: <20260906-gm-series1-ifunc-infra-v1-0-d409f053327f@gmail.com> To: libc-alpha@sourceware.org Cc: Matt Turner X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1269; i=mattst88@gmail.com; h=from:subject:message-id; bh=f6g9XH09PXXOLlOeqOo4+A7UeA1mRNGS2W1YvzolAp4=; b=owGbwMvMwCW25rVmCc8sv+mMp9WSGLLm7pyXtztPbYWpsYmI172O3UsU0pTSi4qUJt8samXeo 5t9fgVvx0cWBjEuhpliiixx6xVZZrXtWOpzWvoXzBxWJpAh0iINDEDAwsCXm5hXaqRjpGeqbahn CGToGMVD5PQYNDKLi0tTi3TTCooc8vJLEksy8/OK9fILUvMK0gv00jLTSjIy8ouKU4FG6OWllpi 6OroZGRqYWDpamDlZOJqaODs7GTq5OTo6uzoZWZqbGDhbOpq4WpozcHEKwFwT7s3wv4z3o8IKJ+ Ug/QK1CxO3FDf9XBFTPOfVtPTr6u8E2Au+/WRkaCptkq2wWtXAlC56etWj+RMsly99pGtfEP+FU f1TsqUmOwA= X-Developer-Key: i=mattst88@gmail.com; a=openpgp; fpr=3BB639E56F861FA2E86505690FDD682D974CA72A X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 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 The Alpha ABI defines two st_other values for functions: 0x80 (STO_ALPHA_NOPV) - .prologue 0: runs on caller's GP 0x88 (STO_ALPHA_STD_GPLOAD) - .prologue 1: standard two-instruction GP load abilist.awk recognized 0x80 but not 0x88 when classifying a dynamic symbol of object type as a function. Symbols like strncat that are weak aliases of .prologue 1 assembly functions appear as STT_NOTYPE with st_other=0x88 in the dynamic symbol table and were incorrectly classified as data. Add 0x88 to the check so both GP-setup variants are treated as functions. --- scripts/abilist.awk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/abilist.awk b/scripts/abilist.awk index 7ea1edf8c0..39f63d0803 100644 --- a/scripts/abilist.awk +++ b/scripts/abilist.awk @@ -70,8 +70,8 @@ $2 == "g" || $2 == "w" && (NF == 6 || NF == 7 || NF == 8) { type = "O"; seen_opd = 1; } - else if (type == "D" && NF == 8 && $7 == "0x80") { - # Alpha functions avoiding plt entry in users + else if (type == "D" && NF == 8 && ($7 == "0x80" || $7 == "0x88")) { + # Alpha functions: 0x80 = STO_ALPHA_NOPV, 0x88 = STO_ALPHA_STD_GPLOAD type = "F"; size = ""; seen_opd = -1; From patchwork Sun Sep 6 19:06:07 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Turner X-Patchwork-Id: 143013 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2889A4BC7EF7 for ; Sun, 6 Sep 2026 19:06:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2889A4BC7EF7 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=jM5ehdR8 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yx1-xb130.google.com (mail-yx1-xb130.google.com [IPv6:2607:f8b0:4864:20::b130]) by sourceware.org (Postfix) with ESMTPS id 9C0F24BCA41A for ; Sun, 6 Sep 2026 19:06:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9C0F24BCA41A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9C0F24BCA41A Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788721574; cv=none; b=VjUXSHBjYxFUE6pJXsDMqmtT92xWpOZvi9Ij4Hya9aXD4QUXHHPo8NTpqIts7G/UGwwLsAZ+VGHsNV+KpuVX+2z0QnzDmLcOt4FmmfsWOT2OhCdQWJagc0WsOdHjwQjSgvvjztUmL/0Q8OQ/l6lasQ1foGiOK/u4qGhWGKdUzWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788721574; c=relaxed/simple; bh=p3ISa8JNmrSFP119UYeT1dcmFnjAdRosJDkxJxNeQgE=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=cx+gtj6jV9bNBM13svFJLYinrUte7kfpwscf+/g2t5+iQIIM+lBQbEG9GaKHdySIUi9A7sE5FRoHIBoJ3ekn2v908pweSYlUqQ3m4MipGFPxtBnP16+D/ajK+MZgYiU1+KHsms972xs5oUpxp4ho68Z+tdPhSlGVzZCJY2LYD0Q= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=jM5ehdR8 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C0F24BCA41A Received: by mail-yx1-xb130.google.com with SMTP id 956f58d0204a3-66fca0709caso685700d50.1 for ; Sun, 06 Sep 2026 12:06:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788721574; x=1789326374; darn=sourceware.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YAheZk0RJSn1XnhV1YW9Q6Gi4k25+vyvroXyfP31d6U=; b=jM5ehdR8/KJg2ifQP9dalVWtdLGwMnWovw/955EltdswQ7qIGXCDC8qo0QI7n5UH8w me2RO2xjiB3ogNknSCERCcFErFsyy/RUU19cC8utecedPktmZ1MMmqdufyUJjSUKpAoP U30k7ftsZPU7keXRvFDoIJD6zNfh7y1z613WdBoO2vaFJyfPX0J27B2gHZZC+kVFMatG EfsscEC3BTZHUr1BL7NNbJPreXFNx7Z2m4ITK95L3V6+XYq/E4DtsMrrYZOxJFQVklbo N5eRBtwBOdI0i7LkRSR9puIL2NvTc4mCrZQEM4dFtkbWbZyBxt/rvVCsVlXxqcgIohSw urtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788721574; x=1789326374; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=YAheZk0RJSn1XnhV1YW9Q6Gi4k25+vyvroXyfP31d6U=; b=VNONi0S96xpliiTAHt05G6jzpf1HW2XRSD+oYWMjVk32hO7Jt7P1+J2fxrnloi34mo pMIt2on/wY5aWpJtuwdZwvWu3DvKg37US5UqzlacAtHmj7usVMjYnUdrF19Zs4ai/rZu Lgqs73fO+86pwNZEn3OrNEngPpkF8TLG1joWn2wTTxkgncfbBwiFHO7btyUS32dc1YsR n1LUmYT8tK+4EE+SLf4uT71YA/6ay6tGQbikDwd0pdRcPkTsyIfBMANoGY4qXgIlMgTf E4QY1ifuFfMfPjxQI8HQr0n7jjwwRrfyVGmDK6cgEb0FwRaIXw4DY8FVi9mAaPnS+D4n Ybgg== X-Gm-Message-State: AFuF++n89Xe6dveAnvEVzf2auKtrNXrHxaA7vAY+vGjAUXiWi1DmC73a Of06n7hf0x2MRhzyb3A/7XMHcVo+f7ubcwkIfyKXjCizMPkFkMB8U/6x9kFF53oJ X-Gm-Gg: AYBFou2BHJYyv4SD92kwlTziFBfEiAFWHaNbQhcDB576qBQoE4qQzhVnNsDuIFeSPAm faZ4IGDFVQLLwM3NbC+LBMysdDgAnVaQuddSqZXWA+deMpGgqnhhmRYBLvwa9V1rfZDOhdSGu6J erwvj2OBe1fvxdsVesUJQY++pi7cPqy5ebYpIrySYpJjpr1DlSP429coBWVrA0rT2jH4/ZlNuPx kjmyUmIUOphvHIBi2DrvG3IQWkddTdTD6IJWBoVlJGPanp/ByVhv09TTE5m0ABDfMSFYkB/HlaF qD3WDGhq5rKKF9sFm5VI1ov3wuG/BH4cde8NWFvOxTeq1/cYa+IchM2W80Q8Z/QKIym3Y2B4HJw ORRiW9obQOW1DxF/WL1PW3puMd/zs1b7Y9WsFobtF0MY3baBGGrb1nWlDdxQSp6nVtqu0Tb5RPw eT4GwqM85SW3PujHTA+3LIeYsUYquS3CHm4TYetbS/4mCQkIn12l7aKDL217rh+G2XoVjcSZw= X-Received: by 2002:a05:690e:144c:b0:66c:effb:3706 with SMTP id 956f58d0204a3-66fb5abd6e9mr5481479d50.38.1788721573777; Sun, 06 Sep 2026 12:06:13 -0700 (PDT) Received: from localhost ([2600:1702:7a90:6f9f:8bc4:8aec:108d:7a04]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8714befac64sm59411107b3.47.2026.09.06.12.06.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Sep 2026 12:06:12 -0700 (PDT) From: Matt Turner Date: Sun, 06 Sep 2026 15:06:07 -0400 Subject: [PATCH 2/4] alpha: add IFUNC support to the dynamic linker MIME-Version: 1.0 Message-Id: <20260906-gm-series1-ifunc-infra-v1-2-d409f053327f@gmail.com> References: <20260906-gm-series1-ifunc-infra-v1-0-d409f053327f@gmail.com> In-Reply-To: <20260906-gm-series1-ifunc-infra-v1-0-d409f053327f@gmail.com> To: libc-alpha@sourceware.org Cc: Matt Turner X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=6267; i=mattst88@gmail.com; h=from:subject:message-id; bh=p3ISa8JNmrSFP119UYeT1dcmFnjAdRosJDkxJxNeQgE=; b=owGbwMvMwCW25rVmCc8sv+mMp9WSGLLm7pyX4HimOrTz+Usd/incT7fJzBLryjHgadcwuSZUJ bON+ZNzx0cWBjEuhpliiixx6xVZZrXtWOpzWvoXzBxWJpAh0iINDEDAwsCXm5hXaqRjpGeqbahn CGToGMVD5PQYNDKLi0tTi3TTCooc8vJLEksy8/OK9fILUvMK0gv00jLTSjIy8ouKU4FG6OWllpi 6OroZGRqYWDpamDlZOJqaODs7GTq5OTo6uzoZWZqbGDhbOpq4WpozcHEKwFzzdxUjQ7PdfalDUx nidh2a6L3Rq69jsoWA7jP24mUfju2xWOWtZ8XIcOk0KyuH8fKq0o8PXxdt4q2YpLGG5dXDTrYbk 75Xur7PZgEA X-Developer-Key: i=mattst88@gmail.com; a=openpgp; fpr=3BB639E56F861FA2E86505690FDD682D974CA72A X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 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 Define R_ALPHA_IRELATIVE (42) and teach the dynamic linker to resolve STT_GNU_IFUNC symbols with it. elf_machine_rela runs the resolver for R_ALPHA_IRELATIVE and stores what it returns, and ELF_MACHINE_IRELATIVE turns on the IRELATIVE pass in elf/do-rel.h. elf_machine_lazy_rel resolves an IFUNC PLT entry eagerly rather than deferring it to the trampoline, which has no way to tell an IFUNC apart from an ordinary lazy binding. A symbolic reference to an IFUNC needs the same treatment: for R_ALPHA_GLOB_DAT, R_ALPHA_JMP_SLOT and R_ALPHA_REFQUAD the address the lookup returns is the resolver, not the implementation it picks, so the resolver has to run there too, as the other targets do. Without it every call through such a symbol enters the resolver and takes the address it returns as the result of the call. With multi-arch enabled that is most of the string functions -- strlen returning an address, memcmp a nonzero constant for equal buffers, math/test-fenv crashing -- and quietly, since the values look like plausible integers. dl-irel.h provides elf_ifunc_invoke and elf_irela for a static binary, where the C library applies the IRELATIVE relocations itself at startup. --- elf/elf.h | 1 + sysdeps/alpha/dl-irel.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++ sysdeps/alpha/dl-machine.h | 40 +++++++++++++++++++++++++++++++----- 3 files changed, 87 insertions(+), 5 deletions(-) diff --git a/elf/elf.h b/elf/elf.h index b482fcfb64..f93215d8e6 100644 --- a/elf/elf.h +++ b/elf/elf.h @@ -2544,6 +2544,7 @@ enum #define R_ALPHA_TPRELHI 39 #define R_ALPHA_TPRELLO 40 #define R_ALPHA_TPREL16 41 +#define R_ALPHA_IRELATIVE 42 /* Keep this the last entry. */ #define R_ALPHA_NUM 46 diff --git a/sysdeps/alpha/dl-irel.h b/sysdeps/alpha/dl-irel.h new file mode 100644 index 0000000000..bbceaf846c --- /dev/null +++ b/sysdeps/alpha/dl-irel.h @@ -0,0 +1,51 @@ +/* Machine-dependent ELF indirect relocation inline functions. + Alpha version. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _DL_IREL_H +#define _DL_IREL_H + +#include +#include + +#define ELF_MACHINE_IRELA 1 + +static inline ElfW(Addr) +__attribute ((always_inline)) +elf_ifunc_invoke (ElfW(Addr) addr) +{ + return ((ElfW(Addr) (*) (void)) (addr)) (); +} + +static inline void +__attribute ((always_inline)) +elf_irela (const ElfW(Rela) *reloc) +{ + ElfW(Addr) *const reloc_addr = (void *) reloc->r_offset; + const unsigned long int r_type = ELFW(R_TYPE) (reloc->r_info); + + if (__glibc_likely (r_type == R_ALPHA_IRELATIVE)) + { + ElfW(Addr) value = elf_ifunc_invoke (reloc->r_addend); + *reloc_addr = value; + } + else + __libc_fatal ("Unexpected reloc type in static binary.\n"); +} + +#endif /* dl-irel.h */ diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h index 7c500ea850..d31da6bd81 100644 --- a/sysdeps/alpha/dl-machine.h +++ b/sysdeps/alpha/dl-machine.h @@ -203,6 +203,9 @@ _dl_start_user: \n\ /* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */ #define ELF_MACHINE_JMP_SLOT R_ALPHA_JMP_SLOT +/* The IRELATIVE relocation for this architecture. */ +#define ELF_MACHINE_IRELATIVE R_ALPHA_IRELATIVE + /* We define an initialization functions. This is called very early in * _dl_sysdep_start. */ #define DL_PLATFORM_INIT dl_platform_init () @@ -360,12 +363,23 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], Elf64_Addr sym_value; Elf64_Addr sym_raw_value; - sym_raw_value = sym_value = reloc->r_addend; + sym_raw_value = reloc->r_addend; + sym_value = sym_map ? SYMBOL_ADDRESS (sym_map, sym, true) : 0; if (sym_map) - { - sym_raw_value += sym->st_value; - sym_value += SYMBOL_ADDRESS (sym_map, sym, true); - } + sym_raw_value += sym->st_value; + +#ifndef RTLD_BOOTSTRAP + /* For an IFUNC symbol the address above is the resolver's; the + address to use is what calling it returns. The addend applies + to that returned address, not to the resolver's own address, so + add it in only after the call. */ + if (sym != NULL + && __glibc_unlikely (ELF64_ST_TYPE (sym->st_info) == STT_GNU_IFUNC) + && __glibc_likely (sym->st_shndx != SHN_UNDEF) + && __glibc_likely (!skip_ifunc)) + sym_value = ((Elf64_Addr (*) (void)) sym_value) (); +#endif + sym_value += reloc->r_addend; if (r_type == R_ALPHA_GLOB_DAT) *reloc_addr = sym_value; @@ -410,6 +424,15 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], } # endif } +#ifndef RTLD_BOOTSTRAP + else if (r_type == R_ALPHA_IRELATIVE) + { + Elf64_Addr value = map->l_addr + reloc->r_addend; + if (__glibc_likely (!skip_ifunc)) + value = ((Elf64_Addr (*) (void)) value) (); + *reloc_addr = value; + } +#endif else _dl_reloc_bad_type (map, r_type, 0); } @@ -451,6 +474,13 @@ elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[], to the .plt. */ *reloc_addr += l_addr; } + else if (r_type == R_ALPHA_IRELATIVE) + { + Elf64_Addr value = l_addr + reloc->r_addend; + if (__glibc_likely (!skip_ifunc)) + value = ((Elf64_Addr (*) (void)) value) (); + *reloc_addr = value; + } else if (r_type == R_ALPHA_NONE) return; else From patchwork Sun Sep 6 19:06:08 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Turner X-Patchwork-Id: 143014 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 772584BCA432 for ; Sun, 6 Sep 2026 19:07:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 772584BCA432 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=OID1RjOb X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by sourceware.org (Postfix) with ESMTPS id 9A5344BC7EE6 for ; Sun, 6 Sep 2026 19:06:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9A5344BC7EE6 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9A5344BC7EE6 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788721576; cv=none; b=tOgPRMmR+gi092Ib1SDWeJdsfnOvLJLSjCFHsvlkLSMWtdtj2rYShKW34b00CpBrb54MY5GvDLWN/cx60XECGmot/o4SdwG18MfD5gjQXZPLg3nluYhvQ8l+Sr3t/pDdM1Eg1/OxlymdZfPAIFDmK5+ycohVfW7nrS5Bu3fMPGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788721576; c=relaxed/simple; bh=yT+/HrHEm9LAh+ko5/kbcwCrLKw+idvvobIJ9tD+20Q=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=RQrMJ9BxOU3di2NSKb6a7btMdmvt6ImAPOaOoJVJN5np4DETCPH1N/tQK56LssQB8LxzvrWswawkv0hkFLwe4zyslexfZ/xbXQAftkXFusEyuxt8Iz4VPzFvRTl4xf/8CISRF+PuxBiwljNhWUIw3y2Q9OVWEvqVizzmi8KJPJk= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=OID1RjOb DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A5344BC7EE6 Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-861145fc841so23008717b3.3 for ; Sun, 06 Sep 2026 12:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788721576; x=1789326376; darn=sourceware.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=FeUVZnrWX9CzwmhTaQKYd/k23+nW4o9hDBoQhQ5PUqE=; b=OID1RjObce+nHnUl77md0qTJ5xLSRDZRgYe0l0YfPzKW5iICJtF9ZHH5dR0YCpqk27 KTShtdDLJG6EBQonukUoQdYk/lyuDkcelBEMpMrllCiFREZZ93DxXp4drTAtSlyIw/IH bKWFtA2C5uDjmkWlNuuAz/vhDyWim8FUFwKB+bjQoDLfwkf7SzCqdsqX/LKSeaFZj7b5 AqvIYJ16D+WJaI//pvhY9MJeV1+gyFBZyz4E9OoC3oRrRCvJ1rRUP4tBCSdz7dzVbORg jV3ieZG9p6AswPkPDHxomhGl/5ofHE6APBdh+BBSbS5NLRLLK3u58jB/xkpioVXvVM/M E9bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788721576; x=1789326376; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=FeUVZnrWX9CzwmhTaQKYd/k23+nW4o9hDBoQhQ5PUqE=; b=gynfKVveolZO1LqR8vCw3aiAF+bYY7JhOy6z8RQHGTtZ6IVCeyPkEYR6NhI2AYO0+W Z58zSl5MAjl1zX5l0TE5r6l+4aDaa7TD4j1ktr1iax4pj3pBANEk1Qi4AGPCepLRZ+UR 2CkIoeI7Y6hS66iOYXj54aoixoSKxQ4PMIlyfMiAGX45CuoWpHwYZ6DGfvSjsNuLvlT9 +4o5ofechnnEV1mpUdDmcrfXKqCkLvOHI2zfM2pB0dUSDIbKmoXAz2try7H4UQrbTJB4 UY1XNrvlTSiJyFt+OF02lE8Zs2NT53yTxTzOl5yYt01FB+t0b/QJNWaJY+Fu4cTz1I+X oPYg== X-Gm-Message-State: AFuF++mR2/7dEydBX7EMWs2CkzzOiKEEycaIGWCjfcQpvuYzdCitgGbM VgIGM09Uo2rBJvs10w4CTrT5g2CMtG6JY95FJM+eRhnY2qci6+AqubkKyOBHbcrp X-Gm-Gg: AYBFou31KHAd0kSPYApeBDkSZhab48l6/DUctz1kwRLEwSIhQAYX0ulswG73AxPZQaY cf/Ev57a4r69kRpFDLGgh90aBCnpdelGXwEkb5ylbSSlMTU5uCTh4fLhPPyH3u/fpYc7DyIdZ1j iU7eVRdL+RPm28jQG9X3IBmwcrE/Pxw8GppPV/VoTEzwDKbIezC2OVnWKHN9EMZxGOj4noCPU79 OctdO5ZlvTcK+21OddkBbP53eVNEllmb7grurMH5MaTUy08dVDkoyxUNirphIhZsBDdUTBRHVf2 wUw97xqkcsq8qLllGpGiEUDs17RrfHmym99IbhHdL7c7CFff+7ngcJ/k4Sy11IjADibKybpj/R5 N+T2+BbQwvSrovJV4tjlLPl6fnhOtBB5gNOUOYh0btPMpKE7YW41P849WblZ7M9+svgP4J7kWTn PLbUH5+qerHSyExY+MSMIW+xswY/6z6tAVlt/dsB/AxqwIkQgeMNRQtjNrj6ASWnYewg8qJDI= X-Received: by 2002:a05:690c:c4fa:b0:866:e57f:58db with SMTP id 00721157ae682-8711ec239e9mr74968027b3.0.1788721575816; Sun, 06 Sep 2026 12:06:15 -0700 (PDT) Received: from localhost ([2600:1702:7a90:6f9f:8bc4:8aec:108d:7a04]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8714ab77c4dsm59729467b3.34.2026.09.06.12.06.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Sep 2026 12:06:14 -0700 (PDT) From: Matt Turner Date: Sun, 06 Sep 2026 15:06:08 -0400 Subject: [PATCH 3/4] alpha: add multiarch infrastructure for IFUNC dispatch MIME-Version: 1.0 Message-Id: <20260906-gm-series1-ifunc-infra-v1-3-d409f053327f@gmail.com> References: <20260906-gm-series1-ifunc-infra-v1-0-d409f053327f@gmail.com> In-Reply-To: <20260906-gm-series1-ifunc-infra-v1-0-d409f053327f@gmail.com> To: libc-alpha@sourceware.org Cc: Matt Turner X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4655; i=mattst88@gmail.com; h=from:subject:message-id; bh=yT+/HrHEm9LAh+ko5/kbcwCrLKw+idvvobIJ9tD+20Q=; b=owGbwMvMwCW25rVmCc8sv+mMp9WSGLLm7pxXJe/g1NK+k1n/+/fI11PYmg/HqDDa7y0wu6Zid OBo4r0FHR9ZGMS4GGaKKbLErVdkmdW2Y6nPaelfMHNYmUCGSIs0MAABCwNfbmJeqZGOkZ6ptqGe IZChYxQPkdNj0MgsLi5NLdJNKyhyyMsvSSzJzM8r1ssvSM0rSC/QS8tMK8nIyC8qTgUaoZeXWmL q6uhmZGhgYuloYeZk4Whq4uzsZOjk5ujo7OpkZGluYuBs6WjiamnOwMUpAHONqAvDP9u/P1vuZJ eFSmypv7By16GvUocKyk7p5qVWzNj5yn/f0vcM/yw8PjhFfPqftaxg3ReHh24chrNae/ccWOkgI hKQZWP3iAEA X-Developer-Key: i=mattst88@gmail.com; a=openpgp; fpr=3BB639E56F861FA2E86505690FDD682D974CA72A X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 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 Add the framework for runtime CPU-based dispatch on alpha. init-arch.h wraps the implver and amask instructions, which resolvers use directly rather than going through AT_HWCAP: both are unprivileged, so a resolver can ask the processor what it is without help from the kernel. IS_EV6_OR_LATER tests implver for the 21264 family, IS_EV7_OR_LATER for the 21364, and HAS_CIX asks amask for the count extension the 21264A introduced. The wrappers reach the instructions through __builtin_alpha_implver/__builtin_alpha_amask rather than inline asm: GCC has modeled both for alpha for a long time, so it knows their real semantics directly instead of us hand-writing asm constraints. configure inserts /multiarch immediately before for each term of the Implies chain, so a multiarch directory shadows only the assembly in its own directory. sysdeps/alpha/multiarch therefore sits after sysdeps/alpha/alphaev6 and sysdeps/alpha/alphaev67 in sysnames, and an --host=alphaev6 or later build picks the CPU assembly over the dispatchers, leaving IFUNC dispatch inert on exactly the configurations that have the tuned implementations. Give the two levels that carry assembly an Implies-only multiarch directory chaining down to sysdeps/alpha/multiarch, as powerpc does for its per-CPU directories, which places the dispatchers ahead of the assembly. A --disable-multi-arch build is unaffected: no multiarch directory enters sysnames and the assembly is used directly. The dispatchers themselves follow in the next patch. --- sysdeps/alpha/alphaev6/multiarch/Implies | 1 + sysdeps/alpha/alphaev67/multiarch/Implies | 1 + sysdeps/alpha/multiarch/init-arch.h | 65 +++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/sysdeps/alpha/alphaev6/multiarch/Implies b/sysdeps/alpha/alphaev6/multiarch/Implies new file mode 100644 index 0000000000..c07181098c --- /dev/null +++ b/sysdeps/alpha/alphaev6/multiarch/Implies @@ -0,0 +1 @@ +alpha/multiarch diff --git a/sysdeps/alpha/alphaev67/multiarch/Implies b/sysdeps/alpha/alphaev67/multiarch/Implies new file mode 100644 index 0000000000..fb91f5988c --- /dev/null +++ b/sysdeps/alpha/alphaev67/multiarch/Implies @@ -0,0 +1 @@ +alpha/alphaev6/multiarch diff --git a/sysdeps/alpha/multiarch/init-arch.h b/sysdeps/alpha/multiarch/init-arch.h new file mode 100644 index 0000000000..25ed0df178 --- /dev/null +++ b/sysdeps/alpha/multiarch/init-arch.h @@ -0,0 +1,65 @@ +/* Define IFUNC resolver CPU detection for Alpha. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _ALPHA_INIT_ARCH_H +#define _ALPHA_INIT_ARCH_H + +/* implver returns: + 0 = EV4 (21064) + 1 = EV5 (21164) + 2 = EV6 (21264) + 3 = EV7 (21364) */ + +static inline unsigned long +__attribute__ ((always_inline)) +alpha_implver (void) +{ + return __builtin_alpha_implver (); +} + +/* amask tests for optional extensions. Returns zero bits for + supported features. Known bits: + 0x01 = BWX (byte/word extensions, EV56+) + 0x02 = FIX (sqrt/ftoi extensions, EV6+) + 0x04 = CIX (count extensions, EV67+) + 0x100 = MVI (multimedia extensions, PCA56+) */ + +static inline unsigned long +__attribute__ ((always_inline)) +alpha_amask (unsigned long mask) +{ + return __builtin_alpha_amask (mask); +} + +#define ALPHA_IMPL_EV4 0 +#define ALPHA_IMPL_EV5 1 +#define ALPHA_IMPL_EV6 2 +#define ALPHA_IMPL_EV7 3 + +#define ALPHA_AMASK_BWX 0x01 +#define ALPHA_AMASK_FIX 0x02 +#define ALPHA_AMASK_CIX 0x04 +#define ALPHA_AMASK_MVI 0x100 + +#define IS_EV6_OR_LATER (alpha_implver () >= ALPHA_IMPL_EV6) +#define IS_EV7_OR_LATER (alpha_implver () >= ALPHA_IMPL_EV7) +#define HAS_CIX (!(alpha_amask (ALPHA_AMASK_CIX))) + +#define INIT_ARCH() + +#endif /* _ALPHA_INIT_ARCH_H */ From patchwork Sun Sep 6 19:06:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Turner X-Patchwork-Id: 143016 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F88B4BC7ECB for ; Sun, 6 Sep 2026 19:09:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F88B4BC7ECB Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=s+J8NWBx X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x112a.google.com (mail-yw1-x112a.google.com [IPv6:2607:f8b0:4864:20::112a]) by sourceware.org (Postfix) with ESMTPS id 045AF4BC7EEC for ; Sun, 6 Sep 2026 19:06:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 045AF4BC7EEC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 045AF4BC7EEC Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788721580; cv=none; b=IvairqvNUd5ibBNAcwxjzB4YijS1BzsxL2IA25rN8jTJOdrImfWWgiHZ+og02j7ZrzXSdxL4Pk6tJZv+hAvIIqpg+a1fGRZDlgO20d4UfeP/R1nehE5arThsFcTthP3jeTcJtA4iyQzenblH1ajnuiyY4ioV0/wkCKSsYty+p8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788721580; c=relaxed/simple; bh=YuwlzdcJo/0FT7hpvq2amLlyQWH6E9ZAImRKZHhzDpE=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=PvJS5V00dvUGnFcXBiZKJLfDJgiDvGTiNAGHyK5BTkDnoqd0LIeJ5NWLrRQcQN3OQEu1lSyKqKd96/Vjz/4wrfmjuMjpzQHATotTT3O1kfedu5zgI7eVNQJ1Fu3DiMM52TWqjOuFzHDWOESMCbdkXgOO7LmHGFRNUs8uHUbMcGk= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=s+J8NWBx DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 045AF4BC7EEC Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-866e57f63a3so29941737b3.3 for ; Sun, 06 Sep 2026 12:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788721579; x=1789326379; darn=sourceware.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=eZrLePrbBSq65xZJkgBLKzZNwHPTVyLGU8n9m98KPiE=; b=s+J8NWBxMeZdLQLOdLbyCI7EUlyzwRfpAJwyuzVf+1mSNau3Fibdntp0de/eFey7XZ k9TpQ+t5i4DhNrzbKCnp7p3Ef4xi0rxllioLgk1NVtF4SdWz0AobnEtvFHdjopaLKycL VFrtgMdVKU+1EQK6BSdSkuAn/yy8TswpYZgAeCsyR9uFz+o/wz+jgGwSv5DKVE1qcnp0 /2/vAB+o8MgmpGfkehB4+6LPheVr6GVAqUagsb023tp/lWndq6cj50mDhf/01KumGfUB qHhHjOa0HiRsj/Wk44coRe1mpuUs+h+lyyu5932DD3EBU9v5dYrr92eF1+YVmX0J/jd3 k2yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788721579; x=1789326379; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=eZrLePrbBSq65xZJkgBLKzZNwHPTVyLGU8n9m98KPiE=; b=L4fzDLZeJ5EEErOrLwEDW98bp562YtcbFfZQheIEJhm5AHPbbuiPl7GkO3+NIWDi2C hQCPhS2j9aYw9NfInMNSCWRkzssALIoFFF4Mv2tArQ/uDI3FS2dBIgRbXtEKj+dNmcqJ A/USiU3jJYfa6zK080nlfPpBe9Ii6dsw5lnUhUii0NbImmDvAHX8MsH1w2F4inJM9ZZS bhzbERZrgneA3rzsU4vcrZcYUcYgrcEcoiT4KAnZ/ZFCqX8/PEJJAEGzeRwtZM4w5Aka w0/tx1nmkh0pwh5PX4gLljAg2rEZTOixFlCDhZRFSIyDAOlfSmH6hhMgzpQB0JnYm+vr gflg== X-Gm-Message-State: AFuF++ld/7THE5/sHfAaHlP5iit4n8zAaddEnodvjOAOa19aPTb5E2AG Ft3L8gY8b1nSssK6jMo0c/GbDpyZpYyaSxZJNJoIGmHIBI+pUdJg2I1zvy7cilE4 X-Gm-Gg: AYBFou0Iz8KY1IOisnC7aIl82bMjnKE/+0UjHJBAxf+Qf2OXWuXSeVPcGuG1eIDashx iNXCgigmzspEOhg5RL9yaSCRvdKFFUK34PGCdpf/dG5fCuUKdyEoZdZVaaTPGZWGyZ+BrrhLcjM pbZPhMcv0Tu2/9EIBzn8vIt+sM4SX/Rn82IOyoeqrREcU4PMtc9sDCwi7YgNZoegm7NvkQF90B+ fSQHJWHlUn2c5ZYu9m/FKa02AiueMVyjxQHixzl4//+x2NZWFCjrIVRksvGD+Z1HiufppYmwK4z UL6qtbk+nn66xLxrafwjyGw1LUj+VU3Z7JcpXxLSJ1mVdKDNBjQAtQJfPwIWu2nh+rWlmWpP6sq SiiPajLtgxu3faaq6jGvI7jWMXXsMmrx8tcxqG80gnKfLcNbr70O+isZvRT6X9LNf5bb2tZqeh5 lDTKn96HqPE8sIM3t5jfgwHai+sF6kc84LllilVXlO90erlWf/KTZG5GaUpxGBYQ== X-Received: by 2002:a05:690c:6e10:b0:827:b35:9d2d with SMTP id 00721157ae682-8712800df19mr73430057b3.27.1788721578492; Sun, 06 Sep 2026 12:06:18 -0700 (PDT) Received: from localhost ([2600:1702:7a90:6f9f:8bc4:8aec:108d:7a04]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8714a0b654dsm59238557b3.25.2026.09.06.12.06.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Sep 2026 12:06:17 -0700 (PDT) From: Matt Turner Date: Sun, 06 Sep 2026 15:06:09 -0400 Subject: [PATCH 4/4] alpha: add multiarch IFUNC dispatchers MIME-Version: 1.0 Message-Id: <20260906-gm-series1-ifunc-infra-v1-4-d409f053327f@gmail.com> References: <20260906-gm-series1-ifunc-infra-v1-0-d409f053327f@gmail.com> In-Reply-To: <20260906-gm-series1-ifunc-infra-v1-0-d409f053327f@gmail.com> To: libc-alpha@sourceware.org Cc: Matt Turner X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=56531; i=mattst88@gmail.com; h=from:subject:message-id; bh=YuwlzdcJo/0FT7hpvq2amLlyQWH6E9ZAImRKZHhzDpE=; b=owGbwMvMwCW25rVmCc8sv+mMp9WSGLLm7pxnuGnZ7hXcbLtnvC425NuuL97Rfi4hUi1gT1fyk aOOihMLOj6yMIhxMcwUU2SJW6/IMqttx1Kf09K/YOawMoEMkRZpYAACFga+3MS8UiMdIz1TbUM9 QyBDxygeIqfHoJFZXFyaWqSbVlDkkJdfkliSmZ9XrJdfkJpXkF6gl5aZVpKRkV9UnAo0Qi8vtcT U1dHNyNDAxNLRwszJwtHUxNnZydDJzdHR2dXJyNLcxMDZ0tHE1dKcgYtTAOYaJ1OG/25frt2due J++Maf8mdZu/zbDXktCh48Zk0Si2jQ2aVxspXhn/Li1cWG1wMUam20eK4LyRzaK7cij1Xt9uzCk u85v74nswAA X-Developer-Key: i=mattst88@gmail.com; a=openpgp; fpr=3BB639E56F861FA2E86505690FDD682D974CA72A X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 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 Dispatch at runtime between the generic implementations and the EV6/EV67-optimized ones for nine functions: memset: generic (EV4/EV5) vs EV6 assembly (dispatch on implver) memcpy: generic (C) vs EV6 assembly (dispatch on implver) strlen: generic vs EV67 CIX assembly (dispatch on amask CIX) stpcpy: generic vs EV67 CIX assembly stpncpy: generic vs EV67 CIX assembly strcat: generic vs EV67 CIX assembly strchr: generic vs EV67 CIX assembly rawmemchr: generic vs EV67 CIX assembly strncat: generic vs EV67 CIX assembly Each function gets a resolver in a .c file and two assembly wrappers (_ev5/_ev6 or _ev5/_ev67) that include the original source with renamed entry points. The mem* functions have no generic alpha assembly, so they use C generic wrappers for EV4/EV5. The internal aliases are defined in the dispatchers, against the redirected type, so that calls from inside libc go through the IFUNC too. Defining them in the _ev5 variants instead, as the assembly they include does, would point __GI_strlen and the rest at the ev5 implementation and every caller inside libc would get that one whatever the CPU. string.h needs care in these files. It defines __stpcpy as a macro calling the corresponding builtin and, in the static library, redirects that builtin back to the __ name, which collides with the redirection the multiarch files set up; they define __NO_STRING_INLINES and NO_MEMPCPY_STPCPY_REDIRECT first, as the x86_64 and s390 versions do. ifunc-impl-list.c enumerates the implementations for the string tests, which run each one in turn rather than only whichever the resolver picks. The dynamic linker cannot dispatch through an IFUNC before it has relocated itself, so dl-symbol-redir-ifunc.h names an implementation directly for the functions it needs while bootstrapping, for the static case. The real ld.so pulls in the same multiarch objects as libc does, though, so each _ev6/_ev67 wrapper here renames its entry point unconditionally -- in both IS_IN(libc) and IS_IN(rtld) -- leaving only the intended safe baseline (_ev5/generic) to define the plain public name for rtld's own internal calls. Getting this wrong is silent and CPU-dependent: whichever wrapper's object the static rtld link happens to pick wins, with no runtime check at all, since rtld runs before any ifunc resolver exists. Verified under qemu-alpha across ev4/ev56/ev6/ev67/ev68 that ld.so's own memcpy/memset/strlen/stpcpy/ strchr calls all resolve to the safe baseline, and that dispatch to the fast paths on ev56+ is unaffected. With --enable-multi-arch a single binary selects the implementation the processor wants at load time. --- sysdeps/alpha/multiarch/Makefile | 22 ++++++++ sysdeps/alpha/multiarch/dl-symbol-redir-ifunc.h | 35 +++++++++++++ sysdeps/alpha/multiarch/ifunc-impl-list.c | 68 +++++++++++++++++++++++++ sysdeps/alpha/multiarch/memcpy.c | 49 ++++++++++++++++++ sysdeps/alpha/multiarch/memcpy_ev6.S | 34 +++++++++++++ sysdeps/alpha/multiarch/memcpy_generic.c | 26 ++++++++++ sysdeps/alpha/multiarch/memset.c | 49 ++++++++++++++++++ sysdeps/alpha/multiarch/memset_ev5.S | 33 ++++++++++++ sysdeps/alpha/multiarch/memset_ev6.S | 34 +++++++++++++ sysdeps/alpha/multiarch/rawmemchr.c | 55 ++++++++++++++++++++ sysdeps/alpha/multiarch/rawmemchr_ev5.S | 36 +++++++++++++ sysdeps/alpha/multiarch/rawmemchr_ev67.S | 37 ++++++++++++++ sysdeps/alpha/multiarch/stpcpy.c | 62 ++++++++++++++++++++++ sysdeps/alpha/multiarch/stpcpy_ev5.S | 39 ++++++++++++++ sysdeps/alpha/multiarch/stpcpy_ev67.S | 40 +++++++++++++++ sysdeps/alpha/multiarch/stpncpy.c | 55 ++++++++++++++++++++ sysdeps/alpha/multiarch/stpncpy_ev5.S | 36 +++++++++++++ sysdeps/alpha/multiarch/stpncpy_ev67.S | 37 ++++++++++++++ sysdeps/alpha/multiarch/strcat.c | 49 ++++++++++++++++++ sysdeps/alpha/multiarch/strcat_ev5.S | 33 ++++++++++++ sysdeps/alpha/multiarch/strcat_ev67.S | 34 +++++++++++++ sysdeps/alpha/multiarch/strchr.c | 50 ++++++++++++++++++ sysdeps/alpha/multiarch/strchr_ev5.S | 36 +++++++++++++ sysdeps/alpha/multiarch/strchr_ev67.S | 37 ++++++++++++++ sysdeps/alpha/multiarch/strlen.c | 49 ++++++++++++++++++ sysdeps/alpha/multiarch/strlen_ev5.S | 33 ++++++++++++ sysdeps/alpha/multiarch/strlen_ev67.S | 34 +++++++++++++ sysdeps/alpha/multiarch/strncat.c | 49 ++++++++++++++++++ sysdeps/alpha/multiarch/strncat_ev5.S | 30 +++++++++++ sysdeps/alpha/multiarch/strncat_ev67.S | 29 +++++++++++ 30 files changed, 1210 insertions(+) diff --git a/sysdeps/alpha/multiarch/Makefile b/sysdeps/alpha/multiarch/Makefile new file mode 100644 index 0000000000..fb92fecb93 --- /dev/null +++ b/sysdeps/alpha/multiarch/Makefile @@ -0,0 +1,22 @@ +ifeq ($(subdir),string) +sysdep_routines += \ + memcpy_ev6 \ + memcpy_generic \ + memset_ev5 \ + memset_ev6 \ + rawmemchr_ev5 \ + rawmemchr_ev67 \ + stpcpy_ev5 \ + stpcpy_ev67 \ + stpncpy_ev5 \ + stpncpy_ev67 \ + strcat_ev5 \ + strcat_ev67 \ + strchr_ev5 \ + strchr_ev67 \ + strlen_ev5 \ + strlen_ev67 \ + strncat_ev5 \ + strncat_ev67 \ +# sysdep_routines +endif diff --git a/sysdeps/alpha/multiarch/dl-symbol-redir-ifunc.h b/sysdeps/alpha/multiarch/dl-symbol-redir-ifunc.h new file mode 100644 index 0000000000..3fb11f5511 --- /dev/null +++ b/sysdeps/alpha/multiarch/dl-symbol-redir-ifunc.h @@ -0,0 +1,35 @@ +/* Symbol redirection for loader/static initialization code. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _DL_IFUNC_GENERIC_H +#define _DL_IFUNC_GENERIC_H + +/* Only the static dynamic linker needs these: the real ld.so pulls the + same multiarch objects in as libc does, and each _ev6/_ev67 wrapper + never defines the plain name in that case, leaving it to the safe + baseline (_ev5/generic). Redirecting here too would just be + redundant for the shared build. */ +#ifndef SHARED + +asm ("memcpy = __memcpy_generic"); +asm ("memset = __memset_ev5"); +asm ("strlen = __strlen_ev5"); + +#endif /* !SHARED */ + +#endif diff --git a/sysdeps/alpha/multiarch/ifunc-impl-list.c b/sysdeps/alpha/multiarch/ifunc-impl-list.c new file mode 100644 index 0000000000..dfa0ddfb5d --- /dev/null +++ b/sysdeps/alpha/multiarch/ifunc-impl-list.c @@ -0,0 +1,68 @@ +/* Enumerate available IFUNC implementations of a function. Alpha version. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include + +size_t +__libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, + size_t max) +{ + size_t i = max; + + IFUNC_IMPL (i, name, memcpy, + IFUNC_IMPL_ADD (array, i, memcpy, IS_EV6_OR_LATER, __memcpy_ev6) + IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_generic)); + + IFUNC_IMPL (i, name, memset, + IFUNC_IMPL_ADD (array, i, memset, IS_EV6_OR_LATER, __memset_ev6) + IFUNC_IMPL_ADD (array, i, memset, 1, __memset_ev5)); + + IFUNC_IMPL (i, name, rawmemchr, + IFUNC_IMPL_ADD (array, i, rawmemchr, HAS_CIX, ___rawmemchr_ev67) + IFUNC_IMPL_ADD (array, i, rawmemchr, 1, ___rawmemchr_ev5)); + + IFUNC_IMPL (i, name, stpcpy, + IFUNC_IMPL_ADD (array, i, stpcpy, HAS_CIX, ___stpcpy_ev67) + IFUNC_IMPL_ADD (array, i, stpcpy, 1, ___stpcpy_ev5)); + + IFUNC_IMPL (i, name, stpncpy, + IFUNC_IMPL_ADD (array, i, stpncpy, HAS_CIX, ___stpncpy_ev67) + IFUNC_IMPL_ADD (array, i, stpncpy, 1, ___stpncpy_ev5)); + + IFUNC_IMPL (i, name, strcat, + IFUNC_IMPL_ADD (array, i, strcat, HAS_CIX, __strcat_ev67) + IFUNC_IMPL_ADD (array, i, strcat, 1, __strcat_ev5)); + + IFUNC_IMPL (i, name, strchr, + IFUNC_IMPL_ADD (array, i, strchr, HAS_CIX, __strchr_ev67) + IFUNC_IMPL_ADD (array, i, strchr, 1, __strchr_ev5)); + + IFUNC_IMPL (i, name, strlen, + IFUNC_IMPL_ADD (array, i, strlen, HAS_CIX, __strlen_ev67) + IFUNC_IMPL_ADD (array, i, strlen, 1, __strlen_ev5)); + + IFUNC_IMPL (i, name, strncat, + IFUNC_IMPL_ADD (array, i, strncat, HAS_CIX, __strncat_ev67) + IFUNC_IMPL_ADD (array, i, strncat, 1, __strncat_ev5)); + + return 0; +} diff --git a/sysdeps/alpha/multiarch/memcpy.c b/sysdeps/alpha/multiarch/memcpy.c new file mode 100644 index 0000000000..2592706ede --- /dev/null +++ b/sysdeps/alpha/multiarch/memcpy.c @@ -0,0 +1,49 @@ +/* Multiple versions of memcpy. Alpha version. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if IS_IN (libc) +# undef memcpy +# define memcpy __redirect_memcpy +# include +# include + +extern __typeof (__redirect_memcpy) __libc_memcpy; + +extern __typeof (__redirect_memcpy) __memcpy_generic attribute_hidden; +extern __typeof (__redirect_memcpy) __memcpy_ev6 attribute_hidden; + +static inline __typeof (__redirect_memcpy) * +select_memcpy_ifunc (void) +{ + if (IS_EV6_OR_LATER) + return __memcpy_ev6; + + return __memcpy_generic; +} + +libc_ifunc (__libc_memcpy, select_memcpy_ifunc ()); + +# undef memcpy +strong_alias (__libc_memcpy, memcpy); +/* Internal callers use __GI_memcpy, which libc_hidden_builtin_def would + normally define; the name is redirected here, so define it by hand. */ +# ifdef SHARED +__hidden_ver1 (__libc_memcpy, __GI_memcpy, __redirect_memcpy) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (memcpy); +# endif +#endif diff --git a/sysdeps/alpha/multiarch/memcpy_ev6.S b/sysdeps/alpha/multiarch/memcpy_ev6.S new file mode 100644 index 0000000000..31673014ef --- /dev/null +++ b/sysdeps/alpha/multiarch/memcpy_ev6.S @@ -0,0 +1,34 @@ +/* memcpy for Alpha, EV6 version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* Rename unconditionally, in both the libc and rtld builds: the plain + "memcpy" name is reserved for whichever wrapper is the safe rtld + bootstrap default (memcpy_generic.c), so this file must never define + it, in either build. */ +#if IS_IN (libc) || IS_IN (rtld) +# define memcpy __memcpy_ev6 +#endif + +#if IS_IN (libc) +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) +#endif + +#include diff --git a/sysdeps/alpha/multiarch/memcpy_generic.c b/sysdeps/alpha/multiarch/memcpy_generic.c new file mode 100644 index 0000000000..1c5e3a96ee --- /dev/null +++ b/sysdeps/alpha/multiarch/memcpy_generic.c @@ -0,0 +1,26 @@ +/* memcpy for Alpha, generic C version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if IS_IN (libc) +# define MEMCPY __memcpy_generic + +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) +#endif + +#include diff --git a/sysdeps/alpha/multiarch/memset.c b/sysdeps/alpha/multiarch/memset.c new file mode 100644 index 0000000000..7dc4c3f52f --- /dev/null +++ b/sysdeps/alpha/multiarch/memset.c @@ -0,0 +1,49 @@ +/* Multiple versions of memset. Alpha version. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if IS_IN (libc) +# undef memset +# define memset __redirect_memset +# include +# include + +extern __typeof (__redirect_memset) __libc_memset; + +extern __typeof (__redirect_memset) __memset_ev5 attribute_hidden; +extern __typeof (__redirect_memset) __memset_ev6 attribute_hidden; + +static inline __typeof (__redirect_memset) * +select_memset_ifunc (void) +{ + if (IS_EV6_OR_LATER) + return __memset_ev6; + + return __memset_ev5; +} + +libc_ifunc (__libc_memset, select_memset_ifunc ()); + +# undef memset +strong_alias (__libc_memset, memset); +/* Internal callers reach this through __GI_memset. Alias it to the IFUNC + so that they get the implementation chosen for this CPU too. */ +# ifdef SHARED +__hidden_ver1 (__libc_memset, __GI_memset, __redirect_memset) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (memset); +# endif +#endif diff --git a/sysdeps/alpha/multiarch/memset_ev5.S b/sysdeps/alpha/multiarch/memset_ev5.S new file mode 100644 index 0000000000..d6844d086a --- /dev/null +++ b/sysdeps/alpha/multiarch/memset_ev5.S @@ -0,0 +1,33 @@ +/* memset for Alpha, EV4/EV5 version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if IS_IN (libc) +# define memset __memset_ev5 + +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) + +#endif + +#include + +#if IS_IN (rtld) +strong_alias (memset, __memset_ev5) +#endif diff --git a/sysdeps/alpha/multiarch/memset_ev6.S b/sysdeps/alpha/multiarch/memset_ev6.S new file mode 100644 index 0000000000..6bd1ea502f --- /dev/null +++ b/sysdeps/alpha/multiarch/memset_ev6.S @@ -0,0 +1,34 @@ +/* memset for Alpha, EV6 version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* Rename unconditionally, in both the libc and rtld builds: the plain + "memset" name is reserved for whichever wrapper is the safe rtld + bootstrap default (memset_ev5.S), so this file must never define it, + in either build. */ +#if IS_IN (libc) || IS_IN (rtld) +# define memset __memset_ev6 +#endif + +#if IS_IN (libc) +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) +#endif + +#include diff --git a/sysdeps/alpha/multiarch/rawmemchr.c b/sysdeps/alpha/multiarch/rawmemchr.c new file mode 100644 index 0000000000..0235d5c7c3 --- /dev/null +++ b/sysdeps/alpha/multiarch/rawmemchr.c @@ -0,0 +1,55 @@ +/* Multiple versions of rawmemchr. Alpha version. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if IS_IN (libc) +# undef rawmemchr +# define rawmemchr __redirect_rawmemchr +# undef __rawmemchr +# define __rawmemchr __redirect___rawmemchr +# include +# include + +extern __typeof (__redirect___rawmemchr) __libc___rawmemchr; + +extern __typeof (__redirect___rawmemchr) ___rawmemchr_ev5 attribute_hidden; +extern __typeof (__redirect___rawmemchr) ___rawmemchr_ev67 attribute_hidden; + +static inline __typeof (__redirect___rawmemchr) * +select_rawmemchr_ifunc (void) +{ + if (HAS_CIX) + return ___rawmemchr_ev67; + + return ___rawmemchr_ev5; +} + +libc_ifunc (__libc___rawmemchr, select_rawmemchr_ifunc ()); + +# undef rawmemchr +# undef __rawmemchr +strong_alias (__libc___rawmemchr, __rawmemchr); +weak_alias (__rawmemchr, rawmemchr); +/* Not libc_hidden_def: string.h declared the hidden prototype under the + redirected name, so that would alias to a __GI_ symbol nothing defines. + Alias it to the IFUNC so internal callers also get the implementation + chosen for this CPU. */ +# ifdef SHARED +__hidden_ver1 (__rawmemchr, __GI___rawmemchr, __redirect___rawmemchr) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (rawmemchr); +# endif +#endif diff --git a/sysdeps/alpha/multiarch/rawmemchr_ev5.S b/sysdeps/alpha/multiarch/rawmemchr_ev5.S new file mode 100644 index 0000000000..8bbc83a525 --- /dev/null +++ b/sysdeps/alpha/multiarch/rawmemchr_ev5.S @@ -0,0 +1,36 @@ +/* rawmemchr for Alpha, generic version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if IS_IN (libc) +# define __rawmemchr ___rawmemchr_ev5 + +# undef weak_alias +# define weak_alias(a, b) + +# undef libc_hidden_def +# define libc_hidden_def(name) + +#endif + +#include + +#if IS_IN (rtld) +strong_alias (__rawmemchr, ___rawmemchr_ev5) +#endif diff --git a/sysdeps/alpha/multiarch/rawmemchr_ev67.S b/sysdeps/alpha/multiarch/rawmemchr_ev67.S new file mode 100644 index 0000000000..d23466aec8 --- /dev/null +++ b/sysdeps/alpha/multiarch/rawmemchr_ev67.S @@ -0,0 +1,37 @@ +/* rawmemchr for Alpha, EV67 version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* Rename unconditionally, in both the libc and rtld builds: the plain + "__rawmemchr" name is reserved for whichever wrapper is the safe rtld + bootstrap default (rawmemchr_ev5.S), so this file must never define + it, in either build. */ +#if IS_IN (libc) || IS_IN (rtld) +# define __rawmemchr ___rawmemchr_ev67 +#endif + +#if IS_IN (libc) +# undef weak_alias +# define weak_alias(a, b) + +# undef libc_hidden_def +# define libc_hidden_def(name) +#endif + +#include diff --git a/sysdeps/alpha/multiarch/stpcpy.c b/sysdeps/alpha/multiarch/stpcpy.c new file mode 100644 index 0000000000..de4c3ee38b --- /dev/null +++ b/sysdeps/alpha/multiarch/stpcpy.c @@ -0,0 +1,62 @@ +/* Multiple versions of stpcpy. Alpha version. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if IS_IN (libc) +# undef stpcpy +# define stpcpy __redirect_stpcpy +# undef __stpcpy +# define __stpcpy __redirect___stpcpy +/* string.h defines __stpcpy as a macro calling __builtin_stpcpy, and + redirects __builtin_stpcpy back to __stpcpy in the static library; + both get in the way of redirecting the name here. */ +# define __NO_STRING_INLINES +# define NO_MEMPCPY_STPCPY_REDIRECT +# include +# include + +extern __typeof (__redirect___stpcpy) __libc___stpcpy; + +extern __typeof (__redirect___stpcpy) ___stpcpy_ev5 attribute_hidden; +extern __typeof (__redirect___stpcpy) ___stpcpy_ev67 attribute_hidden; + +static inline __typeof (__redirect___stpcpy) * +select_stpcpy_ifunc (void) +{ + if (HAS_CIX) + return ___stpcpy_ev67; + + return ___stpcpy_ev5; +} + +libc_ifunc (__libc___stpcpy, select_stpcpy_ifunc ()); + +# undef stpcpy +# undef __stpcpy +strong_alias (__libc___stpcpy, __stpcpy); +weak_alias (__stpcpy, stpcpy); +/* Not libc_hidden_def: string.h declared the hidden prototype under the + redirected name, so that would alias to a __GI_ symbol nothing defines. + Alias both internal names to the IFUNC so internal callers also get the + implementation chosen for this CPU. */ +# ifdef SHARED +__hidden_ver1 (__stpcpy, __GI___stpcpy, __redirect___stpcpy) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (stpcpy); +__hidden_ver1 (__stpcpy, __GI_stpcpy, __redirect_stpcpy) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (stpcpy); +# endif +#endif diff --git a/sysdeps/alpha/multiarch/stpcpy_ev5.S b/sysdeps/alpha/multiarch/stpcpy_ev5.S new file mode 100644 index 0000000000..9525d46a8d --- /dev/null +++ b/sysdeps/alpha/multiarch/stpcpy_ev5.S @@ -0,0 +1,39 @@ +/* stpcpy for Alpha, generic version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if IS_IN (libc) +# define __stpcpy ___stpcpy_ev5 + +# undef weak_alias +# define weak_alias(a, b) + +# undef libc_hidden_def +# define libc_hidden_def(name) + +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) + +#endif + +#include + +#if IS_IN (rtld) +strong_alias (__stpcpy, ___stpcpy_ev5) +#endif diff --git a/sysdeps/alpha/multiarch/stpcpy_ev67.S b/sysdeps/alpha/multiarch/stpcpy_ev67.S new file mode 100644 index 0000000000..eb125ed502 --- /dev/null +++ b/sysdeps/alpha/multiarch/stpcpy_ev67.S @@ -0,0 +1,40 @@ +/* stpcpy for Alpha, EV67 version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* Rename unconditionally, in both the libc and rtld builds: the plain + "__stpcpy" name is reserved for whichever wrapper is the safe rtld + bootstrap default (stpcpy_ev5.S), so this file must never define it, + in either build. */ +#if IS_IN (libc) || IS_IN (rtld) +# define __stpcpy ___stpcpy_ev67 +#endif + +#if IS_IN (libc) +# undef weak_alias +# define weak_alias(a, b) + +# undef libc_hidden_def +# define libc_hidden_def(name) + +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) +#endif + +#include diff --git a/sysdeps/alpha/multiarch/stpncpy.c b/sysdeps/alpha/multiarch/stpncpy.c new file mode 100644 index 0000000000..e6d58a4754 --- /dev/null +++ b/sysdeps/alpha/multiarch/stpncpy.c @@ -0,0 +1,55 @@ +/* Multiple versions of stpncpy. Alpha version. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if IS_IN (libc) +# undef stpncpy +# define stpncpy __redirect_stpncpy +# undef __stpncpy +# define __stpncpy __redirect___stpncpy +# include +# include + +extern __typeof (__redirect___stpncpy) __libc___stpncpy; + +extern __typeof (__redirect___stpncpy) ___stpncpy_ev5 attribute_hidden; +extern __typeof (__redirect___stpncpy) ___stpncpy_ev67 attribute_hidden; + +static inline __typeof (__redirect___stpncpy) * +select_stpncpy_ifunc (void) +{ + if (HAS_CIX) + return ___stpncpy_ev67; + + return ___stpncpy_ev5; +} + +libc_ifunc (__libc___stpncpy, select_stpncpy_ifunc ()); + +# undef stpncpy +# undef __stpncpy +strong_alias (__libc___stpncpy, __stpncpy); +weak_alias (__stpncpy, stpncpy); +/* Not libc_hidden_def: string.h declared the hidden prototype under the + redirected name, so that would alias to a __GI_ symbol nothing defines. + Alias it to the IFUNC so internal callers also get the implementation + chosen for this CPU. */ +# ifdef SHARED +__hidden_ver1 (__stpncpy, __GI___stpncpy, __redirect___stpncpy) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (stpncpy); +# endif +#endif diff --git a/sysdeps/alpha/multiarch/stpncpy_ev5.S b/sysdeps/alpha/multiarch/stpncpy_ev5.S new file mode 100644 index 0000000000..e9995a517e --- /dev/null +++ b/sysdeps/alpha/multiarch/stpncpy_ev5.S @@ -0,0 +1,36 @@ +/* stpncpy for Alpha, generic version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if IS_IN (libc) +# define __stpncpy ___stpncpy_ev5 + +# undef weak_alias +# define weak_alias(a, b) + +# undef libc_hidden_def +# define libc_hidden_def(name) + +#endif + +#include + +#if IS_IN (rtld) +strong_alias (__stpncpy, ___stpncpy_ev5) +#endif diff --git a/sysdeps/alpha/multiarch/stpncpy_ev67.S b/sysdeps/alpha/multiarch/stpncpy_ev67.S new file mode 100644 index 0000000000..725126d484 --- /dev/null +++ b/sysdeps/alpha/multiarch/stpncpy_ev67.S @@ -0,0 +1,37 @@ +/* stpncpy for Alpha, EV67 version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* Rename unconditionally, in both the libc and rtld builds: the plain + "__stpncpy" name is reserved for whichever wrapper is the safe rtld + bootstrap default (stpncpy_ev5.S), so this file must never define it, + in either build. */ +#if IS_IN (libc) || IS_IN (rtld) +# define __stpncpy ___stpncpy_ev67 +#endif + +#if IS_IN (libc) +# undef weak_alias +# define weak_alias(a, b) + +# undef libc_hidden_def +# define libc_hidden_def(name) +#endif + +#include diff --git a/sysdeps/alpha/multiarch/strcat.c b/sysdeps/alpha/multiarch/strcat.c new file mode 100644 index 0000000000..bbba7bfa33 --- /dev/null +++ b/sysdeps/alpha/multiarch/strcat.c @@ -0,0 +1,49 @@ +/* Multiple versions of strcat. Alpha version. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if IS_IN (libc) +# undef strcat +# define strcat __redirect_strcat +# include +# include + +extern __typeof (__redirect_strcat) __libc_strcat; + +extern __typeof (__redirect_strcat) __strcat_ev5 attribute_hidden; +extern __typeof (__redirect_strcat) __strcat_ev67 attribute_hidden; + +static inline __typeof (__redirect_strcat) * +select_strcat_ifunc (void) +{ + if (HAS_CIX) + return __strcat_ev67; + + return __strcat_ev5; +} + +libc_ifunc (__libc_strcat, select_strcat_ifunc ()); + +# undef strcat +strong_alias (__libc_strcat, strcat); +/* Internal callers reach this through __GI_strcat. Alias it to the IFUNC + so that they get the implementation chosen for this CPU too. */ +# ifdef SHARED +__hidden_ver1 (__libc_strcat, __GI_strcat, __redirect_strcat) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (strcat); +# endif +#endif diff --git a/sysdeps/alpha/multiarch/strcat_ev5.S b/sysdeps/alpha/multiarch/strcat_ev5.S new file mode 100644 index 0000000000..5b0c421381 --- /dev/null +++ b/sysdeps/alpha/multiarch/strcat_ev5.S @@ -0,0 +1,33 @@ +/* strcat for Alpha, generic version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if IS_IN (libc) +# define strcat __strcat_ev5 + +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) + +#endif + +#include + +#if IS_IN (rtld) +strong_alias (strcat, __strcat_ev5) +#endif diff --git a/sysdeps/alpha/multiarch/strcat_ev67.S b/sysdeps/alpha/multiarch/strcat_ev67.S new file mode 100644 index 0000000000..c9614176e9 --- /dev/null +++ b/sysdeps/alpha/multiarch/strcat_ev67.S @@ -0,0 +1,34 @@ +/* strcat for Alpha, EV67 version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* Rename unconditionally, in both the libc and rtld builds: the plain + "strcat" name is reserved for whichever wrapper is the safe rtld + bootstrap default (strcat_ev5.S), so this file must never define it, + in either build. */ +#if IS_IN (libc) || IS_IN (rtld) +# define strcat __strcat_ev67 +#endif + +#if IS_IN (libc) +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) +#endif + +#include diff --git a/sysdeps/alpha/multiarch/strchr.c b/sysdeps/alpha/multiarch/strchr.c new file mode 100644 index 0000000000..57ca43ab81 --- /dev/null +++ b/sysdeps/alpha/multiarch/strchr.c @@ -0,0 +1,50 @@ +/* Multiple versions of strchr. Alpha version. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if IS_IN (libc) +# undef strchr +# define strchr __redirect_strchr +# include +# include + +extern __typeof (__redirect_strchr) __libc_strchr; + +extern __typeof (__redirect_strchr) __strchr_ev5 attribute_hidden; +extern __typeof (__redirect_strchr) __strchr_ev67 attribute_hidden; + +static inline __typeof (__redirect_strchr) * +select_strchr_ifunc (void) +{ + if (HAS_CIX) + return __strchr_ev67; + + return __strchr_ev5; +} + +libc_ifunc (__libc_strchr, select_strchr_ifunc ()); + +# undef strchr +strong_alias (__libc_strchr, strchr); +weak_alias (strchr, index); +/* Internal callers reach this through __GI_strchr. Alias it to the IFUNC + so that they get the implementation chosen for this CPU too. */ +# ifdef SHARED +__hidden_ver1 (__libc_strchr, __GI_strchr, __redirect_strchr) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (strchr); +# endif +#endif diff --git a/sysdeps/alpha/multiarch/strchr_ev5.S b/sysdeps/alpha/multiarch/strchr_ev5.S new file mode 100644 index 0000000000..2bed0a475f --- /dev/null +++ b/sysdeps/alpha/multiarch/strchr_ev5.S @@ -0,0 +1,36 @@ +/* strchr for Alpha, generic version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if IS_IN (libc) +# define strchr __strchr_ev5 + +# undef weak_alias +# define weak_alias(a, b) + +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) + +#endif + +#include + +#if IS_IN (rtld) +strong_alias (strchr, __strchr_ev5) +#endif diff --git a/sysdeps/alpha/multiarch/strchr_ev67.S b/sysdeps/alpha/multiarch/strchr_ev67.S new file mode 100644 index 0000000000..4518d471c5 --- /dev/null +++ b/sysdeps/alpha/multiarch/strchr_ev67.S @@ -0,0 +1,37 @@ +/* strchr for Alpha, EV67 version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* Rename unconditionally, in both the libc and rtld builds: the plain + "strchr" name is reserved for whichever wrapper is the safe rtld + bootstrap default (strchr_ev5.S), so this file must never define it, + in either build. */ +#if IS_IN (libc) || IS_IN (rtld) +# define strchr __strchr_ev67 +#endif + +#if IS_IN (libc) +# undef weak_alias +# define weak_alias(a, b) + +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) +#endif + +#include diff --git a/sysdeps/alpha/multiarch/strlen.c b/sysdeps/alpha/multiarch/strlen.c new file mode 100644 index 0000000000..7c9bda3e67 --- /dev/null +++ b/sysdeps/alpha/multiarch/strlen.c @@ -0,0 +1,49 @@ +/* Multiple versions of strlen. Alpha version. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if IS_IN (libc) +# undef strlen +# define strlen __redirect_strlen +# include +# include + +extern __typeof (__redirect_strlen) __libc_strlen; + +extern __typeof (__redirect_strlen) __strlen_ev5 attribute_hidden; +extern __typeof (__redirect_strlen) __strlen_ev67 attribute_hidden; + +static inline __typeof (__redirect_strlen) * +select_strlen_ifunc (void) +{ + if (HAS_CIX) + return __strlen_ev67; + + return __strlen_ev5; +} + +libc_ifunc (__libc_strlen, select_strlen_ifunc ()); + +# undef strlen +strong_alias (__libc_strlen, strlen); +/* Internal callers reach this through __GI_strlen. Alias it to the IFUNC + so that they get the implementation chosen for this CPU too. */ +# ifdef SHARED +__hidden_ver1 (__libc_strlen, __GI_strlen, __redirect_strlen) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (strlen); +# endif +#endif diff --git a/sysdeps/alpha/multiarch/strlen_ev5.S b/sysdeps/alpha/multiarch/strlen_ev5.S new file mode 100644 index 0000000000..8894b77486 --- /dev/null +++ b/sysdeps/alpha/multiarch/strlen_ev5.S @@ -0,0 +1,33 @@ +/* strlen for Alpha, generic version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if IS_IN (libc) +# define strlen __strlen_ev5 + +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) + +#endif + +#include + +#if IS_IN (rtld) +strong_alias (strlen, __strlen_ev5) +#endif diff --git a/sysdeps/alpha/multiarch/strlen_ev67.S b/sysdeps/alpha/multiarch/strlen_ev67.S new file mode 100644 index 0000000000..d1ac881cd6 --- /dev/null +++ b/sysdeps/alpha/multiarch/strlen_ev67.S @@ -0,0 +1,34 @@ +/* strlen for Alpha, EV67 version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* Rename unconditionally, in both the libc and rtld builds: the plain + "strlen" name is reserved for whichever wrapper is the safe rtld + bootstrap default (strlen_ev5.S), so this file must never define it, + in either build. */ +#if IS_IN (libc) || IS_IN (rtld) +# define strlen __strlen_ev67 +#endif + +#if IS_IN (libc) +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) +#endif + +#include diff --git a/sysdeps/alpha/multiarch/strncat.c b/sysdeps/alpha/multiarch/strncat.c new file mode 100644 index 0000000000..b844518d1a --- /dev/null +++ b/sysdeps/alpha/multiarch/strncat.c @@ -0,0 +1,49 @@ +/* Multiple versions of strncat. Alpha version. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if IS_IN (libc) +# undef strncat +# define strncat __redirect_strncat +# include +# include + +extern __typeof (__redirect_strncat) __libc_strncat; + +extern __typeof (__redirect_strncat) __strncat_ev5 attribute_hidden; +extern __typeof (__redirect_strncat) __strncat_ev67 attribute_hidden; + +static inline __typeof (__redirect_strncat) * +select_strncat_ifunc (void) +{ + if (HAS_CIX) + return __strncat_ev67; + + return __strncat_ev5; +} + +libc_ifunc (__libc_strncat, select_strncat_ifunc ()); + +# undef strncat +strong_alias (__libc_strncat, strncat); +/* Internal callers reach this through __GI_strncat. Alias it to the IFUNC + so that they get the implementation chosen for this CPU too. */ +# ifdef SHARED +__hidden_ver1 (__libc_strncat, __GI_strncat, __redirect_strncat) + __attribute__ ((visibility ("hidden"))) __attribute_copy__ (strncat); +# endif +#endif diff --git a/sysdeps/alpha/multiarch/strncat_ev5.S b/sysdeps/alpha/multiarch/strncat_ev5.S new file mode 100644 index 0000000000..591ac9173d --- /dev/null +++ b/sysdeps/alpha/multiarch/strncat_ev5.S @@ -0,0 +1,30 @@ +/* strncat for Alpha, generic version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if IS_IN (libc) +# define strncat __strncat_ev5 + +#endif + +#include + +#if IS_IN (rtld) +strong_alias (strncat, __strncat_ev5) +#endif diff --git a/sysdeps/alpha/multiarch/strncat_ev67.S b/sysdeps/alpha/multiarch/strncat_ev67.S new file mode 100644 index 0000000000..79850a941a --- /dev/null +++ b/sysdeps/alpha/multiarch/strncat_ev67.S @@ -0,0 +1,29 @@ +/* strncat for Alpha, EV67 version for multiarch dispatch. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* Rename unconditionally, in both the libc and rtld builds: the plain + "strncat" name is reserved for whichever wrapper is the safe rtld + bootstrap default (strncat_ev5.S), so this file must never define it, + in either build. */ +#if IS_IN (libc) || IS_IN (rtld) +# define strncat __strncat_ev67 +#endif + +#include