From patchwork Sun Nov 17 00:36:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 101324 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E9CB385734F for ; Sun, 17 Nov 2024 00:38:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E9CB385734F Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=i/GHr1q1 X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by sourceware.org (Postfix) with ESMTPS id 91C1E3857341 for ; Sun, 17 Nov 2024 00:36:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 91C1E3857341 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 91C1E3857341 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1132 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731803817; cv=none; b=gq1WR9gEXFOuPYUyePuzAhYxlGB8oqz+Ie5Zmt31i9X9TEa/lAIceym/jVFCbmk15kFa4XuhJHs43qDBl9fCGrm0kJhApT4lKQBBOxY4MB15TzfZAoXE2D+jrKNcbSlOKej0b9Vpg/lTGNV6GUfub2rW8YXRvoWxPceo6DoPMlc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731803817; c=relaxed/simple; bh=Zrb0Eo3PSdqJi4KYFX7oTGiWfKD2nVxUY6oocw05kSU=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=PKol1uqFKhpztWdnmI3oLUTliqSn/QVvqLKCtd2JccSl0Pt6+tekPVqgP6+Wuz5kyX9KWfc4dn9tEiHMesGEwIzAe6xWKhxXlVbtvqOh5yd9o6TJ967xctHNQb2gihYXso34UbyNXrx2jrPZZzZT9WKDBuzXCrNe/M7f2QdFbCU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 91C1E3857341 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-6ee7ea48ad8so3341587b3.3 for ; Sat, 16 Nov 2024 16:36:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731803817; x=1732408617; darn=sourceware.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=pNxziqoRI9nY9tsYXJbGpAYcwphfgLZasdEEI1XcBVM=; b=i/GHr1q1bDRRbW64obXThg2v1EkV00TZ4R82Mlz9efB7RkOIEVPb6L58q0FVkavD47 X8+hSNililTi+d9olE+w6cXn584HbP5XNcpTYJJp/mLvQhR9Gxc2uFcQ6uWLli2PVwMS 4ZLe3BGq34x8nvrXC/d59LDrM6QJDSgQ3mwhEoLeCmD5YXyBsDMkEX9Id9XGUqRt7NGX tg13gDt+WrmCCKf6lSMW1a9WSNd4rWXLRb772MKAkYIeLdqjwW3J3T5253TidMJQECte lj+I5ZQyPu2EYFD45YbKKlghJqXTVaxot4ZX/aJvnuvx2261OkwCDrT5AocyZ0twTNlD jWuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731803817; x=1732408617; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=pNxziqoRI9nY9tsYXJbGpAYcwphfgLZasdEEI1XcBVM=; b=N2YVGeAUqj07zY7kA9yzdltgY3xD93GGH4sjZd6+S/jUG9GZ9bW5Abtyx0Nk9V5iwL uZ+As5r4cEVYaYF2TyfwDRaCqXARBTe7bZwUmJaQ8ZocngYddoGHnkX5/WOpRxWKQRV5 2LXco4c6HP3C7eyyHr5rvxNeykJ5O43O9KXELaDDWiTsQ2gjNBnBi4Gq8xMwVDShfWnc tFLve99WnZHkokQQPJ+et1wrIKSfJLhv/nmX5I9k/IpVpW38dSQWCH/AUYf9FG/QVBQ5 vxDazS4tyJNbOHCmYwuc0Ppye+qyOEOhg85jt0wR9f78vtS+WZyLKQQvt+mQ0xkYTsma 4brg== X-Gm-Message-State: AOJu0YzZkV8MX7hoRK/U+KhZapCcz34t0ERT1UYSQ49VK3BuOjSdItR5 i7XEOIU1z+uYmaDxZPuA+eDliijShbLMyp3iYvyCIsHfKXol2HsMsQceYQqvTeKCsd7084iL18u t5H3iPZehwfXOyL1t9VNAan4/+a4COXh7u3K+gpng X-Google-Smtp-Source: AGHT+IFoN+2uuMDnafzVHcBjCKPor/5Uz6YhTcEfcteoE6Zmq6H9ZVLkye18VXcLi1CcfkmRf+dXyBZ8KPgC++mq8eQ= X-Received: by 2002:a05:690c:4c02:b0:6ea:916f:e897 with SMTP id 00721157ae682-6ee55c27343mr83496167b3.29.1731803816776; Sat, 16 Nov 2024 16:36:56 -0800 (PST) MIME-Version: 1.0 From: "H.J. Lu" Date: Sun, 17 Nov 2024 08:36:20 +0800 Message-ID: Subject: [PATCH] x86-64: Drop x32 references in PLT entry variables To: Binutils X-Spam-Status: No, score=-3017.5 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 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org e9c11d58b95 x86-64: Remove BND from 64-bit IBT PLT removed the BND prefix from 64-bit IBT PLT by using x32 IBT PLT. Drop x32 references in PLT entry variables. * elf64-x86-64.c (elf_x86_64_lazy_ibt_plt_entry): Renamed to ... (elf_x86_64_lazy_bnd_ibt_plt_entry): This. (elf_x32_lazy_ibt_plt_entry): Renamed to ... (elf_x86_64_lazy_ibt_plt_entry): This. (elf_x86_64_non_lazy_ibt_plt_entry): Renamed to ... (elf_x86_64_non_lazy_bnd_ibt_plt_entry): This. (elf_x32_non_lazy_ibt_plt_entry): Renamed to ... (elf_x86_64_non_lazy_ibt_plt_entry): This. (elf_x86_64_eh_frame_lazy_ibt_plt): Renamed to ... (elf_x86_64_eh_frame_lazy_bnd_ibt_plt): This. (elf_x32_eh_frame_lazy_ibt_plt): Renamed to ... (elf_x86_64_eh_frame_lazy_ibt_plt): This. (elf_x86_64_lazy_ibt_plt): Renamed to ... (elf_x86_64_lazy_bnd_ibt_plt): This. Updated. (elf_x32_lazy_ibt_plt): Renamed to ... (elf_x86_64_lazy_ibt_plt): This. Updated. (elf_x86_64_non_lazy_ibt_plt): Renamed to ... (elf_x86_64_non_lazy_bnd_ibt_plt): This. Updated. (elf_x32_non_lazy_ibt_plt): Renamed to ... (elf_x86_64_non_lazy_ibt_plt): This. Updated. (elf_x86_64_get_synthetic_symtab): Updated. (elf_x86_64_link_setup_gnu_properties): Likewise. From e050bfa001eaf0ec01c07a5a6d397b45dbedf1c6 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sun, 17 Nov 2024 07:23:35 +0800 Subject: [PATCH] x86-64: Drop x32 references in PLT entry variables e9c11d58b95 x86-64: Remove BND from 64-bit IBT PLT removed the BND prefix from 64-bit IBT PLT by using x32 IBT PLT. Drop x32 references in PLT entry variables. * elf64-x86-64.c (elf_x86_64_lazy_ibt_plt_entry): Renamed to ... (elf_x86_64_lazy_bnd_ibt_plt_entry): This. (elf_x32_lazy_ibt_plt_entry): Renamed to ... (elf_x86_64_lazy_ibt_plt_entry): This. (elf_x86_64_non_lazy_ibt_plt_entry): Renamed to ... (elf_x86_64_non_lazy_bnd_ibt_plt_entry): This. (elf_x32_non_lazy_ibt_plt_entry): Renamed to ... (elf_x86_64_non_lazy_ibt_plt_entry): This. (elf_x86_64_eh_frame_lazy_ibt_plt): Renamed to ... (elf_x86_64_eh_frame_lazy_bnd_ibt_plt): This. (elf_x32_eh_frame_lazy_ibt_plt): Renamed to ... (elf_x86_64_eh_frame_lazy_ibt_plt): This. (elf_x86_64_lazy_ibt_plt): Renamed to ... (elf_x86_64_lazy_bnd_ibt_plt): This. Updated. (elf_x32_lazy_ibt_plt): Renamed to ... (elf_x86_64_lazy_ibt_plt): This. Updated. (elf_x86_64_non_lazy_ibt_plt): Renamed to ... (elf_x86_64_non_lazy_bnd_ibt_plt): This. Updated. (elf_x32_non_lazy_ibt_plt): Renamed to ... (elf_x86_64_non_lazy_ibt_plt): This. Updated. (elf_x86_64_get_synthetic_symtab): Updated. (elf_x86_64_link_setup_gnu_properties): Likewise. Signed-off-by: H.J. Lu --- bfd/elf64-x86-64.c | 77 +++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index a62fa621f99..435b93e7b87 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -629,7 +629,7 @@ static const bfd_byte elf_x86_64_lazy_bnd_plt_entry[LAZY_PLT_ENTRY_SIZE] = entries for a IBT-enabled lazy procedure linkage table look like this. */ -static const bfd_byte elf_x86_64_lazy_ibt_plt_entry[LAZY_PLT_ENTRY_SIZE] = +static const bfd_byte elf_x86_64_lazy_bnd_ibt_plt_entry[LAZY_PLT_ENTRY_SIZE] = { 0xf3, 0x0f, 0x1e, 0xfa, /* endbr64 */ 0x68, 0, 0, 0, 0, /* pushq immediate */ @@ -637,11 +637,11 @@ static const bfd_byte elf_x86_64_lazy_ibt_plt_entry[LAZY_PLT_ENTRY_SIZE] = 0x90 /* nop */ }; -/* The first entry in the x32 IBT-enabled lazy procedure linkage table +/* The first entry in the IBT-enabled lazy procedure linkage table is the same as the normal lazy PLT. Subsequent entries for an - x32 IBT-enabled lazy procedure linkage table look like this. */ + IBT-enabled lazy procedure linkage table look like this. */ -static const bfd_byte elf_x32_lazy_ibt_plt_entry[LAZY_PLT_ENTRY_SIZE] = +static const bfd_byte elf_x86_64_lazy_ibt_plt_entry[LAZY_PLT_ENTRY_SIZE] = { 0xf3, 0x0f, 0x1e, 0xfa, /* endbr64 */ 0x68, 0, 0, 0, 0, /* pushq immediate */ @@ -668,11 +668,11 @@ static const bfd_byte elf_x86_64_non_lazy_bnd_plt_entry[NON_LAZY_PLT_ENTRY_SIZE] 0x90 /* nop */ }; -/* Entries for branches with IBT-enabled in the non-lazey procedure - linkage table look like this. They have the same size as the lazy - PLT entry. */ +/* Entries for IBT-enabled branches with BND prefix in the non-lazey + procedure linkage table look like this. They have the same size as + the lazy PLT entry. */ -static const bfd_byte elf_x86_64_non_lazy_ibt_plt_entry[LAZY_PLT_ENTRY_SIZE] = +static const bfd_byte elf_x86_64_non_lazy_bnd_ibt_plt_entry[LAZY_PLT_ENTRY_SIZE] = { 0xf3, 0x0f, 0x1e, 0xfa, /* endbr64 */ 0xf2, 0xff, 0x25, /* bnd jmpq *name@GOTPC(%rip) */ @@ -680,11 +680,11 @@ static const bfd_byte elf_x86_64_non_lazy_ibt_plt_entry[LAZY_PLT_ENTRY_SIZE] = 0x0f, 0x1f, 0x44, 0x00, 0x00 /* nopl 0x0(%rax,%rax,1) */ }; -/* Entries for branches with IBT-enabled in the x32 non-lazey procedure +/* Entries for branches with IBT-enabled in the non-lazey procedure linkage table look like this. They have the same size as the lazy PLT entry. */ -static const bfd_byte elf_x32_non_lazy_ibt_plt_entry[LAZY_PLT_ENTRY_SIZE] = +static const bfd_byte elf_x86_64_non_lazy_ibt_plt_entry[LAZY_PLT_ENTRY_SIZE] = { 0xf3, 0x0f, 0x1e, 0xfa, /* endbr64 */ 0xff, 0x25, /* jmpq *name@GOTPC(%rip) */ @@ -770,9 +770,10 @@ static const bfd_byte elf_x86_64_eh_frame_lazy_bnd_plt[] = DW_CFA_nop, DW_CFA_nop, DW_CFA_nop, DW_CFA_nop }; -/* .eh_frame covering the lazy .plt section with IBT-enabled. */ +/* .eh_frame covering the lazy .plt section with IBT-enabled and BND + prefix. */ -static const bfd_byte elf_x86_64_eh_frame_lazy_ibt_plt[] = +static const bfd_byte elf_x86_64_eh_frame_lazy_bnd_ibt_plt[] = { PLT_CIE_LENGTH, 0, 0, 0, /* CIE length */ 0, 0, 0, 0, /* CIE ID */ @@ -805,9 +806,9 @@ static const bfd_byte elf_x86_64_eh_frame_lazy_ibt_plt[] = DW_CFA_nop, DW_CFA_nop, DW_CFA_nop, DW_CFA_nop }; -/* .eh_frame covering the x32 lazy .plt section with IBT-enabled. */ +/* .eh_frame covering the lazy .plt section with IBT-enabled. */ -static const bfd_byte elf_x32_eh_frame_lazy_ibt_plt[] = +static const bfd_byte elf_x86_64_eh_frame_lazy_ibt_plt[] = { PLT_CIE_LENGTH, 0, 0, 0, /* CIE length */ 0, 0, 0, 0, /* CIE ID */ @@ -1081,11 +1082,11 @@ static const struct elf_x86_non_lazy_plt_layout elf_x86_64_non_lazy_bnd_plt = sizeof (elf_x86_64_eh_frame_non_lazy_plt) /* eh_frame_plt_size */ }; -static const struct elf_x86_lazy_plt_layout elf_x86_64_lazy_ibt_plt = +static const struct elf_x86_lazy_plt_layout elf_x86_64_lazy_bnd_ibt_plt = { elf_x86_64_lazy_bnd_plt0_entry, /* plt0_entry */ LAZY_PLT_ENTRY_SIZE, /* plt0_entry_size */ - elf_x86_64_lazy_ibt_plt_entry, /* plt_entry */ + elf_x86_64_lazy_bnd_ibt_plt_entry, /* plt_entry */ LAZY_PLT_ENTRY_SIZE, /* plt_entry_size */ elf_x86_64_tlsdesc_plt_entry, /* plt_tlsdesc_entry */ LAZY_PLT_ENTRY_SIZE, /* plt_tlsdesc_entry_size */ @@ -1103,16 +1104,16 @@ static const struct elf_x86_lazy_plt_layout elf_x86_64_lazy_ibt_plt = 4+1+5+5, /* plt_plt_insn_end */ 0, /* plt_lazy_offset */ elf_x86_64_lazy_bnd_plt0_entry, /* pic_plt0_entry */ - elf_x86_64_lazy_ibt_plt_entry, /* pic_plt_entry */ - elf_x86_64_eh_frame_lazy_ibt_plt, /* eh_frame_plt */ - sizeof (elf_x86_64_eh_frame_lazy_ibt_plt) /* eh_frame_plt_size */ + elf_x86_64_lazy_bnd_ibt_plt_entry, /* pic_plt_entry */ + elf_x86_64_eh_frame_lazy_bnd_ibt_plt, /* eh_frame_plt */ + sizeof (elf_x86_64_eh_frame_lazy_bnd_ibt_plt) /* eh_frame_plt_size */ }; -static const struct elf_x86_lazy_plt_layout elf_x32_lazy_ibt_plt = +static const struct elf_x86_lazy_plt_layout elf_x86_64_lazy_ibt_plt = { elf_x86_64_lazy_plt0_entry, /* plt0_entry */ LAZY_PLT_ENTRY_SIZE, /* plt0_entry_size */ - elf_x32_lazy_ibt_plt_entry, /* plt_entry */ + elf_x86_64_lazy_ibt_plt_entry, /* plt_entry */ LAZY_PLT_ENTRY_SIZE, /* plt_entry_size */ elf_x86_64_tlsdesc_plt_entry, /* plt_tlsdesc_entry */ LAZY_PLT_ENTRY_SIZE, /* plt_tlsdesc_entry_size */ @@ -1130,15 +1131,15 @@ static const struct elf_x86_lazy_plt_layout elf_x32_lazy_ibt_plt = 4+5+5, /* plt_plt_insn_end */ 0, /* plt_lazy_offset */ elf_x86_64_lazy_plt0_entry, /* pic_plt0_entry */ - elf_x32_lazy_ibt_plt_entry, /* pic_plt_entry */ - elf_x32_eh_frame_lazy_ibt_plt, /* eh_frame_plt */ - sizeof (elf_x32_eh_frame_lazy_ibt_plt) /* eh_frame_plt_size */ + elf_x86_64_lazy_ibt_plt_entry, /* pic_plt_entry */ + elf_x86_64_eh_frame_lazy_ibt_plt, /* eh_frame_plt */ + sizeof (elf_x86_64_eh_frame_lazy_ibt_plt) /* eh_frame_plt_size */ }; -static const struct elf_x86_non_lazy_plt_layout elf_x86_64_non_lazy_ibt_plt = +static const struct elf_x86_non_lazy_plt_layout elf_x86_64_non_lazy_bnd_ibt_plt = { - elf_x86_64_non_lazy_ibt_plt_entry, /* plt_entry */ - elf_x86_64_non_lazy_ibt_plt_entry, /* pic_plt_entry */ + elf_x86_64_non_lazy_bnd_ibt_plt_entry, /* plt_entry */ + elf_x86_64_non_lazy_bnd_ibt_plt_entry, /* pic_plt_entry */ LAZY_PLT_ENTRY_SIZE, /* plt_entry_size */ 4+1+2, /* plt_got_offset */ 4+1+6, /* plt_got_insn_size */ @@ -1146,10 +1147,10 @@ static const struct elf_x86_non_lazy_plt_layout elf_x86_64_non_lazy_ibt_plt = sizeof (elf_x86_64_eh_frame_non_lazy_plt) /* eh_frame_plt_size */ }; -static const struct elf_x86_non_lazy_plt_layout elf_x32_non_lazy_ibt_plt = +static const struct elf_x86_non_lazy_plt_layout elf_x86_64_non_lazy_ibt_plt = { - elf_x32_non_lazy_ibt_plt_entry, /* plt_entry */ - elf_x32_non_lazy_ibt_plt_entry, /* pic_plt_entry */ + elf_x86_64_non_lazy_ibt_plt_entry, /* plt_entry */ + elf_x86_64_non_lazy_ibt_plt_entry, /* pic_plt_entry */ LAZY_PLT_ENTRY_SIZE, /* plt_entry_size */ 4+2, /* plt_got_offset */ 4+6, /* plt_got_insn_size */ @@ -5328,15 +5329,15 @@ elf_x86_64_get_synthetic_symtab (bfd *abfd, non_lazy_bnd_plt = &elf_x86_64_non_lazy_bnd_plt; if (ABI_64_P (abfd)) { - lazy_ibt_plt = &elf_x86_64_lazy_ibt_plt; - non_lazy_ibt_plt = &elf_x86_64_non_lazy_ibt_plt; - x32_lazy_ibt_plt = &elf_x32_lazy_ibt_plt; - x32_non_lazy_ibt_plt = &elf_x32_non_lazy_ibt_plt; + lazy_ibt_plt = &elf_x86_64_lazy_bnd_ibt_plt; + non_lazy_ibt_plt = &elf_x86_64_non_lazy_bnd_ibt_plt; + x32_lazy_ibt_plt = &elf_x86_64_lazy_ibt_plt; + x32_non_lazy_ibt_plt = &elf_x86_64_non_lazy_ibt_plt; } else { - lazy_ibt_plt = &elf_x32_lazy_ibt_plt; - non_lazy_ibt_plt = &elf_x32_non_lazy_ibt_plt; + lazy_ibt_plt = &elf_x86_64_lazy_ibt_plt; + non_lazy_ibt_plt = &elf_x86_64_non_lazy_ibt_plt; x32_lazy_ibt_plt = NULL; x32_non_lazy_ibt_plt = NULL; } @@ -5727,8 +5728,8 @@ elf_x86_64_link_setup_gnu_properties (struct bfd_link_info *info) init_table.lazy_plt = &elf_x86_64_lazy_plt; init_table.non_lazy_plt = &elf_x86_64_non_lazy_plt; - init_table.lazy_ibt_plt = &elf_x32_lazy_ibt_plt; - init_table.non_lazy_ibt_plt = &elf_x32_non_lazy_ibt_plt; + init_table.lazy_ibt_plt = &elf_x86_64_lazy_ibt_plt; + init_table.non_lazy_ibt_plt = &elf_x86_64_non_lazy_ibt_plt; if (ABI_64_P (info->output_bfd)) { -- 2.47.0