From patchwork Fri Jan 5 19:12:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 1883099 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=S0lfbEpc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T6Clk3n1Qz1yP4 for ; Sat, 6 Jan 2024 06:13:06 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6E5963858402 for ; Fri, 5 Jan 2024 19:13:04 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by sourceware.org (Postfix) with ESMTPS id 83A3B3858D1E for ; Fri, 5 Jan 2024 19:12:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83A3B3858D1E 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 83A3B3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::82a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704481969; cv=none; b=ajprVSqdnK3mOYxnHyvKVHKXJUobWm43/XxxJyKPoxcsjERCUxy5NqSe3r8TJRS/HErcqdMs2Bv1WX1luc/kLVo9p1Z/HeSeuCIeZcD7gVSKWg7JArLyRSgtkSYkJXIxGDzDWcR72Wc4laRUozDp40XlY8bSs6CvUU/laS584M8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704481969; c=relaxed/simple; bh=0/rxF9fqCMVJtBPJsxS2QXXH8IV5r7PcDmTPTkA3QFA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=JU4C4x2WasFLGllo2nzROUSVuGLroIHfkE86wW8g+JgDGCghCpitC97oo0td0tvhDOpIqZLUIV8Ldrgh+rOvtyGjbHLFXsoSxzjoqMoMEmVNhgb3x9zWBEgQEK550H3P+Im3wKM8wkm/foDiJwx0WMDFZ1C8UZ7gICYLhPID89A= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qt1-x82a.google.com with SMTP id d75a77b69052e-4297412a468so7734871cf.0 for ; Fri, 05 Jan 2024 11:12:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704481966; x=1705086766; darn=sourceware.org; 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=A4W30x6DbbhI25NyMnj2LdolhLv9QTnIQMY0awtiEOs=; b=S0lfbEpchmAheR/qNe+3JLpMskjXqStbitYVQVS3tTvumGAeK6EY06FgQYDDrsFrjZ PSwbsolWyf4fvqb0O4U+DPQs9BfCfN3csXtFKDAn/mSgu/Awa9kLZN9sZcOTY1oHZCrw kYUV8fBR+LXkX4rXGdTNfxI7kIjd2fhAqm7FYQxYU3Y2jzOz4y+TRD0/8rAStm6QedYk b1ZsHagT/yt9fqY0QAnl4cXGOFekx4E7dMT8ePEadnPweWwZYAbHxNJNfuyt1Qs7C/QX OXIAyryk/6jKCKWmN4Ff1sXSup586HRCY6x9gCzNhOpim9BWzZKzG/vX7k+F6j8MBBSo V+JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704481966; x=1705086766; 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=A4W30x6DbbhI25NyMnj2LdolhLv9QTnIQMY0awtiEOs=; b=duMCHngxNtarwf2WQVnJhl+G/7avt3Ui3toiPw0ffhbOXVMhFxPvOKy0yDg3SRef/B 4nX4bMU36AgeOhnHbfod11pqTCWgDXQuLUSnie9bAHKz+I68b/KqA9qY2TW17vg9WSAu utNNZE28GXCMZub9CPKeTWBnEWUiVnzE/CRxLWkgJeJm/t7R170TyX8tURu+S5216RQK hcGcRWNkHDjmuy7gHiJXKxKR1j0+Z7etFivUXiRzz0HIfSzBOgMRrpZW27XAd8xDBM+2 EnfoE+6NYEpQGLqkKFtEzFkw8BGavi/hDhtO6LVhEcOZfZ7MgywRthe1vy1RKyfW0RUB nEMg== X-Gm-Message-State: AOJu0Yy20Bs2CMfCJjaaVVHfBbJtb6X9H6c4TJQxmRN9v/7MTQSoK0Px 5HEGz96l44vXRLwvPSbwpNtrpmfzgBk= X-Google-Smtp-Source: AGHT+IF/dFbxbbOHZk1E/Ml+gcOqKzsUQPKua/yB7ngjTuJRfNRFHb+EC/PO3TARL7joZcHRK+8r3Q== X-Received: by 2002:a05:622a:1887:b0:428:3629:21c5 with SMTP id v7-20020a05622a188700b00428362921c5mr2616734qtc.21.1704481966363; Fri, 05 Jan 2024 11:12:46 -0800 (PST) Received: from noahgold-desk.intel.com ([192.55.55.51]) by smtp.gmail.com with ESMTPSA id ch11-20020a05622a40cb00b00427f42aadedsm983557qtb.9.2024.01.05.11.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 11:12:45 -0800 (PST) From: Noah Goldstein To: libc-alpha@sourceware.org Cc: goldstein.w.n@gmail.com, hjl.tools@gmail.com, carlos@systemhalted.org Subject: x86: Fixup some nits in longjmp asm implementation Date: Fri, 5 Jan 2024 11:12:40 -0800 Message-Id: <20240105191240.3646771-1-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240104221634.3612621-1-goldstein.w.n@gmail.com> References: <20240104221634.3612621-1-goldstein.w.n@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Replace a stray `nop` with a `.p2align` directive. --- .../unix/sysv/linux/x86_64/____longjmp_chk.S | 2 +- sysdeps/x86_64/dl-machine.h | 31 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S index 9aa24620b9..9d9732afdc 100644 --- a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S +++ b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S @@ -57,8 +57,8 @@ longjmp_msg: cfi_def_cfa_offset(16); \ LOAD_MSG; \ call HIDDEN_JUMPTARGET(__fortify_fail); \ - nop; \ cfi_restore_state; \ + .p2align 3, 5; \ .Lok2: \ movq %r10, %rdi; \ cfi_restore (%rdi); \ diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h index adcc0f7113..7ef6e24eb5 100644 --- a/sysdeps/x86_64/dl-machine.h +++ b/sysdeps/x86_64/dl-machine.h @@ -618,25 +618,24 @@ x86_64_rewrite_plt (struct link_map *map, ElfW(Addr) plt_rewrite) if (((uint64_t) disp + (uint64_t) ((uint32_t) INT32_MIN)) <= (uint64_t) UINT32_MAX) { - pad = branch_start + JMP32_INSN_SIZE; + pad = branch_start + JMP32_INSN_SIZE; - if (__glibc_unlikely (pad > plt_end)) - continue; + if (__glibc_unlikely (pad > plt_end)) + continue; - /* If the target branch can be reached with a direct branch, - rewrite the PLT entry with a direct branch. */ - if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_BINDINGS)) - { - const char *sym_name = x86_64_reloc_symbol_name (map, - reloc); - _dl_debug_printf ("changing '%s' PLT entry in '%s' to " - "direct branch\n", sym_name, - DSO_FILENAME (map->l_name)); - } + /* If the target branch can be reached with a direct branch, + rewrite the PLT entry with a direct branch. */ + if (__glibc_unlikely (GLRO (dl_debug_mask) & DL_DEBUG_BINDINGS)) + { + const char *sym_name = x86_64_reloc_symbol_name (map, reloc); + _dl_debug_printf ("changing '%s' PLT entry in '%s' to " + "direct branch\n", + sym_name, DSO_FILENAME (map->l_name)); + } - /* Write out direct branch. */ - *(uint8_t *) branch_start = JMP32_INSN_OPCODE; - *((uint32_t *) (branch_start + 1)) = disp; + /* Write out direct branch. */ + *(uint8_t *) branch_start = JMP32_INSN_OPCODE; + *((uint32_t *) (branch_start + 1)) = disp; } else {