[lld] f8ee74f - [ELF] Require two-dash form for --pack-dyn-relocs

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 15 15:36:34 PDT 2021


Author: Fangrui Song
Date: 2021-10-15T15:36:30-07:00
New Revision: f8ee74fc130481f5198231f285447a499df2ce40

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

LOG: [ELF] Require two-dash form for --pack-dyn-relocs

LLD specific options can be more rigid.
Also add a test.

Added: 
    

Modified: 
    lld/ELF/Driver.cpp
    lld/ELF/Options.td
    lld/test/ELF/pack-dyn-relocs.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 9b8b34e14f58..0a80e81026c3 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -810,7 +810,7 @@ static std::pair<bool, bool> getPackDynRelocs(opt::InputArgList &args) {
     return {true, true};
 
   if (s != "none")
-    error("unknown -pack-dyn-relocs format: " + s);
+    error("unknown --pack-dyn-relocs format: " + s);
   return {false, false};
 }
 

diff  --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index 852a27d62812..8c95c8ae9e8d 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -314,7 +314,7 @@ defm orphan_handling:
   Eq<"orphan-handling", "Control how orphan sections are handled when linker script used">;
 
 defm pack_dyn_relocs:
-  Eq<"pack-dyn-relocs", "Pack dynamic relocations in the given format">,
+  EEq<"pack-dyn-relocs", "Pack dynamic relocations in the given format">,
   MetaVarName<"[none,android,relr,android+relr]">;
 
 defm use_android_relr_tags: BB<"use-android-relr-tags",

diff  --git a/lld/test/ELF/pack-dyn-relocs.s b/lld/test/ELF/pack-dyn-relocs.s
index 174d72b69dc8..220addac2451 100644
--- a/lld/test/ELF/pack-dyn-relocs.s
+++ b/lld/test/ELF/pack-dyn-relocs.s
@@ -6,6 +6,10 @@
 // RUN: ld.lld -pie --pack-dyn-relocs=none %t.a32.o %t.a32.so -o %t2.a32
 // RUN: llvm-readobj -r %t2.a32 | FileCheck --check-prefix=UNPACKED32 %s
 
+// RUN: not ld.lld --pack-dyn-relocs=invalid %t.a32.o %t.a32.so -o /dev/null 2>&1 | FileCheck %s --check-prefix=UNKNOWN
+
+// UNKNOWN: unknown --pack-dyn-relocs format: invalid
+
 /// Unpacked should have the relative relocations in their natural order.
 /// UNPACKED32:          Section ({{.+}}) .rel.dyn {
 // UNPACKED32-NEXT:     0x30324 R_ARM_RELATIVE -


        


More information about the llvm-commits mailing list