[llvm] f8a9536 - [JITLink][ELF][AArch64] Implement eh frame handling.
Sunho Kim via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 10 12:06:47 PDT 2022
Author: Sunho Kim
Date: 2022-06-11T04:06:14+09:00
New Revision: f8a9536c55815caf46839063eb88d90b3ab1e93a
URL: https://github.com/llvm/llvm-project/commit/f8a9536c55815caf46839063eb88d90b3ab1e93a
DIFF: https://github.com/llvm/llvm-project/commit/f8a9536c55815caf46839063eb88d90b3ab1e93a.diff
LOG: [JITLink][ELF][AArch64] Implement eh frame handling.
Implements eh frame handling by using generic EHFrame passes. The c++ exception handling works correctly with this change.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D127063
Added:
llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_ehframe.s
Modified:
llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
index 0f6f73192e175..e6b44b11e91be 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
@@ -11,9 +11,11 @@
//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/JITLink/ELF_aarch64.h"
+#include "EHFrameSupportImpl.h"
#include "ELFLinkGraphBuilder.h"
#include "JITLinkGeneric.h"
#include "llvm/BinaryFormat/ELF.h"
+#include "llvm/ExecutionEngine/JITLink/DWARFRecordSectionSplitter.h"
#include "llvm/ExecutionEngine/JITLink/aarch64.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Support/Endian.h"
@@ -402,6 +404,10 @@ void link_ELF_aarch64(std::unique_ptr<LinkGraph> G,
PassConfiguration Config;
const Triple &TT = G->getTargetTriple();
if (Ctx->shouldAddDefaultTargetPasses(TT)) {
+ Config.PrePrunePasses.push_back(DWARFRecordSectionSplitter(".eh_frame"));
+ Config.PrePrunePasses.push_back(EHFrameEdgeFixer(
+ ".eh_frame", 8, aarch64::Pointer32, aarch64::Pointer64,
+ aarch64::Delta32, aarch64::Delta64, aarch64::NegDelta32));
if (auto MarkLive = Ctx->getMarkLivePass(TT))
Config.PrePrunePasses.push_back(std::move(MarkLive));
else
diff --git a/llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_ehframe.s b/llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_ehframe.s
new file mode 100644
index 0000000000000..ff7e5a6546f6f
--- /dev/null
+++ b/llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_ehframe.s
@@ -0,0 +1,80 @@
+# REQUIRES: asserts
+# RUN: llvm-mc -triple=aarch64-linux-gnu -filetype=obj -o %t %s
+# RUN: llvm-jitlink -noexec -phony-externals -debug-only=jitlink %t 2>&1 | \
+# RUN: FileCheck %s
+#
+# Check that splitting of eh-frame sections works.
+#
+# CHECK: DWARFRecordSectionSplitter: Processing .eh_frame...
+# CHECK: Processing block at
+# CHECK: Processing CFI record at
+# CHECK: Extracted {{.*}} section = .eh_frame
+# CHECK: Processing CFI record at
+# CHECK: Extracted {{.*}} section = .eh_frame
+# CHECK: EHFrameEdgeFixer: Processing .eh_frame...
+# CHECK: Processing block at
+# CHECK: Processing CFI record at
+# CHECK: Record is CIE
+# CHECK: Processing block at
+# CHECK: Processing CFI record at
+# CHECK: Record is FDE
+# CHECK: Adding edge at {{.*}} to CIE at: {{.*}}
+# CHECK: Existing edge at {{.*}} to PC begin at {{.*}}
+# CHECK: Adding keep-alive edge from target at {{.*}} to FDE at {{.*}}
+# CHECK: Processing block at
+# CHECK: Processing CFI record at
+# CHECK: Record is FDE
+# CHECK: Adding edge at {{.*}} to CIE at: {{.*}}
+# CHECK: Existing edge at {{.*}} to PC begin at {{.*}}
+# CHECK: Adding keep-alive edge from target at {{.*}} to FDE at {{.*}}
+
+ .text
+ .globl main
+ .p2align 2
+ .type main, at function
+main:
+ .cfi_startproc
+ sub sp, sp, #32
+ .cfi_def_cfa_offset 32
+ stp x29, x30, [sp, #16]
+ add x29, sp, #16
+ .cfi_def_cfa w29, 16
+ .cfi_offset w30, -8
+ .cfi_offset w29, -16
+ stur wzr, [x29, #-4]
+ mov x0, #4
+ bl __cxa_allocate_exception
+ mov w8, #1
+ str w8, [x0]
+ adrp x1, :got:_ZTIi
+ ldr x1, [x1, :got_lo12:_ZTIi]
+ mov x2, xzr
+ bl __cxa_throw
+.main_end:
+ .size main, .main_end-main
+ .cfi_endproc
+
+ .globl dup
+ .p2align 2
+ .type dup, at function
+dup:
+ .cfi_startproc
+ sub sp, sp, #32
+ .cfi_def_cfa_offset 32
+ stp x29, x30, [sp, #16]
+ add x29, sp, #16
+ .cfi_def_cfa w29, 16
+ .cfi_offset w30, -8
+ .cfi_offset w29, -16
+ stur wzr, [x29, #-4]
+ mov x0, #4
+ bl __cxa_allocate_exception
+ mov w8, #1
+ str w8, [x0]
+ adrp x1, :got:_ZTIi
+ ldr x1, [x1, :got_lo12:_ZTIi]
+ mov x2, xzr
+ bl __cxa_throw
+.dup_end:
+ .size dup, .dup_end-dup
+ .cfi_endproc
\ No newline at end of file
More information about the llvm-commits
mailing list