1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
Commit Graph

346 Commits

Author SHA1 Message Date
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
Simon Pilgrim
91d43e01a2 Remove duplicate assignments. NFCI.
llvm-svn: 360064
2019-05-06 19:10:55 +00:00
Jordan Rupprecht
dc435f6b24 Revert [llvm-nm] Fix handling of symbol types + [llvm-nm] Generalize symbol types
This reverts r359311 and r359312 (git commit 0bf06a8f59b0074a60871865e828d92db8930c59 and 5f184f17800ea2ac27be5e4ab540cb94a46e80c7)

llvm-svn: 359830
2019-05-02 21:42:46 +00:00
Fangrui Song
228858c00c [Object] Change getSectionName() to return Expected<StringRef>
Summary:
It currently receives an output parameter and returns
std::error_code. Expected<StringRef> fits for this purpose perfectly.

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

llvm-svn: 359774
2019-05-02 10:32:03 +00:00
Eugene Leviant
e3c3046708 [llvm-nm] Add --special-syms no-op flag
Differential revision: https://reviews.llvm.org/D60502

llvm-svn: 359563
2019-04-30 13:51:48 +00:00
Fangrui Song
3c007d0f01 [llvm-nm] Simplify and fix a buffer overflow
* char SymbolAddrStr[18] can't hold "%" PRIo64 which may need 22 characters.
* Use range-based for
* Delete unnecessary typedef
* format(...).print(Str, sizeof(Str)) + outs() << Str => outs() << format(...)
* Use cascading outs() << .. << ..
* Use iterator_range(Container &&c)
* (A & B) == B => A & B   if B is a power of 2
* replace null sentinel in constants with makeArrayRef

llvm-svn: 359416
2019-04-29 05:38:22 +00:00
Fangrui Song
9e863883e1 [llvm-nm][llvm-readelf] Avoid single-dash -long-option in tests
llvm-svn: 359383
2019-04-27 16:12:14 +00:00
Fangrui Song
96f2149c99 [llvm-nm] Support section type 'u': STB_GNU_UNIQUE
llvm-svn: 359380
2019-04-27 15:32:53 +00:00
Fangrui Song
dad20dc754 [llvm-nm] Revert inadvertently committed 'i' change in r359314
llvm-svn: 359315
2019-04-26 16:27:11 +00:00
Fangrui Song
a1b48835b2 [ThinLTO] Fix X86/strong_non_prevailing.ll after llvm-nm 'r' change
llvm-svn: 359314
2019-04-26 16:21:51 +00:00
Fangrui Song
b5061735b9 [llvm-nm] Generalize symbol types 'N', 'n' and '?'
llvm-svn: 359312
2019-04-26 16:03:31 +00:00
Fangrui Song
ef40253f3f [llvm-nm] Fix handling of symbol types 't' 'd' 'r'
In addition, fix and convert the two tests to yaml2obj based. This
allows us to delete two executables.

X86/weak.test: 'v' was not tested
X86/init-fini.test: symbol types of __bss_start _edata _end were wrong
  GNU nm reports __init_array_start as 't', and __preinit_array_start as 'd'.
  __init_array_start is 't' just because its section ".init_array" starts with ".init"

  'd' makes more sense and allows us to drop the weird SHT_INIT_ARRAY rule.
  So, change __init_array_start to 'd' instead.

llvm-svn: 359311
2019-04-26 16:01:48 +00:00
Serge Guelton
c3542e3376 Make llvm-nm -help great again
Only display help from the llvm-nm category instead of all llvm options, which make it much more usable.
There's still an issue with -s, which is probably a bug in llvm::cl and worth another commit.

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

llvm-svn: 358185
2019-04-11 15:22:48 +00:00
James Henderson
036792c868 [llvm-nm]Add support for --no-demangle
GNU nm has --no-demangle, so llvm-nm should too. It disables the
--demangle switch. The patch also allows --demangle to be specified
multiple times (the last of all --no-demangle/--demangle switches
takes precedence).

Reviewed by: grimar, rupprecht, mattd

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

llvm-svn: 357575
2019-04-03 12:57:46 +00:00
Sunil Srivastava
b609f580a3 Improve "llvm-nm -f sysv" output for Elf files
Specifically, compute and Print Type and Section columns.

This is a re-commit of rL354833, after fixing the Asan problem found a a buildbot.

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

llvm-svn: 355742
2019-03-08 22:00:50 +00:00
Vlad Tsyrklevich
257ec8cb69 Revert "Improve "llvm-nm -f sysv" output for Elf files"
This reverts commit r354833, it was causing ASan test failures on
sanitizer-x86_64-linux-fast.

llvm-svn: 354849
2019-02-26 07:04:56 +00:00
Sunil Srivastava
7c3181b5bd Improve "llvm-nm -f sysv" output for Elf files
Specifically, compute and Print Type and Section columns.

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

llvm-svn: 354833
2019-02-26 00:19:39 +00:00
Dave Lee
58afb80dde llvm-nm: Observe -no-llvm-bc for archive members
Summary:
This change fixes the `-no-llvm-bc` flag to work with object files within
archives. Currently the `-no-llvm-bc` flag works for regular object files, but
not static libraries, where it continues to show bitcode symbol info.

Original support was added in D4371.

Reviewers: compnerd, smeenai, pcc

Reviewed By: compnerd

Subscribers: rupprecht, keith, llvm-commits

Tags: #llvm

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

llvm-svn: 354196
2019-02-16 06:59:49 +00:00
Sunil Srivastava
10930d44a1 Compute the correct symbol size in llvm-nm even without --print-size
In llvm-nm, the symbol size was being computed only with --print-size option,
even though it was being printed in other cases, such as with --format=posix.

This patch simply removes the guard, so that the size is computed
independently of the later decision to print it or not.

Fixes PR39997.

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

llvm-svn: 353011
2019-02-03 22:40:01 +00:00
Matt Davis
16e0966379 [llvm-nm] Report '.comment' ELF sections as 'n' instead of '?'
Summary:
The previous implementation reported `.comment` sections as '?'
GNU uses 'n' which means  "The symbol is a debugging symbol."  `.note`  sections are represented as 'n' too.

The test related to this change was updated to CHECK-NEXT to ensure
order and that we did not miss any symbols in the dump.

Reviewers: jhenderson

Reviewed By: jhenderson

Subscribers: rupprecht, llvm-commits

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

llvm-svn: 352891
2019-02-01 17:38:08 +00:00
Vedant Kumar
5881cafdd3 [llvm-nm] Print out N_COLD_FUNC as "cold func"
Per post-commit feedback from Mike, have llvm-nm print out this symbol
attribute as "[cold func]".

llvm-svn: 352258
2019-01-26 00:33:15 +00:00
Vedant Kumar
8057a16e18 [MC] Teach the MachO object writer about N_FUNC_COLD
N_FUNC_COLD is a new MachO symbol attribute. It's a hint to the linker
to order a symbol towards the end of its section, to improve locality.

Example:

```
void a1() {}
__attribute__((cold)) void a2() {}
void a3() {}
int main() {
  a1();
  a2();
  a3();
  return 0;
}
```

A linker that supports N_FUNC_COLD will order _a2 to the end of the text
section. From `nm -njU` output, we see:

```
_a1
_a3
_main
_a2
```

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

llvm-svn: 352227
2019-01-25 18:30:22 +00:00
Chandler Carruth
ae65e281f3 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00
Saurabh Badhwar
dff123d1a1 [llvm-nm] Allow --size-sort to print symbols with only Symbol size
Summary:
When llvm-nm is passed only the --size-sort option for an object file, there is no output generated.
The commit modifies the behavior to print the symbols sorted and their size which is also inline with
the output of the GNU nm tool.

Signed-off-by: Saurabh Badhwar <sbsaurabhbadhwar9@gmail.com>

Reviewers: enderby, rupprecht

Reviewed By: rupprecht

Subscribers: llvm-commits

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

llvm-svn: 351347
2019-01-16 14:38:22 +00:00
James Henderson
81bc305168 [llvm-nm] Add --portability as alias for --format=posix
GNU nm supports this alias, so supporting it in llvm-nm makes it easier
to transition between the two.

Fixes https://bugs.llvm.org/show_bug.cgi?id=40002

Reviewed by: mstorsjo, rupprecht

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

llvm-svn: 350522
2019-01-07 14:12:51 +00:00
Jordan Rupprecht
dcc03de9b8 [binutils] NFC: fix clang-tidy warning: use empty() instead of size() == 0
llvm-svn: 349710
2018-12-20 00:57:06 +00:00
Francis Visoiu Mistrih
230dbd2b22 [llvm-nm] Fix use-after-free for MachOUniversalBinaries
MachOObjectFile::getHostArch() returns a temporary, and getArchName
returns a StringRef pointing to a temporary std::string.

No tests since it doesn't trigger any errors except with the sanitizers.

llvm-svn: 347230
2018-11-19 17:19:50 +00:00
Jonas Devlieghere
7972433688 [llvm-nm] Use WithColor for error reporting
Use helpers from Support/WithError.h to print errors.

llvm-svn: 346624
2018-11-11 22:12:21 +00:00
Jonas Devlieghere
681a56eed2 [Support] Make error banner optional in logAllUnhandledErrors
In a lot of places an empty string was passed as the ErrorBanner to
logAllUnhandledErrors. This patch makes that argument optional to
simplify the call sites.

llvm-svn: 346604
2018-11-11 01:46:03 +00:00
Fangrui Song
6c158e8d71 [llvm-nm] Simplify. NFC
Change a \t to spaces
Change some zero-filling memcpy to aggregate initialization
Delete redundant ArchiveName.clear() after declaration

llvm-svn: 345367
2018-10-26 06:56:51 +00:00
Jordan Rupprecht
31ccce8fd0 [llvm-nm] Fix crash when running with --print-armap on corrupt archives.
error() in llvm-nm intentionally does not return so that the callee can move on to future files/slices. When printing the archive map, this is not currently handled (the caller assumes that error() returns), so processing continues despite there being an error.

Also, change one return to a break, so that symbols can be printed even if the archive map is corrupt.

llvm-svn: 344268
2018-10-11 17:55:11 +00:00
Martin Storsjo
1020912cfb [llvm-nm] Include the text "@FILE" in the output of --help
libtool requires this text to be present, in order to conclude that
the tool supports response files. Also add an explicit test of using
response files with llvm-nm.

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

llvm-svn: 344222
2018-10-11 06:53:38 +00:00
Petr Hosek
95955db0b5 [llvm-nm] Write "no symbol" output to stderr
This matches the output of binutils' nm and ensures that any scripts
or tools that use nm and expect empty output in case there no symbols
don't break.

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

llvm-svn: 343887
2018-10-05 21:10:03 +00:00
Jordan Rupprecht
d5effeb47c [llvm-nm] Print an explicit "no symbols" message when an object file has no symbols
Summary:
GNU nm (and other nm implementations, such as "go tool nm") prints an explicit "no symbols" message when an object file has no symbols. Currently llvm-nm just doesn't print anything. Adding an explicit "no symbols" message will allow llvm-nm to be used in place of nm: some scripts and build processes use `nm <file> | grep "no symbols"` as a test to see if a file has no symbols. It will also be more familiar to anyone used to nm.

That said, the format implemented here is slightly different, in that it doesn't print the tool name in the message (which IMHO is not useful to include).

Demo:
```
$ for nm in nm bin/llvm-nm ; do echo "nm implementation: $nm"; $nm /tmp/foo{1,2}.o; echo; done
nm implementation: nm

/tmp/foo1.o:
nm: /tmp/foo1.o: no symbols

/tmp/foo2.o:
0000000000000000 T foo2

nm implementation: bin/llvm-nm

/tmp/foo1.o:
no symbols

/tmp/foo2.o:
0000000000000000 T foo2
```

Reviewers: MaskRay

Reviewed By: MaskRay

Subscribers: llvm-commits

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

llvm-svn: 343742
2018-10-03 23:39:49 +00:00
Fangrui Song
c2791239be llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)
Summary: The convenience wrapper in STLExtras is available since rL342102.

Reviewers: dblaikie, javed.absar, JDevlieghere, andreadb

Subscribers: MatzeB, sanjoy, arsenm, dschuff, mehdi_amini, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, eraman, aheejin, kbarton, JDevlieghere, javed.absar, gbedwell, jrtc27, mgrang, atanasyan, steven_wu, george.burgess.iv, dexonsmith, kristina, jsji, llvm-commits

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

llvm-svn: 343163
2018-09-27 02:13:45 +00:00
Dave Lee
1320ae98e2 nm: Add -no-weak flag for hiding weak symbols
Summary:
This adds a new -no-weak flag to nm to hide weak symbols in its output.
This also adds a -W alias for this which is analogous to -U.

Patch by Keith Smiley

Reviewers: kastiglione, enderby, compnerd

Reviewed By: kastiglione

Subscribers: llvm-commits

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

llvm-svn: 336126
2018-07-02 17:24:37 +00:00
Sam Clegg
b0362616c3 Fix debug build by adding missing dependencies on libBinaryFormat
Debug BUILD_SHARED_LIBS build was broken by rL332305

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

llvm-svn: 332315
2018-05-15 00:46:43 +00:00
Rui Ueyama
04fb9911c5 Define InitLLVM to do common initialization all at once.
We have a few functions that virtually all command wants to run on
process startup/shutdown. This patch adds InitLLVM class to do that
all at once, so that we don't need to copy-n-paste boilerplate code
to each llvm command's main() function.

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

llvm-svn: 330046
2018-04-13 18:26:06 +00:00
Mandeep Singh Grang
3cf1a994cb [tools] Change std::sort to llvm::sort in response to r327219
Summary:
r327219 added wrappers to std::sort which randomly shuffle the container before sorting.
This will help in uncovering non-determinism caused due to undefined sorting
order of objects having the same key.

To make use of that infrastructure we need to invoke llvm::sort instead of std::sort.

Note: This patch is one of a series of patches to replace *all* std::sort to llvm::sort.
Refer the comments section in D44363 for a list of all the required patches.

Reviewers: JDevlieghere, zturner, echristo, dberris, friss

Reviewed By: echristo

Subscribers: gbedwell, llvm-commits

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

llvm-svn: 328943
2018-04-01 21:24:53 +00:00
Kevin Enderby
f1015c1f29 Try to fix sanitizer-x86_64-linux-fast bot due to change in r328820.
llvm-svn: 328824
2018-03-29 20:49:24 +00:00
Kevin Enderby
c8edddc947 For llvm-nm and Mach-O files that are fully stripped, special case a redacted LC_MAIN
As a further refinement on:

r328274 - For llvm-nm and Mach-O files also use function starts info in some cases when printing symbols

we want to special case a redacted LC_MAIN so it is easier to find.

rdar://38978929

llvm-svn: 328820
2018-03-29 20:04:29 +00:00
Kevin Enderby
bd5b90f5da For llvm-nm and Mach-O files also use function starts info in some
cases when printing symbols.  As an improvement to:

r305733 - Change llvm-nm for Mach-O files to use dyld info in some cases when printing symbols

it could be made a bit better if it also read the function starts and faked
up nlist entries to those address not already faked up by the other
dyld info.  This would help with stripped static functions.

rdar://38761029

llvm-svn: 328274
2018-03-22 23:59:35 +00:00
Kevin Enderby
d55cebfaec llvm-nm should show a symbol type of T for symbols in the (__TEXT_EXEC,__text) section.
When a the Apple link editor builds a kext bundle file type and the 
value of the -miphoneos-version-min argument is significantly current
(like 11.0) then the (__TEXT,__text) section is changed to the
(__TEXT_EXEC,__text) section.  So it would be nice for llvm-nm to
show symbols in that section with a type of T instead of the generic
type of S for some section other than text, data, etc.

rdar://36262205

llvm-svn: 323836
2018-01-31 00:00:41 +00:00
Michael Zolotukhin
66a95d7c09 Remove redundant includes from tools.
llvm-svn: 320631
2017-12-13 21:31:10 +00:00