395 Commits

Author SHA1 Message Date
Matt Davis
7fac036c20 [ELF] Return the section name when calling getSymbolName on a section symbol.
Summary:
Previously, llvm-nm would report symbols for .debug and .note sections as: '?' with an empty  section name:

```
00000000 ?
00000000 ?
...
```

With this patch the output more closely resembles GNU nm:
```
00000000 N .debug_abbrev
00000000 n .note.GNU-stack
...
```

This patch calls `getSectionName` for sections that belong to symbols of type `ELF::STT_SECTION`, which returns the name of the section from the section string table.

Reviewers: Bigcheese, davide, jhenderson

Reviewed By: davide, jhenderson

Subscribers: rupprecht, jhenderson, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352785 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-31 19:42:21 +00:00
George Rimar
24fe26b1a5 [llvm-objdump] - Restore a piece of code removed by mistake in r352366.
Seems when committed the r352366
("[llvm-objdump] - Print LMAs when dumping section headers.")
I resolved merge conflict incorrectly and removed this piece by mistake.

Bots did not catch this yet, seems they are slow today,
but the `X86/adjust-vma.test` test case fails locally for me without that.





git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352383 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-28 16:36:12 +00:00
George Rimar
4771873908 [llvm-objdump] - Print LMAs when dumping section headers.
When --section-headers is used, GNU objdump prints both LMA and VMA for sections.
llvm-objdump does not do that what makes it's output be slightly inconsistent.

Patch teaches llvm-objdump to print LMA/VMA for ELF file formats.
The behavior for other formats remains unchanged.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352366 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-28 14:11:35 +00:00
George Rimar
aa66d2b539 [llvm-objdump] - Fix comment. NFC.
This was mentioned by James Henderson
in review for https://reviews.llvm.org/D57051.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352348 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-28 10:48:54 +00:00
George Rimar
747cd64953 [llvm-objdump] - Implement the --adjust-vma option.
GNU objdump's help says: "--adjust-vma: Add OFFSET to all displayed section addresses"
In real life what it does is a bit more complicated
(and IMO not always reasonable. For example, GNU objdump prints not only VMA, but also LMA
for sections. And with --adjust-vma it adjusts LMA, but only when a section has relocations.
llvm-objsump does not seem to support printing LMAs yet, but GNU's logic anyways does not
make sense for me here).

This patch tries to adjust VMA. I tried to implement a reasonable approach.
I am not adjusting sections that are not allocatable. As, for example, adjusting debug sections
VA's and rel[a] sections VA's should not make sense. This behavior seems to be GNU compatible.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352347 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-28 10:44:01 +00:00
George Rimar
c01927928c [llvm-objdump] - Move common code to a new printRelocation() helper. NFC.
This extracts the common code for printing relocations into a new helper function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351951 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-23 13:39:12 +00:00
George Rimar
482634dcda [llvm-objdump] - Move variable. NFC.
It was too far from the place where it is used.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351942 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-23 10:52:38 +00:00
George Rimar
7ace113659 [llvm-objdump] - Split disassembleObject() into two methods. NFCI.
Currently, disassembleObject() is a ~550 lines length function.

This patch splits it into two, where first do all helper objects initializations
and calls the second which does all the rest job.
This is a straightforward split.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351940 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-23 10:33:26 +00:00
George Rimar
5d73c0daaf [llvm-objdump] - Introduce getRelocsMap() helper. NFCI.
Currently disassembleObject() is a ~550 lines length function.
This patch extracts the code that creates a section->their relocation
mapping into a new helper function to simplify/reduce it a bit.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351824 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-22 14:09:37 +00:00
Chandler Carruth
6b547686c5 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-19 08:50:56 +00:00
Clement Courbet
1498f1dfed Revert r351529 "[llvm-objdump][NFC] Improve readability."
msan errors in ELF/strip-all.s.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351556 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-18 15:26:14 +00:00
Clement Courbet
e69eed4580 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351553 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-18 14:20:13 +00:00
George Rimar
a99a3c6de1 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351547 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-18 12:01:59 +00:00
George Rimar
605942eacd [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351545 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-18 11:33:26 +00:00
George Rimar
4d0c775881 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351542 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-18 10:41:26 +00:00
Clement Courbet
70872139d5 Revert r351529 "[llvm-objdump][NFC] Improve readability."
Breaks labels-branch.s

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351534 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-18 09:40:19 +00:00
Clement Courbet
123f62d954 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351529 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-18 08:59:39 +00:00
Wouter van Oortmerssen
51123841ae [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351460 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-17 18:14:09 +00:00
James Henderson
bc34da10fa 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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351448 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-17 15:18:44 +00:00
George Rimar
258d6f7e3e [llvm-objdump] - Fix comment. NFC.
Forgot to address this one.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351418 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-17 09:14:33 +00:00
George Rimar
60016bd970 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351417 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-17 09:13:17 +00:00
George Rimar
daf8332471 [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).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351192 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-15 14:03:50 +00:00
George Rimar
45d116d45e [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351171 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-15 09:19:18 +00:00
George Rimar
04fde6bab3 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351006 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-12 12:17:24 +00:00
George Rimar
03e297e48e [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350840 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-10 16:24:10 +00:00
George Rimar
5482030e57 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350823 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-10 14:55:26 +00:00
George Rimar
56b18a6bdf [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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350726 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-09 14:43:33 +00:00
Jordan Rupprecht
f6ea1298bb [binutils] NFC: fix clang-tidy warning: use empty() instead of size() == 0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349710 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-20 00:57:06 +00:00
George Rimar
96c60eab74 [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;

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349617 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-19 10:44:49 +00:00
George Rimar
927407d000 [llvm-objdump] - Fix BB.
Move the helper method before the first incocation in the file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349614 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-19 10:29:35 +00:00
George Rimar
92b052b484 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349613 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-19 10:21:45 +00:00
Xing GUO
4376a2764b [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347135 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-17 08:12:48 +00:00
Jonas Devlieghere
8e8485eda3 [llvm-objdump] Use WithColor for error reporting
Use helpers from Support/WithError.h to print errors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346623 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-11 22:12:04 +00:00
Kristina Brooks
11c0888e5d [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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346610 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-11 17:47:13 +00:00
Jonas Devlieghere
686dfe3676 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346604 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-11 01:46:03 +00:00
Kristina Brooks
a3cc6ce0cb [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345704 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-31 09:35:25 +00:00
Kristina Brooks
bb1b895ac0 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345703 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-31 09:34:08 +00:00
Kristina Brooks
6ee01635fe [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345697 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-31 05:45:01 +00:00
James Henderson
d32696ac37 [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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345503 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-29 14:17:08 +00:00
James Henderson
198a3abf53 [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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345495 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-29 10:05:39 +00:00
Petar Jovanovic
95eb91571b [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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344818 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-19 22:16:49 +00:00
Fangrui Song
3b35e17b21 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343163 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 02:13:45 +00:00
Joel Galenson
e47abe7961 [llvm-objdump] Label calls to the PLT.
Differential Revision: https://reviews.llvm.org/D50204

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340611 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 15:21:57 +00:00
Zachary Turner
c04ae04bb3 [llvm-objdump] Add ability to demangle COFF symbols.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340221 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-20 22:18:21 +00:00
Petr Hosek
85ffa199e1 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339294 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-08 22:23:57 +00:00
Dave Lee
58b1de483d 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338792 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-03 00:06:38 +00:00
Michael Kruse
6069e66e2c [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338034 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-26 15:31:41 +00:00
Paul Semel
05d358bad5 [llvm-objdump] Add dynamic section printing to private-headers option
Differential Revision: https://reviews.llvm.org/D49016

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337902 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-25 11:09:20 +00:00
Paul Semel
baea3f0500 [llvm-objdump] Add -demangle (-C) option
Differential Revision: https://reviews.llvm.org/D49043

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337401 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-18 16:39:21 +00:00
George Rimar
9c475e370b [llvm-objdump] - An attempt to fix BB after r337361.
Seems r337361 is the reason of the following ARM BB failures:
http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick
http://lab.llvm.org:8011/builders/clang-cmake-armv8-full/builds/4633

Reason is unclear to me, other bots are OK.
If this will not help, I'll revert r337361.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337371 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-18 09:25:36 +00:00