From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: <binutils@sourceware.org>
Subject: [PATCH 1/5] bfd: aarch64: Fix BTI stub optimization PR30957
Date: Fri, 3 Nov 2023 13:15:32 +0000 [thread overview]
Message-ID: <8789cd1a77dfb39f2e8f722f6c737119e8cc9ae2.1699016830.git.szabolcs.nagy@arm.com> (raw)
In-Reply-To: <cover.1699016830.git.szabolcs.nagy@arm.com>
The instruction was looked up in the wrong input file (file of branch
source instead of branch target) when optimizing away BTI stubs in
commit 5834f36d93cabf1a8bcc7dd7654141aed3d296bc
bfd: aarch64: Optimize BTI stubs PR30076
This can cause adding BTI stubs when they are not necessary or removing
them when they are (the latter is a correctness issue but it is very
unlikely in practice).
Fixes bug 30957.
---
bfd/elfnn-aarch64.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 4592bd6da27..a0dd17faa7e 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -3675,8 +3675,7 @@ group_sections (struct elf_aarch64_link_hash_table *htab,
/* True if the inserted stub does not break BTI compatibility. */
static bool
-aarch64_bti_stub_p (bfd *input_bfd,
- struct elf_aarch64_stub_hash_entry *stub_entry)
+aarch64_bti_stub_p (struct elf_aarch64_stub_hash_entry *stub_entry)
{
/* Stubs without indirect branch are BTI compatible. */
if (stub_entry->stub_type != aarch64_stub_adrp_branch
@@ -3690,7 +3689,7 @@ aarch64_bti_stub_p (bfd *input_bfd,
file_ptr off = stub_entry->target_value;
bfd_size_type count = sizeof (loc);
- if (!bfd_get_section_contents (input_bfd, section, loc, off, count))
+ if (!bfd_get_section_contents (section->owner, section, loc, off, count))
return false;
uint32_t insn = bfd_getl32 (loc);
@@ -4637,7 +4636,7 @@ _bfd_aarch64_add_call_stub_entries (bool *stub_changed, bfd *output_bfd,
/* A stub with indirect jump may break BTI compatibility, so
insert another stub with direct jump near the target then. */
- if (need_bti && !aarch64_bti_stub_p (input_bfd, stub_entry))
+ if (need_bti && !aarch64_bti_stub_p (stub_entry))
{
stub_entry->double_stub = true;
htab->has_double_stub = true;
--
2.25.1
next prev parent reply other threads:[~2023-11-03 13:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-03 13:15 [PATCH 0/5] aarch64 BTI stub fixes Szabolcs Nagy
2023-11-03 13:15 ` Szabolcs Nagy [this message]
2023-11-03 13:15 ` [PATCH 2/5] bfd: aarch64: Fix broken BTI stub PR30930 Szabolcs Nagy
2023-11-03 13:15 ` [PATCH 3/5] bfd: aarch64: Fix leaks in case of BTI stub reuse Szabolcs Nagy
2023-11-03 13:15 ` [PATCH 4/5] bfd: aarch64: Avoid BTI stub for a PLT that has BTI Szabolcs Nagy
2023-11-03 13:22 ` [PATCH 5/5] ld: aarch64: Add BTI stub insertion test PR30930 Szabolcs Nagy
2023-11-03 13:15 ` Szabolcs Nagy
2023-11-07 11:38 ` [PATCH 0/5] aarch64 BTI stub fixes Nick Clifton
2023-11-07 13:08 ` Szabolcs Nagy
2023-11-09 14:58 ` Szabolcs Nagy
2023-11-17 8:42 ` Fangrui Song
[not found] ` <DS7PR12MB5765CE9DC452CD430E68B89BCBB7A@DS7PR12MB5765.namprd12.prod.outlook.com>
2023-11-20 14:56 ` Szabolcs Nagy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8789cd1a77dfb39f2e8f722f6c737119e8cc9ae2.1699016830.git.szabolcs.nagy@arm.com \
--to=szabolcs.nagy@arm.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).