[lld] [lld] Error on unsupported split stack (PR #88063)
Patrick O'Neill via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 8 18:51:10 PDT 2024
https://github.com/patrick-rivos updated https://github.com/llvm/llvm-project/pull/88063
>From 9bc9fb0aa4374f62c3538d3df1e252e416c85afc Mon Sep 17 00:00:00 2001
From: Patrick O'Neill <patrick at rivosinc.com>
Date: Mon, 8 Apr 2024 15:54:46 -0700
Subject: [PATCH] [lld] Error on unsupported split stack
Targets with no `-fstack-split` support now emit `ld.lld: error: Target doesn't support split stacks.` instead of `UNREACHABLE executed` with a backtrace asking the user to report a bug.
Resolves #88061
---
lld/ELF/Target.cpp | 2 +-
lld/test/ELF/Inputs/riscv-split-stack-callee.s | 4 ++++
lld/test/ELF/riscv-split-stack.s | 15 +++++++++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
create mode 100644 lld/test/ELF/Inputs/riscv-split-stack-callee.s
create mode 100644 lld/test/ELF/riscv-split-stack.s
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index d879a427e9c096..735b2a82d851b4 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -141,7 +141,7 @@ bool TargetInfo::needsThunk(RelExpr expr, RelType type, const InputFile *file,
bool TargetInfo::adjustPrologueForCrossSplitStack(uint8_t *loc, uint8_t *end,
uint8_t stOther) const {
- llvm_unreachable("Target doesn't support split stacks.");
+ fatal("Target doesn't support split stacks.");
}
bool TargetInfo::inBranchRange(RelType type, uint64_t src, uint64_t dst) const {
diff --git a/lld/test/ELF/Inputs/riscv-split-stack-callee.s b/lld/test/ELF/Inputs/riscv-split-stack-callee.s
new file mode 100644
index 00000000000000..f4368e50623fee
--- /dev/null
+++ b/lld/test/ELF/Inputs/riscv-split-stack-callee.s
@@ -0,0 +1,4 @@
+ .globl test
+ .type test, at function
+test:
+ ret
diff --git a/lld/test/ELF/riscv-split-stack.s b/lld/test/ELF/riscv-split-stack.s
new file mode 100644
index 00000000000000..86f9b2711334d3
--- /dev/null
+++ b/lld/test/ELF/riscv-split-stack.s
@@ -0,0 +1,15 @@
+# REQUIRES: riscv
+
+# RUN: llvm-mc -filetype=obj -triple=riscv64 %s -o %t.64.o
+# RUN: llvm-mc -filetype=obj -triple=riscv64 %p/Inputs/riscv-split-stack-callee.s -o %t.64.2.o
+# RUN: not ld.lld %t.64.o %t.64.2.o -o %t.64 2>&1 | FileCheck %s
+# CHECK: ld.lld: error: Target doesn't support split stacks.
+
+ .globl _start
+ .type _start, at function
+_start:
+ call test
+ ret
+end:
+ .size _start, end-_start
+ .section ".note.GNU-split-stack","", at progbits
More information about the llvm-commits
mailing list