[lld] 6506907 - [ELF] Update comments/diagnostics for -defsym and -image-base to use the canonical two-dash form

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 25 14:01:41 PDT 2021


Author: Fangrui Song
Date: 2021-10-25T14:01:36-07:00
New Revision: 6506907a0a1a8a789ad7036ef911f7e31213c9a5

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

LOG: [ELF] Update comments/diagnostics for -defsym and -image-base to use the canonical two-dash form

Added: 
    

Modified: 
    lld/ELF/Driver.cpp
    lld/ELF/Options.td
    lld/test/ELF/arm-thumb-interwork-thunk-range.s
    lld/test/ELF/defsym.s
    lld/test/ELF/image-base.s
    lld/test/ELF/x86-64-plt-high-addr.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 8f0002f58c3c..51b35439e790 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1489,9 +1489,9 @@ void LinkerDriver::createFiles(opt::InputArgList &args) {
       StringRef to;
       std::tie(from, to) = StringRef(arg->getValue()).split('=');
       if (from.empty() || to.empty())
-        error("-defsym: syntax error: " + StringRef(arg->getValue()));
+        error("--defsym: syntax error: " + StringRef(arg->getValue()));
       else
-        readDefsym(from, MemoryBufferRef(to, "-defsym"));
+        readDefsym(from, MemoryBufferRef(to, "--defsym"));
       break;
     }
     case OPT_script:
@@ -1636,11 +1636,11 @@ static Optional<uint64_t> getImageBase(opt::InputArgList &args) {
   StringRef s = arg->getValue();
   uint64_t v;
   if (!to_integer(s, v)) {
-    error("-image-base: number expected, but got " + s);
+    error("--image-base: number expected, but got " + s);
     return 0;
   }
   if ((v % config->maxPageSize) != 0)
-    warn("-image-base: address isn't multiple of page size: " + s);
+    warn("--image-base: address isn't multiple of page size: " + s);
   return v;
 }
 

diff  --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index 2bd635693db8..d0a6ee26f81c 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -256,7 +256,7 @@ def ignore_function_address_equality: F<"ignore-function-address-equality">,
 def ignore_data_address_equality: F<"ignore-data-address-equality">,
   HelpText<"lld can break the address equality of data">;
 
-defm image_base: Eq<"image-base", "Set the base address">;
+defm image_base: EEq<"image-base", "Set the base address">;
 
 defm init: Eq<"init", "Specify an initializer function">,
   MetaVarName<"<symbol>">;

diff  --git a/lld/test/ELF/arm-thumb-interwork-thunk-range.s b/lld/test/ELF/arm-thumb-interwork-thunk-range.s
index 3c013183791b..db50c3bc2cd2 100644
--- a/lld/test/ELF/arm-thumb-interwork-thunk-range.s
+++ b/lld/test/ELF/arm-thumb-interwork-thunk-range.s
@@ -1,6 +1,6 @@
 // REQUIRES: arm
 // RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
-// RUN: ld.lld %t.o -o /dev/null -image-base=0x80000000
+// RUN: ld.lld %t.o -o /dev/null --image-base=0x80000000
 
 // Test that when the thunk is at a high address we don't get confused with it
 // being out of range.

diff  --git a/lld/test/ELF/defsym.s b/lld/test/ELF/defsym.s
index bb5e78346cb8..0168ce854cc1 100644
--- a/lld/test/ELF/defsym.s
+++ b/lld/test/ELF/defsym.s
@@ -13,7 +13,7 @@
 ## when handling the second --defsym.
 # RUN: not ld.lld -o /dev/null %t.o --defsym ERR+ \
 #        --defsym foo2=foo1 2>&1 | FileCheck %s --check-prefix=ERR
-# ERR: error: -defsym: syntax error: ERR+
+# ERR: error: --defsym: syntax error: ERR+
 
 # CHECK-DAG: 0000000000000123     0 NOTYPE  GLOBAL DEFAULT   ABS foo1
 # CHECK-DAG: 0000000000000123     0 NOTYPE  GLOBAL DEFAULT   ABS foo2
@@ -36,16 +36,16 @@
 # EXPR-DAG: 0000000000000128     0 NOTYPE  GLOBAL DEFAULT   ABS foo2
 
 # RUN: not ld.lld -o /dev/null %t.o --defsym=foo2=und 2>&1 | FileCheck %s -check-prefix=ERR1
-# ERR1: error: -defsym:1: symbol not found: und
+# ERR1: error: --defsym:1: symbol not found: und
 
 # RUN: not ld.lld -o /dev/null %t.o --defsym=xxx=yyy,zzz 2>&1 | FileCheck %s -check-prefix=ERR2
-# ERR2: -defsym:1: EOF expected, but got ,
+# ERR2: error: --defsym:1: EOF expected, but got ,
 
 # RUN: not ld.lld -o /dev/null %t.o --defsym=foo 2>&1 | FileCheck %s -check-prefix=ERR3
-# ERR3: error: -defsym: syntax error: foo
+# ERR3: error: --defsym: syntax error: foo
 
 # RUN: not ld.lld -o /dev/null %t.o --defsym= 2>&1 | FileCheck %s -check-prefix=ERR4
-# ERR4: error: -defsym: syntax error:
+# ERR4: error: --defsym: syntax error:
 
 .globl foo1
  foo1 = 0x123

diff  --git a/lld/test/ELF/image-base.s b/lld/test/ELF/image-base.s
index 8396eaf1082a..f6bb26400b92 100644
--- a/lld/test/ELF/image-base.s
+++ b/lld/test/ELF/image-base.s
@@ -1,16 +1,16 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: ld.lld -image-base=0x1000000 %t -o %t1
+# RUN: ld.lld --image-base=0x1000000 %t -o %t1
 # RUN: llvm-readobj -l %t1 | FileCheck %s
 
-# RUN: not ld.lld -image-base=ABC %t -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s
-# ERR: error: -image-base: number expected, but got ABC
+# RUN: not ld.lld --image-base=ABC %t -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s
+# ERR: error: --image-base: number expected, but got ABC
 
-# RUN: ld.lld -image-base=0x1000 -z max-page-size=0x2000 %t -o %t1 2>&1 | FileCheck --check-prefix=WARN %s
-# WARN: warning: -image-base: address isn't multiple of page size: 0x1000
+# RUN: ld.lld --image-base=0x1000 -z max-page-size=0x2000 %t -o %t1 2>&1 | FileCheck --check-prefix=WARN %s
+# WARN: warning: --image-base: address isn't multiple of page size: 0x1000
 
 # Check alias.
-# RUN: ld.lld -image-base 0x1000000 %t -o %t1
+# RUN: ld.lld --image-base 0x1000000 %t -o %t1
 # RUN: llvm-readobj -l %t1 | FileCheck %s
 
 .global _start

diff  --git a/lld/test/ELF/x86-64-plt-high-addr.s b/lld/test/ELF/x86-64-plt-high-addr.s
index 9eef3e15a57c..64d6d9297bdc 100644
--- a/lld/test/ELF/x86-64-plt-high-addr.s
+++ b/lld/test/ELF/x86-64-plt-high-addr.s
@@ -4,7 +4,7 @@
 // RUN: ld.lld -o %t.so -shared %t1.o -soname=so
 
 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t2.o
-// RUN: ld.lld -o %t1.exe %t2.o %t.so -image-base=0xcafe00000000
+// RUN: ld.lld -o %t1.exe %t2.o %t.so --image-base=0xcafe00000000
 // RUN: llvm-objdump -s -j .got.plt %t1.exe | FileCheck %s
 
 // CHECK:      Contents of section .got.plt:
@@ -12,7 +12,7 @@
 // CHECK-NEXT: cafe00003390 00000000 00000000 a6120000 feca0000
 
 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t2.o
-// RUN: ld.lld -o %t2.exe %t2.o %t.so -image-base=0xcafe00000000 -z retpolineplt
+// RUN: ld.lld -o %t2.exe %t2.o %t.so --image-base=0xcafe00000000 -z retpolineplt
 // RUN: llvm-objdump -s -j .got.plt %t2.exe | FileCheck --check-prefix=RETPOLINE %s
 
 // RETPOLINE:      Contents of section .got.plt:


        


More information about the llvm-commits mailing list