This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH][Binutils][AArch64] Set the correct ELF class for AArch64 stubs (PR/25210)
- From: Tamar Christina <Tamar dot Christina at arm dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Cc: nd <nd at arm dot com>, Richard Earnshaw <Richard dot Earnshaw at arm dot com>, Marcus Shawcroft <Marcus dot Shawcroft at arm dot com>
- Date: Tue, 31 Dec 2019 16:02:45 +0000
- Subject: [PATCH][Binutils][AArch64] Set the correct ELF class for AArch64 stubs (PR/25210)
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rm8Z3nx3XvyISdCM2/mFmQaaDscxGYVdyOkC/8QFc9Q=; b=X6e/ubKnWZwfznZ/ROc36evLbC21VgujuflPrshnvfVwHHuk3OFzsc7ecjs3mKeROqoWeShYJvyuSi7Y23CHJX+5xMti9Cfpuu55QLls82j3sd13THkzr6SBDnOifgpnmkitwjcdCaGEHoXeH86krMfrl4TqbL9WuZIa9kJXLN7H6Ylb22vwduHvU5hql+321X22nrN4NAvFnqGHlWS3f2U21O8A/6080+1eJ97P0z88JZ9bXb+0qI7H7JXqX19tDndL3tiH9fRl8CWt4uGvoW9dtwsU5i1G41aW4d1Hlfj6Zro3BKq4evi/7SzxqeQPKX4zeiOmxumkfnLkqK4XiA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gVJ+iPSzZ2dYJXodbbh0ZJeV0NW14qdjq/5bRHfvCX+0bKdai09GkD4SHW68ie3RE1Neml18YMtD3n2ut96Q6VoDZBsCJzn3PAHg8lVn+n57TN4gcx+5Y9oa5iGy5iezSoXL8VMOO5BS9yBwn/MvaDQxipnSoqIciEsOi58g9xtAhe72ON4nsfozRDkrbKn6qCZcAHOufgjlj8qGqbdRix8RbCG+pGKvCFU/p6uTSy63SPbJGAICMlP/SqV8rz1HykGAuHCnVOAtUGyR8kXfuuGn+f9N+KLNxQ6llfaF8vq9+0YkyoM6ybDma+J/BUBU+OJs/9q03zGQbaWeRvUGRQ==
- Original-authentication-results: spf=none (sender IP is ) smtp.mailfrom=Tamar dot Christina at arm dot com;
Hi All,
This fixes PR 25210 by specifying the the correct ELF class for AArch64 stubs.
After doing this the stub section starts behaving like a normal object file
loaded from disk. That is SEC_LINKER_CREATED causes us to have to write the
section manually.
This flag was added as a fix for PR 24753. I believe that
fix to still be correct as linker created sections don't have a size on disk,
but in this case specifying the correct section class also makes the stub
section not be considered by compress.c.
So I partially revert this change so that we don't have to manage the section
manually as implied by SEC_LINKER_CREATED.
build on native hardware and regtested on
aarch64-none-elf, aarch64-none-elf (32 bit host),
aarch64-none-linux-gnu, aarch64-none-linux-gnu (32 bit host),
arm-none-eabi, arm-none-eabi (32 bit host),
arm-none-linux-gnueabihf, arm-none-linux-gnueabihf (32 bit host)
Cross-compiled and regtested on
aarch64-none-linux-gnu, aarch64_be-none-linux-gnu,
arm-none-eabi, armeb-none-eabi, arm-wince-pe
and no issues.
Also performed a full toolchain build for aarch64-none-linux-gnu to confirm
that this doesn't re-introduce the issue mentioned in PR 24753.
Ok for master? and for backport to binutils-2.33?
Thanks,
Tamar
bfd/ChangeLog:
2019-12-31 Tamar Christina <tamar.christina@arm.com>
PR 25210
PR 24753
* elfnn-aarch64.c (_bfd_aarch64_create_stub_section): Set ELF class.
ld/ChangeLog:
2019-12-31 Tamar Christina <tamar.christina@arm.com>
PR 25210
PR 24753
* emultempl/aarch64elf.em (elf${ELFSIZE}_aarch64_add_stub_section):
Remove SEC_LINKER_CREATED.
* testsuite/ld-aarch64/aarch64-elf.exp: Add erratum835769-843419.
* testsuite/ld-aarch64/erratum835769-843419.d: New test.
--
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 51d7526a720bdb30d81db254d7348fb04ecff63f..c2fe7f1e48be9c4ff7c02d2dc334b0ed4cc13eb1 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -3177,6 +3177,10 @@ _bfd_aarch64_create_stub_section (asection *section,
if (s_name == NULL)
return NULL;
+ /* PR 25210. Set the right class on the stub_bfd. */
+ elf_elfheader (htab->stub_bfd)->e_ident[EI_CLASS] = ELFCLASSNN;
+ BFD_ASSERT (ELFCLASSNN == get_elf_backend_data (htab->stub_bfd)->s->elfclass);
+
memcpy (s_name, section->name, namelen);
memcpy (s_name + namelen, STUB_SUFFIX, sizeof (STUB_SUFFIX));
return (*htab->add_stub_section) (s_name, section);
diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em
index f4baf508958714c824b8670ee4a01dfe9a7d254f..d3ff4999c68f600233a6fe7d06cc065ec0aa9428 100644
--- a/ld/emultempl/aarch64elf.em
+++ b/ld/emultempl/aarch64elf.em
@@ -170,7 +170,7 @@ elf${ELFSIZE}_aarch64_add_stub_section (const char *stub_sec_name,
lang_output_section_statement_type *os;
struct hook_stub_info info;
- flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_LINKER_CREATED
+ flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE
| SEC_HAS_CONTENTS | SEC_RELOC | SEC_IN_MEMORY | SEC_KEEP);
stub_sec = bfd_make_section_anyway_with_flags (stub_file->the_bfd,
stub_sec_name, flags);
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
index 2b053d1ee79e6a4aef9eb55edd07c76b75b5a00a..26973982a7e12c1d1ebab0b6f86944f3f856136b 100644
--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
@@ -96,6 +96,7 @@ run_dump_test "erratum843419-far-adr"
run_dump_test "erratum843419-far-full"
run_dump_test "erratum843419-full"
run_dump_test "erratum843419-no-args"
+run_dump_test "erratum835769-843419"
# Relocation Tests
run_dump_test_lp64 "weak-undefined"
diff --git a/ld/testsuite/ld-aarch64/erratum835769-843419.d b/ld/testsuite/ld-aarch64/erratum835769-843419.d
new file mode 100644
index 0000000000000000000000000000000000000000..728765f61d0a1381d54e7d6a700437e79d4f8d26
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/erratum835769-843419.d
@@ -0,0 +1,54 @@
+#source: erratum835769.s
+#as:
+#ld: --fix-cortex-a53-835769 --fix-cortex-a53-843419=full -e0x400000
+#objdump: -dr
+#...
+Disassembly of section .text:
+#...
+[0-9a-f]+ <a1ldr>:
+[ \t0-9a-f]+:[ \t]+b8408c87[ \t]+ldr[ \t]+w7, \[x4, #8\]\!
+[ \t0-9a-f]+:[ \t]+1b017c06[ \t]+mul[ \t]+w6, w0, w1
+[ \t0-9a-f]+:[ \t]+f9400084[ \t]+ldr[ \t]+x4, \[x4\]
+[ \t0-9a-f]+:[ \t0-9a-z]+[ \t]+b[ \t]+[0-9a-f]+ <__erratum_835769_veneer_0>
+[ \t0-9a-f]+:[ \t]+aa0503e0[ \t]+mov[ \t]+x0, x5
+[ \t0-9a-f]+:[ \t]+d65f03c0[ \t]+ret
+
+[0-9a-f]+ <a5ldr>:
+[ \t0-9a-f]+:[ \t]+b8408c87[ \t]+ldr[ \t]+w7, \[x4, #8\]!
+[ \t0-9a-f]+:[ \t]+1b017c06[ \t]+mul[ \t]+w6, w0, w1
+[ \t0-9a-f]+:[ \t]+f9400084[ \t]+ldr[ \t]+x4, \[x4\]
+[ \t0-9a-f]+:[ \t0-9a-z]+[ \t]+b[ \t]+[0-9a-f]+ <__erratum_835769_veneer_1>
+[ \t0-9a-f]+:[ \t]+aa0503e0[ \t]+mov[ \t]+x0, x5
+[ \t0-9a-f]+:[ \t]+d65f03c0[ \t]+ret
+
+[0-9a-f]+ <a6ldr>:
+[ \t0-9a-f]+:[ \t]+b8408c87[ \t]+ldr[ \t]+w7, \[x4, #8\]!
+[ \t0-9a-f]+:[ \t]+1b017c06[ \t]+mul[ \t]+w6, w0, w1
+[ \t0-9a-f]+:[ \t]+f9400084[ \t]+ldr[ \t]+x4, \[x4\]
+[ \t0-9a-f]+:[ \t]+9b031885[ \t]+madd[ \t]+x5, x4, x3, x6
+[ \t0-9a-f]+:[ \t]+aa0503e0[ \t]+mov[ \t]+x0, x5
+[ \t0-9a-f]+:[ \t]+d65f03c0[ \t]+ret
+
+[0-9a-f]+ <a7str>:
+[ \t0-9a-f]+:[ \t]+b8408c87[ \t]+ldr[ \t]+w7, \[x4, #8\]!
+[ \t0-9a-f]+:[ \t]+1b017c06[ \t]+mul[ \t]+w6, w0, w1
+[ \t0-9a-f]+:[ \t]+f9000084[ \t]+str[ \t]+x4, \[x4\]
+[ \t0-9a-f]+:[ \t0-9a-z]+[ \t]+b[ \t]+[0-9a-f]+ <__erratum_835769_veneer_2>
+[ \t0-9a-f]+:[ \t]+aa0503e0[ \t]+mov[ \t]+x0, x5
+[ \t0-9a-f]+:[ \t]+d65f03c0[ \t]+ret
+
+[ \t0-9a-f]+:[ \t]+d503201f[ \t]+nop
+[ \t0-9a-f]+:[ \t]+14000400[ \t]+b[ \t]+[0-9a-f]+ <__erratum_835769_veneer_0\+0xfe8>
+[ \t0-9a-f]+:[ \t]+d503201f[ \t]+nop
+[0-9a-f]+ <__erratum_835769_veneer_2>:
+[ \t0-9a-f]+:[ \t]+9b031885[ \t]+madd[ \t]+x5, x4, x3, x6
+[ \t0-9a-f]+:[ \t0-9a-z]+[ \t]+b[ \t]+[0-9a-f]+ <a7str\+0x[0-9a-f]+>
+
+[0-9a-f]+ <__erratum_835769_veneer_1>:
+[ \t0-9a-f]+:[ \t]+9ba31845[ \t]+umaddl[ \t]+x5, w2, w3, x6
+[ \t0-9a-f]+:[ \t0-9a-z]+[ \t]+b[ \t]+[0-9a-f]+ <a5ldr\+0x[0-9a-f]+>
+
+[0-9a-f]+ <__erratum_835769_veneer_0>:
+[ \t0-9a-f]+:[ \t]+9b031845[ \t]+madd[ \t]+x5, x2, x3, x6
+[ \t0-9a-f]+:[ \t0-9a-z]+[ \t]+b[ \t]+[0-9a-f]+ <a1ldr\+0x[0-9a-f]+>
+#pass