[lld] f7c2c32 - [ELF] Properly reject unsupported e_machine
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 12 17:37:33 PST 2024
Author: Fangrui Song
Date: 2024-02-12T17:37:29-08:00
New Revision: f7c2c32c019275e88fd14e401aaa68b760f32a28
URL: https://github.com/llvm/llvm-project/commit/f7c2c32c019275e88fd14e401aaa68b760f32a28
DIFF: https://github.com/llvm/llvm-project/commit/f7c2c32c019275e88fd14e401aaa68b760f32a28.diff
LOG: [ELF] Properly reject unsupported e_machine
Fix an incorrect llvm_unreachable.
Added:
lld/test/ELF/unsupported-emachine.test
Modified:
lld/ELF/Target.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index 671d22cc66a0e9..286db1e3bbe0ef 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -89,8 +89,9 @@ TargetInfo *elf::getTarget() {
return getSPARCV9TargetInfo();
case EM_X86_64:
return getX86_64TargetInfo();
+ default:
+ fatal("unsupported e_machine value: " + Twine(config->emachine));
}
- llvm_unreachable("unknown target machine");
}
ErrorPlace elf::getErrorPlace(const uint8_t *loc) {
diff --git a/lld/test/ELF/unsupported-emachine.test b/lld/test/ELF/unsupported-emachine.test
new file mode 100644
index 00000000000000..43d907ea72d562
--- /dev/null
+++ b/lld/test/ELF/unsupported-emachine.test
@@ -0,0 +1,11 @@
+# RUN: yaml2obj %s -o %t.o
+# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
+
+# CHECK: error: unsupported e_machine value: 9
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_S370
More information about the llvm-commits
mailing list