Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] _objdump: support LLVM variant

Add support for LLVM variant of objdump (which is used in
recent versions of macOS).
I added all the options listed by 'objdump -help', although several of
them seem to have no effect (simply ignored).

diff --git a/Completion/Unix/Command/_objdump b/Completion/Unix/Command/_objdump
index e012b4cbc..8b0653267 100644
--- a/Completion/Unix/Command/_objdump
+++ b/Completion/Unix/Command/_objdump
@@ -1,12 +1,13 @@
-#compdef objdump eu-objdump
+#compdef objdump eu-objdump llvm-objdump
-local args files variant context state state_descr line
+local opts args files variant curcontext=$context state state_descr line
 typeset -A opt_args
 files='*:object file:_object_files'
-_pick_variant -r variant binutils=GNU elfutils=elfutils unix --version
+_pick_variant -r variant binutils=GNU elfutils=elfutils llvm=LLVM unix --version
+opts=( -s -S )	# options for _arguments
   "(-d --disassemble)"{-d,--disassemble}"[Display assembler code of executable sections]"
   "(-r --reloc)"{-r,--reloc}"[Display relocation information]"
@@ -80,9 +81,74 @@ case $variant in
+  llvm)
+    opts=( -S )	# no option stacking
+    args=(	# start over from an empty array
+      '-aarch64-neon-syntax=[chose style of NEON code (AArch64)]:style:(generic apple)'
+      '-arch=[w -macho: select arch from a fat binary]:arch:(i386 x86_64)'
+      '-arch-name=[specify target arch to disassemble for]:arch:->llvm_targets'
+      '-archive-headers[w -macho: print archive headers]'
+      '-archive-member-offsets[w -macho -archive-headers: print offset to each archive member]'
+      '-bind[display Mach-O binding info]'
+      '-color[use colored syntax highlighting]'
+      '-data-in-code[w -macho: print data in code table]'
+      "-dis-symname=[w -macho: disassemble just the specfied symbol's instructions]"
+      '(-disassemble -d)'{-disassemble,-d}'[display assembler mnemonics for machine instructions]'
+      '(-disassemble-all -D)'{-disassemble-all,-D}'[disassemble all instruction sections]'
+      '-dsym=[w -macho -g: use the specified .dSYM file for debug info]:dsym file:_files'
+      '-dwarf=[dump of dwarf debug section]:section:(frames)'
+      "-dyld-id[w -macho: print the shared library's id for dylib Mach-O file]"
+      '-dylibs-used[w -macho: print the shared libraries used for linked Mach-O files]'
+      '-exports-trie[display Mach-O exported symbols]'
+      '-fault-map-section[display contents of faultmap section]'
+      '-filter-print-funcs=[only print IR for the specified functions]:function names'
+      '-full-leading-addr[w -macho: print full leading address]'
+      '-g[w -macho: print line information from debug info if available]'
+      '-indirect-symbols[w -macho: print indirect symbol table]'
+      '-info-plist[w -macho: print the info plist section]'
+      '-lazy-bind[display Mach-O lazy binding info]'
+      '(-line-numbers -l)'{-line-numbers,-l}'[display source line numbers with disassembly]'
+      '-link-opt-hints[w -macho: print the linker optimization hints]'
+      '(-macho -m)'{-macho,-m}'[use Mach-O specific object file parser]'
+      '*-mattr=[target specific attributes]:attributes'
+      '-mcpu=[specify target cpu type]:cpu type'
+      '-no-leading-addr[w -macho: print no leading address]'
+      '-no-leading-headers[print no leading headers]'
+      '-no-show-raw-insn[do not print instruction bytes when disassembling]'
+      '-no-symbolic-operands[w -macho: do not print operands symbolically when disassembling]'
+      '-non-verbose[w -macho: print info in non-verbose form]'
+      '-objc-meta-data[w -macho: print Objective-C runtime meta data]'
+      '-print-after-all[print IR after each pass]'
+      '-print-before-all[print IR before each pass]'
+      '-print-imm-hex[use hex format for immediate values]'
+      '-private-header[display only the first format specific file header]'
+      '(-private-headers -p)'{-private-headers,-p}'[display format specific file headers]'
+      '-r[display the relocation entries in the file]'
+      '-raw-clang-ast[dump raw binary contents of clang AST section]'
+      '-rebase[display Mach-O rebasing info]'
+      '-rng-seed=[seed for the random number generator]:seed'
+      '-s[display contents of each section]'
+      '*'{-section=,-j}'[operate on the specified section only]:section'
+      '(-section-headers -h)'{-section-headers,-h}'[display summaries of the headers for each section]'
+      '(-source -S)'{-source,-S}'[display source inlined with disassembly]'
+      '-start-address=[start disassembly at the specified address]:address'
+      '-stop-address=[stop disassembly at the specified address]:address'
+      '-t[display the symbol talbe]'
+      '-time-passes[time each pass, print elapsed time on exit]'
+      '-triple=[target triple to disassemble for]:triple'
+      '-universal-headers[w -macho: print Mach-O universal headers]'
+      '-verify-dom-info[verify dominator info (time consuming)]'
+      '-unwind-info[display unwind information]'
+      '-weak-bind[display Mach-O weak binding info]'
+      '-x86-asm-syntax=[chose style of assembler code (x86)]:style:(att intel)'
+      '(- *)-help[display available options]'
+      '(- *)-help-list[display list of available options]'
+      '(- *)-version[display version of objdump]'
+    )
+  ;;
-_arguments -s -S : "$args[@]" $files
+_arguments $opts -C : "$args[@]" $files && return 0
 case "$state" in
@@ -100,6 +166,10 @@ case "$state" in
     _values -s , "disassembler options" "${(@)${(@)${(@M)${(f)${(ps.-M switch.)$(_call_program targets objdump --help)}[2]}:#  [^ ]*}#  }%% *}"
+  llvm_targets)
+    _values "target architecture" "${(z)${(@)${(f)$(_call_program targets
+	    ${~words[1]} -version)##*Registered Targets:}/ -*}}"
+  ;;

Messages sorted by: Reverse Date, Date, Thread, Author