[lld] 1129132 - [ELF] Support --oformat= beside Separate --oformat

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 28 18:44:32 PST 2021


Author: Fangrui Song
Date: 2021-11-28T18:44:23-08:00
New Revision: 11291326cd983288117b52e955e7936548373c89

URL: https://github.com/llvm/llvm-project/commit/11291326cd983288117b52e955e7936548373c89
DIFF: https://github.com/llvm/llvm-project/commit/11291326cd983288117b52e955e7936548373c89.diff

LOG: [ELF] Support --oformat= beside Separate --oformat

Both GNU ld's manpage and ours use --oformat= as the canonical form.
It's odd that we do not support it...

Added: 
    

Modified: 
    lld/ELF/Options.td
    lld/test/ELF/oformat-binary.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index 7f04e052fd317..3bb358c457d3c 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -304,8 +304,8 @@ def no_undefined: F<"no-undefined">,
 def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
   HelpText<"Path to file to write output">;
 
-def oformat: Separate<["--"], "oformat">, MetaVarName<"<format>">,
-  HelpText<"Specify the binary format for the output object file">;
+defm oformat: EEq<"oformat", "Specify the binary format for the output object file">,
+  MetaVarName<"[elf,binary]">;
 
 def omagic: FF<"omagic">, MetaVarName<"<magic>">,
   HelpText<"Set the text and data sections to be readable and writable, do not page align sections, link against static libraries">;

diff  --git a/lld/test/ELF/oformat-binary.s b/lld/test/ELF/oformat-binary.s
index 4b2ad8ec711fd..38af6805140fc 100644
--- a/lld/test/ELF/oformat-binary.s
+++ b/lld/test/ELF/oformat-binary.s
@@ -1,7 +1,7 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
 
-# RUN: ld.lld -o %t.out %t --oformat binary
+# RUN: ld.lld -o %t.out %t --oformat=binary
 # RUN: od -t x1 -v %t.out | FileCheck %s
 # CHECK:      0000000 90 11 22
 # CHECK-NEXT: 0000003
@@ -46,7 +46,7 @@
 # ERR: unknown --oformat value: foo
 
 # RUN: ld.lld -o /dev/null %t --oformat elf
-# RUN: ld.lld -o /dev/null %t --oformat elf-foo
+# RUN: ld.lld -o /dev/null %t --oformat=elf-foo
 
 .text
 .align 4


        


More information about the llvm-commits mailing list