Notification time stamped 2023-03-31 19:48:09 UTC
From a9ea7288842d8d64bfa0ec96483eb3527f5313e9 Mon Sep 17 00:00:00 2001 From: Tulio Magno Quites Machado Filho tuliom@redhat.com Date: Mar 13 2023 19:18:37 +0000 Subject: Fix an issue on AArch64
Backport a patch from LLVM 17.
---
diff --git a/0001-AArch64-fix-bug-55005-handle-DW_CFA_GNU_NegateRAStat.patch b/0001-AArch64-fix-bug-55005-handle-DW_CFA_GNU_NegateRAStat.patch new file mode 100644 index 0000000..1b9abf0 --- /dev/null +++ b/0001-AArch64-fix-bug-55005-handle-DW_CFA_GNU_NegateRAStat.patch @@ -0,0 +1,137 @@ +From 9921197920fc3e9ad9605bd8fe0e835ca2dd41a5 Mon Sep 17 00:00:00 2001 +From: Sebastian Pop spop@amazon.com +Date: Wed, 25 Jan 2023 18:40:48 +0000 +Subject: [PATCH] [AArch64] fix bug #55005 handle DW_CFA_GNU_NegateRAState + +GCC on AArch64 uses DW_CFA_GNU_NegateRAState for return address signing. + +Differential Revision: https://reviews.llvm.org/D142572 +--- + bolt/lib/Core/Exceptions.cpp | 19 ++++-- + .../Inputs/dw_cfa_gnu_window_save.yaml | 62 +++++++++++++++++++ + bolt/test/AArch64/dw_cfa_gnu_window_save.test | 8 +++ + 3 files changed, 83 insertions(+), 6 deletions(-) + create mode 100644 bolt/test/AArch64/Inputs/dw_cfa_gnu_window_save.yaml + create mode 100644 bolt/test/AArch64/dw_cfa_gnu_window_save.test + +diff --git a/bolt/lib/Core/Exceptions.cpp b/bolt/lib/Core/Exceptions.cpp +index f8eabcf48f83..34e7454abfb0 100644 +--- a/bolt/lib/Core/Exceptions.cpp ++++ b/bolt/lib/Core/Exceptions.cpp +@@ -626,18 +626,25 @@ bool CFIReaderWriter::fillCFIInfoFor(BinaryFunction &Function) const { + errs() << "BOLT-WARNING: DW_CFA_MIPS_advance_loc unimplemented\n"; + return false; + case DW_CFA_GNU_window_save: ++ // DW_CFA_GNU_window_save and DW_CFA_GNU_NegateRAState just use the same ++ // id but mean different things. The latter is used in AArch64. ++ if (Function.getBinaryContext().isAArch64()) { ++ Function.addCFIInstruction( ++ Offset, MCCFIInstruction::createNegateRAState(nullptr)); ++ break; ++ } ++ if (opts::Verbosity >= 1) ++ errs() << "BOLT-WARNING: DW_CFA_GNU_window_save unimplemented\n"; ++ return false; + case DW_CFA_lo_user: + case DW_CFA_hi_user: +- if (opts::Verbosity >= 1) { +- errs() << "BOLT-WARNING: DW_CFA_GNU_* and DW_CFA_*_user " +- "unimplemented\n"; +- } ++ if (opts::Verbosity >= 1) ++ errs() << "BOLT-WARNING: DW_CFA_*_user unimplemented\n"; + return false; + default: +- if (opts::Verbosity >= 1) { ++ if (opts::Verbosity >= 1) + errs() << "BOLT-WARNING: Unrecognized CFI instruction: " << Instr.Opcode + << '\n'; +- } + return false; + } + +diff --git a/bolt/test/AArch64/Inputs/dw_cfa_gnu_window_save.yaml b/bolt/test/AArch64/Inputs/dw_cfa_gnu_window_save.yaml +new file mode 100644 +index 000000000000..faa32e0897c6 +--- /dev/null ++++ b/bolt/test/AArch64/Inputs/dw_cfa_gnu_window_save.yaml +@@ -0,0 +1,62 @@ ++--- !ELF ++FileHeader: ++ Class: ELFCLASS64 ++ Data: ELFDATA2LSB ++ Type: ET_EXEC ++ Machine: EM_AARCH64 ++ Entry: 0x4100C0 ++ProgramHeaders: ++ - Type: PT_LOAD ++ Flags: [ PF_X, PF_R ] ++ FirstSec: .init ++ LastSec: .fini ++ VAddr: 0x410000 ++ Align: 0x10000 ++Sections: ++ - Name: .init ++ Type: SHT_PROGBITS ++ Flags: [ SHF_ALLOC, SHF_EXECINSTR ] ++ Address: 0x410000 ++ AddressAlign: 0x4 ++ Offset: 0x10000 ++ Content: 3F2303D5FD7BBFA9FD0300913F000094FD7BC1A8BF2303D5C0035FD6 ++ - Name: .plt ++ Type: SHT_PROGBITS ++ Flags: [ SHF_ALLOC, SHF_EXECINSTR ] ++ Address: 0x410020 ++ AddressAlign: 0x10 ++ Content: F07BBFA9700100F011FE47F910E23F9120021FD61F2003D51F2003D51F2003D590010090110240F91002009120021FD690010090110640F91022009120021FD690010090110A40F91042009120021FD6 ++ - Name: .text ++ Type: SHT_PROGBITS ++ Flags: [ SHF_ALLOC, SHF_EXECINSTR ] ++ Address: 0x410080 ++ AddressAlign: 0x40 ++ Content: 00008052C0035FD61F2003D51F2003D51F2003D51F2003D51F2003D51F2003D51F2003D51F2003D51F2003D51F2003D51F2003D51F2003D51F2003D51F2003D55F2403D51D0080D21E0080D2E50300AAE10340F9E2230091E60300910000009000D00391030080D2040080D2D5FFFF97D8FFFF975F2403D5E2FFFF171F2003D55F2403D5C0035FD6600100F000F047F9400000B4D3FFFF17C0035FD61F2003D5800100908101009000800091218000913F0000EBC000005481000090210840F9610000B4F00301AA00021FD6C0035FD680010090810100900080009121800091210000CB22FC7FD3410C818B21FC4193C10000B482000090420C40F9620000B4F00302AA00021FD6C0035FD63F2303D5FD7BBEA9FD030091F30B00F9930100906082403980000035DEFFFF972000805260820039F30B40F9FD7BC2A8BF2303D5C0035FD65F2403D5E2FFFF17 ++ - Name: .fini ++ Type: SHT_PROGBITS ++ Flags: [ SHF_ALLOC, SHF_EXECINSTR ] ++ Address: 0x4101CC ++ AddressAlign: 0x4 ++ Content: 3F2303D5FD7BBFA9FD030091FD7BC1A8BF2303D5C0035FD6 ++ - Name: .eh_frame ++ Type: SHT_PROGBITS ++ Flags: [ SHF_ALLOC ] ++ Address: 0x420068 ++ AddressAlign: 0x8 ++ Content: 1000000000000000017A520004781E011B0C1F0010000000180000003C00FFFF3C0000000041071E140000002C0000006800FFFF08000000000000000000000010000000440000007000FFFF300000000000000010000000580000008C00FFFF3C00000000000000240000006C000000B400FFFF3800000000412D410E209D049E0342930248DEDDD30E00412D0000001400000094000000C400FFFF08000000000000000000000010000000AC00000068FFFEFF080000000000000000000000 ++ - Name: .rela.text ++ Type: SHT_RELA ++ Flags: [ SHF_INFO_LINK ] ++ Link: .symtab ++ AddressAlign: 0x8 ++ Info: .text ++Symbols: ++ - Name: .text ++ Type: STT_SECTION ++ Section: .text ++ Value: 0x410080 ++ - Name: _ITM_deregisterTMCloneTable ++ Binding: STB_WEAK ++ - Name: _ITM_registerTMCloneTable ++ Binding: STB_WEAK ++... +diff --git a/bolt/test/AArch64/dw_cfa_gnu_window_save.test b/bolt/test/AArch64/dw_cfa_gnu_window_save.test +new file mode 100644 +index 000000000000..2e044b399720 +--- /dev/null ++++ b/bolt/test/AArch64/dw_cfa_gnu_window_save.test +@@ -0,0 +1,8 @@ ++# Check that llvm-bolt can handle DW_CFA_GNU_window_save on AArch64. ++ ++RUN: yaml2obj %p/Inputs/dw_cfa_gnu_window_save.yaml &> %t.exe ++RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s ++ ++CHECK-NOT: paciasp ++CHECK-NOT: autiasp ++CHECK-NOT: ERROR: unable to fill CFI. +-- +2.39.2 + diff --git a/llvm-bolt.spec b/llvm-bolt.spec index ee382b6..cebe24f 100755 --- a/llvm-bolt.spec +++ b/llvm-bolt.spec @@ -30,8 +30,9 @@ Patch11: test.patch # header to be able in order to compile. Try to disable as much libraries as # possible in order to reduce build time. Patch12: rm-llvm-libs.diff -# Backport from LLVM 17. +# Backports from LLVM 17. Patch13: 0001-BOLT-NFC-Remove-C-style-out-of-bounds-array-ref.patch +Patch14: 0001-AArch64-fix-bug-55005-handle-DW_CFA_GNU_NegateRAStat.patch
BuildRequires: gcc BuildRequires: gcc-c++
https://src.fedoraproject.org/rpms/llvm-bolt/c/a9ea7288842d8d64bfa0ec96483eb...
scm-commits@lists.fedoraproject.org