1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00
Commit Graph

389 Commits

Author SHA1 Message Date
Fangrui Song
5aac6f60bc [llvm-nm] Remove one-dash long options except -arch
The documentation and help messages have recommended the double-dash forms for
quite a while. Remove one-dash long options which are not recognized by GNU
style `getopt_long`.

`-arch` is kept as it is in the manpage of classic nm
https://keith.github.io/xcode-man-pages/nm.1.html

Note: the dyldinfo related options don't have a test.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D105948
2021-07-15 09:50:37 -07:00
Fangrui Song
3586ecfc1a [llvm-nm] Switch command line parsing from llvm::cl to OptTable
Part of https://lists.llvm.org/pipermail/llvm-dev/2021-July/151622.html
"Binary utilities: switch command line parsing from llvm::cl to OptTable"

Users should generally observe no difference as long as they only use intended
option forms. Behavior changes:

* `-t=d` is removed. Use `-t d` instead.
* `--demangle=0` cannot be used. Omit the option or use `--no-demangle` instead.
* `--help-list` is removed. This is a `cl::` specific option.

Note:

* `-t` diagnostic gets improved.
* This patch avoids cl::opt collision if we decide to support multiplexing for binary utilities
* One-dash long options are still supported.
* The `-s` collision (`-s segment section` for Mach-O) is unfortunate. `-s` means `--print-armap` in GNU nm.
* This patch removes the last `cl::multi_val` use case from the `llvm/lib/Support/CommandLine.cpp` library

`-M` (`--print-armap`), `-U` (`--defined-only`), and `-W` (`--no-weak`)
are now deprecated. They could conflict with future GNU nm options.
(--print-armap has an existing alias -s, so GNU will unlikely add a new one.
--no-weak (not in GNU nm) is rarely used anyway.)

`--just-symbol-name` is now deprecated in favor of
`--format=just-symbols` and `-j`.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D105330
2021-07-07 13:34:33 -07:00
Martin Storsjö
b2438b1473 [llvm-nm] Support the -V option, print that the tool is compatible with GNU nm
This unlocks some codepaths in libtool.

Differential Revision: https://reviews.llvm.org/D102321
2021-05-13 22:36:25 +03:00
gbreynoo
db4cc8e963 [llvm-nm] Help option output should be consistent with the command guide
The nm command guide shows the short options used as aliases but these
are not found in the help text unless --show-hidden is used, other tools
show aliases with --help. This change fixes the help output to be
consistent with the command guide.

Differential Revision: https://reviews.llvm.org/D102072
2021-05-10 17:25:41 +01:00
Yvan Roux
dbfefbf5ff [llvm-symbolizer][llvm-nm] Fix AArch64 and ARM mapping symbols handling.
Exclude AArch64 mapping symbols ($x and $d) for symtab symbolization as
it was done for ARM since D95916 tom bring bots back to green state.

This is implemented by setting SF_FormatSpecific such that
llvm-symbolizer will ignore them, and use this flag to re-implement
llvm-nm --special-syms option which make it work for both targets.

Differential Revision: https://reviews.llvm.org/D98803
2021-03-23 14:17:12 +01:00
Fangrui Song
d3961f8ad2 [llvm-nm] Add --format=just-symbols and make --just-symbol-name its alias
https://sourceware.org/bugzilla/show_bug.cgi?id=27487 binutils will have
--format=just-symbols/-j as well.

Arbitrarily prefer `-j` to `--format=sysv`. Previously `--format=sysv -j` prints
in the sysv format while `-j` takes precedence over other formats.

Differential Revision: https://reviews.llvm.org/D98569
2021-03-16 10:07:01 -07:00
Keith Smiley
30b780a55a llvm-nm: add flag to suppress no symbols warning
This spelling matches binutils https://sourceware.org/bugzilla/show_bug.cgi?id=27408

Differential Revision: https://reviews.llvm.org/D83152
2021-03-07 16:20:13 -08:00
James Henderson
a9c28d33d4 [llvm-nm] Tidy up error messages
This adds colons to separate the file name from the message, removes a
duplicate space, and removes a trailing full stop from some messages.
These help bring the error messages into line with other tools, as well
as making all llvm-nm message more self-consistent.

Differential Revision: https://reviews.llvm.org/D96601

Reviewed by: Higuoxing, rupprecht, MaskRay
2021-02-15 13:54:08 +00:00
Yang Fan
39bdc30ed4 [NFC][llvm-nm] Fix unused variable warning 2021-01-29 11:42:23 +08:00
Fangrui Song
6e141a22c9 [llvm-nm] Display defined weak STT_GNU_IFUNC symbols as 'i'
This patch makes the behavior match GNU nm.
Note: undefined STT_GNU_IFUNC symbols use 'U'.

Differential Revision: https://reviews.llvm.org/D95461
2021-01-28 09:46:05 -08:00
Martin Storsjö
9488dbd041 [llvm-nm] Silence a gcc warning about a stray semicolon. NFC. 2021-01-26 12:29:14 +02:00
Georgii Rymar
a91e7c7d2b [llvm-nm][ELF] - Use @@ prefix when printing default versions.
llvm-readelf prints default versions with `@@` prefix.
This patch does the same for llvm-nm.

Differential revision: https://reviews.llvm.org/D94912
2021-01-26 12:16:38 +03:00
Georgii Rymar
2900e3238f [libObject,llvm-readelf/obj] - Don't use @@ when printing versions of undefined symbols.
A default version (@@) is only available for defined symbols.

Currently we use "@@" for undefined symbols too.
This patch fixes the issue and improves our test case.

Differential revision: https://reviews.llvm.org/D95219
2021-01-26 12:05:59 +03:00
Georgii Rymar
e9ef9e434c [llvm-nm][ELF] - Make -D display symbol versions.
This fixes https://bugs.llvm.org/show_bug.cgi?id=48670.

Since binutils 2.35, nm -D displays symbol versions by default.
This patch teaches llvm-nm to do the same.

Differential revision: https://reviews.llvm.org/D94907
2021-01-21 11:23:45 +03:00
Georgii Rymar
e13cf8d1c8 [llvm-nm] - Simplify the code in dumpSymbolNamesFromObject. NFC.
It is possible to simplify the logic that extracts symbol names.

D94667 made the `NMSymbol::Name` to be `std::string`,
what allowed this simplification.

Differential revision: https://reviews.llvm.org/D94669
2021-01-15 12:29:49 +03:00
Georgii Rymar
0906a7aca7 [llvm-nm] - Move MachO specific logic out from the dumpSymbolNamesFromObject(). NFC.
`dumpSymbolNamesFromObject` is the method that dumps symbol names.

It has 563 lines, mostly because of huge piece of MachO specific code.
In this patch I move it to separate helper method.

The new size of `dumpSymbolNamesFromObject` is 93 lines. With it it becomes
much easier to maintain it.

I had to change the type of 2 name fields to `std::string`, because MachO logic
uses temporarily buffer strings (e.g `ExportsNameBuffer`, `BindsNameBuffer` etc):

```
  std::string ExportsNameBuffer;
  raw_string_ostream EOS(ExportsNameBuffer);
```

these buffers were moved to `dumpSymbolsFromDLInfoMachO` by this patch and
invalidated after return. Technically, before this patch we had a situation
when local pointers (symbol names) were assigned to members of global static `SymbolList`,
what is dirty by itself.

Differential revision: https://reviews.llvm.org/D94667
2021-01-15 12:18:37 +03:00
Kazu Hirata
586535f9e6 [llvm] Use isa instead of dyn_cast (NFC) 2021-01-01 12:44:56 -08:00
Kazu Hirata
df35ddafb7 [llvm-nm, llvm-objdump] Use llvm::is_contained (NFC) 2020-12-25 09:22:37 -08:00
Francis Visoiu Mistrih
2f99b5b70e [llvm-nm][MachO] Don't call getFlags on redacted symbols
Avoid calling getFlags on a non-existent symbol.

The way this is triggered is by calling strip -N on a binary, which sets
the MH_NLIST_OUTOFSYNC_WITH_DYLDINFO header flag. Then, in the
LC_FUNCTION_STARTS command, nm is trying to print the stripped symbols
and needs the proper checks.
2020-12-04 21:48:53 -08:00
serge-sans-paille
82b6e6053d llvmbuildectomy - replace llvm-build by plain cmake
No longer rely on an external tool to build the llvm component layout.

Instead, leverage the existing `add_llvm_componentlibrary` cmake function and
introduce `add_llvm_component_group` to accurately describe component behavior.

These function store extra properties in the created targets. These properties
are processed once all components are defined to resolve library dependencies
and produce the header expected by llvm-config.

Differential Revision: https://reviews.llvm.org/D90848
2020-11-13 10:35:24 +01:00
Fangrui Song
2e45ee1e4c [llvm-nm] Use aggregate initialization instead of memset zero 2020-09-16 10:27:12 -07:00
Peter Collingbourne
7d1cbe5a8a llvm-nm: Implement --special-syms.
Differential Revision: https://reviews.llvm.org/D82251
2020-06-22 13:05:47 -07:00
Cyndy Ishida
fd46376e35 [llvm][llvm-nm] add TextAPI/MachO support
Summary:
This completes the needed glueing to support reading tbd files from nm.
This includes specifying which slice filtering with `--arch` and a new
option specifically for tbd files `--add-inlinedinfo` which will show
the reexported libraries that are appended in the tbd file.

Reviewers: ributzka, steven_wu, JDevlieghere, jhenderson

Reviewed By: JDevlieghere

Subscribers: hiraditya, MaskRay, dexonsmith, rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81614
2020-06-11 18:54:16 -07:00
Xing GUO
7653f25b98 [llvm-nm/objdump/size] Add tests for dumping symbol tables with invalid sh_size.
This change adds tests for llvm-nm, llvm-objdump and llvm-size when dumping symbol tables with invalid sh_size (sh_size % sizeof(Elf_Sym) != 0).

Reviewed By: jhenderson, MaskRay

Differential Revision: https://reviews.llvm.org/D77864
2020-05-06 17:01:20 +08:00
vgxbj
bbdc25ab11 [Object] Change uint32_t getSymbolFlags() to Expected<uint32_t> getSymbolFlags().
This change enables getSymbolFlags() to return errors which benefit error reporting in clients.

Differential Revision: https://reviews.llvm.org/D77860
2020-04-18 21:27:57 +08:00
Benjamin Kramer
87d13166c7 Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.

This is mostly mechanical from a custom clang-tidy check, with a lot of
manual fixups. It uncovers a lot of minor inefficiencies.

This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-28 23:25:25 +01:00
Fangrui Song
e480c416f6 Reland "[llvm-nm] Don't report "no symbols" error for files that contain symbols" 2020-01-17 10:08:42 -08:00
Sam Clegg
8e90006f5a Revert "[llvm-nm] Don't report "no symbols" error for files that contain symbols"
This reverts commit ab974161ba699534f3e30b1f4b036eec9c33053c.

This change broke several tests, and the pre-commit bot even warning
me that it would. Doh!
2020-01-17 09:57:32 -08:00
Sam Clegg
e162b6ec2d [llvm-nm] Don't report "no symbols" error for files that contain symbols
Previously we were reporting this error if we were list no symbols
which is not the same thing as the file containing no symbols.

Also, always report the filename when printing errors.

This matches the GNU nm behaviour.

This a followup to https://reviews.llvm.org/D52810

Differential Revision: https://reviews.llvm.org/D72658
2020-01-17 09:30:55 -08:00
Sam Clegg
641286a21a [llvm-nm] Use StringRef over const std::string & params
Differential Revision: https://reviews.llvm.org/D72718
2020-01-16 14:02:58 -08:00
Fangrui Song
8e823f1246 [llvm-nm] Display STT_GNU_IFUNC as 'i'
Reviewed By: grimar

Differential Revision: https://reviews.llvm.org/D71803
2019-12-25 09:47:53 -08:00
Cyndy Ishida
c58a95b452 Revert [llvm-nm] Add tapi file support
This reverts r371576 (git commit f88f46358dbffa20af3b054a9346e5154789d50f)

llvm-svn: 371676
2019-09-11 21:35:28 +00:00
Fangrui Song
237f8ee8eb [llvm-nm] Fix -DBUILD_SHARED_LIBS=ON builds after D66160/r371576
llvm-svn: 371585
2019-09-11 01:49:00 +00:00
Cyndy Ishida
5c9f000ded [llvm-nm] Add tapi file support
Summary:
This commit is the final one for adding tapi support to the llvm-nm implementation.
This commit also has accompanying tests the additions to lib/Object

Reviewers: ributzka, steven_wu

Reviewed By: ributzka

Subscribers: hiraditya, plotfi, dexonsmith, rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66160

llvm-svn: 371576
2019-09-11 00:00:53 +00:00
George Rimar
1aecd28b57 [llvm-nm] - Fix a bug and unbreak ASan BB.
BB: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/13820/steps/check-llvm%20asan/logs/stdio

rL371074 revealed a bug in llvm-nm.

This patch fixes it.

llvm-svn: 371318
2019-09-07 19:45:27 +00:00
Sid Manning
439ff91bbd [llvm-nm] Small fix to Exected<StringRef>
Differential Revision: https://reviews.llvm.org/D66976

llvm-svn: 370474
2019-08-30 14:12:04 +00:00
JF Bastien
3fcfd786dd Fix nm on GCC 5.1 after the C++14 move
Summary:
As in D66306, fix the invocation of std::sort with std::function by not using
std::function, since it's easier to read and is broken in libstdc++ from GCC 5.1
(see https://gcc.gnu.org/PR65942).

Reviewers: thakis

Subscribers: jkorous, mgrang, dexonsmith, rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66310

llvm-svn: 369045
2019-08-15 20:38:42 +00:00
George Rimar
21610566c8 Recommit r368812 "[llvm/Object] - Convert SectionRef::getName() to return Expected<>"
Changes: no changes. A fix for the clang code will be landed right on top.

Original commit message:

SectionRef::getName() returns std::error_code now.
Returning Expected<> instead has multiple benefits.

For example, it forces user to check the error returned.
Also Expected<> may keep a valuable string error message,
what is more useful than having a error code.
(Object\invalid.test was updated to show the new messages printed.)

This patch makes a change for all users to switch to Expected<> version.

Note: in a few places the error returned was ignored before my changes.
In such places I left them ignored. My intention was to convert the interface
used, and not to improve and/or the existent users in this patch.
(Though I think this is good idea for a follow-ups to revisit such places
and either remove consumeError calls or comment each of them to clarify why
it is OK to have them).

Differential revision: https://reviews.llvm.org/D66089

llvm-svn: 368826
2019-08-14 11:10:11 +00:00
George Rimar
f64562dc67 Revert r368812 "[llvm/Object] - Convert SectionRef::getName() to return Expected<>"
It broke clang BB: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/16455

llvm-svn: 368813
2019-08-14 08:56:55 +00:00
George Rimar
3a9b0e354d [llvm/Object] - Convert SectionRef::getName() to return Expected<>
SectionRef::getName() returns std::error_code now.
Returning Expected<> instead has multiple benefits.

For example, it forces user to check the error returned.
Also Expected<> may keep a valuable string error message,
what is more useful than having a error code.
(Object\invalid.test was updated to show the new messages printed.)

This patch makes a change for all users to switch to Expected<> version.

Note: in a few places the error returned was ignored before my changes.
In such places I left them ignored. My intention was to convert the interface
used, and not to improve and/or the existent users in this patch.
(Though I think this is good idea for a follow-ups to revisit such places
and either remove consumeError calls or comment each of them to clarify why
it is OK to have them).

Differential revision: https://reviews.llvm.org/D66089

llvm-svn: 368812
2019-08-14 08:46:54 +00:00
Alex Brachet
40547610ff Revert [tools] [llvm-nm] Default to reading from stdin not a.out
This reverts r365889 (git commit 60c81354b1d3fced1bd284d334f118d2d792ab4b)

llvm-svn: 366219
2019-07-16 15:33:43 +00:00
Alex Brachet
c32a25d72b [tools] [llvm-nm] Default to reading from stdin not a.out
Summary: This moves away from defaulting to a.out and uses stdin only if stdin has a file redirected to it. This has been discussed on the llvm-dev mailing list [[ https://lists.llvm.org/pipermail/llvm-dev/2019-July/133642.html | here ]].

Reviewers: jhenderson, rupprecht, MaskRay, chrisjackson

Reviewed By: jhenderson, MaskRay

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D64290

llvm-svn: 365889
2019-07-12 10:20:01 +00:00
Chris Jackson
c94cc22866 [llvm-nm] Fix for BZ41711 - Class character for a symbol with undefined
binding does not match class assigned by GNU nm

 Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=41711

 Differential Revision: https://reviews.llvm.org/D63340

llvm-svn: 364559
2019-06-27 16:27:53 +00:00
Fangrui Song
dc8b667602 [llvm-nm] Generalize ELF symbol types 'N' and 'n'
Reviewed By: grimar, jhenderson

Differential Revision: https://reviews.llvm.org/D63588

llvm-svn: 363918
2019-06-20 10:15:11 +00:00
James Henderson
339634cc14 [llvm-nm] Fix docs and help text for --print-size
The --print-size help text and documentation claimed that the size was
printed instead of the address, but this is incorrect. It is printed as
well as the address. This patch fixes this issue.

Reviewed by: MaskRay, mtrent, ruiu

Differential Revision: https://reviews.llvm.org/D63142

llvm-svn: 363136
2019-06-12 10:44:41 +00:00
Jordan Rupprecht
c14d3f2f48 [llvm-nm] Fix Bug 41353 - unique symbols printed as D instead of u
Summary:
https://bugs.llvm.org/show_bug.cgi?id=41353

I'm new to LLVM and C++ so please do not hesitate to iterate with me on this fix.

Patch by Mike Pozulp!

Reviewers: rupprecht, zbrid, grimar, jhenderson

Reviewed By: rupprecht, jhenderson

Subscribers: jhenderson, chrisjackson, MaskRay, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D61117

llvm-svn: 361595
2019-05-24 04:02:05 +00:00
Michael Trent
91eaabf2d1 Update llvm-nm -s to use a multi-var option
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

Reviewers: lhames, pete

Reviewed By: pete

Subscribers: rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D62070

llvm-svn: 361091
2019-05-18 03:17:27 +00:00
Fangrui Song
e23fb5e721 [Object] Fix macho-invalid.test
llvm-svn: 360420
2019-05-10 10:47:30 +00:00
Fangrui Song
d5d0ffef76 [Object] Change SymbolicFile::printSymbolName to use Error
llvm-svn: 360414
2019-05-10 09:59:04 +00:00
Fangrui Song
464931df65 [llvm-nm] Fix handling of symbol types 't' 'd' 'r'
This restores part of r359311 that was reverted by r359830.

Rewrite the symbol types to fix several issues.

Notable difference is that the type of __init_array_start changes from
't' to 'd'.

GNU nm used to mark ELF symbols relative to .init_array as 't'
https://sourceware.org/bugzilla/show_bug.cgi?id=24505 (before 2.33)
because ".init" is the prefix. The bug was copied by r287803.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D61551

llvm-svn: 360339
2019-05-09 12:43:37 +00:00