[llvm] [MC] Do not crash on switching to sections of unknown types. (PR #92380)
Ivan Kosarev via llvm-commits
llvm-commits at lists.llvm.org
Fri May 17 03:15:17 PDT 2024
https://github.com/kosarev updated https://github.com/llvm/llvm-project/pull/92380
>From c4298d529ab5a7c2c880ba46fa0319a2da45eb0e Mon Sep 17 00:00:00 2001
From: Ivan Kosarev <ivan.kosarev at amd.com>
Date: Thu, 16 May 2024 11:41:23 +0100
Subject: [PATCH] [MCAsmStreamer] Do not crash on switching to sections of
unknown types
MCObjectStreamer already accepts unknown types.
---
llvm/lib/MC/MCSectionELF.cpp | 3 +--
llvm/test/MC/ELF/section-numeric-invalid-type.s | 6 +++---
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp
index b1efb839ba75f..6bbdef3dce32a 100644
--- a/llvm/lib/MC/MCSectionELF.cpp
+++ b/llvm/lib/MC/MCSectionELF.cpp
@@ -175,8 +175,7 @@ void MCSectionELF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
else if (Type == ELF::SHT_LLVM_LTO)
OS << "llvm_lto";
else
- report_fatal_error("unsupported type 0x" + Twine::utohexstr(Type) +
- " for section " + getName());
+ OS << "0x" << Twine::utohexstr(Type);
if (EntrySize) {
assert(Flags & ELF::SHF_MERGE);
diff --git a/llvm/test/MC/ELF/section-numeric-invalid-type.s b/llvm/test/MC/ELF/section-numeric-invalid-type.s
index fefc364d9917b..b707b51c5ecce 100644
--- a/llvm/test/MC/ELF/section-numeric-invalid-type.s
+++ b/llvm/test/MC/ELF/section-numeric-invalid-type.s
@@ -1,7 +1,7 @@
-// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux-gnu %s -o - \
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux-gnu %s \
// RUN: | llvm-readobj -S --symbols - | FileCheck --check-prefix=OBJ %s
-// RUN: not --crash llvm-mc -filetype=asm -triple=x86_64-pc-linux-gnu %s -o - 2>&1 \
+// RUN: llvm-mc -filetype=asm -triple=x86_64-pc-linux-gnu %s \
// RUN: | FileCheck --check-prefix=ASM %s
.section .sec,"a", at 0x7fffffff
@@ -11,4 +11,4 @@
// OBJ-NEXT: Type: Unknown (0x7FFFFFFF)
// OBJ: }
-// ASM: unsupported type 0x7fffffff for section .sec
+// ASM: .section .sec,"a", at 0x7fffffff
More information about the llvm-commits
mailing list