This is an archive of the discontinued LLVM Phabricator instance.

Update llvm-nm -s to use a multi-var option
ClosedPublic

Authored by mtrent on May 17 2019, 11:05 AM.

Details

Summary

Previously llvm-nm relied on a positional parameter to read two values
into the SegSect list. This worked, but required the "-s" paramater and
its arguments to be the last elements on the command-line.

The CommandLine library now supports mutli-var parameters, so it can
naturally deal with "-s" expecting two arguments, and now the input file
can appear anywhere (within reason) in the command line invocation. E.g.

llvm-nm -s __TEXT __text /bin/ls
llvm-nm /bin/ls -s __TEXT __text

rdar://27284011

Diff Detail

Event Timeline

mtrent created this revision.May 17 2019, 11:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2019, 11:05 AM
Herald added a subscriber: rupprecht. · View Herald Transcript
pete accepted this revision.May 17 2019, 5:55 PM

Looks good. That’s nice to see more lines removed than added :)

This revision is now accepted and ready to land.May 17 2019, 5:55 PM
This revision was automatically updated to reflect the committed changes.

It seems that we have some parsing difficulty here:/ I tried to use llvm-nm -s today for --print-armap (GNU/FreeBSD nm) and I noticed that -s is reserved for Mach-O. https://www.unix.com/man-page/osx/1/nm/ says

-s segname sectname
List only those symbols in the section (segname,sectname).

This also appears to be the last use case of cl::multi_val:/ Does -s have a longer option for the SegSect functionality? After all, it has been broken so many years... (the only order which was supported was llvm-nm /bin/ls -s __TEXT __text before this patch).

It seems that we have some parsing difficulty here:/ I tried to use llvm-nm -s today for --print-armap (GNU/FreeBSD nm) and I noticed that -s is reserved for Mach-O. https://www.unix.com/man-page/osx/1/nm/ says

-s segname sectname
List only those symbols in the section (segname,sectname).

This also appears to be the last use case of cl::multi_val:/ Does -s have a longer option for the SegSect functionality? After all, it has been broken so many years... (the only order which was supported was llvm-nm /bin/ls -s __TEXT __text before this patch).

There is no long form replacement for -s.