Commit Graph

10929 Commits

Author SHA1 Message Date
Fangrui Song dc8de6037c Simplify std::lower_bound with llvm::{bsearch,lower_bound}. NFC
llvm-svn: 364006
2019-06-21 05:40:31 +00:00
Seiya Nuta f923d9b53f [llvm-objcopy][MachO] Rebuild the symbol/string table in the writer
Summary: Build the string table using StringTableBuilder, reassign symbol indices, and update symbol indices in relocations to allow adding/modifying/removing symbols from the object.

Reviewers: alexshap, rupprecht, jhenderson

Reviewed By: alexshap

Subscribers: mgorny, jakehehrlich, llvm-commits

Tags: #llvm

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

llvm-svn: 364000
2019-06-21 00:21:50 +00:00
George Rimar 30ea0c4d74 [yaml2obj] - Convert `ELFState<ELFT>::addSymbols` method to `toELFSymbols` helper. NFCI.
ELFState<ELFT>::addSymbols method looks a bit strange.
User code have to create the destination symbols vector outside,
add a null symbol and then pass it to addSymbols when it seems
the more natural logic is to isolate all work with symbols inside some
function, build the list right there and return it.

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

llvm-svn: 363930
2019-06-20 14:44:48 +00:00
Fangrui Song 7064a437f8 [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
Eli Friedman d88e28d13e [llvm-objdump] Switch between ARM/Thumb based on mapping symbols.
The ARMDisassembler changes allow changing between ARM and Thumb mode
based on the MCSubtargetInfo, rather than the Target, which simplifies
the other changes a bit.

I'm not really happy with adding more target-specific logic to
tools/llvm-objdump/, but there isn't any easy way around it: the logic
in question specifically applies to disassembling an object file, and
that code simply isn't located in lib/Target, at least at the moment.

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

llvm-svn: 363903
2019-06-20 00:29:40 +00:00
Yuanfang Chen 40a156b791 [llvm-readobj] Match GNU output for DT_RPATH and DT_RUNPATH when dumping dynamic symbol table.
Reviewers: jhenderson, grimar, MaskRay, rupprecht, espindola

Subscribers: emaste, nemanjai, arichardson, kbarton, llvm-commits

Tags: #llvm

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

llvm-svn: 363868
2019-06-19 19:31:07 +00:00
Yuanfang Chen fee7365b07 [llvm-objdump] Remove unnecessary indentation when dumping ELF data.
Reviewers: MaskRay, jhenderson, rupprecht

Subscribers: llvm-commits

Tags: #llvm

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

llvm-svn: 363858
2019-06-19 18:44:29 +00:00
George Rimar b6e20937b3 [yaml2obj/obj2yaml] - Make RawContentSection::Info Optional<>
This allows to customize this field for "implicit" sections properly.

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

llvm-svn: 363777
2019-06-19 08:57:38 +00:00
Hans Wennborg 9ed156701b vs integration: bump version nbr
llvm-svn: 363769
2019-06-19 07:39:53 +00:00
Hans Wennborg e9435190d6 Revert r359557 "vs integration: vs2019 support"
Turns out this worked on my machine because I still had VS2017 installed, but
it didn't actually work in general.

Since the extension is unmaintained and MS is doing their own LLVM toolset
integration for VS2019, let's just revert.

llvm-svn: 363768
2019-06-19 07:37:53 +00:00
Yuanfang Chen 58dbe47b9c Test commit access
llvm-svn: 363763
2019-06-19 05:40:24 +00:00
Michael Trent c2885ded2b Print dylib load kind (weak, reexport, etc) in llvm-objdump -m -dylibs-used
Summary:
Historically llvm-objdump prints the path to a dylib as well as the
dylib's compatibility version and current version number. This change
extends this information by adding the kind of dylib load: weak,
reexport, etc.

rdar://51383512

Reviewers: pete, lhames

Reviewed By: pete

Subscribers: rupprecht, llvm-commits

Tags: #llvm

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

llvm-svn: 363746
2019-06-18 22:20:10 +00:00
Reid Kleckner a702f07301 [PDB] Ignore .debug$S subsections with high bit set
Some versions of the Visual C++ 2015 runtime have line tables with the
subsection kind of 0x800000F2. In cvinfo.h, 0x80000000 is documented to
be DEBUG_S_IGNORE. This appears to implement the intended behavior.

llvm-svn: 363724
2019-06-18 19:41:25 +00:00
Fangrui Song 677423997d [llvm-readobj] Allow --hex-dump/--string-dump to dump multiple sections
1) `-x foo` currently dumps one `foo`. This change makes it dump all `foo`.
2) `-x foo -x foo` currently dumps `foo` twice. This change makes it dump `foo` once.
   In addition, if foo has section index 9, `-x foo -x 9` dumps `foo` once.
3) Give a warning instead of an error if `foo` does not exist.

The new behaviors match GNU readelf.

Also, print a new line as a separator between two section dumps.
GNU readelf uses two lines, but one seems good enough.

Reviewed By: grimar, jhenderson

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

llvm-svn: 363683
2019-06-18 14:01:03 +00:00
Andrea Di Biagio 3b2f5df12c [MCA] Slightly refactor the bottleneck analysis view. NFCI
This patch slightly refactors data structures internally used by the bottleneck
analysis to track data and resource dependencies.
This patch also updates methods used to print out information about dependency
edges when in debug mode.
This is the last of a sequence of commits done in preparation for an upcoming
patch that fixes PR37494. No functional change intended.

llvm-svn: 363677
2019-06-18 12:59:46 +00:00
Fangrui Song 291e11ea02 [llvm-objdump] Tidy up AMDGCNPrettyPrinter
llvm-svn: 363650
2019-06-18 06:35:18 +00:00
Alex Brachet 7747700937 [llvm-strip] Error when using stdin twice
Summary: Implements bug [[ https://bugs.llvm.org/show_bug.cgi?id=42204 | 42204 ]]. llvm-strip now warns when the same input file is used more than once, and errors when stdin is used more than once.

Reviewers: jhenderson, rupprecht, espindola, alexshap

Reviewed By: jhenderson, rupprecht

Subscribers: emaste, arichardson, jakehehrlich, MaskRay, llvm-commits

Tags: #llvm

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

llvm-svn: 363638
2019-06-18 00:39:10 +00:00
Francis Visoiu Mistrih 34667519dc [Remarks] Extend -fsave-optimization-record to specify the format
Use -fsave-optimization-record=<format> to specify a different format
than the default, which is YAML.

For now, only YAML is supported.

llvm-svn: 363573
2019-06-17 16:06:00 +00:00
Fangrui Song 46f9cbe28d [llvm-objdump] Use %08 instead of %016 to print leading addresses for 32-bit binaries
Reviewed By: grimar

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

llvm-svn: 363539
2019-06-17 09:59:55 +00:00
Seiya Nuta 4f15732067 [yaml2obj][MachO] Don't fill dummy data for virtual sections
Summary:
Currently, MachOWriter::writeSectionData writes dummy data (0xdeadbeef) to fill section data areas in the file even if the section is a virtual one. Since virtual sections don't occupy any space in the file, writing dummy data could results the  "OS.tell() - fileStart <= Sec.offset" assertion failure.

This patch fixes the bug by simply not writing any dummy data for virtual sections.

Reviewers: beanz, jhenderson, rupprecht, alexshap

Reviewed By: alexshap

Subscribers: compnerd, llvm-commits

Tags: #llvm

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

llvm-svn: 363525
2019-06-17 02:07:20 +00:00
Seiya Nuta 13de174b4c [llvm-objcopy] Add elf32-sparc and elf32-sparcel target
Summary:
The "sparc"/"sparcel" architectures appears in ArchMap (used by -B option) but not in OutputFormatMap (used by -I/-O option). Add their targets into OutputFormatMap for consistency.

Note that AFAIK there're no targets for 32-bit little-endian SPARC ("elf32-sparcel") in GNU binutils.

Reviewers: espindola, alexshap, rupprecht, jhenderson, compnerd, jakehehrlich

Reviewed By: jhenderson, compnerd, jakehehrlich

Subscribers: jyknight, emaste, arichardson, fedor.sergeev, jakehehrlich, MaskRay, llvm-commits

Tags: #llvm

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

llvm-svn: 363524
2019-06-17 02:03:45 +00:00
Alex Brachet 899a3072f0 [objcopy] Error when --preserve-dates is specified with standard streams
Summary: llvm-objcopy/strip now error when -p is specified when reading from stdin or writing to stdout

Reviewers: jhenderson, rupprecht, espindola, alexshap

Reviewed By: jhenderson, rupprecht

Subscribers: emaste, arichardson, jakehehrlich, MaskRay, llvm-commits

Tags: #llvm

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

llvm-svn: 363485
2019-06-15 05:32:23 +00:00
Francis Visoiu Mistrih 7a21113ce8 Reland: [Remarks] Refactor optimization remarks setup
* Add a common function to setup opt-remarks
* Rename common options to the same names
* Add error types to distinguish between file errors and regex errors

llvm-svn: 363415
2019-06-14 16:20:51 +00:00
George Rimar 0aecabae14 Revert "Revert r363377: [yaml2obj] - Allow setting custom section types for implicit sections."
LLD test case will be fixed in a following commit.

Original commit message:

[yaml2obj] - Allow setting custom section types for implicit sections.

We were hardcoding the final section type for sections that
are usually implicit. The patch fixes that.

This also fixes a few issues in existent test cases and removes
one precompiled object.

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

llvm-svn: 363401
2019-06-14 14:25:34 +00:00
Rui Ueyama 9f4e21c69a Revert r363377: [yaml2obj] - Allow setting custom section types for implicit sections.
This reverts commit r363377 because lld's ELF/invalid/undefined-local-symbol-in-dso.test
test started failing after this commit.

llvm-svn: 363394
2019-06-14 13:57:25 +00:00
James Henderson 891cdaab7a [docs][llvm-dwarfdump] Make the --show-parents and --show-children help text and docs more consistent and correct
The docs and help text for --show-parents and --show-children were a bit
inconsistent. The help text claimed they had an effect when "=<offset>"
was used, whereas the doc said it had an effect when "--find" or
"--name" were used. This change changes the doc to mention "=<offset>"
and removes this reference from the help text, to avoid having a very
long description in the help text (it still says "when selectively
printing entries").

Reviewed by: JDevlieghere, aprantl

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

llvm-svn: 363380
2019-06-14 13:00:09 +00:00
George Rimar 3b523c0a2e [yaml2obj] - Allow setting custom section types for implicit sections.
We were hardcoding the final section type for sections that
are usually implicit. The patch fixes that.

This also fixes a few issues in existent test cases and removes
one precompiled object.

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

llvm-svn: 363377
2019-06-14 12:16:59 +00:00
James Henderson f7cfabb45d [llvm-readobj] Don't abort printing of dynamic table if string reference is invalid
If dynamic table is missing, output "dynamic strtab not found'. If the index is
out of range, output "Invalid Offset<..>".

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

Reviewed by: jhenderson, grimar, MaskRay

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

Patch by Yuanfang Chen.

llvm-svn: 363374
2019-06-14 12:02:01 +00:00
George Rimar d6df7ded6e [llvm-readobj] - Do not fail to dump the object which has wrong type of .shstrtab.
Imagine we have object that has .shstrtab with type != SHT_STRTAB.
In this case, we fail to dump the object, though GNU readelf dumps it without
any issues and warnings.

This patch fixes that. It adds a code to ELFDumper.cpp which is based on the implementation of getSectionName from the ELF.h:

https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Object/ELF.h#L608
https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Object/ELF.h#L431
https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Object/ELF.h#L539

The difference is that all non critical errors are ommitted what allows us to
improve the dumping on a tool side. Also, this opens a road for a follow-up that
should allow us to dump the section headers, but drop the section names in case if .shstrtab is completely absent and/or broken.

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

llvm-svn: 363371
2019-06-14 11:56:10 +00:00
George Rimar 43f62ff17c [yaml2obj] - Allow setting the custom Address for .strtab
Despite the fact that .strtab is non-allocatable,
there is no reason to disallow setting the custom address
for it.

The patch also adds a test case showing we can set any address
we want for other implicit sections.

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

llvm-svn: 363368
2019-06-14 11:13:32 +00:00
George Rimar cfa1a62a4c [yaml2obj] - Allow setting cutom Flags for implicit sections.
With this patch we get ability to set any flags we want
for implicit sections defined in YAML.

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

llvm-svn: 363367
2019-06-14 11:01:14 +00:00
Alex Brachet e0de6002e8 [llvm-objcopy] Remove no-op flush of errs
Reviewers: alexshap, rupprecht, jhenderson

Subscribers: jakehehrlich, llvm-commits

Tags: #llvm

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

llvm-svn: 363354
2019-06-14 04:34:26 +00:00
Alex Brachet d54d4f9905 [llvm-objcopy] Changed command line parsing errors
Summary: Tidied up errors during command line parsing to be more consistent with the rest of llvm-objcopy errors.

Reviewers: jhenderson, rupprecht, espindola, alexshap

Reviewed By: jhenderson, rupprecht

Subscribers: emaste, arichardson, MaskRay, llvm-commits, jakehehrlich

Tags: #llvm

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

llvm-svn: 363350
2019-06-14 02:04:02 +00:00
Stanislav Mekhanoshin c43e67bfff [AMDGPU] gfx1011/gfx1012 targets
Differential Revision: https://reviews.llvm.org/D63307

llvm-svn: 363344
2019-06-14 00:33:31 +00:00
Francis Visoiu Mistrih e4147ea1ef Revert "[Remarks] Refactor optimization remarks setup"
This reverts commit 6e6e3af55b.

This breaks greendragon.

llvm-svn: 363343
2019-06-14 00:05:56 +00:00
Seiya Nuta b1027a480a [llvm-objcopy] Fix sparc target endianness
Summary: AFAIK, the "sparc" target is big endian and the target for 32-bit little-endian SPARC is denoted as "sparcel". This patch fixes the endianness of "sparc" target and adds "sparcel" target for 32-bit little-endian SPARC.

Reviewers: espindola, alexshap, rupprecht, jhenderson

Reviewed By: jhenderson

Subscribers: jyknight, emaste, arichardson, fedor.sergeev, jakehehrlich, MaskRay, llvm-commits

Tags: #llvm

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

llvm-svn: 363336
2019-06-13 23:24:12 +00:00
Francis Visoiu Mistrih 6e6e3af55b [Remarks] Refactor optimization remarks setup
* Add a common function to setup opt-remarks
* Rename common options to the same names
* Add error types to distinguish between file errors and regex errors

llvm-svn: 363328
2019-06-13 21:46:57 +00:00
Eugene Leviant 86b7f865ac [llvm-objcopy] Implement IHEX reader
This is the final part of IHEX format support in llvm-objcopy
Differential revision: https://reviews.llvm.org/D62583

llvm-svn: 363243
2019-06-13 09:56:14 +00:00
Serge Guelton 4548c1cfca Sanitize llvm-extract -help output
Filter out irrelevant options

New output:

    OVERVIEW: llvm extractor

    USAGE: llvm-extract [options] <input bitcode file>

    OPTIONS:

    Generic Options:

      --help              - Display available options (--help-hidden for more)
      --help-list         - Display list of available options (--help-list-hidden for more)
      --version           - Display the version of this program

    llvm-extract Options:

      --alias=<alias>     - Specify alias to extract
      --bb=<function:bb>  - Specify <function, basic block> pairs to extract
      --delete            - Delete specified Globals from Module
      -f                  - Enable binary output on terminals
      --func=<function>   - Specify function to extract
      --glob=<global>     - Specify global to extract
      -o=<filename>       - Specify output filename
      --ralias=<ralias>   - Specify alias(es) to extract using a regular expression
      --recursive         - Recursively extract all called functions
      --rfunc=<rfunction> - Specify function(s) to extract using a regular expression
      --rglob=<rglobal>   - Specify global(s) to extract using a regular expression

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

llvm-svn: 363201
2019-06-12 21:08:19 +00:00
Jordan Rupprecht 565f1e2298 [llvm-readobj] Fix output interleaving issue caused by using multiple streams at the same time.
Summary:
Use llvm::fouts() as the default stream for outputing. No new stream
should be constructed to output at the same time.

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

Reviewers: jhenderson, grimar, MaskRay, phosek, rupprecht

Reviewed By: rupprecht

Subscribers: llvm-commits

Tags: #llvm

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

Patch by Yuanfang Chen!

llvm-svn: 363198
2019-06-12 20:16:22 +00:00
Matt Arsenault f29366b1f5 StackProtector: Use PointerMayBeCaptured
This was using its own, outdated list of possible captures. This was
at minimum not catching cmpxchg and addrspacecast captures.

One change is now any volatile access is treated as capturing. The
test coverage for this pass is quite inadequate, but this required
removing volatile in the lifetime capture test.

Also fixes some infrastructure issues to allow running just the IR
pass.

Fixes bug 42238.

llvm-svn: 363169
2019-06-12 14:23:33 +00:00
Ben Dunbobbin 52d3e4b4aa [Legacy LTO] Fix build bots: r363140: Fix export name
llvm-svn: 363151
2019-06-12 12:17:49 +00:00
Nico Weber 1dc2123d64 Share /machine: handling code with llvm-cvtres too
r363016 let lld-link and llvm-lib share the /machine: parsing code.
This lets llvm-cvtres share it as well.

Making llvm-cvtres depend on llvm-lib seemed a bit strange (it doesn't
need llvm-lib's dependencies on BinaryFormat and BitReader) and I
couldn't find a good place to put this code. Since it's just a few
lines, put it in lib/Object for now.

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

llvm-svn: 363144
2019-06-12 11:32:43 +00:00
Ben Dunbobbin 564d248ec2 [ThinLTO]LTO]Legacy] Fix dependent libraries support by adding querying of the IRSymtab
Dependent libraries support for the legacy api was committed in a
broken state (see: https://reviews.llvm.org/D60274). This was missed
due to the painful nature of having to integrate the changes into a
linker in order to test. This change implements support for dependent
libraries in the legacy LTO api:

- I have removed the current api function, which returns a single
string, and   added functions to access each dependent library
specifier individually.

- To reduce the testing pain, I have made the api functions as thin as
possible to   maximize coverage from llvm-lto.

- When doing ThinLTO the system linker will load the modules lazily
when scanning   the input files. Unfortunately, when modules are
lazily loaded there is no access   to module level named metadata. To
fix this I have added api functions that allow   querying the IRSymtab
for the dependent libraries. I hope to expand the api in the   future
so that, eventually, all the information needed by a client linker
during   scan can be retrieved from the IRSymtab.

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

llvm-svn: 363140
2019-06-12 11:07:56 +00:00
James Henderson 2c16bb8034 [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
James Henderson 9487963244 [llvm-dwarfdump] Simplify --ignore-case help text and documentation
There was a typo in the --ignore-case help text that was copied into the
llvm-dwarfdump command-guide. Additionally, this patch simplifies the
wording, since it was unnecessarily verbose: the switch applies for
searching in general and doesn't need explicitly stating different
search modes (which might go out-of-date as options are added or
removed).

Reviwed by: JDevlieghere

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

llvm-svn: 363066
2019-06-11 13:51:18 +00:00
Nico Weber dd6019526d Let writeWindowsResourceCOFF() take a TimeStamp parameter
For lld, pass in Config->Timestamp (which is set based on lld's
/timestamp: and /Brepro flags). Since the writeWindowsResourceCOFF()
data is only used in-memory by LLD and the obj's timestamp isn't used
for anything in the output, this doesn't change behavior.

For llvm-cvtres, add an optional /timestamp: parameter, and use the
current behavior of calling time() if the parameter is not passed in.

This doesn't really change observable behavior (unless someone passes
/timestamp: to llvm-cvtres, which wasn't possible before), but it
removes the last unqualified call to time() from llvm/lib, which seems
like a good thing.

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

llvm-svn: 363050
2019-06-11 11:26:50 +00:00
James Henderson d5f38dae59 [llvm-dwarfdump] Add -o to help text and remove --out-file from doc
-o is in the documentation, but not in the llvm-dwarfdump help text.
This patch adds it by inverting the -o and --out-file aliasing. It also
removes --out-file from the documentation, since we don't really want
people to be using this switch in practice.

Reviewed by: aprantl, JDevlieghere, dblaikie

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

llvm-svn: 363044
2019-06-11 10:20:07 +00:00
George Rimar ffb3c72a74 [yaml2elf] - Check we are able to set custom sh_link for .symtab/.dynsym
Allow using both custom numeric and string values for Link field of the
dynamic and regular symbol tables.

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

llvm-svn: 363042
2019-06-11 10:00:51 +00:00
Peter Collingbourne e5bdedac9d Symbolize: Make DWPName a symbolizer option instead of an argument to symbolize{,Inlined}Code.
This makes the interface simpler and more consistent with the interface for
.dSYM files and fixes a bug where llvm-symbolizer would not read the dwp if
it was asked to symbolize data before symbolizing code.

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

llvm-svn: 363025
2019-06-11 02:32:27 +00:00
Peter Collingbourne a2048f868d Symbolize: Replace the Options constructor with in-class initialization. NFCI.
This is not only less code but also clearer at the use site.

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

llvm-svn: 363024
2019-06-11 02:31:54 +00:00
Daniel Sanders cd0bc47836 Break a couple more false dependencies on target libraries
Summary: Repeat r361567 for a few more tools.

Reviewers: bogner

Reviewed By: bogner

Subscribers: mgorny, llvm-commits

Tags: #llvm

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

llvm-svn: 363011
2019-06-10 23:52:38 +00:00
Jonas Devlieghere 60e52cab86 [dsymutil] Remove stale comment (NFC)
The comment was no longer relevant after r362621.

llvm-svn: 363008
2019-06-10 23:30:20 +00:00
Jordan Rupprecht f8f9d65f85 [llvm-objcopy] Fix SHT_GROUP ordering.
Summary:
When llvm-objcopy sorts sections during finalization, it only sorts based on the offset, which can cause the group section to come after the sections it contains. This causes link failures when using gold to link objects created by llvm-objcopy.

Fix this for now by copying GNU objcopy's behavior of placing SHT_GROUP sections first. In the future, we may want to remove this sorting entirely to more closely preserve the input file layout.

This fixes https://bugs.llvm.org/show_bug.cgi?id=42052.

Reviewers: jakehehrlich, jhenderson, MaskRay, espindola, alexshap

Reviewed By: MaskRay

Subscribers: phuongtrang148993, emaste, arichardson, llvm-commits

Tags: #llvm

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

llvm-svn: 362973
2019-06-10 18:35:01 +00:00
Andrea Di Biagio c650a9084f [llvm-mca] Enable bottleneck analysis when flag -all-views is specified.
Bottleneck Analysis is one of the many views available in llvm-mca. Therefore,
it should be enabled when flag -all-views is passed in input to the tool.

llvm-svn: 362964
2019-06-10 16:56:25 +00:00
George Rimar dd4f253c4d [llvm-readobj/llvm-readelf] - Don't fail to dump the object if .dynsym has broken sh_link field.
This is https://bugs.llvm.org/show_bug.cgi?id=42215.

GNU readelf allows to dump the objects in that case,
but llvm-readobj/llvm-readelf reports an error and stops.

The patch fixes that.

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

llvm-svn: 362938
2019-06-10 14:23:46 +00:00
Andrea Di Biagio 49d8699ecc [MCA] Fix -Wunused-private-field warning after r362933. NFC
This should unbreak the buildbots.

llvm-svn: 362935
2019-06-10 13:33:54 +00:00
Andrea Di Biagio 47db08dbb1 [MCA] Further refactor the bottleneck analysis view. NFCI.
llvm-svn: 362933
2019-06-10 12:50:08 +00:00
George Rimar 1e41007aeb [yaml2obj/obj2yaml] - Make RawContentSection::Content and RawContentSection::Size optional
This is a follow-up for D62809.

Content and Size fields should be optional as was discussed in comments
of the D62809's thread. With that, we can describe a specific string table and
symbol table sections in a more correct way and also show appropriate errors.

The patch adds lots of test cases where the behavior is described in details.

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

llvm-svn: 362931
2019-06-10 12:43:18 +00:00
George Rimar 379aa18a39 [yaml2obj] - Do not assert when .dynsym is specified explicitly, but .dynstr is not present.
We have a code in buildSectionIndex() that adds implicit sections:

// Add special sections after input sections, if necessary.
for (StringRef Name : implicitSectionNames())
  if (SN2I.addName(Name, SecNo)) {
    // Account for this section, since it wasn't in the Doc
    ++SecNo;
    DotShStrtab.add(Name);
  }

The problem arises when .dynsym is specified explicitly and no
DynamicSymbols is used. In that case, we do not add
.dynstr implicitly and will assert later when will try to set Link
for .dynsym.

Seems, in this case, reasonable behavior is to allow Link field to be zero.
This is what this patch does.

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

llvm-svn: 362929
2019-06-10 11:38:06 +00:00
Simon Pilgrim c6a930e4b4 Fix MSVC "32-bit shift implicitly converted to 64 bits" warning. NFCI.
llvm-svn: 362927
2019-06-10 10:13:32 +00:00
George Rimar d71017bc86 [yaml2obj] - Remove helper methods that are probably excessive. NFC.
These methods are used only once. One of them is not used at all.

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

llvm-svn: 362925
2019-06-10 09:57:29 +00:00
Sylvestre Ledru 375297f38f fix a typo unavaliable=>unavailable
llvm-svn: 362878
2019-06-08 15:07:55 +00:00
Seiya Nuta b728e53b95 [llvm-objcopy][MachO] Recompute and update offset/size fields in the writer
Summary:
Recompute and update offset/size fields so that we can implement llvm-objcopy options like --only-section.

This patch is the first step and focuses on supporting load commands that covered by existing tests: executable files and
dynamic libraries are not supported.

Reviewers: alexshap, rupprecht, jhenderson

Reviewed By: alexshap, rupprecht

Subscribers: compnerd, jakehehrlich, llvm-commits

Tags: #llvm

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

llvm-svn: 362863
2019-06-08 01:22:54 +00:00
Jordan Rupprecht 7dd813fea1 [llvm-objdump] Fix Bugzilla ID 41862 to support checking addresses of disassembled object
Summary:
This fixes the bugzilla id,41862 to support dealing with checking
stop address against start address to support this not being a
proper object to check the disasembly against like gnu objdump
currently does.

Reviewers: jakehehrlich, rupprecht, echristo, jhenderson, grimar

Reviewed By: jhenderson

Subscribers: MaskRay, smeenai, rupprecht, llvm-commits

Tags: #llvm

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

Patch by Nicholas Krause!

llvm-svn: 362847
2019-06-07 21:49:26 +00:00
Shoaib Meenai 20361de879 [llvm-lipo] Drop unneeded braces. NFC
llvm-svn: 362841
2019-06-07 20:52:17 +00:00
Shoaib Meenai 61f7df54e3 [llvm-lipo] Implement -archs
Displays the architecture names of an input file.
Unknown architectures are represented by unknown(cputype,cpusubtype).

Patch by Anusha Basana <anusha.basana@gmail.com>

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

llvm-svn: 362840
2019-06-07 20:47:58 +00:00
Michael Pozulp c3c18f4a0d [llvm-objdump] Add warning if --disassemble-functions specifies an unknown symbol
Summary:
Fixes Bug 41904 https://bugs.llvm.org/show_bug.cgi?id=41904

Re-land r362768 after it was reverted in r362826.

Reviewers: jhenderson, rupprecht, grimar, MaskRay

Reviewed By: jhenderson, rupprecht, MaskRay

Subscribers: dexonsmith, rupprecht, kristina, llvm-commits

Tags: #llvm

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

llvm-svn: 362838
2019-06-07 20:34:31 +00:00
Peter Collingbourne 9fa6538f3b Unbreak 32-bit build.
llvm-svn: 362827
2019-06-07 18:57:32 +00:00
Vlad Tsyrklevich e67f6206ac Revert "[llvm-objdump] Add warning if --disassemble-functions specifies an unknown symbol"
This reverts commit 50f61af3f3, it used
the function introduced in the previous revert of
0bddef7901.

llvm-svn: 362826
2019-06-07 18:55:12 +00:00
Simon Pilgrim 1a6ce24ee1 Fix -Wunused-lambda-capture warning. NFCI.
llvm-svn: 362822
2019-06-07 18:20:09 +00:00
Peter Collingbourne 8d58a98c59 llvm-objcopy: Implement --extract-partition and --extract-main-partition.
This implements the functionality described in
https://lld.llvm.org/Partitions.html. It works as follows:

- Reads the section headers using the ELF header at file offset 0;
- If extracting a loadable partition:
  - Finds the section containing the required partition ELF header by looking it up in the section table;
  - Reads the ELF and program headers from the section.
- If extracting the main partition:
  - Reads the ELF and program headers from file offset 0.
- Filters the section table according to which sections are in the program headers that it read:
  - If ParentSegment != nullptr or section is not SHF_ALLOC, then it goes in.
  - Sections containing partition ELF headers or program headers are excluded as there are no headers for these in ordinary ELF files.

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

llvm-svn: 362818
2019-06-07 17:57:48 +00:00
Jonas Devlieghere bb8de35384 [dsymutil] Use the number of threads specified.
Before this patch we used either a single thread, or the number of
hardware threads available, effectively ignoring the number of threads
specified on the command line.

llvm-svn: 362815
2019-06-07 17:35:19 +00:00
George Rimar 33044a7ae2 [llvm-objcopy] - Emit error and don't crash if program header reaches past end of file.
This is https://bugs.llvm.org/show_bug.cgi?id=42122.

If an object file has a size less than program header's file [offset + size]
(i.e. if we have overflow), llvm-objcopy crashes instead of reporting a
error.

The patch fixes this issue.

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

llvm-svn: 362778
2019-06-07 08:34:18 +00:00
George Rimar eb394e93d2 [yaml2elf] - Refactoring followup for D62809
This is a refactoring follow-up for D62809
"Change how we handle implicit sections.".
It allows to simplify the code.

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

llvm-svn: 362777
2019-06-07 08:31:36 +00:00
Sam Parker c5ef502ee8 [CodeGen] Generic Hardware Loop Support
Patch which introduces a target-independent framework for generating
hardware loops at the IR level. Most of the code has been taken from
PowerPC CTRLoops and PowerPC has been ported over to use this generic
pass. The target dependent parts have been moved into
TargetTransformInfo, via isHardwareLoopProfitable, with
HardwareLoopInfo introduced to transfer information from the backend.
    
Three generic intrinsics have been introduced:
- void @llvm.set_loop_iterations
  Takes as a single operand, the number of iterations to be executed.
- i1 @llvm.loop_decrement(anyint)
  Takes the maximum number of elements processed in an iteration of
  the loop body and subtracts this from the total count. Returns
  false when the loop should exit.
- anyint @llvm.loop_decrement_reg(anyint, anyint)
  Takes the number of elements remaining to be processed as well as
  the maximum numbe of elements processed in an iteration of the loop
  body. Returns the updated number of elements remaining.

llvm-svn: 362774
2019-06-07 07:35:30 +00:00
Michael Pozulp 767bdd55e1 [llvm-objdump] Print source when subsequent lines in the translation unit come from the same line in two different headers.
Reviewers: grimar, rupprecht, jhenderson

Reviewed By: grimar, jhenderson

Subscribers: llvm-commits, jhenderson

Tags: #llvm

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

llvm-svn: 362771
2019-06-07 06:23:54 +00:00
Michael Pozulp 50f61af3f3 [llvm-objdump] Add warning if --disassemble-functions specifies an unknown symbol
Summary: Fixes Bug 41904 https://bugs.llvm.org/show_bug.cgi?id=41904

Reviewers: jhenderson, rupprecht, grimar, MaskRay

Reviewed By: jhenderson, rupprecht, MaskRay

Subscribers: dexonsmith, rupprecht, kristina, llvm-commits

Tags: #llvm

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

llvm-svn: 362768
2019-06-07 05:11:13 +00:00
Owen Reynolds bf5bca5bea [llvm-ar] Create thin archives with MRI scripts
This patch implements the "CREATE_THIN" MRI script command, allowing thin archives to be created via MRI scripts. 

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

llvm-svn: 362704
2019-06-06 13:19:50 +00:00
Jonas Devlieghere 3027a2999c [dsymutil] Support more than 4 architectures
When running dsymutil on a fat binary, we use temporary files in a small
vector of size four. When processing more than 4 architectures, this
resulted in a user-after-move, because the temporary files got moved to
the heap. Instead of storing an optional temp file, we now use a unique
pointer, so the location of the actual temp file doesn't change.

We could test this by checking in 5 binaries for 5 different
architectures, but this seems wasteful, especially since the number of
elements in the small vector is arbitrary.

llvm-svn: 362621
2019-06-05 17:14:32 +00:00
George Rimar 66296dc3e4 [yaml2obj] - Change how we handle implicit sections.
We have a few sections that can be added implicitly to the output:
".dynsym", ".dynstr", ".symtab", ".strtab" and ".shstrtab".

Problem appears when such section is listed explicitly in YAML.
In that case it's content is written twice:
first time during writing of regular sections listed in the document
and second time during special handling.

Because of that their file offsets can become unexpectedly broken:
(yaml file for sample below lists .dynsym explicitly before .text.foo)

Before patch:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .dynsym           DYNSYM           0000000000000100  00000250
       0000000000000030  0000000000000018   A       6     0     8
  [ 2] .text.foo         PROGBITS         0000000000000200  00000200
       0000000000000000  0000000000000000  AX       0     0     0

After patch:
Section Headers:
  [Nr] Name         Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .dynsym           DYNSYM           0000000000000100  00000200
       0000000000000030  0000000000000018   A       6     0     8
  [ 2] .text.foo         PROGBITS         0000000000000200  00000230
       0000000000000000  0000000000000000  AX       0     0     0

This patch reorganizes our code and fixes the issue described.

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

llvm-svn: 362602
2019-06-05 13:16:53 +00:00
George Rimar b42196661b [llvm-objdump] - Disassemble non-executable sections if specifically requested.
This is https://bugs.llvm.org/show_bug.cgi?id=41897.

Previously -d + -j .data had no effect, that wasn't consistent with GNU,
which proccesses .data in that case. With this patch we follow this behavior.

Diffeential revision: https://reviews.llvm.org/D62848

llvm-svn: 362596
2019-06-05 11:37:53 +00:00
Serge Guelton daeeb33f86 Sanitize llvm-size help
Remove irrelevant options from standard help output.

New output:

    OVERVIEW: llvm object size dumper

    USAGE: llvm-size [options] <input files>

    OPTIONS:

    Generic Options:

      --help           - Display available options (--help-hidden for more)
      --help-list      - Display list of available options (--help-list-hidden for more)
      --version        - Display the version of this program

    llvm-size Options:

      Specify output format
          -A             - System V format
          -B             - Berkeley format
          -m             - Darwin -m format
      --arch=<string>  - architecture(s) from a Mach-O file to dump
      --common         - Print common symbols in the ELF file.  When using Berkely format, this is added to bss.
      Print size in radix:
          -o             - Print size in octal
          -d             - Print size in decimal
          -x             - Print size in hexadecimal
      --format=<value> - Specify output format
        =sysv          -   System V format
        =berkeley      -   Berkeley format
        =darwin        -   Darwin -m format
      -l               - When format is darwin, use long format to include addresses and offsets.
      --radix=<value>  - Print size in radix
        =8             -   Print size in octal
        =10            -   Print size in decimal
        =16            -   Print size in hexadecimal
      --totals         - Print totals of all objects - Berkeley format only

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

llvm-svn: 362593
2019-06-05 10:32:28 +00:00
James Henderson 7f3135037d [llvm-symbolizer] Flush output on bad input
One way of using llvm-symbolizer is to interactively within a process
write a line from a parent process to llvm-symbolizer's stdin, and then
read the output, then write the next line, read, etc. This worked as
long as all the lines were good. However, this didn't work prior to this
patch if any of the inputs were bad inputs, because the output is not
flushed after a bad input, meaning the parent process is sat waiting for
output, whilst llvm-symbolizer is sat waiting for input. This patch
flushes the output after every invocation of symbolizeInput when reading
from stdin. It also removes unnecessary flushing when llvm-symbolizer is
not reading addresses from stdin, which should give a slight performance
boost in these situations.

Reviewed by: ikudrin

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

llvm-svn: 362511
2019-06-04 15:34:58 +00:00
Peter Smith 49d7221f71 [AArch64][ELF][llvm-readobj] Add support for BTI and PAC dynamic tags
ELF for the 64-bit Arm Architecture defines two processor-specific dynamic
tags:
DT_AARCH64_BTI_PLT 0x70000001, d_val
DT_AARCH64_PAC_PLT 0x70000003, d_val

These presence of these tags indicate that PLT sequences have been
protected using Branch Target Identification and Pointer Authentication
respectively. The presence of both indicates that the PLT sequences have
been protected with both Branch Target Identification and Pointer
Authentication.

This patch adds the tags and tests for llvm-readobj and yaml2obj.

As some of the processor specific dynamic tags overlap, this patch splits
them up, keeping their original default value if they were not previously
mentioned explicitly in a switch case.

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

llvm-svn: 362493
2019-06-04 11:44:33 +00:00
Peter Smith 580c6d31c0 [AARCH64][ELF][llvm-readobj] Support for AArch64 .note.gnu.property
ELF for the 64-bit Arm Architecture defines a processor specific property
type GNU_PROPERTY_AARCH64_FEATURE_1_AND as GNU_PROPERTY_LOPROC. This
property works in a similar way to the existing X86 processor specific
property GNU_PROPERTY_GNU_X86_FEATURE_1_AND.

Two feature bits are defined for GNU_PROPERTY_AARCH64_FEATURE_1_AND:
- GNU_PROPERTY_AARCH64_FEATURE_1_BTI 0x1
- GNU_PROPERTY_AARCH64_FEATURE_1_PAC 0x2

This patch defines the property, feature bits and implements support for
printing in llvm-readobj.

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

llvm-svn: 362490
2019-06-04 11:28:22 +00:00
Owen Reynolds 5d5078e341 [llvm-ar] Reapply Fix relative thin archive path handling
Includes a fix for an introduced build failure due to a post c++11 use of std::mismatch. 

This fixes some thin archive relative path issues, paths are shortened where possible and paths are output correctly when using the display table command.

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

llvm-svn: 362484
2019-06-04 10:13:03 +00:00
Reid Kleckner 221e604d6f [PDB] Copy inlinee lines records into the PDB
Summary:
- Fixes inline call frame line table display in windbg.
- Improve llvm-pdbutil to dump extra file ids.
- Warn on unknown subsections so we don't have this kind of bug in the
  future.

Reviewers: inglorion, akhuang, aganea

Subscribers: eraman, zturner, llvm-commits

Tags: #llvm

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

llvm-svn: 362429
2019-06-03 18:15:38 +00:00
Dmitri Gribenko 857de979a7 Revert "[llvm-ar] Fix relative thin archive path handling"
This reverts commit r362407.  It broke compilation of
llvm/lib/Object/ArchiveWriter.cpp:

error: type 'llvm::sys::path::const_iterator' does not provide a call
operator

llvm-svn: 362413
2019-06-03 16:21:37 +00:00
Owen Reynolds fade9cbed7 [llvm-ar] Fix relative thin archive path handling
This fixes some thin archive relative path issues, paths are shortened where possible and paths are output correctly when using the display table command.

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

llvm-svn: 362407
2019-06-03 15:26:07 +00:00
Alex Brachet b3498346fd [llvm-objcopy] test commit
llvm-svn: 362289
2019-06-01 07:36:57 +00:00
Tom Tan eb4d6142dc [COFF, ARM64] Add CodeView register mapping
CodeView has its own register map which is defined in cvconst.h. Missing this
mapping before saving register to CodeView causes debugger to show incorrect
value for all register based variables, like variables in register and local
variables addressed by register (stack pointer + offset).

This change added mapping between LLVM register and CodeView register so the
correct register number will be stored to CodeView/PDB, it aso fixed the
mapping from CodeView register number to register name based on current
CPUType but print PDB to yaml still assumes X86 CPU and needs to be fixed.

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

llvm-svn: 362280
2019-05-31 23:43:31 +00:00
Reid Kleckner eddd6c25b5 [codeview] Revert inline line table change of r362264
Testing with debuggers shows that our previous behavior was correct.
The reason I thought MSVC did things differently is that MSVC prefers to
use the 0xB combined code offset and code length update opcode when
inline sites are discontiguous.

Keep the test changes, and update the llvm-pdbutil inline line table
dumper to account for this new interpretation of the opcodes.

llvm-svn: 362277
2019-05-31 22:55:03 +00:00
Nick Desaulniers 8b1f64f63d [Bugpoint] fix another use-after-move. NFC
Summary:
This was flagged in https://www.viva64.com/en/b/0629/ under "Snippet No.
7".

These statements are order independent, short of the use-after-move.

Reviewers: echristo, srhines, RKSimon

Reviewed By: RKSimon

Subscribers: dblaikie, llvm-commits

Tags: #llvm

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

llvm-svn: 362267
2019-05-31 21:36:21 +00:00
Andrea Di Biagio 065bd45da9 [MCA] Remove unused fields from BottleneckAnalysis. NFC
This should appease the buildbots.

llvm-svn: 362251
2019-05-31 18:01:42 +00:00
Andrea Di Biagio 312f3a2bbf [MCA] Refactor class BottleneckAnalysis. NFCI
The resource pressure distribution computation is now delegated by class
BottleneckAnalysis to an instance of class PressureTracker.
Class PressureTracker is also responsible for:
 - tracking users of processor resource units.
 - tracking the number of delay cycles caused by increases in backpressure.

BottleneckAnalysis internally initializes a dependency graph. Each nodes
represents an instruction in the input code sequence.  Edges of the dependency
graph are critical register/memory/resource dependencies.  Dependencies are only
added to the graph if they are seen as critical by backend pressure events.

The DependencyGraph is currently unused. It is possible to print the dependency
 graph (see method DependencyGraph::dump()) for debugging purposes.
The long term goal is to use the information stored by the dependency graph in
order to do critical path computation.

llvm-svn: 362246
2019-05-31 17:18:34 +00:00
Sam Clegg 9d21f510ee Fix -DBUILD_SHARED_LIBS=ON build after rL362160
Differential Revision: https://reviews.llvm.org/D62709

llvm-svn: 362180
2019-05-31 01:04:00 +00:00
Francis Visoiu Mistrih 6ada11f134 [Remarks][NFC] Move the serialization to lib/Remarks
Separate the remark serialization to YAML from the LLVM Diagnostics.

This adds a new serialization abstraction: remarks::Serializer. It's
completely independent from lib/IR and it provides an easy way to
replace YAML by providing a new remarks::Serializer.

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

llvm-svn: 362160
2019-05-30 21:45:59 +00:00
Michael Trent c58130bc84 Write new tests for r362121
Summary:
The tests for r362121 ran dsymutil against a test binary every time.
This caused problems on lld-x86_64-ubuntu-fast as dsymutil required
a lipo tool be available to process those binaries.

This change rewrites the new test cases in macho-disassemble-g-dsym
to use bespoke test binaries (exe and dwarf) simplifying the test's
runtime dependencies.

The changes to tools/llvm-objdump/MachODump.cpp are unchanged from
r362121

Reviewers: pete, lhames, JDevlieghere

Reviewed By: pete

Subscribers: smeenai, aprantl, rupprecht, llvm-commits

Tags: #llvm

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

llvm-svn: 362141
2019-05-30 20:09:09 +00:00
Michael Trent 5d5f629922 Reverting change r362121 due to lld-x86_64-ubuntu-fast test failures
llvm-svn: 362123
2019-05-30 18:17:10 +00:00
Michael Trent 50daaa5f6b Support Universal dSYM files in llvm-objdump
Summary:
Commonly programmers use llvm-objdump to disassemble Mach-O target
binaries with Mach-O dSYMS. While llvm-objdump allows programmers to
disassemble Universal binaries, it previously did not recognize
Universal dSYM files. This change updates llvm-objdump to support
passing in Universal files via the -dsym option. Now, when
disassembling a Mach-O file either as a stand alone file or as an entry
in a Universal binariy, llvm-objdump will search through a Universal
dSYM for a Mach-O matching the architecture flag of the file being
disassembled.

Reviewers: pete, lhames

Reviewed By: pete

Subscribers: rupprecht, llvm-commits

Tags: #llvm

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

llvm-svn: 362121
2019-05-30 17:56:05 +00:00
George Rimar 28e1ff2c3f [llvm-readobj] - An attemp to fix BB.
BB failed:
http://lab.llvm.org:8011/builders/clang-armv7-linux-build-cache/builds/15062/steps/build%20stage%201/logs/stdio

Error was:
/home/buildslave/buildslave/clang-armv7-linux-build-cache/llvm/tools/llvm-readobj/ELFDumper.cpp:3540:7:
error: non-constant-expression cannot be narrowed from type 'llvm::support::detail::packed_endian_specific_integral<unsigned long long,
llvm::support::endianness::little, 1>::value_type' (aka 'unsigned long long') to 'size_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
      StrTabSec->sh_size};

llvm-svn: 362084
2019-05-30 10:42:47 +00:00
George Rimar c372f41c18 [llvm-readobj/llvm-readelf] - Implement GNU style dumper of the SHT_GNU_verdef section.
It was not implemented yet, we had only LLVM style dumper implemented.
Section description is here: https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/symversion.html

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

llvm-svn: 362082
2019-05-30 10:36:52 +00:00
George Rimar e3406c42a4 [llvm-readobj/llvm-readelf] - Implement GNU style dumper of the SHT_GNU_verneed section.
It was not implemented yet, we had only LLVM style dumper implemented.
Section description is here: https://refspecs.linuxfoundation.org/LSB_2.0.1/LSB-Core/LSB-Core/symverrqmts.html

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

llvm-svn: 362080
2019-05-30 10:14:41 +00:00
Eugene Leviant fa147c97d6 [llvm-objcopy] Remove %p format specifiers
On 32-bit machines %p expects 32 bit values, however
addresses in llvm-objcopy are always 64 bits.

llvm-svn: 362074
2019-05-30 09:09:01 +00:00
Seiya Nuta 4bc710166f [llvm-objcopy][MachO] Print an error message on use of unsupported options
Summary:
It is better to print an error message instead of silently ignoring unsupported options.

As mentioned in https://reviews.llvm.org/D57045, this is not the best solution and we should print which flag is not supported at some time.

Reviewers: alexshap, rupprecht, jhenderson, jakehehrlich

Reviewed By: alexshap, rupprecht, jakehehrlich

Subscribers: jakehehrlich, llvm-commits

Tags: #llvm

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

llvm-svn: 362040
2019-05-29 22:21:12 +00:00
Reid Kleckner 86bad3f924 [llvm-pdbutil] Dump inline call site line table annotations
This ports and improves on some existing llvm-readobj -codeview dumping
functionality that llvm-pdbutil lacked.

Helpful for comparing inline line tables between MSVC and clang.

llvm-svn: 362037
2019-05-29 21:26:25 +00:00
Eugene Leviant 33da02762f Attempt to fix buildbot after r361949
llvm-svn: 361954
2019-05-29 12:26:23 +00:00
Eugene Leviant a6fb183c98 [llvm-objcopy] Implement IHEX writer
Differential revision: https://reviews.llvm.org/D60270

llvm-svn: 361949
2019-05-29 11:37:16 +00:00
George Rimar 8ac7b2d07b [llvm-readelf] - Allow dumping of the .dynamic section even if there is no PT_DYNAMIC header.
It is now possible after D61937 was landed and was discussed
in it's review comments. It is not consistent with GNU, which
does not output .dynamic section content in this case for
no visible reason.

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

llvm-svn: 361943
2019-05-29 10:31:46 +00:00
Fangrui Song ed6fa44f23 [llvm-readobj] -u: don't crash when dumping SHT_ARM_EXIDX if .symtab doesn't exist
Reviewed By: kongyi

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

llvm-svn: 361929
2019-05-29 06:18:34 +00:00
Alexander Shaposhnikov 88aed8da61 [tools] Introduce llvm-lipo
This diff starts the implementation of llvm-lipo 
which is supposed to be a drop-in replacement for the well-known tool lipo.

Test plan: make check-all

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

llvm-svn: 361896
2019-05-28 23:22:12 +00:00
Peter Collingbourne 0dac476072 Change ELF tools to allow multiple sections per file.
This is how multi-partition combined output files are going to look. If we
see multiple sections, the tools will just read the first one.

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

llvm-svn: 361869
2019-05-28 20:01:25 +00:00
Jason Liu 9212206d25 [XCOFF] Implement parsing symbol table for xcoffobjfile and output as yaml format
Summary:
This patch implement parsing symbol table for xcoffobjfile and
output as yaml format. Parsing auxiliary entries of a symbol
will be in a separate patch.

The XCOFF object file (aix_xcoff.o) used in the test comes from
-bash-4.2$ cat test.c
extern int i;
extern int TestforXcoff;
int main()
{
i++;
TestforXcoff--;
}

Patch by DiggerLin

Reviewers: sfertile, hubert.reinterpretcast, MaskRay, daltenty

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

llvm-svn: 361832
2019-05-28 14:37:59 +00:00
Hans Wennborg 80343a348b Cleanups for r361807 that I somehow failed to commit
llvm-svn: 361812
2019-05-28 12:30:35 +00:00
Hans Wennborg 5b86163f62 Fix some llvm-readelf tests after r361633
They were failing on 32-bit Windows. In the cases where I've changed
test expectations, I've checked that they match the output of GNU
readelf.

llvm-svn: 361807
2019-05-28 11:24:20 +00:00
Serge Guelton 6e379e2b68 Make llvm-as --help great again
This is a follow-up to https://reviews.llvm.org/D60411, but for llvm-as.

New output:

    OVERVIEW: llvm .ll -> .bc assembler

    USAGE: llvm-as [options] <input .llvm file>

    OPTIONS:

    Generic Options:

      -help                        - Display available options (-help-hidden for more)
      -help-list                   - Display list of available options (-help-list-hidden for more)
      -version                     - Display the version of this program

    llvm-as Options:

      -data-layout=<layout-string> - data layout string to use
      -disable-output              - Disable output
      -f                           - Enable binary output on terminals
      -module-hash                 - Emit module hash
      -o=<filename>                - Override output filename

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

llvm-svn: 361750
2019-05-27 08:24:06 +00:00
Jonas Devlieghere 0da8160df3 [dwarfdump] Add flag to limit the number of parents DIEs
This adds `-parent-recurse-depth` which limits the number of parent DIEs
being dumped.

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

llvm-svn: 361671
2019-05-24 21:11:28 +00:00
George Rimar c1cc8d0eca [llvm-objcopy] - Strip undefined symbols if they are no longer referenced following --only-section
This is https://bugs.llvm.org/show_bug.cgi?id=40004.

In this patch I teach llvm-objcopy to remove undefined symbols if
them are not used anymore after applying -j/--only-section option.

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

llvm-svn: 361642
2019-05-24 15:04:50 +00:00
Andrea Di Biagio 21977d8e29 [MCA] Zero-initialize field CRD in InstructionBase. Also run clang-format on a couple of files. NFC
llvm-svn: 361637
2019-05-24 13:56:01 +00:00
Simon Atanasyan 8362cbe13b [llvm-readobj] Implement GNU-style output for dynamic table
GNU readelf tool prints slightly different dynamic table "header" and
surrounds dynamic tag names by brackets. This patch implements the same
formatting for GNU-style output of the `llvm-readobj`.

LLVM
```
DynamicSection [ (13 entries)
  Tag        Type                 Name/Value
  0x00000006 SYMTAB               0x168
  ...
]
```

GNU
```
Dynamic section at offset 0x1d0 contains 13 entries:
  Tag        Type                 Name/Value
  0x00000006 (SYMTAB)             0x168
  ...
```

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

llvm-svn: 361633
2019-05-24 12:22:53 +00:00
George Rimar 33bee053c3 Revert r361630 "[llvm-readelf] - Allow dumping of the .dynamic section even if there is no PT_DYNAMIC header."
It broke BB:
http://lab.llvm.org:8011/builders/ppc64le-lld-multistage-test/builds/3748

llvm-svn: 361631
2019-05-24 11:24:42 +00:00
George Rimar f835fcf412 [llvm-readelf] - Allow dumping of the .dynamic section even if there is no PT_DYNAMIC header.
It is now possible after D61937 was landed and was discussed
in it's review comments. It is not consistent with GNU, which
does not output .dynamic section content in this case for
no visible reason.

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

llvm-svn: 361630
2019-05-24 11:12:50 +00:00
Simon Atanasyan e4f01ec50c [llvm-readobj][mips] Align GOT columns headers properly in 64-bit case
llvm-svn: 361626
2019-05-24 10:26:48 +00:00
Jordan Rupprecht 01d6173667 [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
Daniel Sanders 4cecdaa05f Fix BUILD_SHARED_LIBS builds after r361567
Also fixed a comment I noticed while debugging this build

llvm-svn: 361591
2019-05-24 02:15:27 +00:00
Peter Collingbourne ab09cca310 llvm-objcopy: Change sectionWithinSegment() to use virtual addresses instead of file offsets for SHT_NOBITS sections.
Without this, sectionWithinSegment() will return the wrong answer for bss
sections. This doesn't seem to matter now (for non-broken ELF files), but
it will matter with a change that I'm working on.

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

llvm-svn: 361578
2019-05-24 00:21:46 +00:00
Daniel Sanders 3e4acaabb9 Break false dependencies on target libraries
Summary:
For the most part this consists of replacing ${LLVM_TARGETS_TO_BUILD} with
some combination of AllTargets* so that they depend on specific components
of a target backend rather than all of it. The overall effect of this is
that, for example, tools like opt no longer falsely depend on the
disassembler, while tools like llvm-ar no longer depend on the code
generator.

There's a couple quirks to point out here:
* AllTargetsCodeGens is a bit more prevalent than expected. Tools like dsymutil
  seem to need it which I was surprised by.
* llvm-xray linked to all the backends but doesn't seem to need any of them.
  It builds and passes the tests so that seems to be correct.
* I left gold out as it's not built when binutils is not available so I'm
  unable to test it

Reviewers: bogner, JDevlieghere

Reviewed By: bogner

Subscribers: mehdi_amini, mgorny, steven_wu, dexonsmith, rupprecht, llvm-commits

Tags: #llvm

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

llvm-svn: 361567
2019-05-23 23:02:56 +00:00
Fangrui Song 6aebd8394a [Object] object::ELFObjectFile::symbol_begin(): skip symbol index 0
For clients iterating the symbol table, none expects to handle index 0
(STN_UNDEF). Skip it to improve consistency with other binary formats.
Clients that need STN_UNDEF (e.g. lld) can use
getSectionContentsAsArray(). A test will be added in D62148.

Reviewed By: mtrent

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

llvm-svn: 361506
2019-05-23 16:01:59 +00:00
George Rimar e98a8f7b2a [llvm-objcopy] - Many minor NFC changes to cleanup/improve the code in ELF/Object.cpp.
The code in ELF/Object.cpp is sometimes a bit hard to read because of
lots of auto used everywhere. The main intention of this patch is
to replace them with the real type for places where it is not obvious.
Also it cleanups few places.

It is NFC change, but I want to be sure that there is no objections to do that since it
is massive.

DIfferential revision: https://reviews.llvm.org/D62260

llvm-svn: 361466
2019-05-23 09:18:57 +00:00
Seiya Nuta ada9d2d884 [llvm-objcopy] Add file names to error messages
Summary:
This patch adds the file names to llvm-objcopy error messages. It makes easy to identify which file causes an error.

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

Reviewers: espindola, alexshap, rupprecht, jhenderson, jakehehrlich

Reviewed By: rupprecht, jhenderson, jakehehrlich

Subscribers: emaste, arichardson, jakehehrlich, MaskRay, llvm-commits

Tags: #llvm

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

llvm-svn: 361450
2019-05-23 00:42:46 +00:00
Fangrui Song c289d218b9 [llvm-objdump] Dump inline relocations if the relocated section is specified with --section
This fixes PR41886: llvm-objdump -d -r -j .text doesn't show inline relocations of .text

While here, switch to stable_sort() because we don't want to change the order of relocations applied to the same location. gABI says consecutive relocation records are composed together and their order matters. In practise it is difficult to see relocations applied to the same location not consecutive, we just have to keep the relative order of relocations with the same offset.

Reviewed By: grimar

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

llvm-svn: 361395
2019-05-22 15:12:51 +00:00
Clement Courbet b9274f2694 [llvm-exegesis] Move native target initialization code to a separate file.
Summary: This helps building internal tools on top of the library.

Reviewers: gchatelet

Subscribers: tschuett, llvm-commits, bdb, ondrasej

Tags: #llvm

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

llvm-svn: 361385
2019-05-22 13:50:16 +00:00
James Henderson 5316a0d200 [llvm-objcopy] Tidy up error messages
This patch brings various error messages into line with each other, by
removing trailing full stops, and making the first letter lower-case.
This addresses https://bugs.llvm.org/show_bug.cgi?id=40859.

Reviewed by: jhenderson, rupprecht, jakehehrlich

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

Patch by Alex Brachet

llvm-svn: 361384
2019-05-22 13:23:26 +00:00
Serge Guelton 94c36fa15b Properly categorize llvm-objdump options
Filters out noise, and distinguish Mach-O related options from others.

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

llvm-svn: 361351
2019-05-22 06:30:46 +00:00
Lang Hames a2ee80b084 [ORC] Guarantee unique JITDylib names in lli, add usage notes to createJITDylib.
JITDylibs should have unique names. This patch adds code to lli to respect this
invariant (by refering to the exist JITDylib if a -jd <name> option is specified
more than once). It also adds usage notes to the doxygen comment for
createJITDylib method in ExecutionSession and LLJIT.

http://llvm.org/PR41937

llvm-svn: 361322
2019-05-21 22:07:53 +00:00
Nick Desaulniers 92febc6498 [Bugpoint] fix use-after-move. NFC
Summary:
This was flagged in https://www.viva64.com/en/b/0629/ under "Snippet No.
6".

Note that author also states:
"Note that the loop doesn't actually execute at all."

This is not true, but the author can be forgiven; there's two distinct
variables with very similar identifiers:

MiscompiledFunctions
MisCompFunctions

Reviewers: echristo, srhines, RKSimon

Reviewed By: RKSimon

Subscribers: llvm-commits

Tags: #llvm

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

llvm-svn: 361279
2019-05-21 17:55:26 +00:00
Jonas Devlieghere b43dfaa6c0 [Dsymutil] Remove redundant argument (NFC)
The dwarf streamer already holds a copy of the link options, so there's
no need to pass them as an argument.

llvm-svn: 361276
2019-05-21 17:31:51 +00:00
George Rimar f44eb922c0 [llvm-objdump] Make --disassemble-functions imply -d
Fixes https://bugs.llvm.org/show_bug.cgi?id=41903

Patch by Mike Pozulp!

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

llvm-svn: 361240
2019-05-21 11:05:46 +00:00
Eugene Leviant ec767b0b4a [llvm-objcopy] Strip file symbols with --strip-unneeded
Differential revision: https://reviews.llvm.org/D61641

llvm-svn: 361231
2019-05-21 09:09:33 +00:00
Lang Hames 93d2bdda6b [Support] Renamed member 'Size' to 'AllocatedSize' in MemoryBlock and OwningMemoryBlock.
Rename member 'Size' to 'AllocatedSize' in order to provide a hint that the
allocated size may be different than the requested size. Comments are added to
clarify this point.  Updated the InMemoryBuffer in FileOutputBuffer.cpp to track
the requested buffer size.

Patch by Machiel van Hooren. Thanks Machiel!

https://reviews.llvm.org/D61599

llvm-svn: 361195
2019-05-20 20:53:05 +00:00
George Rimar 72f821d3de [llvm-readelf] - Rework how we parse the .dynamic section.
This is a result of what I found during my work on https://bugs.llvm.org/show_bug.cgi?id=41679.

Previously LLVM readelf took the information about .dynamic section
from its PT_DYNAMIC segment only. GNU tools have a bit different logic.
They also use the information from the .dynamic section header if it is available.
This patch changes the code to improve the compatibility with the GNU Binutils.

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

llvm-svn: 361165
2019-05-20 15:41:48 +00:00
Michael Trent 07c96ebd94 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
Ben Dunbobbin 1d16515fb4 [ELF] Implement Dependent Libraries Feature
This patch implements a limited form of autolinking primarily designed to allow
either the --dependent-library compiler option, or "comment lib" pragmas (
https://docs.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?view=vs-2017) in
C/C++ e.g. #pragma comment(lib, "foo"), to cause an ELF linker to automatically
add the specified library to the link when processing the input file generated
by the compiler.

Currently this extension is unique to LLVM and LLD. However, care has been taken
to design this feature so that it could be supported by other ELF linkers.

The design goals were to provide:

- A simple linking model for developers to reason about.
- The ability to to override autolinking from the linker command line.
- Source code compatibility, where possible, with "comment lib" pragmas in other
  environments (MSVC in particular).

Dependent library support is implemented differently for ELF platforms than on
the other platforms. Primarily this difference is that on ELF we pass the
dependent library specifiers directly to the linker without manipulating them.
This is in contrast to other platforms where they are mapped to a specific
linker option by the compiler. This difference is a result of the greater
variety of ELF linkers and the fact that ELF linkers tend to handle libraries in
a more complicated fashion than on other platforms. This forces us to defer
handling the specifiers to the linker.

In order to achieve a level of source code compatibility with other platforms
we have restricted this feature to work with libraries that meet the following
"reasonable" requirements:

1. There are no competing defined symbols in a given set of libraries, or
   if they exist, the program owner doesn't care which is linked to their
   program.
2. There may be circular dependencies between libraries.

The binary representation is a mergeable string section (SHF_MERGE,
SHF_STRINGS), called .deplibs, with custom type SHT_LLVM_DEPENDENT_LIBRARIES
(0x6fff4c04). The compiler forms this section by concatenating the arguments of
the "comment lib" pragmas and --dependent-library options in the order they are
encountered. Partial (-r, -Ur) links are handled by concatenating .deplibs
sections with the normal mergeable string section rules. As an example, #pragma
comment(lib, "foo") would result in:

.section ".deplibs","MS",@llvm_dependent_libraries,1
         .asciz "foo"

For LTO, equivalent information to the contents of a the .deplibs section can be
retrieved by the LLD for bitcode input files.

LLD processes the dependent library specifiers in the following way:

1. Dependent libraries which are found from the specifiers in .deplibs sections
   of relocatable object files are added when the linker decides to include that
   file (which could itself be in a library) in the link. Dependent libraries
   behave as if they were appended to the command line after all other options. As
   a consequence the set of dependent libraries are searched last to resolve
   symbols.
2. It is an error if a file cannot be found for a given specifier.
3. Any command line options in effect at the end of the command line parsing apply
   to the dependent libraries, e.g. --whole-archive.
4. The linker tries to add a library or relocatable object file from each of the
   strings in a .deplibs section by; first, handling the string as if it was
   specified on the command line; second, by looking for the string in each of the
   library search paths in turn; third, by looking for a lib<string>.a or
   lib<string>.so (depending on the current mode of the linker) in each of the
   library search paths.
5. A new command line option --no-dependent-libraries tells LLD to ignore the
   dependent libraries.

Rationale for the above points:

1. Adding the dependent libraries last makes the process simple to understand
   from a developers perspective. All linkers are able to implement this scheme.
2. Error-ing for libraries that are not found seems like better behavior than
   failing the link during symbol resolution.
3. It seems useful for the user to be able to apply command line options which
   will affect all of the dependent libraries. There is a potential problem of
   surprise for developers, who might not realize that these options would apply
   to these "invisible" input files; however, despite the potential for surprise,
   this is easy for developers to reason about and gives developers the control
   that they may require.
4. This algorithm takes into account all of the different ways that ELF linkers
   find input files. The different search methods are tried by the linker in most
   obvious to least obvious order.
5. I considered adding finer grained control over which dependent libraries were
   ignored (e.g. MSVC has /nodefaultlib:<library>); however, I concluded that this
   is not necessary: if finer control is required developers can fall back to using
   the command line directly.

RFC thread: http://lists.llvm.org/pipermail/llvm-dev/2019-March/131004.html.

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

llvm-svn: 360984
2019-05-17 03:44:15 +00:00
Xing Xue af8cda15de [tests][go]Add -stdlib=libc++ to build GO test if LLVM is built with libc++
When libc++ is used to build LLVM libraries, these libraries have dependencies on libc++ and C++ STL signatures in these libraries are corresponding to libc++ implementation. Therefore, -stdlib=libc++ is required on the C++ compiler command for building GO tests that link with these LLVM libraries.

Reviewers: hubert.reinterpretcast, sfertile, amyk, EricWF

Reviewed By: sfertile, hubert.reinterpretcast

Subscribers: jsji, llvm-commits

Tags: #llvm

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

llvm-svn: 360895
2019-05-16 13:32:55 +00:00
Fangrui Song e183340c29 Recommit [Object] Change object::SectionRef::getContents() to return Expected<StringRef>
r360876 didn't fix 2 call sites in clang.

Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now.

Follow-up of D61781.

llvm-svn: 360892
2019-05-16 13:24:04 +00:00
Hans Wennborg 4da9ff9fcf Revert r360876 "[Object] Change object::SectionRef::getContents() to return Expected<StringRef>"
It broke the Clang build, see llvm-commits thread.

> Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now.
>
> Follow-up of D61781.

llvm-svn: 360878
2019-05-16 12:08:34 +00:00
Fangrui Song a076ec54be [Object] Change object::SectionRef::getContents() to return Expected<StringRef>
Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now.

Follow-up of D61781.

llvm-svn: 360876
2019-05-16 11:33:48 +00:00
George Rimar ec895f11ce [llvm-readobj] - Revert r360676 partially. NFC.
In the r360676 "Apply clang format. NFC" I applied clang-format
for whole ELFDumper.cpp. It caused a little discussion,
one of the points mentioned was that previously nicely lined up
tables are not so nice now.

This patch reverts them.

llvm-svn: 360860
2019-05-16 06:22:51 +00:00
Reid Kleckner 7c438c5b07 [codeview] Finish support for reading and writing S_ANNOTATION records
Implement dumping via llvm-pdbutil and llvm-readobj.

llvm-svn: 360813
2019-05-15 20:53:39 +00:00
George Rimar 9e88a26863 [llvm-readobj] - Apply clang format. NFC.
I am a bit tired of the formatting issues.

llvm-svn: 360676
2019-05-14 14:22:44 +00:00
Tim Northover ff6875acd9 AArch64: support binutils-like things on arm64_32.
This adds support for the arm64_32 watchOS ABI to LLVM's low level tools,
teaching them about the specific MachO choices and constants needed to
disassemble things.

llvm-svn: 360663
2019-05-14 11:25:44 +00:00
James Henderson 9df3883618 [llvm-objcopy] Cache gnu_debuglink's target CRC
.gnu_debuglink section contains information regarding file with
debugging symbols, identified by its CRC32. This target file is not
intended to ever change or it would invalidate the stored checksum, yet
the checksum is calculated over and over again for each of the objects
inside the archive, usually hundreds of times.

This patch precomputes the CRC32 of the target once and then reuses the
value where required, saving lots of redundant I/O.

The error message reported should stay the same, although now it might
be reported earlier.

Reviewed by: jhenderson, jakehehrlich, MaskRay

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

Patch by Michal Janiszewski

llvm-svn: 360661
2019-05-14 10:59:04 +00:00
Fangrui Song e1cb2c0f40 [Object] Change ObjectFile::getSectionContents to return Expected<ArrayRef<uint8_t>>
Change
std::error_code getSectionContents(DataRefImpl, StringRef &) const;
to
Expected<ArrayRef<uint8_t>> getSectionContents(DataRefImpl) const;

Many object formats use ArrayRef<uint8_t> as the underlying type, which
is generally better than StringRef to represent binary data, so change
the type to decrease the number of type conversions.

Reviewed By: ruiu, sbc100

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

llvm-svn: 360648
2019-05-14 04:22:51 +00:00
Serge Guelton 2cabb4dc5b Simplify llvm-cat help
Only output options that are directly relevant.

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

llvm-svn: 360575
2019-05-13 11:29:25 +00:00
Lang Hames 23085ec36d [JITLink] Add a test for zero-filled content.
Also updates RuntimeDyldChecker and llvm-rtdyld to support zero-fill tests by
returning a content address of zero (but no error) for zero-fill atoms, and
treating loads from zero as returning zero.

llvm-svn: 360547
2019-05-12 22:26:33 +00:00
Puyan Lotfi a10f016006 [NFC] yaml2obj/yam2elf.cpp whitespace changes: dos2unix removed CRs.
llvm-svn: 360527
2019-05-11 17:03:36 +00:00
Reid Kleckner 7eb6b5ffc3 [COFF] Fix .bss section size bug in obj2yaml / yaml2obj
We need to serialize SizeOfRawData through even when there is no data,
as in a .bss section.

Fixes PR41836

llvm-svn: 360473
2019-05-10 21:53:44 +00:00
Fangrui Song 6150407951 [llvm-objdump] Print st_other
Add support for ".hidden" ".internal" ".protected" and " 0x%02x" for
other st_other bits used by some architectures.

Reviewed By: sfertile

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

llvm-svn: 360439
2019-05-10 16:24:57 +00:00
Fangrui Song c8e68253de [Object] Fix macho-invalid.test
llvm-svn: 360420
2019-05-10 10:47:30 +00:00
Fangrui Song e357ca8231 [Object] Change SymbolicFile::printSymbolName to use Error
llvm-svn: 360414
2019-05-10 09:59:04 +00:00
Caroline Tice abf25745b3 llvm-dwarfdump: Add dwo parsing to --statistics.
Add check for, and parsing of, .dwo files to Statistics.cpp; create a new getNon
SkeletonUnitDie function for DWARFUnit.h

Reviewers: dblaikie

Differential Revision: https://review.llvm.org/D61755

llvm-svn: 360380
2019-05-09 21:53:33 +00:00
Simon Pilgrim 952391d8eb [llvm-cxxfilt] Fix -Wshadow warning. NFCI.
Local variable Decorated was shadowing the global variable Decorated

llvm-svn: 360352
2019-05-09 15:58:16 +00:00
Andrea Di Biagio 4e62554bfa [MCA] Add support for nested and overlapping region markers
This patch fixes PR41523
https://bugs.llvm.org/show_bug.cgi?id=41523

Regions can now nest/overlap provided that they have different names.
Anonymous regions cannot overlap.

Region end markers must specify the region name. The only exception is for when
there is only one user-defined region; in that particular case, the region end
marker doesn't need to specify a name.

Incorrect region end markers are no longer ignored. Instead, the tool reports an
error and we exit with an error code.

Added test cases to verify the new diagnostic error messages.

Updated the llvm-mca docs to reflect this feature change.

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

llvm-svn: 360351
2019-05-09 15:18:09 +00:00
Fangrui Song bc1c6a0b44 [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
James Henderson 5a2b5ca7d2 [llvm-objcopy] Improve error message for unrecognised archive member
Prior to this patch, llvm-objcopy's error messages for archives with
unsupported members only mentioned the archive name, not the member
name, making them unhelpful. This change improves it by approximately
following GNU objcopy's error message syntax of
"<archive name>(<member name>): <problem>".

Reviewed by: grimar

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

llvm-svn: 360251
2019-05-08 13:28:58 +00:00
Andrea Di Biagio d52a542e4c [MCA] Don't add a name to the default code region.
This is done in preparation for a patch that fixes PR41523.

llvm-svn: 360243
2019-05-08 11:00:43 +00:00
Andrea Di Biagio 86654dd8a0 [MCA] Slightly refactor CodeRegion.h. NFCI
Also, use a SmallVector instead of a std::vector for the code region.

llvm-svn: 360240
2019-05-08 10:44:05 +00:00
James Henderson fa11fb33ad [llvm-objcopy] Add --prefix-alloc-sections
This patch adds support for --prefix-alloc-sections, which adds a prefix
to every allocated section names.

It adds a prefix after renaming section names by --rename-section as GNU
objcopy does.

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

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

Patch by Seiya Nuta.

llvm-svn: 360233
2019-05-08 09:49:35 +00:00
George Rimar 17dbb19f70 [llvm-objcopy] - Fix for "Bug 41775 - SymbolTableSection::addSymbol - shadow variable names"
This is a fix for https://bugs.llvm.org/show_bug.cgi?id=41775,

Problem is in the final line:
Size += this->EntrySize;

I checked that we do not actually need it in this place,
since we always call removeSectionReferences which
calls removeSymbols which updates the Size.

But it worth to keep it, that allows to relax the dependencies.

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

llvm-svn: 360227
2019-05-08 07:31:05 +00:00
George Rimar 5c922f6988 [llvm-objdump] - Print relocation record in a GNU format.
This fixes the https://bugs.llvm.org/show_bug.cgi?id=41355.

Previously with -r we printed relocation section name instead of the target section name.
It was like this: "RELOCATION RECORDS FOR [.rel.text]"
Now it is: "RELOCATION RECORDS FOR [.text]"

Also when relocation target section has more than one relocation section,
we did not combine the output. Now we do.

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

llvm-svn: 360143
2019-05-07 13:14:18 +00:00
Roman Lebedev 9bac7d8165 [llvm-exegesis] BenchmarkRunner::runConfiguration(): write small snippet to memory
It was previously writing this temporary snippet to file,
then reading it back, but leaving the tmp file in place.
This is both unefficient, and results in huge garbage pileup
in /tmp.

One would have thought it would have been caught during D60317..

llvm-svn: 360138
2019-05-07 12:28:08 +00:00
George Rimar 0974688a42 [yaml2obj] - Allow setting st_value explicitly for Symbol.
In some cases it is useful to explicitly set symbol's st_name value.
For example, I am using it in a patch for LLD to remove the broken
binary from a test case and replace it with a YAML test.

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

llvm-svn: 360137
2019-05-07 12:10:51 +00:00
Roman Lebedev 724a68f372 [llvm-exegesis] InstructionBenchmark::writeYamlTo(): don't forget to flush()
This *APPEARS* to fix a *very* infuriating issue of Yaml's being corrupted,
partially written, truncated. Or at least i'm not seeing the issue
on a new benchmark sweep.

The issue is somewhat rare, happens maybe once in 1000 benchmarks.
Which means there are up to hundreds of broken benchmarks
for a full x86 sweep in a single mode.

llvm-svn: 360124
2019-05-07 09:21:13 +00:00
Sam Clegg 5f8c2edef3 [WebAssembly] Add more test coverage for reloctions against section symbols
The only known user of this relocation type and symbol type is
the debug info sections, but we were not testing the `--relocatable`
output path.

This change adds a minimal test case to cover relocations against
section symbols includes `--relocatable` output.

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

llvm-svn: 360110
2019-05-07 03:53:16 +00:00
Fangrui Song da82ce99b7 [DebugInfo] Delete TypedDINodeRef
TypedDINodeRef<T> is a redundant wrapper of Metadata * that is actually a T *.

Accordingly, change DI{Node,Scope,Type}Ref uses to DI{Node,Scope,Type} * or their const variants.
This allows us to delete many resolve() calls that clutter the code.

Reviewed By: rnk

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

llvm-svn: 360108
2019-05-07 02:06:37 +00:00
Simon Pilgrim 3dd9cb7518 Remove duplicate assignments. NFCI.
llvm-svn: 360064
2019-05-06 19:10:55 +00:00
Anders Waldenborg 09b91a2696 [llvm-c-test] Make include-all.c do what its name says it does
The purpose of this file is to make sure that all includes in llvm-c
works when included from a C source file (i.e no C++isms sneaked in).
To do this it must actually include all the include files.

Reviewed By: whitequark
Differential Revision: https://reviews.llvm.org/D61567

llvm-svn: 360033
2019-05-06 11:31:45 +00:00
Sid Manning 5ad18a7d59 Let --discard-all imply --strip-debug.
This will match gnu strip's behavior.

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

llvm-svn: 359887
2019-05-03 14:14:01 +00:00
Simon Pilgrim aa49be4926 Avoid cppcheck operator precedence warnings. NFCI.
Prefer ((X & Y) ? A : B) to (X & Y ? A : B)

llvm-svn: 359884
2019-05-03 13:50:38 +00:00
Sean Fertile fd75ee9154 [Object][XCOFF] Add an XCOFF dumper for llvm-readobj.
Patch adds support for dumping of file headers with llvm-readobj. XCOFF
object files are added to test dumping a well formed file, and dumping
both negative timestamps and negative symbol counts, both of which are
allowed in the XCOFF definition.

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

llvm-svn: 359878
2019-05-03 12:57:07 +00:00
Jordan Rupprecht 51a1418768 Revert [llvm-nm] Fix handling of symbol types + [llvm-nm] Generalize symbol types
This reverts r359311 and r359312 (git commit 0bf06a8f59 and 5f184f1780)

llvm-svn: 359830
2019-05-02 21:42:46 +00:00
Nico Weber 81862f82ee lld-link: Add /force:multipleres extension to make dupe resource diag non-fatal
As a side benefit, lld-link now reports more than one duplicate resource
entry before exiting with an error even if the new flag is not passed.

llvm-svn: 359829
2019-05-02 21:21:55 +00:00
George Rimar 366212726a [yaml2obj] - Make interface of `NameToIdxMap` class be human friendly and fix users.
This patch inverses the values returned by `addName` and
`lookup` methods of the class mentioned so that they
now return true on success and false on failure.
Also, it does minor code cleanup.

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

llvm-svn: 359818
2019-05-02 19:28:04 +00:00
James Henderson e4a89a1bee [llvm-strip]Add --no-strip-all to disable --strip-all behaviour (including default stripping)
If certain switches are not specified, llvm-strip behaves as if
--strip-all were specified. This means that for testing, when we don't
want the stripping behaviour, we have to specify one of these switches,
which can be confusing. This change adds --no-strip-all to allow an
alternative way of suppressing the default stripping, in a less
confusing manner.

Reviewed by: jakehehrlich, MaskRay

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

llvm-svn: 359781
2019-05-02 11:53:02 +00:00
Fangrui Song facbfe0690 [llvm-readobj] Delete and inline relocAddressLess
It is used only once in COFFDumper.cpp. Deleting it from the public
interface seems better.

llvm-svn: 359775
2019-05-02 10:49:27 +00:00
Fangrui Song 8be28cdc52 [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
Fangrui Song 5387c2cd17 [llvm-objdump] Print newlines before and after "Disassembly of section ...:"
This improves readability and the behavior is consistent with GNU objdump.

The new test test/tools/llvm-objdump/X86/disassemble-section-name.s
checks we print newlines before and after "Disassembly of section ...:"

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

llvm-svn: 359668
2019-05-01 10:40:48 +00:00
George Rimar f5345a3f4c [yaml2obj] - Report when unknown section is referenced from program header declaration block.
Previously we did not report this.
Also this removes multiple lookups in the map
what cleanups the code.

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

llvm-svn: 359663
2019-05-01 09:45:55 +00:00
Fangrui Song e29e30b139 [llvm-readobj] Change -long-option to --long-option in tests. NFC
We use both -long-option and --long-option in tests. Switch to --long-option for consistency.

In the "llvm-readelf" mode, -long-option is discouraged as it conflicts with grouped short options and it is not accepted by GNU readelf.

While updating the tests, change llvm-readobj -s to llvm-readobj -S to reduce confusion ("s" is --section-headers in llvm-readobj but --symbols in llvm-readelf).

llvm-svn: 359649
2019-05-01 05:27:20 +00:00
Fangrui Song aa1f2c50a8 [llvm-objcopy] Simplify SHT_NOBITS -> SHT_PROGBITS promotion
GNU objcopy uses bfd_elf_get_default_section_type to decide the candidate section type,
which roughly translates to our [a] (I assume SEC_COMMON implies SHF_ALLOC):

  (!(Sec.Flags & ELF::SHF_ALLOC) || Flags & (SectionFlag::SecContents | SectionFlag::SecLoad)))

Then, it updates the section type in bfd/elf.c:elf_fake_sections if:

  if (this_hdr->sh_type == SHT_NULL)
    this_hdr->sh_type = sh_type; // common case
  else if (this_hdr->sh_type == SHT_NOBITS
           && sh_type == SHT_PROGBITS
           && (asect->flags & SEC_ALLOC) != 0)  // uncommon case
    ...
    this_hdr->sh_type = sh_type;

If the following condition is met the uncommon branch is executed:

  if (elf_section_type (osec) == SHT_NULL
      && (osec->flags == isec->flags
	  || (final_link
	      && ((osec->flags ^ isec->flags)
		  & ~(SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_RELOC)) == 0)))

I suggest we just ignore this clause and follow the common case
behavior, which is done in this patch. Rationales to do so:

If --set-section-flags is a no-op (osec->flags == isec->flags)
(corresponds to the "readonly" test in set-section-flags.test), GNU
objcopy will require (Sec.Flags & ELF::SHF_ALLOC). [a] is essentially:

  Flags & (SectionFlag::SecContents | SectionFlag::SecLoad)

This special case is not really useful. Non-SHF_ALLOC SHT_NOBITS
sections do not make much sense and it doesn't matter if they are
SHT_NOBITS or SHT_PROGBITS.

For all other RUN lines in set-section-flags.test, the new behavior
matches GNU objcopy, i.e. this patch improves compatibility.

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

llvm-svn: 359639
2019-05-01 00:39:31 +00:00
Rong Xu 998b97f6f1 [llvm-profdata] Add overlap command to compute similarity b/w two profile files
Add overlap functionality to llvm-profdata tool to compute the similarity
between two profile files.

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

llvm-svn: 359612
2019-04-30 21:19:12 +00:00
Dan Gohman 3b5b9d0e72 [WebAssembly] Support EXPLICIT_NAME symbols in llvm-readobj
Teach llvm-readobj about WASM_SYMBOL_EXPLICIT_NAME.

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

Reviewer: sbc100
llvm-svn: 359602
2019-04-30 19:30:24 +00:00
Jordan Rupprecht 96bbb1dc2b [llvm-objcopy] Add RISC-V support for -B/-O
Reviewers: jorgbrown, espindola, alexshap, jhenderson

Subscribers: emaste, arichardson, fedor.sergeev, jakehehrlich, kito-cheng, shiva0217, MaskRay, rogfer01, rkruppe, llvm-commits

Tags: #llvm

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

llvm-svn: 359568
2019-04-30 15:21:36 +00:00
Eugene Leviant fd0831d0f5 [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
Hans Wennborg 6014107702 vs integration: vs2019 support
llvm-svn: 359557
2019-04-30 12:41:33 +00:00
George Rimar 67f590e286 [llvm-objcopy] - Check dynamic relocation sections for broken references.
This is a fix for https://bugs.llvm.org/show_bug.cgi?id=41371.

Currently, it is possible to break the sh_link field of the dynamic relocation section
by removing the section it refers to. The patch fixes an issue and adds 2 test cases.

One of them shows that it does not seem possible to break the sh_info field.
I added an assert to verify this.

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

llvm-svn: 359552
2019-04-30 11:02:09 +00:00
David Bolvansky 59b6889238 Revert r359520
llvm-svn: 359544
2019-04-30 10:09:28 +00:00
David Bolvansky 1a52eaf773 [PDB] Fixed null pointer dereference
Reviewers: zturner, rnk

Reviewed By: rnk

Subscribers: llvm-commits

Tags: #llvm

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

llvm-svn: 359520
2019-04-29 23:57:20 +00:00
Lang Hames eb14dc7585 [ORC] Replace the LLJIT/LLLazyJIT Create methods with Builder utilities.
LLJITBuilder and LLLazyJITBuilder construct LLJIT and LLLazyJIT instances
respectively. Over time these will allow more configurable options to be
added while remaining easy to use in the default case, which for default
in-process JITing is now:

auto J = ExitOnErr(LLJITBuilder.create());

llvm-svn: 359511
2019-04-29 22:37:27 +00:00
Simon Pilgrim 1303f90d49 [llvm-pdbutil] FunctionDumper::dump(PDBSymbolTypeFunctionArg) - fix null dereference warning
Reported in https://www.viva64.com/en/b/0629/

llvm-svn: 359488
2019-04-29 19:40:12 +00:00
Quentin Colombet 2d977935a2 [llvm-extract] Expose the group extraction feature of the BlockExtractor
This patch extends the `-bb` option to be able to use the group
extraction feature from the BlockExtractor.
In particular, `-bb=func:bb` is modified to support a list of basic
blocks per function: `-bb=func:bb1[;bb2...]` that will be extracted
together if at all possible (region must be single entry.)

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

llvm-svn: 359464
2019-04-29 16:14:03 +00:00
George Rimar bc4d3c43a3 [yaml2obj] - Simplify and reduce the code. NFC.
This inlines 2 single line static methods
and simplifies the code.

It is also possible to remove the `Is64Bit`
variable since it is used only once,
but I am not sure it will be better for readability.

llvm-svn: 359445
2019-04-29 12:25:01 +00:00
George Rimar bd8bfd333f [yaml2obj] - Replace a loop with write_zeros(). NFCI.
This looks better.

llvm-svn: 359444
2019-04-29 12:05:53 +00:00
George Rimar 4828811a2d [yaml2obj] - Cleanup and simplify the code. NFCI.
The current code has the following problems:
`initSymtabSectionHeader` and `initStrtabSectionHeader` method
names saying us they are going to initialize the section headers.
Though for a few cases sh_flags field is initialized outside of them.
It does not look clean. This patch moves initialization of the
sh_flags inside these methods.

Also, it removes an excessive variable, what together with the above
change hopefully makes the code a bit more readable.

llvm-svn: 359443
2019-04-29 11:54:10 +00:00
Russell Gallop d8212edf68 vs integration: Use llvm-lib for librarian
This uses llvm-lib.exe for the librarian instead of Visual Studio
provided lib.exe. Without this it is not possible to create static
libraries with -flto using the plugin.

Original patch by Steven Noonan

This fixes: PR41147

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

llvm-svn: 359430
2019-04-29 10:10:17 +00:00
Fangrui Song b521d1b887 [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
Lang Hames 15c072a161 [lli] Fix a typo in a cl::opt description.
Patch by Wasiher. Thanks Wasiher!

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

llvm-svn: 359384
2019-04-27 16:13:53 +00:00
Fangrui Song 763a2e1f36 [llvm-nm][llvm-readelf] Avoid single-dash -long-option in tests
llvm-svn: 359383
2019-04-27 16:12:14 +00:00
Fangrui Song 0969af6962 [llvm-nm] Support section type 'u': STB_GNU_UNIQUE
llvm-svn: 359380
2019-04-27 15:32:53 +00:00
Lang Hames a9fdf375b3 [ORC] Add a 'plugin' interface to ObjectLinkingLayer for events/configuration.
ObjectLinkingLayer::Plugin provides event notifications when objects are loaded,
emitted, and removed. It also provides a modifyPassConfig callback that allows
plugins to modify the JITLink pass configuration.

This patch moves eh-frame registration into its own plugin, and teaches
llvm-jitlink to only add that plugin when performing execution runs on
non-Windows platforms. This should allow us to re-enable the test case that was
removed in r359198.

llvm-svn: 359357
2019-04-26 22:58:39 +00:00
Fangrui Song 283bc74054 [llvm-nm] Revert inadvertently committed 'i' change in r359314
llvm-svn: 359315
2019-04-26 16:27:11 +00:00
Fangrui Song 5015aa854d [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 5f184f1780 [llvm-nm] Generalize symbol types 'N', 'n' and '?'
llvm-svn: 359312
2019-04-26 16:03:31 +00:00
Fangrui Song 0bf06a8f59 [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
George Rimar 5fcdebe75f [yaml2obj] - Make implicitSectionNames() return std::vector<StringRef>. NFCI.
No need to use SmallVector of char* here.
This simplifies the code.

llvm-svn: 359301
2019-04-26 13:09:11 +00:00
George Rimar c1da14941f [yaml2obj] - Remove excessive variable. NFC.
`auto &Strtab` was used only once.

llvm-svn: 359300
2019-04-26 12:45:54 +00:00
George Rimar fb7780a41f [yaml2obj] - Make the code to match the LLVM style. NFCI.
This renames the variables to uppercase and
removes use of `auto` for unobvious type.

llvm-svn: 359298
2019-04-26 12:20:51 +00:00
George Rimar da1b3abad6 [yaml2elf] - Cleanup the initSectionHeaders(). NFCI.
This encapsulates the section specific code inside the
corresponding writeSectionContent methods.
Making the code a bit more consistent.

llvm-svn: 359297
2019-04-26 12:15:32 +00:00
Nico Weber ae73e1fcfb Minor formatting tweak, no behavior change
llvm-svn: 359295
2019-04-26 11:44:10 +00:00
Fangrui Song 2aa0bdeb25 Fix typos: (re)?sor?uce -> (re)?source
Closes: https://github.com/llvm/llvm-project/pull/10

In-collaboration-with:	Olivier Cochard-Labbé <olivier@FreeBSD.org>
Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>

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

llvm-svn: 359277
2019-04-26 05:56:23 +00:00
Fangrui Song 2db79e9d2c [llvm-objcopy] Accept --long-option but not -long-option
Summary:

llvm-{objcopy,strip} (and many other LLVM binary utilities) accept
cl::opt style -long-option as well as many short options (e.g. -p -S
-x). People who use them as replacement of GNU binutils often use the
grouped option syntax (POSIX Utility Conventions), e.g. -Sx => -S -x,
-Wd => -W -d, -sj.text => -s -j.text

There is ambiguity if a long option starts with the character used by a
short option. Drop the support for -long-option to resolve the ambiguity.

This divergence from other utilities is accepted (other utilities
continue supporting -long-option).
https://lists.llvm.org/pipermail/llvm-dev/2019-April/131786.html

Reviewers: alexshap, jakehehrlich, jhenderson, rupprecht, espindola

Reviewed By: jakehehrlich, jhenderson, rupprecht

Subscribers: grimar, emaste, arichardson, llvm-commits

Tags: #llvm

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

llvm-svn: 359265
2019-04-26 02:10:10 +00:00
George Rimar 45d042ed96 [yaml2obj] - Don't crash on invalid inputs.
yaml2obj might crash on invalid input when unable to parse the YAML.

Recently a crash with a very similar nature was fixed for an empty files. 
This patch revisits the fix and does it in yaml::Input instead.
It seems to be more correct way to handle such situation.

With that crash for invalid inputs is also fixed now.

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

llvm-svn: 359178
2019-04-25 09:59:55 +00:00
Lang Hames cf49aa3908 [llvm-rtdyld] Add support for passing command line arguments to rtdyld-run code.
The --args option can now be used to pass arguments to code linked with
llvm-rtdyld. E.g.

$ llvm-rtdyld file1.o file2.o --args a b c

is equivalent to:

$ ld -o program file1.o file2.o
$ ./program a b c

This is the rtdyld counterpart to the jitlink change in r359115, and makes
benchmarking and comparison between the tools easier.

llvm-svn: 359168
2019-04-25 05:02:10 +00:00
Alina Sbirlea 733c8c40c8 Enable LoopVectorization by default.
Summary:
When refactoring vectorization flags, vectorization was disabled by default in the new pass manager.
This patch re-enables is for both managers, and changes the assumptions opt makes, based on the new defaults.
Comments in opt.cpp should clarify the intended use of all flags to enable/disable vectorization.

Reviewers: chandlerc, jgorbe

Subscribers: jlebar, llvm-commits

Tags: #llvm

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

llvm-svn: 359167
2019-04-25 04:49:48 +00:00
Fangrui Song 3458ff361a [llvm-objdump] errorToErrorCode+message -> toString
For test/Object/elf-invalid-phdr.test, the intended error message got lost due to errorToErrorCode().

llvm-svn: 359166
2019-04-25 04:31:26 +00:00
Nico Weber 23cb79ff93 llvm-cvtres: Make new dupe resource error a bit friendlier
For well-known type IDs, include the name of the type.

To not duplicate the ID->name map, make llvm-readobj call this new
function as well.  It has slightly different output, so this also
requires updating a few tests.

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

llvm-svn: 359153
2019-04-24 23:26:30 +00:00
Nico Weber 1591693c7c llvm-cvtres: Remove a default argument. No behavior change.
llvm-svn: 359128
2019-04-24 19:13:38 +00:00
Lang Hames d959a609a4 [JITLink] Add support for passing arguments to jit-linked code.
The --args option can now be used to pass arguments to code linked with
llvm-jitlink. E.g.

$ llvm-jitlink file1.o file2.o --args a b c

is equivalent to:

$ ld -o program file1.o file2.o
$ ./program a b c

llvm-svn: 359115
2019-04-24 17:23:05 +00:00
Stanislav Mekhanoshin cee607e414 [AMDGPU] Add gfx1010 target definitions
Differential Revision: https://reviews.llvm.org/D61041

llvm-svn: 359113
2019-04-24 17:03:15 +00:00
JF Bastien 46d67fa6c5 Revert "[llvm-objdump] errorToErrorCode+message -> toString"
Revert r359100

It breaks llvm/test/Object/elf-invalid-phdr.test

llvm-svn: 359110
2019-04-24 16:49:30 +00:00
Lang Hames b1ba4d8a8a [JITLink] Refer to FDE's CIE (not the most recent CIE) when parsing eh-frame.
Frame Descriptor Entries (FDEs) have a pointer back to a Common Information
Entry (CIE) that describes how the rest FDE should be parsed. JITLink had been
assuming that FDEs always referred to the most recent CIE encountered, but the
spec allows them to point back to any previously encountered CIE. This patch
fixes JITLink to look up the correct CIE for the FDE.

The testcase is a MachO binary with an FDE that refers to a CIE that is not the
one immediately proceeding it (the layout can be viewed wit
'dwarfdump --eh-frame <testcase>'. This test case had to be a binary as llvm-mc
now sorts FDEs (as of r356216) to ensure FDEs *do* point to the most recent CIE.

llvm-svn: 359105
2019-04-24 15:15:55 +00:00
Fangrui Song aaecb8f799 [llvm-objdump] Delete redundant check
llvm-svn: 359102
2019-04-24 15:09:23 +00:00
George Rimar 93a47a6291 [obj2yamp] - Simplify and cleanup the code in ELFDumper<ELFT>::dumpGroup a bit. NFC.
This makes the variables naming to match LLVM style,
simplifies the code used to extract the group members,
simplifies the loop and reorders the code around a bit.

llvm-svn: 359101
2019-04-24 15:03:53 +00:00
Fangrui Song a5f8dcb63f [llvm-objdump] errorToErrorCode+message -> toString
llvm-svn: 359100
2019-04-24 15:03:46 +00:00
Fangrui Song de0462a500 [yaml2obj] Replace num_zeros with write_zeros
llvm-svn: 359091
2019-04-24 13:23:15 +00:00
George Rimar b49e192a37 [yaml2elf] - Replace a loop with write_zeros(). NFC.
And apply clang-format to the method changed.

llvm-svn: 359090
2019-04-24 13:02:15 +00:00
Fangrui Song b5f3984541 [CommandLine] Provide parser<unsigned long> instantiation to allow cl::opt<uint64_t> on LP64 platforms
Summary:
And migrate opt<unsigned long long> to opt<uint64_t>

Fixes PR19665

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

llvm-svn: 359068
2019-04-24 02:40:20 +00:00
Nico Weber 39a2d20a0f llvm-cvtres: Accept /? as help flag, like cvtres.exe
llvm-svn: 359064
2019-04-24 02:11:24 +00:00
Adrian Prantl 2351d6102f [dsymutil] Put Swift interface files into a per-arch subdirectory.
This was meant to be part of the original commit r358921, but somehow
got lost.

<rdar://problem/49751748>

llvm-svn: 359010
2019-04-23 16:42:35 +00:00
Adrian Prantl 53bd7ce42e [dsymutil] Fix use-after-free when sys::path::append grows the buffer.
<rdar://problem/50117620>

llvm-svn: 359003
2019-04-23 15:44:22 +00:00
Adrian Prantl c7bde29cfe Revert "[dsymutil] Fix use-after-free when sys::path::append grows the buffer."
llvm-svn: 359002
2019-04-23 15:44:19 +00:00
Adrian Prantl 03e906d9d5 [dsymutil] Fix use-after-free when sys::path::append grows the buffer.
<rdar://problem/50117620>

llvm-svn: 359001
2019-04-23 15:39:13 +00:00
Adrian Prantl 05aad1567b Fully qualify llvm::Optional, some compilers complain otherwise.
llvm-svn: 358933
2019-04-22 22:51:34 +00:00
Adrian Prantl e495ec23fe Try to work around compile errors with older versions of GCC.
llvm-svn: 358927
2019-04-22 22:40:37 +00:00
Adrian Prantl 0d809aa218 [dsymutil] Collect parseable Swift interfaces in the .dSYM bundle.
When a Swift module built with debug info imports a library without
debug info from a textual interface, the textual interface is
necessary to reconstruct types defined in the library's interface. By
recording the Swift interface files in DWARF dsymutil can collect them
and LLDB can find them.

This patch teaches dsymutil to look for DW_TAG_imported_modules and
records all references to parseable Swift ingterfrace files and copies
them to

  a.out.dSYM/Contents/Resources/<Arch>/<ModuleName>.swiftinterface

<rdar://problem/49751748>

llvm-svn: 358921
2019-04-22 21:33:22 +00:00
Fangrui Song a5355a5ed1 Use llvm::stable_sort. NFC
llvm-svn: 358897
2019-04-22 15:53:43 +00:00
Nico Weber 405e62b805 Attemp get llvm-jitlink building on Windows
By removing an include of dlfcn.h that looks unused.

And clang-format a too-long line while here.

llvm-svn: 358864
2019-04-21 23:50:24 +00:00
Lang Hames bc76bbcaa0 [JITLink] Add an option to dump relocated section content.
The -dump-relocated-section-content option will dump the contents of each
section after relocations are applied, and before any checks are run or
code executed.

llvm-svn: 358863
2019-04-21 20:34:19 +00:00
Lang Hames daed9b10f1 [JITLink] Add BinaryFormat to JITLink's dependencies.
Hopefully this will fix the missing dependence on llvm::identify_magic that is
showing up on some PPC bots. E.g.

http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/9617

llvm-svn: 358827
2019-04-20 19:48:45 +00:00