[PATCH] D71101: [lld][RISCV] Use an e_flags of 0 if there are only binary input files.

John Baldwin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 17:19:18 PST 2019


bsdjhb updated this revision to Diff 234421.
bsdjhb added a comment.

- Add a comment and expand the description in the commit log.
- Rename test from riscv-binary.s to riscv-elf-flags.s


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71101/new/

https://reviews.llvm.org/D71101

Files:
  lld/ELF/Arch/RISCV.cpp
  lld/test/ELF/riscv-elf-flags.s


Index: lld/test/ELF/riscv-elf-flags.s
===================================================================
--- /dev/null
+++ 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: ]
Index: lld/ELF/Arch/RISCV.cpp
===================================================================
--- lld/ELF/Arch/RISCV.cpp
+++ lld/ELF/Arch/RISCV.cpp
@@ -106,7 +106,10 @@
 }
 
 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());
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71101.234421.patch
Type: text/x-patch
Size: 834 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191218/cfd7aeb2/attachment.bin>


More information about the llvm-commits mailing list