From e36223c85cd49858a808a2420144b64cad37839f Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 15 May 2020 10:48:46 -0700 Subject: [PATCH] [ELF] Enforce two dashes for Flag options not supported by GNU ld (i.e. no compatibility burden) Announced on https://lists.llvm.org/pipermail/llvm-dev/2020-May/141416.html Similar to D79371, but for `multiclass B` (convenience helper for defining --foo and --no-foo) Some changed options are also used by gold, but I haven't seen their one-dash use cases outside of lld's testsuite. --- lld/ELF/Options.td | 33 +++++++++++++--------- lld/test/ELF/debug-gnu-pubnames.s | 2 +- lld/test/ELF/dynstr-no-rosegment.s | 2 +- lld/test/ELF/eh-frame-padding-no-rosegment.s | 2 +- lld/test/ELF/elf-header.s | 2 +- lld/test/ELF/execute-only-mixed-data.s | 2 +- lld/test/ELF/execute-only.s | 2 +- lld/test/ELF/gdb-index-no-debug.s | 2 +- .../ELF/invalid/invalid-debug-relocations.test | 2 +- lld/test/ELF/segments.s | 2 +- lld/test/ELF/sort-norosegment.s | 2 +- 11 files changed, 29 insertions(+), 24 deletions(-) diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td index ecef228..a6ca642 100644 --- a/lld/ELF/Options.td +++ b/lld/ELF/Options.td @@ -13,6 +13,11 @@ multiclass EEq { HelpText; } +multiclass BB { + def NAME: Flag<["--"], name>, HelpText; + def no_ # NAME: Flag<["--"], "no-" # name>, HelpText; +} + // For options whose names are multiple letters, either one dash or // two can precede the option name except those that start with 'o'. class F: Flag<["--", "-"], name>; @@ -55,7 +60,7 @@ defm compress_debug_sections: defm defsym: Eq<"defsym", "Define a symbol alias">, MetaVarName<"=">; -defm optimize_bb_jumps: B<"optimize-bb-jumps", +defm optimize_bb_jumps: BB<"optimize-bb-jumps", "Remove direct jumps at the end to the next basic block", "Do not remove any direct jumps at the end to the next basic block (default)">; @@ -86,11 +91,11 @@ defm allow_shlib_undefined: B<"allow-shlib-undefined", "Allow unresolved references in shared libraries (default when linking a shared library)", "Do not allow unresolved references in shared libraries (default when linking an executable)">; -defm apply_dynamic_relocs: B<"apply-dynamic-relocs", +defm apply_dynamic_relocs: BB<"apply-dynamic-relocs", "Apply link-time values for dynamic relocations", "Do not apply link-time values for dynamic relocations (default)">; -defm dependent_libraries: B<"dependent-libraries", +defm dependent_libraries: BB<"dependent-libraries", "Process dependent library specifiers from input files (default)", "Ignore dependent library specifiers from input files">; @@ -101,7 +106,7 @@ defm as_needed: B<"as-needed", defm call_graph_ordering_file: Eq<"call-graph-ordering-file", "Layout sections to optimize the given callgraph">; -defm call_graph_profile_sort: B<"call-graph-profile-sort", +defm call_graph_profile_sort: BB<"call-graph-profile-sort", "Reorder sections with call graph profile (default)", "Do not reorder sections with call graph profile">; @@ -168,7 +173,7 @@ def error_unresolved_symbols: F<"error-unresolved-symbols">, defm exclude_libs: Eq<"exclude-libs", "Exclude static libraries from automatic export">; -defm execute_only: B<"execute-only", +defm execute_only: BB<"execute-only", "Mark executable sections unreadable", "Mark executable sections readable (default)">; @@ -200,11 +205,11 @@ defm gc_sections: B<"gc-sections", "Enable garbage collection of unused sections", "Disable garbage collection of unused sections (default)">; -defm gdb_index: B<"gdb-index", +defm gdb_index: BB<"gdb-index", "Generate .gdb_index section", "Do not generate .gdb_index section (default)">; -defm gnu_unique: B<"gnu-unique", +defm gnu_unique: BB<"gnu-unique", "Enable STB_GNU_UNIQUE symbol binding (default)", "Disable STB_GNU_UNIQUE symbol binding">; @@ -244,7 +249,7 @@ defm merge_exidx_entries: B<"merge-exidx-entries", "Enable merging .ARM.exidx entries (default)", "Disable merging .ARM.exidx entries">; -defm mmap_output_file: B<"mmap-output-file", +defm mmap_output_file: BB<"mmap-output-file", "Mmap the output file for writing (default)", "Do not mmap the output file for writing">; @@ -288,7 +293,7 @@ defm pack_dyn_relocs: Eq<"pack-dyn-relocs", "Pack dynamic relocations in the given format">, MetaVarName<"[none,android,relr,android+relr]">; -defm use_android_relr_tags: B<"use-android-relr-tags", +defm use_android_relr_tags: BB<"use-android-relr-tags", "Use SHT_ANDROID_RELR / DT_ANDROID_RELR* tags instead of SHT_RELR / DT_RELR*", "Use SHT_RELR / DT_RELR* tags (default)">; @@ -325,7 +330,7 @@ def print_map: F<"print-map">, defm reproduce: Eq<"reproduce", "Write a tar file containing input files and command line options to reproduce link">; -defm rosegment: B<"rosegment", +defm rosegment: BB<"rosegment", "Put read-only non-executable sections in their own segment (default)", "Do not put read-only non-executable sections in their own segment">; @@ -417,7 +422,7 @@ def version: F<"version">, HelpText<"Display the version number and exit">; defm version_script: Eq<"version-script", "Read a version script">; -defm warn_backrefs: B<"warn-backrefs", +defm warn_backrefs: BB<"warn-backrefs", "Warn about backward symbol references to fetch archive members", "Do not warn about backward symbol references to fetch archive members (default)">; @@ -431,11 +436,11 @@ defm warn_common: B<"warn-common", "Warn about duplicate common symbols", "Do not warn about duplicate common symbols (default)">; -defm warn_ifunc_textrel: B<"warn-ifunc-textrel", +defm warn_ifunc_textrel: BB<"warn-ifunc-textrel", "Warn about using ifunc symbols with text relocations", "Do not warn about using ifunc symbols with text relocations (default)">; -defm warn_symbol_ordering: B<"warn-symbol-ordering", +defm warn_symbol_ordering: BB<"warn-symbol-ordering", "Warn about problems with the symbol ordering file (default)", "Do not warn about problems with the symbol ordering file">; @@ -533,7 +538,7 @@ def opt_remarks_format: Separate<["--"], "opt-remarks-format">, def save_temps: F<"save-temps">; def lto_basicblock_sections: JJ<"lto-basicblock-sections=">, HelpText<"Enable basic block sections for LTO">; -defm lto_unique_bb_section_names: B<"lto-unique-bb-section-names", +defm lto_unique_bb_section_names: BB<"lto-unique-bb-section-names", "Give unique names to every basic block section for LTO", "Do not give unique names to every basic block section for LTO (default)">; def shuffle_sections: JJ<"shuffle-sections=">, MetaVarName<"">, diff --git a/lld/test/ELF/debug-gnu-pubnames.s b/lld/test/ELF/debug-gnu-pubnames.s index 11244e7..51a289e 100644 --- a/lld/test/ELF/debug-gnu-pubnames.s +++ b/lld/test/ELF/debug-gnu-pubnames.s @@ -6,7 +6,7 @@ # CHECK: .debug_gnu_pubnames # CHECK: .debug_gnu_pubtypes -# RUN: ld.lld -gdb-index %t.o -o %t2.exe +# RUN: ld.lld --gdb-index %t.o -o %t2.exe # RUN: llvm-readobj --sections %t2.exe | FileCheck %s --check-prefix=GDB # GDB-NOT: .debug_gnu_pubnames # GDB-NOT: .debug_gnu_pubtypes diff --git a/lld/test/ELF/dynstr-no-rosegment.s b/lld/test/ELF/dynstr-no-rosegment.s index bad6300..b0ea881 100644 --- a/lld/test/ELF/dynstr-no-rosegment.s +++ b/lld/test/ELF/dynstr-no-rosegment.s @@ -2,7 +2,7 @@ # Verify that a .dynstr in the .text segment has null byte terminators # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -# RUN: ld.lld %t.o -no-rosegment -o %t.so -shared +# RUN: ld.lld %t.o --no-rosegment -o %t.so -shared # RUN: llvm-objdump %t.so -s -j .dynstr | FileCheck %s # CHECK: 00666f6f 00 .foo. diff --git a/lld/test/ELF/eh-frame-padding-no-rosegment.s b/lld/test/ELF/eh-frame-padding-no-rosegment.s index 754903e..fe4c312 100644 --- a/lld/test/ELF/eh-frame-padding-no-rosegment.s +++ b/lld/test/ELF/eh-frame-padding-no-rosegment.s @@ -32,7 +32,7 @@ bar: // OBJ-NEXT: 0020: 20000000 00000000 00000000 00000000 // OBJ-NEXT: ) -// RUN: ld.lld --hash-style=sysv %t.o -no-rosegment -o %t -shared +// RUN: ld.lld --hash-style=sysv %t.o --no-rosegment -o %t -shared // Check that .eh_frame is in the same segment as .text // RUN: llvm-readelf -l %t | FileCheck --check-prefix=PHDR %s diff --git a/lld/test/ELF/elf-header.s b/lld/test/ELF/elf-header.s index da8fe34..aedbe43 100644 --- a/lld/test/ELF/elf-header.s +++ b/lld/test/ELF/elf-header.s @@ -3,7 +3,7 @@ # RUN: ld.lld %t.o -o %t1 # RUN: llvm-readobj --file-headers %t1 | FileCheck %s -# RUN: ld.lld %t.o -no-rosegment -o %t2 +# RUN: ld.lld %t.o --no-rosegment -o %t2 # RUN: llvm-readobj --file-headers %t2 | FileCheck %s # CHECK: ElfHeader { diff --git a/lld/test/ELF/execute-only-mixed-data.s b/lld/test/ELF/execute-only-mixed-data.s index 32248bd..5a03d73 100644 --- a/lld/test/ELF/execute-only-mixed-data.s +++ b/lld/test/ELF/execute-only-mixed-data.s @@ -7,7 +7,7 @@ // RUN: .text : { *(.text) *(.rodata.foo) } \ // RUN: .rodata : { *(.rodata.bar) } \ // RUN: }" > %t.lds -// RUN: not ld.lld -T%t.lds %t.o -o /dev/null -execute-only 2>&1 | FileCheck %s +// RUN: not ld.lld -T%t.lds %t.o -o /dev/null --execute-only 2>&1 | FileCheck %s // RUN: echo "SECTIONS \ // RUN: { \ diff --git a/lld/test/ELF/execute-only.s b/lld/test/ELF/execute-only.s index 7a825cb..24cea11 100644 --- a/lld/test/ELF/execute-only.s +++ b/lld/test/ELF/execute-only.s @@ -1,7 +1,7 @@ // REQUIRES: aarch64 // RUN: llvm-mc -filetype=obj -triple=aarch64-linux-none %s -o %t.o -// RUN: ld.lld -Ttext=0xcafe0000 %t.o -o %t.so -shared -execute-only +// RUN: ld.lld -Ttext=0xcafe0000 %t.o -o %t.so -shared --execute-only // RUN: llvm-readelf -l %t.so | FileCheck %s // CHECK: LOAD {{.*}} 0x00000000cafe0000 0x000004 0x000004 E 0x{{.*}} diff --git a/lld/test/ELF/gdb-index-no-debug.s b/lld/test/ELF/gdb-index-no-debug.s index dba5fcf..fce4f54 100644 --- a/lld/test/ELF/gdb-index-no-debug.s +++ b/lld/test/ELF/gdb-index-no-debug.s @@ -1,6 +1,6 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -# RUN: ld.lld -o %t.exe -gdb-index %t.o +# RUN: ld.lld -o %t.exe --gdb-index %t.o # RUN: llvm-objdump --section-headers %t.exe | FileCheck %s # CHECK-NOT: .gdb_index diff --git a/lld/test/ELF/invalid/invalid-debug-relocations.test b/lld/test/ELF/invalid/invalid-debug-relocations.test index c53a879..25a6b9e 100644 --- a/lld/test/ELF/invalid/invalid-debug-relocations.test +++ b/lld/test/ELF/invalid/invalid-debug-relocations.test @@ -1,6 +1,6 @@ # REQUIRES: x86 # RUN: yaml2obj %s -o %t.o -# RUN: not ld.lld -gdb-index %t.o -o /dev/null 2>&1 | FileCheck %s +# RUN: not ld.lld --gdb-index %t.o -o /dev/null 2>&1 | FileCheck %s # CHECK: error: {{.*}}invalid-debug-relocations.test.tmp.o:(.debug_info+0x0): unknown relocation (255) against symbol _start diff --git a/lld/test/ELF/segments.s b/lld/test/ELF/segments.s index 9b88f48..d9af9a3 100644 --- a/lld/test/ELF/segments.s +++ b/lld/test/ELF/segments.s @@ -45,7 +45,7 @@ # ROSEGMENT-NEXT: Alignment: 4096 # ROSEGMENT-NEXT: } -# RUN: ld.lld -no-rosegment %t -o %t2 +# RUN: ld.lld --no-rosegment %t -o %t2 # RUN: llvm-readobj --program-headers %t2 | FileCheck --check-prefix=NOROSEGMENT %s # NOROSEGMENT: ProgramHeader { diff --git a/lld/test/ELF/sort-norosegment.s b/lld/test/ELF/sort-norosegment.s index 37393ce..9bf38ea 100644 --- a/lld/test/ELF/sort-norosegment.s +++ b/lld/test/ELF/sort-norosegment.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -# RUN: ld.lld --hash-style=sysv -no-rosegment -o %t %t.o -shared +# RUN: ld.lld --hash-style=sysv --no-rosegment -o %t %t.o -shared # RUN: llvm-readelf -S %t | FileCheck %s # CHECK: .dynsym {{.*}} A -- 2.7.4