1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
Commit Graph

12065 Commits

Author SHA1 Message Date
Georgii Rymar
393d75e8ca [obj2yaml] - Don't emit EM_NONE.
When ELF header's `e_machine == 0`, we emit:

```
Machine: EM_NONE
```

We can avoid doing this, because yaml2obj sets the
`e_machine` field to `EM_NONE` by default.

Differential revision: https://reviews.llvm.org/D87829
2020-09-17 15:58:44 +03:00
Fangrui Song
1bd4869627 [llvm-cov gcov] Add --demangled-names (-m)
gcov 4.9 introduced the option.
2020-09-16 23:18:50 -07:00
Rahman Lavaee
e3e9dd3c7b [obj2yaml] - Match ".stack_size" with the original section name, and not the uniquified name.
Without this patch, obj2yaml decodes the content of only one ".stack_size" section. Other sections are dumped with their full contents.

Reviewed By: grimar, MaskRay

Differential Revision: https://reviews.llvm.org/D87727
2020-09-16 14:17:29 -07:00
Rahman Lavaee
c08157a6ed Revert "[obj2yaml] - Match ".stack_size" with the original section name, and not the uniquified name."
This reverts commit 14e55f82980cf1342d4d3eea4885a5375e829496.
2020-09-16 11:42:37 -07:00
Rahman Lavaee
848731407e [obj2yaml] - Match ".stack_size" with the original section name, and not the uniquified name.
Without this patch, obj2yaml decodes the content of only one ".stack_size" section. Other sections are dumped with their full contents.

Reviewed By: grimar, MaskRay

Differential Revision: https://reviews.llvm.org/D87727
2020-09-16 11:33:20 -07:00
Fangrui Song
2e45ee1e4c [llvm-nm] Use aggregate initialization instead of memset zero 2020-09-16 10:27:12 -07:00
Arthur Eubanks
825221f2e5 [NPM] Translate alias analysis into require<> as well
'require<globals-aa>' is needed to make globals-aa work in NPM, since
globals-aa is a module analysis but function passes cannot run module
analyses on demand.
So don't skip translating alias analyses to 'require<>'.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D87743
2020-09-16 08:54:09 -07:00
Xing GUO
db83a6f653 [obj2yaml] Add support for dumping the .debug_addr(v5) section.
This patch adds support for dumping the .debug_addr(v5) section to
obj2yaml.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D87601
2020-09-16 14:48:03 +08:00
Martin Storsjö
2b119dcf7e [llvm-rc] Lowercase the option definitions. NFC.
This matches how such options are most commonly defined in other tools.

This was pointed out in an earlier review a few months ago, that
the llvm-rc td entries felt shouty.

The INCLUDE option is renamed to includepath, to avoid clashing with
the tablegen include directive.
2020-09-16 09:34:26 +03:00
Martin Storsjö
7b4e9362ee [llvm-rc] Update a comment. NFC.
Fix a typo and mention one missing step.
2020-09-16 09:34:26 +03:00
Martin Storsjö
50a529e27d [llvm-rc] Allow omitting components from VERSIONINFO versions
MS rc.exe doesn't require specifying all 4 components.

Differential Revision: https://reviews.llvm.org/D87570
2020-09-16 09:34:26 +03:00
Arthur Eubanks
6ec58c2371 [Bugpoint][NewPM] Pin bugpoint to legacy PM
Bugpoint has lots of assumptions and hacks around the legacy PM, put off migrating it to NPM until later.
Fixes tests under BugPoint under NPM.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D87655
2020-09-15 11:29:10 -07:00
Georgii Rymar
2d1a45eca4 [llvm-readobj/elf] - Don't crash when the size of s dynamic symbol table, inferred from the hash table, is broken.
Currently we might derive the dynamic symbol table size from the DT_HASH hash table (using its `nchain` field).
It is possible to crash dumpers with a broken relocation that refers to a symbol with an index
that is too large. To trigger it, the inferred size of the dynamic symbol table should go past the end of the object.

This patch adds a size validation + warning.

Differential revision: https://reviews.llvm.org/D86923
2020-09-15 17:44:16 +03:00
Georgii Rymar
276064cb00 [llvm-readobj/elf] - Simplify and refine the implementation which dumps .stack_sizes
Our implementation of stack sizes section dumping heavily uses `ELFObjectFile<ELFT>`,
while the rest of the code uses `ELFFile<ELFT>`.

That APIs are very different. `ELFObjectFile<ELFT>` is very generic
and has `SectionRef`, `RelocationRef`, `SymbolRef` and other generic concepts.
The `ELFFile<ELFT>` class works directly with `Elf_Shdr`, `Elf_Rel[a]`, `Elf_Sym` etc,
what is probably much cleaner for ELF dumper.

Also, `ELFObjectFile<ELFT>` API does not always provide a way to check
for possible errors. E.g. the implementation of `symbol_end()` does not verify the `sh_size`:

```
template <class ELFT>
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
  const Elf_Shdr *SymTab = DotSymtabSec;
  if (!SymTab)
    return symbol_begin();
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
  return basic_symbol_iterator(SymbolRef(Sym, this));
}
```
There are many other examples which makes me thing we might win from
switching to `ELFFile<ELFT>` API, where we heavily validate an input data already.

This patch is the first step in this direction. I've converted the large portion of the code
to use `ELFFile<ELFT>`.

Differential revision: https://reviews.llvm.org/D87362
2020-09-15 11:57:00 +03:00
Georgii Rymar
dfa9fe5b23 [lib/Object] - Refine interface of ELFFile<ELFT>. NFCI.
`ELFFile<ELFT>` has many methods that take pointers,
though they assume that arguments are never null and
hence could take references instead.

This patch performs such clean-up.

Differential revision: https://reviews.llvm.org/D87385
2020-09-15 11:38:31 +03:00
Martin Storsjö
132d94ce5c [llvm-readobj] [ARMWinEH] Print ARM64 packed unwind info
In addition to printing the individual fields, synthesize and
print the corresponding prolog for the unwind info (in reverse
order, to match how it's printed for non-packed unwind info).

Differential Revision: https://reviews.llvm.org/D87370
2020-09-15 08:50:02 +03:00
Georgii Rymar
f5bde848bb [llvm-readobj/elf] - Don't use unwrapOrError when reporting errors about SHT_DYNAMIC sections.
This changes messages reported to stop using dynamic section names (use `describe()` instead).
This allows to avoid `unwrapOrError` and improves diagnostics.

Differential revision: https://reviews.llvm.org/D87503
2020-09-14 14:55:16 +03:00
Georgii Rymar
a6a5b19211 [llvm-readobj] - Cleanup implementation LLVMStyle<ELFT>::printAddrsig().
It has following issues:
1) `getStaticSymbolName` returns `std::string`, but the code
   assigns a result to `Expected<std::string>`.
2) The code uses `unwrapOrError` and never tests the error reported.

This patch fixes these issues.

Differential revision: https://reviews.llvm.org/D87507
2020-09-14 14:52:06 +03:00
Georgii Rymar
ee3b1b7614 [llvm-readelf/obj] - Refine and generalize the code that is used to dump notes.
There is some code that can be shared between GNU/LLVM styles.
Also, this fixes 2 inconsistencies related to dumping unknown note types:
1) For GNU style we printed "Unknown note type: (0x00000003)" in some cases, and
   "Unknown note type (0x00000003)" (no colon) in other cases.
   GNU readelf always prints `:`. This patch removes the related code
   duplication and does the same.
2) For LLVM style in some cases we printed "Unknown note type (0x00000003)",
   but sometimes just "Unknown (0x00000003)". The latter is the right form, which
   is consistent with other unknowns that are printed in LLVM style.

Rebased on top of D87453.

Differential revision: https://reviews.llvm.org/D87454
2020-09-14 14:31:50 +03:00
Fangrui Song
c8bd947872 [llvm-cov gcov] Refactor counting and reporting
The current organization of FileInfo and its referenced utility functions of
(GCOVFile, GCOVFunction, GCOVBlock) is messy. Some members of FileInfo are just
copied from GCOVFile. FileInfo::print (.gcov output and --intermediate output)
is interleaved with branch statistics and computation of line execution counts.
--intermediate has to do redundant .gcov output to gather branch statistics.

This patch deletes lots of code and introduces a clearer work flow:

```
fn collectFunction
  for each block b
    for each line lineNum
      let line be LineInfo of the file on lineNum
      line.exists = 1
      increment function's lines & linesExec if necessary
      increment line.count
      line.blocks.push_back(&b)

fn collectSourceLine
  compute cycle counts
  count = incoming_counts + cycle_counts
  if line.exists
    ++summary->lines
    if line.count
      ++summary->linesExec

fn collectSource
  for each line
    call collectSourceLine

fn main
  for each function
    call collectFunction
    print function summary
  for each source file
    call collectSource
    print file summary
    annotate the source file with line execution counts
  if -i
    print intermediate file
```

The output order of functions and files now follows the original order in
.gcno files.
2020-09-13 23:00:59 -07:00
Fangrui Song
0637c5d6a0 [llvm-cov gcov] Add -r (--relative-only) && -s (--source-prefix)
gcov 4.7 introduced the two options.
https://sourceware.org/pipermail/gcc-patches/2011-November/328782.html

-r only dumps files with relative paths or absolute paths with the prefix
specified by -s. The two options are useful filtering out system header files.
2020-09-13 14:54:20 -07:00
Mateusz Mikuła
8e6bb7d616 [MinGW] Use lib prefix for libraries
In MinGW world, UNIX like lib prefix is preferred for the libraries.
This patch adjusts CMake files to do that.

Differential Revision: https://reviews.llvm.org/D87517
2020-09-12 22:01:29 +03:00
Xing GUO
c2de775a93 [obj2yaml] Add support for dumping the .debug_ranges section.
This patch adds support for dumping the .debug_ranges section to
elf2yaml.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D87429
2020-09-11 08:47:01 +08:00
Martin Storsjö
00b9701362 [llvm-readobj] [ARMWinEH] Print set_fp/add_fp differently in epilogues
This matches how e.g. stp/ldp and other opcodes are printed differently
for epilogues.

Also add a missing --strict-whitespace in an existing test that
was added explicitly for testing vertical alignment, and change to
using temp files for the generated object files.

Differential Revision: https://reviews.llvm.org/D87363
2020-09-10 11:26:43 +03:00
Alexander Shaposhnikov
85362afc67 [llvm-install-name-tool] Add -V flag
This diff adds -V alias for --version to make llvm-install-name-tool
consistent with other tools (llvm-objcopy, llvm-strip, etc).

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D87264
2020-09-09 17:11:08 -07:00
Ronak Chauhan
7073a2ba14 Revert "[AMDGPU] Support disassembly for AMDGPU kernel descriptors"
This reverts commit 487a80531006add8102d50dbcce4b6fd729ab1f6.

Tests fail on big endian machines.
2020-09-09 18:01:28 +05:30
Xing GUO
a4b3197f72 [elf2yaml] Fix dumping a debug section whose name is not recognized.
If the debug section's name isn't recognized, it should be
dumped as a raw content section.

Reviewed By: jhenderson, grimar

Differential Revision: https://reviews.llvm.org/D87346
2020-09-09 20:07:05 +08:00
Ronak Chauhan
6a6f27edd0 [AMDGPU] Support disassembly for AMDGPU kernel descriptors
Decode AMDGPU Kernel descriptors as assembler directives.

Reviewed By: scott.linder, jhenderson, kzhuravl

Differential Revision: https://reviews.llvm.org/D80713
2020-09-08 21:26:11 +05:30
Xing GUO
51d61a7d47 [DWARFYAML] Make the debug_ranges section optional.
This patch makes the debug_ranges section optional. When we specify an
empty debug_ranges section, yaml2obj only emits the section header.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D87263
2020-09-08 19:55:47 +08:00
Xing GUO
063c6c1b3c [obj2yaml] Stop parsing the debug_str section when it encounters a string without the null terminator.
When obj2yaml encounters a string without the null terminator, it should
stop parsing the debug_str section. This patch addresses comments in
[D86867](https://reviews.llvm.org/D86867#inline-803291).

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D87261
2020-09-08 16:09:36 +08:00
Georgii Rymar
cebe3f34e6 [llvm-readobj] - Remove code duplication when printing dynamic relocations. NFCI.
LLVM style code can be simplified to avoid the duplication of logic
related to printing dynamic relocations.

Differential revision: https://reviews.llvm.org/D87089
2020-09-07 16:11:12 +03:00
Georgii Rymar
9a2f89a341 [llvm-readobj/elf] - Generalize the code for printing dynamic relocations. NFCI.
Currently we have 2 large `printDynamicRelocations` methods that
have a very similar code for GNU/LLVM styles.

This patch removes the duplication and renames them to `printDynamicReloc`
for consistency.

Differential revision: https://reviews.llvm.org/D87087
2020-09-07 15:36:51 +03:00
Georgii Rymar
3bb0607fee [llvm-readobj/elf] - Introduce Relocation<ELFT> helper.
It removes templating for Elf_Rel[a] handling that we
introduced earlier and introduces a helper class instead.

It was briefly discussed in D87087, which showed,
why having templates is probably not ideal for the generalization
of dumpers code.

Differential revision: https://reviews.llvm.org/D87141
2020-09-07 15:08:05 +03:00
Xing GUO
8a5f7ba413 [obj2yaml] Add support for dumping the .debug_str section.
This patch adds support for dumping the .debug_str section to obj2yaml.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D86867
2020-09-07 19:46:56 +08:00
Lang Hames
976cbeac7c [ORC] Fix some bugs in TPCDynamicLibrarySearchGenerator, use in llvm-jitlink.
TPCDynamicLibrarySearchGenerator was generating errors on missing
symbols, but that doesn't fit the DefinitionGenerator contract: A symbol
that isn't generated by a particular generator should not cause an
error.

This commit fixes the error by using SymbolLookupFlags::WeaklyReferencedSymbol
for all elements of the lookup, and switches llvm-jitlink to use
TPCDynamicLibrarySearchGenerator.
2020-09-04 13:23:52 -07:00
Daniel Sanders
ee2ed1e94a [objdump][macho] Emit segment names along with section names
I recently came across a MachO with multiple sections of the same name but
different segments. We should emit the segment name alongside the section name
for MachO's.

Differential Revision: https://reviews.llvm.org/D87119
2020-09-04 09:57:02 -07:00
Georgii Rymar
6dae2e3dea [llvm-readelf/obj] - Use RelSymbol<ELFT> instead of std::pair. NFCI.
We have the `RelSymbol<ELFT>` struct and can use it instead
of `std::pair<const Elf_Sym *, std::string>` in a few methods.
This is a bit cleaner.

Differential revision: https://reviews.llvm.org/D87092
2020-09-04 13:18:11 +03:00
Georgii Rymar
eb861517a5 [llvm-readobj/elf] - Refine signature of print*Reloc methods.
This makes the interface cleaner and slightly improves messages
reported.

Differential revision: https://reviews.llvm.org/D87086
2020-09-04 12:53:29 +03:00
Fangrui Song
25dfeb3f99 [llvm-symbolizer] Add back --use-symbol-table=true
It is used by clusterfuzz (https://github.com/google/clusterfuzz/pull/2009/)
and having this compatibility option for a while can help they do bisection
with the latest llvm-symbolizer.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D87067
2020-09-03 14:27:06 -07:00
Georgii Rymar
270c64f7de [llvm-readelf] - Move a bit of common code to printDynamicRelocHeader(). NFC.
This helps to isolate printing of the relocation's summary header
in a single place.

Differential revision: https://reviews.llvm.org/D87042
2020-09-03 13:25:11 +03:00
Georgii Rymar
4e4b3fa83d [llvm-readobj/elf] - Improve warning messages, reported for .stack_sizes sections.
Instead of referring to stack sizes sections only by name, we can add
section indexes and types to warnings reported.

Differential revision: https://reviews.llvm.org/D86934
2020-09-03 13:17:07 +03:00
Georgii Rymar
414ea6a00d [llvm-readelf/obj] - Cleanup the interface of DumpStyle. NFCI.
We have 2 DumpStyles currently:
`class GNUStyle : public DumpStyle<ELFT>` and `class LLVMStyle : public DumpStyle<ELFT>`.

The problem of `DumpStyle` interface is that almost for each method
we provide `const ELFFile<ELFT> *` as argument. But in fact each of
dump styles keeps `ELFDumper<ELFT> *Dumper` which can be used to get an object from.

But since we use the `Obj` too often, I've decided to introduce a one more reference member
instead of reading it from the `Dumper` each time:
`const ELFFile<ELFT> &Obj;` This is kind of similar to `FileName` member which we have already:
it is also used to store a the file name which can be read from `Dumper->getElfObject()->getFileName()`.

I had to adjust the code which previously worked with a pointer to an object
and now works with a reference.

In a follow-up I am going to try to get rid of `const ELFObjectFile<ELFT>` arguments
which are still passed to a set of functions.

Differential revision: https://reviews.llvm.org/D87040
2020-09-03 12:17:46 +03:00
Martin Storsjö
5443644017 [AArch64] Add asm directives for the remaining SEH unwind codes
Add support in llvm-readobj for displaying them and support in the
asm parsser, AArch64TargetStreamer and MCWin64EH for emitting them.

The directives for the remaining basic opcodes have names that
match the opcode in the documentation.

The directives for custom stack cases, that are named
MSFT_OP_TRAP_FRAME, MSFT_OP_MACHINE_FRAME, MSFT_OP_CONTEXT
and MSFT_OP_CLEAR_UNWOUND_TO_CALL, are given matching assembler
directive names that fit into the rest of the opcode naming;
.seh_trap_frame, .seh_context, .seh_clear_unwound_to_call

The opcode MSFT_OP_MACHINE_FRAME is mapped to the existing
opecode enum UOP_PushMachFrame that is used on x86_64, and also
uses the corresponding existing x86_64 directive name
.seh_pushframe.

Differential Revision: https://reviews.llvm.org/D86889
2020-09-03 11:12:01 +03:00
Eric Astor
6cecc11ec7 Make sure that llvm-ml uses MASM integer lexing when in --as-lex mode 2020-09-02 16:03:01 -04:00
Georgii Rymar
41a5636b6f [llvm-readobj] - Remove Error.cpp,.h and drop dependencies in the code.
We have Error.cpp/.h which contains some code for working with error codes.
In fact we use Error/Expected<> almost everywhere already and we can get rid
of these files.

Note: a few places in the code used readobj specific error codes,
e.g. `return readobj_error::unknown_symbol`. But these codes are never really used,
i.e. the code checks the fact of a success/error call only.
So I've changes them to `return inconvertibleErrorCode()` for now.
It seems that these places probably should be converted to use `Error`/`Expected<>`.

Differential revision: https://reviews.llvm.org/D86772
2020-09-01 16:46:17 +03:00
Georgii Rymar
522d076ef9 [llvm-readobj/elf] - Report warnings instead of errors when dumping broken stack sizes sections.
This replaces `reportError` calls with `reportUniqueWarning` and improves testing
for the code that is related to stack sizes dumping.

Differential revision: https://reviews.llvm.org/D86783
2020-09-01 13:46:54 +03:00
Xing GUO
45321f3e73 [DWARFYAML] Make the debug_str section optional.
This patch makes the debug_str section optional. When the debug_str
section exists but doesn't contain anything, yaml2obj will emit a
section header for it.

Reviewed By: grimar

Differential Revision: https://reviews.llvm.org/D86860
2020-09-01 10:02:09 +08:00
Christopher Tetreault
b93c073189 [SVE] Remove calls to VectorType::getNumElements() from llvm-stress
Differential Revision: https://reviews.llvm.org/D86898
2020-08-31 15:51:15 -07:00
Florian Hahn
102583c8b4 [llvm-reduce] Create returns with undef values for non-void functions.
Currently replaceBranchTerminator/removeUninterestingBBsFromSwitch
always creates `ret void` instructions if no successor is in the chunk.

This results in invalid IR for functions with non-void return types,
which makes those reductions unfeasible. Instead, create `ret ty undef`
for functions with non-void return types.

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D86849
2020-08-31 16:33:46 +01:00
Georgii Rymar
e56dc2e569 [llvm-readobj/elf] - Don't fail when dumping an archive with a member that can't be recognized.
Imagine we have an archive that has 3 objects in the following order:
<valid known object>,<unknown object> and <valid known object>.

Currently llvm-readelf/obj report an error and stops dumping in the middle.
This patch changes the error reported to warning.

Differential revision: https://reviews.llvm.org/D86771
2020-08-31 13:16:15 +03:00