summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Arch/RISCV.cpp5
-rw-r--r--lld/test/ELF/riscv-elf-flags.s8
2 files changed, 12 insertions, 1 deletions
diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp
index 7b807aa494d..d4acccf80a3 100644
--- a/lld/ELF/Arch/RISCV.cpp
+++ b/lld/ELF/Arch/RISCV.cpp
@@ -108,7 +108,10 @@ static uint32_t getEFlags(InputFile *f) {
}
uint32_t RISCV::calcEFlags() const {
- assert(!objectFiles.empty());
+ // If there are only binary input files (from -b binary), use a
+ // value of 0 for the ELF header flags.
+ if (objectFiles.empty())
+ return 0;
uint32_t target = getEFlags(objectFiles.front());
diff --git a/lld/test/ELF/riscv-elf-flags.s b/lld/test/ELF/riscv-elf-flags.s
new file mode 100644
index 00000000000..137c89db348
--- /dev/null
+++ b/lld/test/ELF/riscv-elf-flags.s
@@ -0,0 +1,8 @@
+# REQUIRES: riscv
+
+# RUN: echo -n "BLOB" > %t.binary
+# RUN: ld.lld -m elf64lriscv -b binary %t.binary -o %t.out
+# RUN: llvm-readobj -h %t.out | FileCheck %s
+
+# CHECK: Flags [
+# CHECK-NEXT: ]
OpenPOWER on IntegriCloud