diff --git a/llvm/docs/CommandGuide/llvm-readobj.rst b/llvm/docs/CommandGuide/llvm-readobj.rst index 201d1df803c0..84f0aa423514 100644 --- a/llvm/docs/CommandGuide/llvm-readobj.rst +++ b/llvm/docs/CommandGuide/llvm-readobj.rst @@ -95,7 +95,7 @@ file formats. Display the relocation entries in the file. -.. option:: --sections, --section-headers, -s, -S +.. option:: --sections, --section-headers, -S Display all sections. @@ -123,7 +123,7 @@ file formats. Display the specified section(s) as a list of strings. ``section`` may be a section index or section name. -.. option:: --symbols, --syms, -t +.. option:: --symbols, --syms, -s Display the symbol table. diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst index ad3905080338..3a18d3667010 100644 --- a/llvm/docs/ReleaseNotes.rst +++ b/llvm/docs/ReleaseNotes.rst @@ -164,6 +164,11 @@ Changes to the LLVM tools ``--x86-asm-syntax`` is a deprecated internal option which will be removed in LLVM 14.0.0. (`D101695 `_) +* The llvm-readobj short aliases ``-s`` (previously ``--sections``) and ``-t`` + (previously ``--syms``) have been changed to ``--syms`` and + ``--section-details`` respectively, to match llvm-readelf. + (`D105055 `_) + Changes to LLDB --------------------------------- diff --git a/llvm/test/tools/llvm-readobj/ELF/merged.test b/llvm/test/tools/llvm-readobj/ELF/merged.test index 5b464ebbdce7..c3df02691f61 100644 --- a/llvm/test/tools/llvm-readobj/ELF/merged.test +++ b/llvm/test/tools/llvm-readobj/ELF/merged.test @@ -52,7 +52,7 @@ DynamicSymbols: ## llvm-readobj does not support merged args, because it also supports some old ## flags (-st, -sd, etc.), and it would be confusing if only some merged args ## were supported. -# RUN: not llvm-readobj -aeWhSrnudlVgIs %t.o 2>&1 | FileCheck %s --check-prefix=UNKNOWN +# RUN: not llvm-readobj -aeWhSsrnudlVgIS %t.o 2>&1 | FileCheck %s --check-prefix=UNKNOWN # CHECK-NOT: Unknown command line argument # UNKNOWN: for the --section-headers option: may only occur zero or one times! diff --git a/llvm/test/tools/llvm-readobj/ELF/sections.test b/llvm/test/tools/llvm-readobj/ELF/sections.test index efd268bcd8e9..73b0cd21617b 100644 --- a/llvm/test/tools/llvm-readobj/ELF/sections.test +++ b/llvm/test/tools/llvm-readobj/ELF/sections.test @@ -10,16 +10,12 @@ # RUN: llvm-readobj --sections %t64 > %t64.llvm.sections # RUN: llvm-readobj -S %t64 > %t64.llvm.upper.s # RUN: cmp %t64.llvm.sections %t64.llvm.upper.s -# RUN: llvm-readobj -s %t64 > %t64.llvm.lower.s -# RUN: cmp %t64.llvm.sections %t64.llvm.lower.s # RUN: llvm-readobj --section-headers %t64 > %t64.llvm.section-headers # RUN: cmp %t64.llvm.sections %t64.llvm.section-headers # RUN: llvm-readobj --sections %t32 > %t32.llvm.sections # RUN: llvm-readobj -S %t32 > %t32.llvm.upper.s # RUN: cmp %t32.llvm.sections %t32.llvm.upper.s -# RUN: llvm-readobj -s %t32 > %t32.llvm.lower.s -# RUN: cmp %t32.llvm.sections %t32.llvm.lower.s # RUN: llvm-readobj --section-headers %t32 > %t32.llvm.section-headers # RUN: cmp %t32.llvm.sections %t32.llvm.section-headers diff --git a/llvm/test/tools/llvm-readobj/ELF/symbols.test b/llvm/test/tools/llvm-readobj/ELF/symbols.test index bd126b2f0333..fd4c07c5cceb 100644 --- a/llvm/test/tools/llvm-readobj/ELF/symbols.test +++ b/llvm/test/tools/llvm-readobj/ELF/symbols.test @@ -70,17 +70,13 @@ # RUN: llvm-readobj --symbols %t64 > %t.symbols # RUN: llvm-readobj --syms %t64 > %t.syms # RUN: cmp %t.symbols %t.syms -# RUN: llvm-readobj -t %t64 > %t.t -# RUN: cmp %t.symbols %t.t -# RUN: llvm-readelf -s --elf-output-style=LLVM %t64 > %t.lowers -# RUN: cmp %t.symbols %t.lowers +# RUN: llvm-readobj -s %t64 | diff %t.symbols - +# RUN: llvm-readelf -s --elf-output-style=LLVM %t64 | diff %t.symbols - # RUN: llvm-readelf --symbols %t64 > %t.symbols.gnu # RUN: llvm-readelf --syms %t64 > %t.syms.gnu # RUN: cmp %t.symbols.gnu %t.syms.gnu - -## -s is an llvm-readobj option to dump sections. -# RUN: llvm-readobj -s --elf-output-style=GNU %t64 | FileCheck %s --implicit-check-not="Symbol table" +# RUN: llvm-readelf -s %t64 | diff %t.symbols.gnu - ## Case 3: Test that both regular and dynamic symbols are dumped when `--symbols` and `--dyn-symbols` ## are specified together. Note that the order is different for different styles. diff --git a/llvm/test/tools/llvm-readobj/basic.test b/llvm/test/tools/llvm-readobj/basic.test index 08c83ad91000..a30ac4eaedef 100644 --- a/llvm/test/tools/llvm-readobj/basic.test +++ b/llvm/test/tools/llvm-readobj/basic.test @@ -54,8 +54,6 @@ HELP: OVERVIEW: LLVM Object Reader OBJ: llvm-readobj{{.*}} [options] ELF: llvm-readelf{{.*}} [options] HELP: OPTIONS: -OBJ: -s - Alias for --section-headers -OBJ: -t - Alias for --symbols -ELF: -s - Alias for --symbols -ELF: -t - Alias for --section-details +HELP -s - Alias for --symbols +HELP -t - Alias for --section-details HELP: @FILE diff --git a/llvm/test/tools/yaml2obj/ELF/duplicate-symbol-names.yaml b/llvm/test/tools/yaml2obj/ELF/duplicate-symbol-names.yaml index 75a25f34ac32..d4883d642fb9 100644 --- a/llvm/test/tools/yaml2obj/ELF/duplicate-symbol-names.yaml +++ b/llvm/test/tools/yaml2obj/ELF/duplicate-symbol-names.yaml @@ -2,7 +2,7 @@ ## containing symbols with duplicate names (but different name suffixes). # RUN: yaml2obj --docnum=1 %s -o %t1 -# RUN: llvm-readobj -t %t1 | FileCheck %s --check-prefix=CASE1 +# RUN: llvm-readobj --syms %t1 | FileCheck %s --check-prefix=CASE1 # CASE1: Name: localfoo (1) # CASE1: Name: localfoo (1) diff --git a/llvm/tools/llvm-readobj/llvm-readobj.cpp b/llvm/tools/llvm-readobj/llvm-readobj.cpp index 86f9a0a85566..8d07688dd07f 100644 --- a/llvm/tools/llvm-readobj/llvm-readobj.cpp +++ b/llvm/tools/llvm-readobj/llvm-readobj.cpp @@ -142,6 +142,10 @@ namespace opts { // Also -t in llvm-readelf mode. cl::opt SectionDetails("section-details", cl::desc("Display the section details")); + static cl::alias SectionDetailsShort("t", + cl::desc("Alias for --section-details"), + cl::aliasopt(SectionDetails), + cl::NotHidden); // --symbols // Also -s in llvm-readelf mode, or -t in llvm-readobj mode. @@ -151,6 +155,9 @@ namespace opts { "symbol table when using GNU output style for ELF")); cl::alias SymbolsGNU("syms", cl::desc("Alias for --symbols"), cl::aliasopt(Symbols)); + static cl::alias SymbolsShort("s", cl::desc("Alias for --symbols"), + cl::aliasopt(Symbols), cl::NotHidden, + cl::Grouping); // --dyn-symbols, --dyn-syms // Also --dt in llvm-readobj mode. @@ -694,16 +701,6 @@ static void dumpInput(StringRef File, ScopedPrinter &Writer) { /// Registers aliases that should only be allowed by readobj. static void registerReadobjAliases() { - // -s has meant --sections for a very long time in llvm-readobj despite - // meaning --symbols in readelf. - static cl::alias SectionsShort("s", cl::desc("Alias for --section-headers"), - cl::aliasopt(opts::SectionHeaders), - cl::NotHidden); - - // llvm-readelf reserves it for --section-details. - static cl::alias SymbolsShort("t", cl::desc("Alias for --symbols"), - cl::aliasopt(opts::Symbols), cl::NotHidden); - // The following two-letter aliases are only provided for readobj, as readelf // allows single-letter args to be grouped together. static cl::alias SectionRelocationsShort( @@ -721,16 +718,6 @@ static void registerReadobjAliases() { /// Registers aliases that should only be allowed by readelf. static void registerReadelfAliases() { - // -s is here because for readobj it means --sections. - static cl::alias SymbolsShort("s", cl::desc("Alias for --symbols"), - cl::aliasopt(opts::Symbols), cl::NotHidden, - cl::Grouping); - - // -t is here because for readobj it is an alias for --symbols. - static cl::alias SectionDetailsShort( - "t", cl::desc("Alias for --section-details"), - cl::aliasopt(opts::SectionDetails), cl::NotHidden); - // Allow all single letter flags to be grouped together. for (auto &OptEntry : cl::getRegisteredOptions()) { StringRef ArgName = OptEntry.getKey();