Index: lld/ELF/Driver.cpp =================================================================== --- lld/ELF/Driver.cpp +++ lld/ELF/Driver.cpp @@ -501,6 +501,8 @@ StringRef S = Arg->getValue(); if (S == "binary") return true; + if (S.startswith("elf")) + return false; error("unknown --oformat value: " + S); } return false; Index: lld/test/ELF/oformat-elf.s =================================================================== --- /dev/null +++ lld/test/ELF/oformat-elf.s @@ -0,0 +1,19 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t + +# RUN: ld.lld -o %t.out %t --oformat elf64-x86-64 +# RUN: od -t x1 -v %t.out | FileCheck %s +# CHECK: 0000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 +# CHECK: 0010000 90 11 22 cc cc cc cc cc cc cc cc cc cc cc cc cc + +.text +.align 4 +.globl _start +_start: + nop + +.section .mysec.1,"ax" +.byte 0x11 + +.section .mysec.2,"ax" +.byte 0x22