From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2765 invoked by alias); 29 May 2017 05:05:56 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41177 Received: (qmail 7280 invoked from network); 29 May 2017 05:05:56 -0000 X-Qmail-Scanner-Diagnostics: from rcpt-mqugw.biglobe.ne.jp by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(133.208.100.3):SA:0(-0.7/5.0):. Processed in 1.057958 secs); 29 May 2017 05:05:56 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: takimoto-j@kba.biglobe.ne.jp X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at spf01.biglobe.ne.jp designates 133.208.100.3 as permitted sender) X-Biglobe-Sender: From: "Jun T." Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: [PATCH] _nm: support macOS and OpenBSD Message-Id: <017A0CCA-3F02-4DC8-8E2A-AF822E0BD69D@kba.biglobe.ne.jp> Date: Mon, 29 May 2017 13:28:38 +0900 To: "zsh-workers@zsh.org" Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) X-Mailer: Apple Mail (2.1510) X-Biglobe-Spnum: 60701 Added support for darwin and openbsd. (FreeBSD is now using elftoolchain. NetBSD and dragonfly are still using binutils.) Also included a few updates for elftoolchain/elfutils. diff --git a/Completion/Unix/Command/_nm b/Completion/Unix/Command/_nm index 963b43f..146a69e 100644 --- a/Completion/Unix/Command/_nm +++ b/Completion/Unix/Command/_nm @@ -5,55 +5,62 @@ local args files variant files=3D"*:object file:_object_files" args=3D( '(-A -o --print-file-name)'{-A,-o,--print-file-name}'[print name of = input file on each line]' - '(--demangle)-C[decode symbol names]' + '(--demangle --no-demangle)-C[decode symbol names]' '(-D --dynamic)'{-D,--dynamic}'[display dynamic symbols instead of = normal ones]' '(-g --extern-only)'{-g,--extern-only}'[display only global symbols]' '(-t --radix -o -x)'{-t,--radix}'[specify radix for numeric = values]:radix:((d\:decimal o\:octal x\:hexadecimal))' ) =20 if _pick_variant -r variant binutils=3DGNU elftoolchain=3Delftoolchain = elfutils=3Delfutils unix -V; then - compset -P '@' && files=3D'*:options file:_files' args+=3D( '(- *)--help[display help information]' - '(- *)--version[display version information]' + '(- *)'{-V,--version}'[display version information]' '(-f --format -P --portability)-B[same as --format=3Dbsd]' - '(-C --no-demangle)--demangle=3D-[decode symbol names]::style:(auto = gnu lucid arm hp edg gnu-v3 java gnat)' - "(-C --demangle)--no-demangle[don't decode symbol names]" '(-u --undefined-only)--defined-only[display only defined symbols]' '(-f --format -P)--format=3D[specify output format]:format:(bsd = sysv posix)' '(-n --numeric-sort -p --no-sort --size-sort = -v)'{-n,--numeric-sort}'[sort symbols numerically by address]' - '(-p --no-sort -n --numeric-sort -r -P --reverse-sort = --size-sort)'{-p,--no-sort}'[do not sort symbols]' + '(-p --no-sort -n -v --numeric-sort -r --reverse-sort = --size-sort)'{-p,--no-sort}'[do not sort symbols]' '(-P --portability -B -f --format)'{-P,--portability}'[same as = --format=3Dposix]' - '(-r --reverse-sort -p --no-sort --size-sort = -v)'{-r,--reverse-sort}'[reverse sort order]' + '(-r --reverse-sort -p --no-sort)'{-r,--reverse-sort}'[reverse sort = order]' '(-u --undefined-only = --defined-only)'{-u,--undefined-only}'[display only undefined symbols]' '(-a --debug-syms)'{-a,--debug-syms}'[display debugger-only = symbols]' '(-S --print-size)'{-S,--print-size}'[print size of defined = symbols]' '(-s --print-armap)'{-s,--print-armap}'[include index for symbols = from archive members]' - '(-p --no-sort -n --numeric-sort -r -v)--size-sort[sort symbols by = size]' ) case $variant in elftoolchain|binutils) args+=3D( '(-l --line-numbers)'{-l,--line-numbers}'[display source file = and line numbers from debug information]' + "(-C --demangle)--no-demangle[don't decode symbol names]" + '(-p --no-sort -n -v --numeric-sort)--size-sort[sort symbols by = size]' + '(-n --numeric-sort -p --no-sort --size-sort)-v[sort symbols = numerically by address]' + '(- *)-h[display help information]' ) ;| elftoolchain) - args=3D( ${args:#*--(portability|extern-only)\[*} - '(- *)-h[display help information]' - '(-t -x)-o[print values in octal]' - '(-t -o)-x[print values in hexadecimal]' - '(--size-sort)-v[sort output by value]' + args=3D( ${args:#*(-C|-o|--portability)\[*} + '(-C --demangle)'{-C,--demangle=3D-}'[decode symbol = names]::style:(auto gnu-v2 gnu-v3 arm)' + '(-g --extern-only)-e[only display global and static symbols]' + '(--format -P)-F+[specify output format]:format:(bsd sysv = posix)' + '-o[with -P, same as -t o; otherwise same as -A]' + '(-t --radix)-x[print values in hexadecimal]' ) ;; elfutils) args+=3D( '--mark-special[mark special symbols]' '--color=3D[use color in output]:color:(always auto never)' + '(-C)--demangle[decode symbol names]' + '(--format -P)-f+[specify output format]:format:(bsd sysv = posix)' + '(- *)--usage[give a short usage message]' + '(- *)-\\?[display help information]' ) ;; binutils) + compset -P '@' && files=3D'*:options file:_files' args+=3D( '(-f --format -P)-f+[specify output format]:format:(bsd sysv = posix)' + '(-C --no-demangle)--demangle=3D-[decode symbol = names]::style:(auto gnu lucid arm hp edg gnu-v3 java gnat)' '--plugin[load specified plugin]:plugin' '--special-syms[include special symbols in the output]' '--synthetic[display synthetic symbols as well]' @@ -63,22 +70,65 @@ if _pick_variant -r variant binutils=3DGNU = elftoolchain=3Delftoolchain elfutils=3Delfu ;; esac else - # following flags are accurate for Solaris - args=3D( ${args:#(|*\)(\*|))-[o-]*} - "-h[don't display column headers]" - '-l[distinguish WEAK symbols with * character]' - '(-t -x)-o[print values in octal]' - '(-v)-n[sort symbols by name]' - '(-P)-p[produce parsable output]' - '(-p)-P[portable output format]' - '(-r)-R[print archive name, object file and symbol name]' - '-r[prepend name of input file to each symbol name]' - '-s[print section name instead of index]' - '-u[print undefined symbols only]' - '(-n)-v[sort external symbols by value]' - '-V[display version of the nm command]' - '(-o -t)-x[print values in hexadecimal]' - ) + case $OSTYPE in + (darwin*|openbsd*) + args=3D( + '(-A -o)'{-A,-o}'[prepend file name to each output line]' + '(-g)-a[display all symbols including those for debuggers]' + '(-a)-g[display only global symbols]' + '(-U)-u[display only undefined symbols]' + '(-p)-n[sort numerically rather than alphabetically]' + "(-n -r)-p[don't sort; display in symbol-table order]" + '(-p)-r[sort in reverse order]' + '(-j)-P[print information in a portable format]' + '(-j)-t[specify radix for numeric values (used with = -P)]:radix:((d\:decimal o\:octal x\:hexadecimal))' + );| + (darwin*) + args+=3D( + "(-u)-U[don't display undefined symbols]" + '-f[display symbol table of dynamic library flat]' + '(-P -t -m)-j[just display symbol names (no value or type)]' + '-l[display .section_start if no symbol is in the section (used = with -s)]' + '(-j)-m[use verbose format for Mach-O symbols]' + '-s[list only symbols in the specified section]:segment name: = :section name: ' + "-x[display symbol table entry's fields in hexadecimal]" + '*-arch[select architecture from universal = file]:architecture:(all i386 x86_64)' + );; + (openbsd*) + args+=3D( + '-C[decode low-level symbol names]' + '-D[display dynamic symbol table instead of normal symbol = table]' + '-e[output extended information]' + '-s[show archive index]' + '-w[warn about non-object archive members]' + );; + (solaris*) + args=3D( ${args:#(|*\)(\*|))-[o-]*} + "-h[don't display column headers]" + '-l[distinguish WEAK symbols with * character]' + '(-t -x)-o[print values in octal]' + '(-v)-n[sort symbols by name]' + '(-P)-p[produce parsable output]' + '(-p)-P[portable output format]' + '(-r)-R[print archive name, object file and symbol name]' + '-r[prepend name of input file to each symbol name]' + '-s[print section name instead of index]' + '-u[print undefined symbols only]' + '(-n)-v[sort external symbols by value]' + '-V[display version of the nm command]' + '(-o -t)-x[print values in hexadecimal]' + );; + (*) + # minimal POSIX + args=3D( + '-A[print name of input file on each line]' + '(-u)-g[display only global symbols]' + '-P[print information in a portable format]' + '-t[specify radix for numeric values]:radix:((d\:decimal = o\:octal x\:hexadecimal))' + '(-g)-u[display only undefined symbols]' + '-v[sort symbols by value instead of by name]' + );; + esac fi =20 -_arguments -s "$args[@]" $files +_arguments -s -S : "$args[@]" $files