Skip to content

Commit

Permalink
[MC] Do not crash on switching to sections of unknown types.
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarev committed May 16, 2024
1 parent ba2e4fe commit 25e04db
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/MC/MCSectionELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/MC/ELF/section-numeric-invalid-type.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux-gnu %s -o - \
// 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 -o - \
// RUN: | FileCheck --check-prefix=ASM %s

.section .sec,"a",@0x7fffffff
Expand All @@ -11,4 +11,4 @@
// OBJ-NEXT: Type: Unknown (0x7FFFFFFF)
// OBJ: }

// ASM: unsupported type 0x7fffffff for section .sec
// ASM: .section .sec,"a",@0x7fffffff

0 comments on commit 25e04db

Please sign in to comment.