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

714 Commits

Author SHA1 Message Date
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
Clement Courbet
6d903be6b8 Revert r351529 "[llvm-objdump][NFC] Improve readability."
msan errors in ELF/strip-all.s.

llvm-svn: 351556
2019-01-18 15:26:14 +00:00
Clement Courbet
6e365b0dd8 Reland r351529 "[llvm-objdump][NFC] Improve readability."
`SectionSymbol*` is cast from `void*` to
`std::tuple<uint64_t, StringRef, uint8_t>` in AMDGPUSymbolizer, so it has to
*be* one, not *act like* one.

llvm-svn: 351553
2019-01-18 14:20:13 +00:00
George Rimar
3b0a98a3a9 [llvm-objdump] - Dump the archive headers when -all-headers is specified.
When -all-headers is given it is supposed to dump all headers,
but now it skips the archive headers for no reason.

The patch fixes that.

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

llvm-svn: 351547
2019-01-18 12:01:59 +00:00
George Rimar
588ddb3054 [llvm-objdump] - Move getRelocationValueString and dependenices out of the llvm-objdump.cpp
getRelocationValueString is a dispatcher function that calls the
corresponding ELF/COFF/Wasm/MachO implementations
that currently live in the llvm-objdump.cpp file.

These implementations better be moved to ELFDump.cpp,
COFFDump.cpp and other corresponding files, to move platform specific
implementation out from the common logic.

The patch does that. Also, I had to move ToolSectionFilter helper
and SectionFilterIterator, SectionFilter to a header to make them
available across the objdump code.

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

llvm-svn: 351545
2019-01-18 11:33:26 +00:00
George Rimar
98e561489f [llvm-objdump] - Show aliases in -help.
Currently llvm-objdump is inconsistent.

When -help is specified it shows no aliases except two.
Aliases are shown with -help-hidden though.
GNU objdump also prints them by default.

This patch does a change to always show all aliases
when -help is given.

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

llvm-svn: 351542
2019-01-18 10:41:26 +00:00
Clement Courbet
439811e0d3 Revert r351529 "[llvm-objdump][NFC] Improve readability."
Breaks labels-branch.s

llvm-svn: 351534
2019-01-18 09:40:19 +00:00
Clement Courbet
f2174f1846 [llvm-objdump][NFC] Improve readability.
Summary:
Introduce a `struct SectionSymbol` instead of
`tuple<uint64_t, StringRef, uint8>`.

Reviewers: jhenderson, davide

Subscribers: rupprecht, llvm-commits

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

llvm-svn: 351529
2019-01-18 08:59:39 +00:00
Wouter van Oortmerssen
9741215258 [WebAssembly] Fixed objdump not parsing function headers.
Summary:
objdump was interpreting the function header containing the locals
declaration as instructions. To parse these without injecting target
specific code in objdump, MCDisassembler::onSymbolStart was added to
be implemented by the WebAssembly implemention.

WasmObjectFile now returns a code offset for the "address" of a symbol,
rather than the index. This is also more in-line with what other
targets do.

Also ensured that the AsmParser correctly puts each function
in its own segment to enable this test case.

Reviewers: sbc100, dschuff

Subscribers: jgravelle-google, aheejin, sunfish, rupprecht, llvm-commits

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

llvm-svn: 351460
2019-01-17 18:14:09 +00:00
James Henderson
ccbf0e437b Move demangling function from llvm-objdump to Demangle library
This allows it to be used in an upcoming llvm-readobj change.

A small change in internal behaviour of the function is to always call
the microsoftDemangle function if the string does not have an itanium
encoding prefix, rather than only if it starts with '?'. This is
harmless because the microsoftDemangle function does the same check
already.

Reviewed by: grimar, erik.pilkington

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

llvm-svn: 351448
2019-01-17 15:18:44 +00:00
George Rimar
94ab87488c [llvm-objdump] - Fix comment. NFC.
Forgot to address this one.

llvm-svn: 351418
2019-01-17 09:14:33 +00:00
George Rimar
6b3ecc0c1d [llvm-objdump] - Simplify the getRelocationValueString. NFCI.
This refactors the getRelocationValueString method.
It is a bit overcomplicated and it is possible to reduce it without
losing the functionality it seems.

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

llvm-svn: 351417
2019-01-17 09:13:17 +00:00
Michael Trent
6b390602a4 llvm-objdump -m -D should disassemble all text segments
Summary:
When running llvm-objdump with the -macho option objdump will by default
disassemble only the __TEXT,__text section (or __TEXT_EXEC,__text when
disassembling MH_KEXT_BUNDLE files). The -disassemble-all option is
treated no diferently than -disassemble.

This change upates llvm-objdump's MachO parsing code to disassemble all
__text sections found in a file when -disassemble-all is specified. This
is useful for disassembling files with more than one __text section, or
when disassembling files whose __text section is not present in __TEXT.

I added a lit test case that verifies "llvm-objdump -m -d" and 
"llvm-objdump -m -D" produce the expected results on a reference binary. 
I also updated the CommandGuide documentation for llvm-objdump.rst and
verified it renders correctly as man and html.

rdar://42899338

Reviewers: ab, pete, lhames

Reviewed By: lhames

Subscribers: rupprecht, llvm-commits

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

llvm-svn: 351238
2019-01-15 20:41:30 +00:00
George Rimar
c1709da283 [llvm-obdump] - Fix the help lines for -stop-address and -z.
It was broken by me by mistake in r350823 during addressing the
review comment before committing (changed not the right text line).

llvm-svn: 351192
2019-01-15 14:03:50 +00:00
George Rimar
a8d5b084c3 [llvm-objdump] - Cleanup the code. NFCI.
This is a cosmetic cleanup for the llvm-objdump code.

This patch:
* Renames things to match the official LLVM code style (lower case -> upper case).
* Removes few obviously excessive variables.
* Moves a few lines closer to the place of use, reorders the code a bit to simplify it,
to avoid doing excessive returns and to avoid using 'else` after returns.

I focused only on a llvm-objdump.h/llvm-objdump.cpp files. Few changes in the
MachODump.cpp and COFFDump.cpp are a result of llvm-objdump.h modification.

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

llvm-svn: 351171
2019-01-15 09:19:18 +00:00
George Rimar
a7eabaeadb [llvm-objdump] - Change the output for --all-headers.
This is for https://bugs.llvm.org/show_bug.cgi?id=40008,

it starts printing the file headers when --all-headers is given and
do a minor cosmetic change.

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

llvm-svn: 351006
2019-01-12 12:17:24 +00:00
Francis Visoiu Mistrih
92f3fd2a98 [llvm-objdump][MachO] Fix error reporting after r350848 and r350849
llvm-svn: 350851
2019-01-10 17:36:54 +00:00
Francis Visoiu Mistrih
8ad327596d [llvm-objdump][MachO] Use the -dsym file name when reporting errors
Instead of using the binary filename.

llvm-svn: 350849
2019-01-10 17:16:42 +00:00
Francis Visoiu Mistrih
e911a16fb9 [llvm-objdump][MachO] Correctly handle the llvm::Error when -dsym has errors
In an assert build, the Error gets destroyed and we get "Program aborted
due to an unhandled Error:".

In release, we get an empty message.

llvm-svn: 350848
2019-01-10 17:16:37 +00:00
George Rimar
263ffa3eae [llvm-objdump] - Do not include reserved undefined symbol in -t output.
This is https://bugs.llvm.org/show_bug.cgi?id=26892,

GNU objdump hides the special symbol entry:

SYMBOL TABLE:
000000000000a7e0 l     F .text	00000000000003f9 bi_copymodules
while llvm-objdump does not:

SYMBOL TABLE:
0000000000000000         *UND*		 00000000 
000000000000a7e0 l     F .text		 000003f9 bi_copymodules

Patch makes the behavior of the llvm-objdump to be consistent with the GNU objdump.

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

llvm-svn: 350840
2019-01-10 16:24:10 +00:00
George Rimar
de25995821 [llvm-objdump] - Implement -z/--disassemble-zeroes.
This is https://bugs.llvm.org/show_bug.cgi?id=37151,

GNU objdump spec says that "Normally the disassembly output will skip blocks of zeroes.",
but currently, llvm-objdump prints them.

The patch implements the -z/--disassemble-zeroes option and switches the default to always
skip blocks of zeroes.

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

llvm-svn: 350823
2019-01-10 14:55:26 +00:00
George Rimar
f5fc25dc9a [llvm-objdump] - Print symbol addressed when dumping disassembly output (-d)
When GNU objdump dumps the input with -d it prints the symbol addresses,
for example:

0000000000000031 <foo>:
  31:	00 00                	add    %al,(%rax)
	...

llvm-objdump currently does not do that.
Patch changes the behavior to match the GNU objdump.

That is useful for implementing -z/--disassemble-zeroes (D56083),
it allows omitting first zero bytes and keep the information
about the symbol address in the output.

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

llvm-svn: 350726
2019-01-09 14:43:33 +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
George Rimar
a16b4294c8 [llvm-objdump] - Fix one more BB.
Should fix the http://lab.llvm.org:8011/builders/polly-amd64-linux/builds/25876/steps/build/logs/stdio:

/home/grosser/buildslave/polly-amd64-linux/llvm.src/tools/llvm-objdump/llvm-objdump.cpp:539:25: error: conditional expression is ambiguous; 'std::string' (aka 'basic_string<char>') can be converted to 'typename std::remove_reference<StringRef>::type' (aka 'llvm::StringRef') and vice versa
      Target = Demangle ? demangle(*SymName) : *SymName;

llvm-svn: 349617
2018-12-19 10:44:49 +00:00
George Rimar
022235f4c8 [llvm-objdump] - Fix BB.
Move the helper method before the first incocation in the file.

llvm-svn: 349614
2018-12-19 10:29:35 +00:00
George Rimar
d9516920d3 [llvm-objdump] - Demangle the symbols when printing symbol table and relocations.
This is https://bugs.llvm.org/show_bug.cgi?id=40009,

llvm-objdump does not demangle the symbols when prints symbol
table and/or relocations.

Patch teaches it to do that.

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

llvm-svn: 349613
2018-12-19 10:21:45 +00:00
Michael Trent
bc00ad23c1 Update the Swift version numbers reported by objdump
Summary:
Add Swift 4.1, Swift 4.2, and Swift 5 version numbers to objdump's
MachODump's print_imae_info routines. 

rdar://46548425

Reviewers: pete, lhames, bob.wilson

Reviewed By: pete, bob.wilson

Subscribers: bob.wilson, llvm-commits

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

llvm-svn: 348632
2018-12-07 19:55:03 +00:00
Xing GUO
37ef87de25 [llvm-objdump] Print a blank row at the end of sections
Summary:
When using option `-x` (--all-headers), it will print `Sections`, `Symbol Table`, `Program Header` ...
`Sections` and `Symbol Table` will be connected together.

Before:
```
Sections:
Idx Name          Size      Address          Type
  0               00000000 0000000000000000
  ...
  29 .shstrtab     0000011a 0000000000000000
SYMBOL TABLE:
  ...
```

After:
```
Sections:
Idx Name          Size      Address          Type
  0               00000000 0000000000000000
  ...
  29 .shstrtab     0000011a 0000000000000000

SYMBOL TABLE:
  ...
```

Reviewers: Higuoxing

Reviewed By: Higuoxing

Subscribers: llvm-commits, jhenderson

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

llvm-svn: 347135
2018-11-17 08:12:48 +00:00
Xing GUO
5672b55a7b [llvm-objdump] Use auto declaration in typecasting
Summary:
According to `MaskRay`, use `auto` for type inference, according to coding standards.
Delete some comments, because these comments can be easily inferred from codes.

Reviewers: jhenderson, MaskRay

Reviewed By: jhenderson

Subscribers: llvm-commits

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

llvm-svn: 346946
2018-11-15 11:51:13 +00:00
Xing GUO
485320d557 [llvm-objdump] Improve ELF file type checking statements (D54509)
llvm-svn: 346851
2018-11-14 11:30:34 +00:00
Jonas Devlieghere
893b7db33a [llvm-objdump] Use WithColor for error reporting
Use helpers from Support/WithError.h to print errors.

llvm-svn: 346623
2018-11-11 22:12:04 +00:00
Kristina Brooks
d4928ee68f [llvm-objdump] Add symbol 'O' for object data
Improve compatibility with GNU objdump by showing `O` next to
global symbol names, instead of a blank space.

Patch by Higuoxing (Xing).

Reviewers: MaskRay

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

llvm-svn: 346610
2018-11-11 17:47:13 +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
Kristina Brooks
4066f020f9 [llvm-objdump] Mark syms/t flags as NotHidden. NFC.
Slight improvement to help output of llvm-objdump that exposes the
shorter -t flag for -syms instead of it being hidden away.

llvm-svn: 345704
2018-10-31 09:35:25 +00:00
Kristina Brooks
81b760cc8c [llvm-objdump] Add --reloc alias for -r (PR39407)
This addresses PR39407 (https://bugs.llvm.org/show_bug.cgi?id=39407)
improving compatibility with GNU binutils counterparts.

Reviewed By: kristina

Patch by Higuoxing (Xing).

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

llvm-svn: 345703
2018-10-31 09:34:08 +00:00
Kristina Brooks
27e5e119e7 [llvm-objdump] support '--syms' as an alias of -t
This adds support for '--syms' as an alias of '-t' for llvm-objdump,
fixing PR39406 (https://bugs.llvm.org/show_bug.cgi?id=39406).

Patch by Higuoxing (Xing).

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

llvm-svn: 345697
2018-10-31 05:45:01 +00:00
James Henderson
b17cda5fef [llvm-objdump] Don't crash when using -a on non-archives
This fixes PR39402. The crash was caused when dereferencing nullptr in
DumpObject and printArchiveChild.

Reviewed By: jhenderson

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

Patch by Xing GUO

llvm-svn: 345503
2018-10-29 14:17:08 +00:00
James Henderson
dc0e1e6c1b [llvm-objdump] Add '--full-contents' as alias for '-s'
This fixes PR39404.

Reviewed By: jhenderson

Patch by Xing Guo

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

llvm-svn: 345495
2018-10-29 10:05:39 +00:00
Petar Jovanovic
a8b511d699 [llvm-objdump] Fix --file-headers (-f) option
Changed the format call to match the surrounding code. Previously it was
printing an unsigned int while the return type being printed was
long unsigned int or wider. This caused problems for big-endian systems
which were discovered on mips64.
Also, the printed address had less characters than it should because the
character count was directly obtained from the number of bytes in the
address.
The tests were adapted to fit this fix and now use longer addresses.

Patch by Milos Stojanovic.

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

llvm-svn: 344818
2018-10-19 22:16: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
Francis Visoiu Mistrih
00515aab2a [llvm-objdump] Keep the memory buffer from the dSYM alive when using -g -dsym
When using -g and -dsym, llvm-objdump opens the dsym file and keeps the
MachOObjectFile alive, while the memory buffer that the MachOObjectFile
was based on gets destroyed.

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

llvm-svn: 341209
2018-08-31 13:10:54 +00:00
Joel Galenson
4e688902c2 [llvm-objdump] Label calls to the PLT.
Differential Revision: https://reviews.llvm.org/D50204

llvm-svn: 340611
2018-08-24 15:21:57 +00:00
Zachary Turner
b7d1c521b2 Print "invalid mangled name" when we can't demangle something.
llvm-svn: 340340
2018-08-21 21:23:29 +00:00
Zachary Turner
0e0b1410ae [llvm-objdump] Add ability to demangle COFF symbols.
llvm-svn: 340221
2018-08-20 22:18:21 +00:00
Petr Hosek
a98aa0866c [ADT] Normalize empty triple components
LLVM triple normalization is handling "unknown" and empty components
differently; for example given "x86_64-unknown-linux-gnu" and
"x86_64-linux-gnu" which should be equivalent, triple normalization
returns "x86_64-unknown-linux-gnu" and "x86_64--linux-gnu". autoconf's
config.sub returns "x86_64-unknown-linux-gnu" for both
"x86_64-linux-gnu" and "x86_64-unknown-linux-gnu". This changes the
triple normalization to behave the same way, replacing empty triple
components with "unknown".

This addresses PR37129.

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

llvm-svn: 339294
2018-08-08 22:23:57 +00:00
Fangrui Song
4c80642b2c [llvm-objdump] Remove continue after report_error which is unreachable
llvm-svn: 338951
2018-08-04 05:19:00 +00:00
Dave Lee
956ce46fd0 objdump: Better handling of Mach-O universal binaries
Summary:
With Mach-O, there is a flag requirement discrepancy between working with
universal binaries and thin binaries. Many flags that don't require the `-macho`
flag (for example `-private-headers` and `-disassemble`) fail to work on
universal binaries unless `-macho` is given. When this happens, the error
message is unhelpful, stating:

    The file was not recognized as a valid object file.

Which can lead to confusion.

This change allows generic flags to be used on universal binaries with and
without the `-macho` flag. This means flags that can be used for thin files can
be used consistently with fat files too.

To do this, the universal binary support within `ParseInputMachO()` is extracted
into a new function. This new function is called directly from `DumpInput()`
when the input binary is universal. Additionally the `-arch` flag validation in
`ParseInputMachO()` was extracted to be reused.

Reviewers: compnerd

Reviewed By: compnerd

Subscribers: keith, llvm-commits

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

llvm-svn: 338792
2018-08-03 00:06:38 +00:00
Michael Kruse
8fc32bf8f9 [ADT] Replace std::isprint by llvm::isPrint.
The standard library functions ::isprint/std::isprint have platform-
and locale-dependent behavior which makes LLVM's output less
predictable. In particular, regression tests my fail depending on the
implementation of these functions.

Implement llvm::isPrint in StringExtras.h with a standard behavior and
replace all uses of ::isprint/std::isprint by a call it llvm::isPrint.
The function is inlined and does not look up language settings so it
should perform better than the standard library's version.

Such a replacement has already been done for isdigit, isalpha, isxdigit
in r314883. gtest does the same in gtest-printers.cc using the following
justification:

    // Returns true if c is a printable ASCII character.  We test the
    // value of c directly instead of calling isprint(), which is buggy on
    // Windows Mobile.
    inline bool IsPrintableAscii(wchar_t c) {
      return 0x20 <= c && c <= 0x7E;
    }

Similar issues have also been encountered by Julia:
https://github.com/JuliaLang/julia/issues/7416

I noticed the problem myself when on Windows isprint('\t') started to
evaluate to true (see https://stackoverflow.com/questions/51435249) and
thus caused several unit tests to fail. The result of isprint doesn't
seem to be well-defined even for ASCII characters. Therefore I suggest
to replace isprint by a platform-independent version.

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

llvm-svn: 338034
2018-07-26 15:31:41 +00:00
Paul Semel
3560e7c201 [llvm-objdump] Add dynamic section printing to private-headers option
Differential Revision: https://reviews.llvm.org/D49016

llvm-svn: 337902
2018-07-25 11:09:20 +00:00
Paul Semel
d8d82c148d [llvm-objdump] Add -demangle (-C) option
Differential Revision: https://reviews.llvm.org/D49043

llvm-svn: 337401
2018-07-18 16:39:21 +00:00