Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MCAsmStreamer] Do not crash on switching to sections of unknown types #92380

Merged
merged 1 commit into from
May 17, 2024

Conversation

kosarev
Copy link
Collaborator

@kosarev kosarev commented May 16, 2024

MCObjectStreamer already accepts unknown types.

@llvmbot llvmbot added the mc Machine (object) code label May 16, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented May 16, 2024

@llvm/pr-subscribers-mc

Author: Ivan Kosarev (kosarev)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/92380.diff

2 Files Affected:

  • (modified) llvm/lib/MC/MCSectionELF.cpp (+1-2)
  • (modified) llvm/test/MC/ELF/section-numeric-invalid-type.s (+2-2)
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..32ef8fc462a8f 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-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
@@ -11,4 +11,4 @@
 // OBJ-NEXT:   Type: Unknown (0x7FFFFFFF)
 // OBJ:      }
 
-// ASM: unsupported type 0x7fffffff for section .sec
+// ASM: .section .sec,"a",@0x7fffffff

Copy link
Member

@MaskRay MaskRay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most commits don't append a trailing . to the title.

The description can be made to say that this fixes a crash for MCAsmStreamer. MCObjectStreamer already accepts unknown types.

@@ -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 - \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop -o - since it's the default

MCObjectStreamer already accepts unknown types.
@kosarev kosarev changed the title [MC] Do not crash on switching to sections of unknown types. [MCAsmStreamer] Do not crash on switching to sections of unknown types May 17, 2024
@kosarev kosarev merged commit bbe40b9 into llvm:main May 17, 2024
3 of 4 checks passed
@kosarev kosarev deleted the fix-switch-section branch May 17, 2024 10:20
qiaojbao pushed a commit to GPUOpen-Drivers/llvm-project that referenced this pull request Jun 5, 2024
…9650cd441

Local branch amd-gfx c169650 Merged main:b27eb0ae8280675fc8fb249d39f1ccafa3ee2187 into amd-gfx:ea66a9b7b6c7
Remote branch main bbe40b9 [MCAsmStreamer] Do not crash on switching to sections of unknown types (llvm#92380)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants