about summary refs log tree commit diff
path: root/Completion/Unix/Command/_readelf
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Command/_readelf')
-rw-r--r--Completion/Unix/Command/_readelf62
1 files changed, 62 insertions, 0 deletions
diff --git a/Completion/Unix/Command/_readelf b/Completion/Unix/Command/_readelf
new file mode 100644
index 000000000..9312ea864
--- /dev/null
+++ b/Completion/Unix/Command/_readelf
@@ -0,0 +1,62 @@
+#compdef readelf eu-readelf
+
+local variant args sections
+
+_elf_file() {
+  [[ -x $REPLY || $REPLY = (core*|*.([ao]|so|elf)) ]]
+}
+
+sections=( .bss .data .dynamic .dynsym .got .interp .shstrtab .symtab .text )
+_pick_variant -r variant elftoolchain=elftoolchain elfutils=elfutils binutils --version
+
+args=(
+  '(-a --all)'{-a,--all}'[show all tables]'
+  '(-h --file-header)'{-h,--file-header}'[show file header]'
+  '(-l --program-headers --segments)'{-l,--program-headers,--segments}'[show program headers]'
+  '(-S --section-headers --sections)'{-S,--section-headers,--sections}'[show sections header]'
+  '(-s --syms --symbols)'{-s,--syms,--symbols}'[show symbol table]'
+  '(-n --notes)'{-n,--notes}'[show core notes (if present)]'
+  '(-r --relocs)'{-r,--relocs}'[show relocations (if present)]'
+  '(-d --dynamic)'{-d,--dynamic}'[show dynamic section (if present)]'
+  '(-V --version-info)'{-V,--version-info}'[show version sections (if present)]'
+  '(-A --arch-specific)'{-A,--arch-specific}'[show architecture specific information (if any)]'
+  '(-c --archive-index)'{-c,--archive-index}'[show symbol/file index in an archive]'
+  \*{-x,--hex-dump=}"[dump contents of specified section as bytes]:section:($sections)"
+  \*{-p,--string-dump=}"[dump contents of specified section as strings]:section:($sections)"
+  '-w+[show the contents of DWARF2 debug sections]::debug section:(l L i a p r m f F s o R t)'
+  '--debug-dump=[show the contents of DWARF2 debug sections]::section:(rawline decodedline info abbrev pubnames aranges macro frames frames-interp str loc Ranges pubtypes gdb_index trace_info trace_abbrev trace_aranges)'
+  '(-I --histogram)'{-I,--histogram}'[show histogram of bucket list lengths]'
+  '(-W --wide)'{-W,--wide}'[allow output width to exceed 80 characters]'
+  '(- *)'{-H,--help}'[display help information]'
+  '(- *)'{-v,--version}'[display version information]'
+  "*:elf file:_files -g '*(-.e:_elf_file:)'"
+)
+
+case $variant in
+  elftoolchain|binutils)
+    args+=(
+      '(-g --section-groups)'{-g,--section-groups}'[show section groups]'
+      '(-t --section-details)'{-t,--section-details}'[show section details]'
+      '(-e --headers)'{-e,--headers}'[show file, program and sections headers]'
+      '(-u --unwind)'{-u,--unwind}'[show unwind info (if present)]'
+      '(-D --use-dynamic)'{-D,--use-dynamic}'[use dynamic section info when showing symbols]'
+    )
+  ;|
+  binutils)
+    args+=(
+      '--dyn-syms[show dynamic symbol table]'
+      \*{-R,--relocated-dump=}"[dump contents of specified section as relocated bytes]:section:($sections)"
+      "--dwarf-depth=[don't show DIEs at greater than specified depth]:depth"
+      '--dwarf-start=[show DIEs starting at specified depth or deeper]:depth'
+    )
+  ;;
+  elfutils)
+    args+=(
+      '--elf-section[used specified section as ELF input data]::section'
+      '(-e --exception)'{-e,--exception}'[show sections for exception handling]'
+      '(-N --numeric-addresses)'{-N,--numeric-addresses}"[don't find symbol names for addresses in DWARF data]"
+    )
+  ;;
+esac
+
+_arguments -s "$args[@]"