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

639 Commits

Author SHA1 Message Date
Rafael Auler
4c9b85b364 [llvm-objdump] Support disassembling by symbol name
Summary:
Add a new option -df to llvm-objdump that takes function names
as arguments and instructs the disassembler to only dump those function
contents. Based on code originally written by Bill Nell.

Reviewers: espindola, JDevlieghere

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

llvm-svn: 327164
2018-03-09 19:13:44 +00:00
Kevin Enderby
99afb7391a For llvm-objdump and Mach-O files, update the printing of some thread states
from core files.  I tested this against the couple of core files that were
getting errors about unknown thread flavors and it now produce the same output as
the Xcode otool-classic(1) tool.  Since the core files are huge I didn’t include
them as test cases.

rdar://38216356

llvm-svn: 327077
2018-03-08 23:10:38 +00:00
Scott Linder
03316a5291 [DebugInfo] Support DWARF v5 source code embedding extension
In DWARF v5 the Line Number Program Header is extensible, allowing values with
new content types. In this extension a content type is added,
DW_LNCT_LLVM_source, which contains the embedded source code of the file.

Add new optional attribute for !DIFile IR metadata called source which contains
source text. Use this to output the source to the DWARF line table of code
objects. Analogously extend METADATA_FILE in Bitcode and .file directive in ASM
to support optional source.

Teach llvm-dwarfdump and llvm-objdump about the new values. Update the output
format of llvm-dwarfdump to make room for the new attribute on file_names
entries, and support embedded sources for the -source option in llvm-objdump.

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

llvm-svn: 325970
2018-02-23 23:01:06 +00:00
David Blaikie
0786bea9d6 [llvm-objdump] Use unique_ptr to simplify memory ownership
Followup to r325099/r325100 to simplify further.

llvm-svn: 325612
2018-02-20 18:48:51 +00:00
Serge Pavlov
23a9f5e3f8 Use delete[] instead of free
llvm-svn: 325100
2018-02-14 06:14:30 +00:00
Serge Pavlov
18df8e9c56 Use delete[] to deallocate array of chars
llvm-svn: 325099
2018-02-14 05:14:31 +00:00
Serge Pavlov
4d8a6548e7 Refactor DisassembleInfo in MachODump.cpp
The change implements constructor of DisassembleInfo to avoid duplication
of initialization code and gets rid of malloc/free where possible.

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

llvm-svn: 325098
2018-02-14 03:26:27 +00:00
Kevin Enderby
92c00fc744 llvm-objdump when printing the Objective-C meta data also prints the Swift ABI
from the value stored in swift_version bits in the flags field in the
objc_image_info struct.  ABI version 3 thru 6 were previously added but this
code was not updated to print the Swift version.

rdar://35624067

llvm-svn: 324767
2018-02-09 19:31:27 +00:00
Alex Denisov
97f8598271 Fix typo
llvm-svn: 324123
2018-02-02 19:20:37 +00:00
Tim Northover
8cd9e2abc7 llvm-objdump: prevent out of bounds accesses during unwind dumping.
We were a bit too trusting about the offsets encoded in MachO compact unwind
sections, so this passes every access through a bounds check just in case. It
prevents a few segfaults on malformed object files, if one should ever come
along.

Mostly to silence fuzzers in the vague hope they might be able to produce
something useful without the noise.

llvm-svn: 323198
2018-01-23 13:51:57 +00:00
Benjamin Kramer
cf82ff23c4 Avoid int to string conversion in Twine or raw_ostream contexts.
Some output changes from uppercase hex to lowercase hex, no other functionality change intended.

llvm-svn: 321526
2017-12-28 16:58:54 +00:00
Dimitry Andric
1d6fcfc9f4 Fix more inconsistent line endings. NFC.
llvm-svn: 321016
2017-12-18 19:46:56 +00:00
Michael Trent
6fc9db117d Updated llvm-objdump to display local relocations in Mach-O binaries
Summary:
llvm-objdump's Mach-O parser was updated in r306037 to display external
relocations for MH_KEXT_BUNDLE file types. This change extends the Macho-O
parser to display local relocations for MH_PRELOAD files. When used with
the -macho option relocations will be displayed in a historical format.

All tests are passing for llvm, clang, and lld. llvm-objdump builds without
compiler warnings.

rdar://35778019

Reviewers: enderby

Reviewed By: enderby

Subscribers: llvm-commits

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

llvm-svn: 320832
2017-12-15 17:57:40 +00:00
Michael Zolotukhin
66a95d7c09 Remove redundant includes from tools.
llvm-svn: 320631
2017-12-13 21:31:10 +00:00
Michael Trent
511ebcb9d3 reverting out -r320532 because a warning is breaking the lld build
llvm-svn: 320534
2017-12-13 00:36:13 +00:00
Michael Trent
2f85b30aff Updated llvm-objdump to display local relocations in Mach-O binaries
Summary:
llvm-objdump's Mach-O parser was updated in r306037 to display external
relocations for MH_KEXT_BUNDLE file types. This change extends the Macho-O
parser to display local relocations for MH_PRELOAD files. When used with
the -macho option relocations will be displayed in a historical format.

rdar://35778019

Reviewers: enderby

Subscribers: llvm-commits

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

llvm-svn: 320532
2017-12-12 23:53:46 +00:00
Michael Trent
4d0db94081 Reverting r320166 to fix test failures.
llvm-svn: 320174
2017-12-08 19:09:26 +00:00
Michael Trent
09dad69aba Updated llvm-objdump to display local relocations in Mach-O binaries
Summary:
llvm-objdump's Mach-O parser was updated in r306037 to display external
relocations for MH_KEXT_BUNDLE file types. This change extends the Macho-O
parser to display local relocations for MH_PRELOAD files. When used with
the -macho option relocations will be displayed in a historical format.

rdar://35778019

Reviewers: enderby

Reviewed By: enderby

Subscribers: llvm-commits

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

llvm-svn: 320166
2017-12-08 17:51:04 +00:00
Shoaib Meenai
d81bfe1cb8 [CMake] Use PRIVATE in target_link_libraries for executables
We currently use target_link_libraries without an explicit scope
specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables.
Dependencies added in this way apply to both the target and its
dependencies, i.e. they become part of the executable's link interface
and are transitive.

Transitive dependencies generally don't make sense for executables,
since you wouldn't normally be linking against an executable. This also
causes issues for generating install export files when using
LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM
library dependencies, which are currently added as interface
dependencies. If clang is in the distribution components but the LLVM
libraries it depends on aren't (which is a perfectly legitimate use case
if the LLVM libraries are being built static and there are therefore no
run-time dependencies on them), CMake will complain about the LLVM
libraries not being in export set when attempting to generate the
install export file for clang. This is reasonable behavior on CMake's
part, and the right thing is for LLVM's build system to explicitly use
PRIVATE dependencies for executables.

Unfortunately, CMake doesn't allow you to mix and match the keyword and
non-keyword target_link_libraries signatures for a single target; i.e.,
if a single call to target_link_libraries for a particular target uses
one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must
also be updated to use those keywords. This means we must do this change
in a single shot. I also fully expect to have missed some instances; I
tested by enabling all the projects in the monorepo (except dragonegg),
and configuring both with and without shared libraries, on both Darwin
and Linux, but I'm planning to rely on the buildbots for other
configurations (since it should be pretty easy to fix those).

Even after this change, we still have a lot of target_link_libraries
calls that don't specify a scope keyword, mostly for shared libraries.
I'm thinking about addressing those in a follow-up, but that's a
separate change IMO.

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

llvm-svn: 319840
2017-12-05 21:49:56 +00:00
Michael Trent
b34aad4a84 Test commit, as per the LLVM Developer Policy.
Commit message, as per the same policy. I added a blank space to the end
of the file. Excelsior.

llvm-svn: 319743
2017-12-05 07:50:00 +00:00
Kevin Enderby
6d1133e544 Fix a crash in llvm-objdump when printing a bad x86_64 relocation in a Mach-O
file with a bad section number.

rdar://35207539

llvm-svn: 317373
2017-11-03 21:32:44 +00:00
Aaron Ballman
b071b10879 Add llvm::for_each as a range-based extensions to <algorithm> and make use of it in some cases where it is a more clear alternative to std::for_each.
llvm-svn: 317356
2017-11-03 20:01:25 +00:00
Shoaib Meenai
8e98660f03 [tools] Add option to install binutils symlinks
The LLVM tools can be used as a replacement for binutils, in which case
it's convenient to create symlinks with the binutils names. Add support
for these symlinks in the build system. As with any other llvm tool
symlinks, the user can limit the installed symlinks by only adding the
desired ones to `LLVM_TOOLCHAIN_TOOLS`.

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

llvm-svn: 317272
2017-11-02 21:43:32 +00:00
NAKAMURA Takumi
c59f1ab92f Untabify.
llvm-svn: 316079
2017-10-18 13:31:28 +00:00
Rafael Espindola
7824d0422f Convert a few ErrorOr to Expected.
llvm-svn: 315477
2017-10-11 17:23:15 +00:00
Francis Ricci
a55e7b5513 [llvm-objdump] Use initializer list for scoped xar api constructors
llvm-svn: 315243
2017-10-09 20:27:14 +00:00
Francis Ricci
ae8c64ffc0 Guard xar RAII behind HAVE_LIBXAR
llvm-svn: 315072
2017-10-06 15:54:20 +00:00
Francis Ricci
ca7bdaa659 [llvm-objdump] Add RAII for xar apis
Summary:
xar_open and xar_iter_new require manual calls to close/free functions
to deallocate resources. This makes it easy to introduce memory leaks,
so add RAII struct wrappers for these resources.

Reviewers: enderby, rafael, compnerd, lhames, dblaikie

Subscribers: llvm-commits

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

llvm-svn: 315069
2017-10-06 15:33:28 +00:00
Reid Kleckner
e0df0bbd27 [Support] Rename tool_output_file to ToolOutputFile, NFC
This class isn't similar to anything from the STL, so it shouldn't use
the STL naming conventions.

llvm-svn: 314050
2017-09-23 01:03:17 +00:00
Kevin Enderby
63cb9b07be Fix a bug in llvm-objdump when disassembling using the wrong default CPU
in the second slice of a Mach-O universal file.

The code in llvm-objdump in in DisassembleMachO() was getting the default
CPU then incorrectly setting into the global variable used for the -mcpu option
if that was not set.  This caused a second call to DisassembleMachO() to use
the wrong default CPU when disassembling the next slice in a Mach-O universal
file.  And would result in bad disassembly and an error message about an
recognized processor for the target:

% llvm-objdump -d -m -arch all  fat.macho-armv7s-arm64 
fat.macho-armv7s-arm64 (architecture armv7s):
(__TEXT,__text) section
armv7:
       0:	60 47 	bx	r12
fat.macho-armv7s-arm64 (architecture arm64):
'cortex-a7' is not a recognized processor for this target (ignoring processor)
'cortex-a7' is not a recognized processor for this target (ignoring processor)
(__TEXT,__text) section
___multc3:
       0:		.long	0x1e620810

rdar://34439149

llvm-svn: 313921
2017-09-21 21:45:02 +00:00
Vlad Tsyrklevich
f226d9a550 Allow public Triple deduction from ObjectFiles.
Move logic that allows for Triple deduction from an ObjectFile object
out of llvm-objdump.cpp into a public factory, found in the ObjectFile
class.

This should allow other tools in the future to use this logic without
reimplementation.

Patch by Mitch Phillips

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

llvm-svn: 313605
2017-09-19 02:22:48 +00:00
Jonas Devlieghere
158da0d39f [dwarfdump] Make .eh_frame an alias for .debug_frame
This patch makes the `.eh_frame` extension an alias for `.debug_frame`.
Up till now it was only possible to dump the section using objdump, but
not with dwarfdump. Since the two are essentially interchangeable, we
dump whichever of the two is present.

As a workaround, this patch also adds parsing for 3 currently
unimplemented CFA instructions: `DW_CFA_def_cfa_expression`,
`DW_CFA_expression`, and `DW_CFA_val_expression`. Because I lack the
required knowledge, I just parse the fields without actually creating
the instructions.

Finally, this also fixes the typo in the `.debug_frame` section name
which incorrectly contained a trailing `s`.

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

llvm-svn: 313530
2017-09-18 14:15:57 +00:00
Francis Ricci
90cfa11011 [llvm-objdump] Fix memory leaks in macho dump
Summary: Detected by LeakSanitizer for Darwin

Reviewers: enderby, rafael

Subscribers: llvm-commits

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

llvm-svn: 313146
2017-09-13 13:57:45 +00:00
Vlad Tsyrklevich
a334ade382 Remove unneccessary string copies from method invocations.
Summary:
Change string parameter 'File' to be passed by const-reference to
reduce copies.

Patch by Mitch Phillips

Reviewers: vlad.tsyrklevich

Reviewed By: vlad.tsyrklevich

Subscribers: Eugene.Zelenko, llvm-commits

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

llvm-svn: 312994
2017-09-12 02:27:39 +00:00
Adrian Prantl
37ec73c718 llvm-dwarfdump: Replace -debug-dump=sect option with individual options.
As discussed on llvm-dev in
http://lists.llvm.org/pipermail/llvm-dev/2017-September/117301.html
this changes the command line interface of llvm-dwarfdump to match the
one used by the dwarfdump utility shipping on macOS. In addition to
being shorter to type this format also has the advantage of allowing
more than one section to be specified at the same time.

In a nutshell, with this change

  $ llvm-dwarfdump --debug-dump=info
  $ llvm-dwarfdump --debug-dump=apple-objc

becomes

  $ dwarfdump --debug-info --apple-objc

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

llvm-svn: 312970
2017-09-11 22:59:45 +00:00
NAKAMURA Takumi
b40db7c573 Untabify.
llvm-svn: 311875
2017-08-28 06:47:47 +00:00
Simon Dardis
a7f75ee70d [llvm-objdump] Use PRIx64 for output of ARM64_RELOC_ADDEND
llvm-svn: 310250
2017-08-07 12:29:38 +00:00
Rafael Espindola
abf9b1c7a5 Don't pass the code model to MC
I was surprised to see the code model being passed to MC. After all,
it assembles code, it doesn't create it.

The one place it is used is in the expansion of .cfi directives to
handle .eh_frame being more that 2gb away from the code.

As far as I can tell, gnu assembler doesn't even have an option to
enable this. Compiling a c file with gcc -mcmodel=large produces a
regular looking .eh_frame. This is probably because in practice linker
parse and recreate .eh_frames.

In llvm this is used because the JIT can place the code and .eh_frame
very far apart. Ideally we would fix the jit and delete this
option. This is hard.

Apart from confusion another problem with the current interface is
that most callers pass CodeModel::Default, which is bad since MC has
no way to map it to the target default if it actually needed to.

This patch then replaces the argument with a boolean with a default
value. The vast majority of users don't ever need to look at it. In
fact, only CodeGen and llvm-mc use it and llvm-mc just to enable more
testing.

llvm-svn: 309884
2017-08-02 20:32:26 +00:00
Alexander Shaposhnikov
5614ad605c [llvm] Update MachOObjectFile::exports interface
This diff removes the second argument of the method MachOObjectFile::exports.
In all in-tree uses this argument is equal to "this" and 
without this argument the interface seems to be cleaner.

Test plan: make check-all

llvm-svn: 309462
2017-07-29 00:30:45 +00:00
Kevin Enderby
fe3ae3d76e Add error handling to the dyld compact export entries in libObject.
lld needs a matching change for this will be my next commit.
Expect it to fail build until that matching commit is picked up by the bots.

Like the changes in r296527 for dyld bind entires and the changes in
r298883 for lazy bind, weak bind and rebase entries the export
entries are the last of the dyld compact info to have error handling added.

This follows the model of iterators that can fail that Lang Hanes
designed when fixing the problem for bad archives r275316 (or r275361).

So that iterating through the exports now terminates if there is an error
and returns an llvm::Error with an error message in all cases for malformed
input.

This change provides the plumbing for the error handling, all the needed
testing of error conditions and test cases for all of the unique error messages.

llvm-svn: 308690
2017-07-20 23:08:41 +00:00
Rafael Espindola
d66fd5d54c Use delegation instead of inheritance.
This changes DwarfContext to delegate to DwarfObject instead of having
pure virtual methods.

With this DwarfContextInMemory is replaced with an implementation of
DwarfObject that is local to a .cpp file.

llvm-svn: 308543
2017-07-19 22:27:28 +00:00
Martin Storsjo
3f62f9037a [llvm-objdump] Properly print MachO aarch64 addend relocations
Previously such relocations fell into the last case for local
symbols, using the relocation addend as symbol index, leading to
a crash.

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

llvm-svn: 307927
2017-07-13 17:03:02 +00:00
Martin Storsjo
842285000a [llvm-objdump] Correctly distinguish between the MachO upper/lower16 relocations
All other code in MachODump.cpp uses the same comparison,
((r_length & 0x1) == 1), for distinguishing between the two,
while the code in llvm-objdump.cpp seemed to be incorrect.

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

llvm-svn: 307882
2017-07-13 05:54:08 +00:00
Sam Clegg
6392bbbc67 [WebAssembly] Add support for printing relocations with llvm-objdump
Differential Revision: https://reviews.llvm.org/D34658

llvm-svn: 306461
2017-06-27 20:40:53 +00:00
Kevin Enderby
a8f3f45fde Updated llvm-objdump for arm64 Mach-O MH_KEXT_BUNDLE file types so
it symbolically disassembles the __text section from the
__TEXT_EXEC segment not the usual __TEXT segment by default.

rdar://30590208

llvm-svn: 306046
2017-06-22 19:50:56 +00:00
Kevin Enderby
0b97356076 Updated llvm-objdump symbolic disassembly with x86_64 Mach-O MH_KEXT_BUNDLE
file types so it symbolically disassembles operands using the external
relocation entries.

rdar://31521343

llvm-svn: 306037
2017-06-22 17:41:22 +00:00
Kevin Enderby
3f637e8013 Updated llvm-objdump with Mach-O files and the -objc-meta-data option so
that it symbolically prints the superclass when it has dyld bind info for it.

rdar://7638823

llvm-svn: 305866
2017-06-20 22:55:11 +00:00
Kevin Enderby
c4ac67070a Change llvm-objdump with Mach-O files and the -info-plist option with the
-no-leading-headers option so that it does not print the leading header.

rdar://27378808

llvm-svn: 305849
2017-06-20 21:00:25 +00:00
Kevin Enderby
dbfe579a76 Fix a FIXME in llvm-objdump for the -exports-trie option that was not adding
in the base address.

Without this Mach-O files, like 64-bit executables, don’t have the correct
addresses printed for their exports.  As the default is to link at address
0x100000000 not zero.

llvm-svn: 305744
2017-06-19 21:23:07 +00:00
Kevin Enderby
1a26f183b2 Change llvm-nm for Mach-O files to use dyld info in some cases when printing symbols.
In order to reduce swift binary sizes, Apple is now stripping swift symbols
from the nlist symbol table.  llvm-nm currently only looks at the nlist symbol
table and misses symbols that are present in dyld info.   This makes it hard to
know the set of symbols for a binary using just llvm-nm.  Unless you know to
run llvm-objdump -exports-trie that can output the exported symbols in the dyld
info from the export trie, which does so but in a different format.

Also moving forward the time may come a when a fully linked Mach-O file that
uses dyld will no longer have an nlist symbol table to avoid duplicating the
symbol information.

This change adds three flags to llvm-nm, -add-dyldinfo, -no-dyldinfo, and
-dyldinfo-only.

The first, -add-dyldinfo, has the same effect as when the new bit in the Mach-O
header, MH_NLIST_OUTOFSYNC_WITH_DYLDINFO, appears in a binary.  In that it
looks through the dyld info from the export trie and adds symbols to be printed
that are not already in its internal SymbolList variable.  The -no-dyldinfo
option turns this behavior off.

The -dyldinfo-only option only looks at the dyld information and recreates the
symbol table from the dyld info from the export trie and binding information.
As if it the Mach-O file had no nlist symbol table.

Also fixed a few bugs with Mach-O N_INDR symbols not correctly printing the
indirect name, or in the same format as the old nm-classic program.

rdar://32021551

llvm-svn: 305733
2017-06-19 19:38:22 +00:00