llvm-nm supports --just-symbol-name which omits the address and the symbol key. % llvm-nm -D --just-symbol-name =cat _ITM_deregisterTMCloneTable _ITM_registerTMCloneTable __ctype_b_loc@GLIBC_2.3 __ctype_get_mb_cur_max@GLIBC_2.2.5 __cxa_atexit@GLIBC_2.2.5 __cxa_finalize@GLIBC_2.2.5 __errno_location@GLIBC_2.2.5 ... % llvm-nm --just-symbol-name a.o __llvm_profile_filename __llvm_profile_raw_version __profd_foo __profd_main foo main puts Without the option, the user can pipe the output to cut % nm a.o | cut -c20- 20 needs to be tuned for ELFCLASS32.
Created attachment 13305 [details] Proposed patch
Hi Fangrui, To me this option sounds like a new output format. So please take a look at the attached patch which adds --format=just-symbols (or -j for short). Does this meet your needs ? Cheers Nick
Hi Nick, thanks for the patch! --format=just-symbols and -j look good to me. I wonder whether it is necessary to reserve -J. -J can probably be used for other purposes.
The master branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1996d0f12cd57391e01e0eebe32e44510e6ec17d commit 1996d0f12cd57391e01e0eebe32e44510e6ec17d Author: Nick Clifton <nickc@redhat.com> Date: Mon Mar 15 10:55:49 2021 +0000 Add a symbols-only mode to nm. PR 27487 * nm.c (FORMAT_JUST_SYMBOLS): Define. (struct optput_fns): Add entry for FORMAT_JUST_SYMBOLS. (long_options): Add just-symbols. (set_output_format): Add support for just-symbols. (get_print_format): Likewise. (do_not_print_object_filename): New function. (do_not_print_archive_filename): New function. (do_not_print_archive_member): New function. (do_not_print_symbol_filename): New function. (just_print_symbol_name): New function. (main): Handle --just-symbols. * NEWS: Mention the new feature. * doc/binutils.texi: Document the new feature.
Good point. '-J' removed. Patch committed. :-)
Fixed in 2.37.