Commit Graph

5355 Commits

Author SHA1 Message Date
Jean-Daniel Dupas
206b84f324 Add mach-o LC_RPATH support to llvm-objdump
Summary: Add rpath load command support in Mach-O object and update llvm-objdump to use it.

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D6512

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223343 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-04 07:37:02 +00:00
NAKAMURA Takumi
6c46ca33bf Introduce "llvm-ranlib" as a name of targets since Object/archive-symtab.test requires llvm-ranlib.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223332 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-04 01:34:11 +00:00
Rafael Espindola
471e834c8d For copy, cmake needs the full path to llvm-ar.
This should fix the windows build.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223324 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-04 00:23:58 +00:00
Rafael Espindola
fbcb697a00 Add missing dependency on llvm-ar. Should hopefully fix the bots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223321 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-04 00:00:36 +00:00
Rafael Espindola
cc0061b299 This reverts commit r223306 and r223277.
The code is using uninitialized memory and failing on linux.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223315 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-03 23:29:34 +00:00
Rafael Espindola
a63b95fd14 Make llvm-ar a real build target and install it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223309 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-03 23:17:24 +00:00
Kevin Enderby
5b9d42b68c Add support to llvm-objdump for Mach-O universal files and archives with -macho.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223277 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-03 22:29:40 +00:00
Peter Collingbourne
bb660fc192 Prologue support
Patch by Ben Gamari!

This redefines the `prefix` attribute introduced previously and
introduces a `prologue` attribute.  There are a two primary usecases
that these attributes aim to serve,

  1. Function prologue sigils

  2. Function hot-patching: Enable the user to insert `nop` operations
     at the beginning of the function which can later be safely replaced
     with a call to some instrumentation facility

  3. Runtime metadata: Allow a compiler to insert data for use by the
     runtime during execution. GHC is one example of a compiler that
     needs this functionality for its tables-next-to-code functionality.

Previously `prefix` served cases (1) and (2) quite well by allowing the user
to introduce arbitrary data at the entrypoint but before the function
body. Case (3), however, was poorly handled by this approach as it
required that prefix data was valid executable code.

Here we redefine the notion of prefix data to instead be data which
occurs immediately before the function entrypoint (i.e. the symbol
address). Since prefix data now occurs before the function entrypoint,
there is no need for the data to be valid code.

The previous notion of prefix data now goes under the name "prologue
data" to emphasize its duality with the function epilogue.

The intention here is to handle cases (1) and (2) with prologue data and
case (3) with prefix data.

References
----------

This idea arose out of discussions[1] with Reid Kleckner in response to a
proposal to introduce the notion of symbol offsets to enable handling of
case (3).

[1] http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-May/073235.html

Test Plan: testsuite

Differential Revision: http://reviews.llvm.org/D6454

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223189 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-03 02:08:38 +00:00
Lang Hames
5ab94e7135 [MCJIT] Unique-ptrify the RTDyldMemoryManager member of MCJIT. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223183 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-03 00:51:19 +00:00
Duncan P. N. Exon Smith
9416f9c57d DebugIR: Delete -debug-ir
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222945 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-29 03:15:47 +00:00
Lang Hames
21f9d78c25 [MCJIT] Update CMakeLists.txt for llvm-rtdyld to add Object as a requirement.
Hopefully this will fix
http://bb.pgr.jp/builders/clang-3stage-x86_64-linux/builds/8271/steps/stage1_build/logs/stdio



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222866 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-27 04:18:50 +00:00
Peter Collingbourne
a9ce03858d Teach LLVM about llgo subproject.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222860 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-27 00:15:21 +00:00
Rui Ueyama
d2077b0631 Object/COFF: Fix off-by-one error for object having lots of relocations
llvm-objdump printed out an error message for this off-by-one error,
but because it always exits with 0 whether or not it found an error,
the test (llvm-objdump/coff-many-relocs.test) succeeded.
I made llvm-objdump exit with EXIT_FAILURE when an error is found.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222852 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-26 22:17:25 +00:00
Lang Hames
216e532dc1 [MCJIT] Reapply r222828 and r222810-r222812 with fix for MSVC move-op issues.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222840 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-26 16:54:40 +00:00
Aaron Ballman
19afe67157 Reverting r222828 and r222810-r222812 as they broke the build on Windows.
http://bb.pgr.jp/builders/ninja-clang-i686-msc17-R/builds/11753

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222833 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-26 15:27:39 +00:00
Lang Hames
7acaefabf6 [MCJIT] Clean up RuntimeDyld's quirky object-ownership/modification scheme.
Previously, when loading an object file, RuntimeDyld (1) took ownership of the
ObjectFile instance (and associated MemoryBuffer), (2) potentially modified the
object in-place, and (3) returned an ObjectImage that managed ownership of the
now-modified object and provided some convenience methods. This scheme accreted
over several years as features were tacked on to RuntimeDyld, and was both
unintuitive and unsafe (See e.g. http://llvm.org/PR20722).

This patch fixes the issue by removing all ownership and in-place modification
of object files from RuntimeDyld. Existing behavior, including debugger
registration, is preserved.

Noteworthy changes include:

(1) ObjectFile instances are now passed to RuntimeDyld by const-ref.
(2) The ObjectImage and ObjectBuffer classes have been removed entirely, they
    existed to model ownership within RuntimeDyld, and so are no longer needed.
(3) RuntimeDyld::loadObject now returns an instance of a new class,
    RuntimeDyld::LoadedObjectInfo, which can be used to construct a modified
    object suitable for registration with the debugger, following the existing
    debugger registration scheme.
(4) The JITRegistrar class has been removed, and the GDBRegistrar class has been
    re-written as a JITEventListener.

This should fix http://llvm.org/PR20722 .



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222810 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-26 06:53:26 +00:00
Rafael Espindola
2fbbd7a369 gold plugin: call llvm_shutdown so that -stats works.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-25 20:52:49 +00:00
Charlie Turner
94c465cf10 Correctly handle Tag_CPU_arch_profile.
Fix ARMAttributeParser::CPU_arch_profile so that it doesn't switch on the value
'0' as a legal value of this build attribute.

Change-Id: Ie05a08900a82bb10b78c841b437df747ce3bb38e

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222743 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-25 09:30:09 +00:00
Rafael Espindola
f1ca1d4bc3 Add a disable-output option to the gold plugin.
This corresponds to the opt option and is handy for profiling.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222687 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-24 21:18:14 +00:00
Duncan P. N. Exon Smith
d871594be4 gold-plugin: Fix typo in error message
Spotted while reading code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222395 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-19 22:39:21 +00:00
Kevin Enderby
32f8e055f2 Fix Use-of-uninitialized-value for adrp_addr and adrp_inst in MachODump.cpp
Fixes PR21607


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222385 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-19 20:20:16 +00:00
Colin LeMahieu
e0bb2f31b2 [llvm-readobj][NFC]
Appeasing mingw without C++11 std::to_string

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222369 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-19 17:10:39 +00:00
David Blaikie
1d4f28c6bc Remove StringMap::GetOrCreateValue in favor of StringMap::insert
Having two ways to do this doesn't seem terribly helpful and
consistently using the insert version (which we already has) seems like
it'll make the code easier to understand to anyone working with standard
data structures. (I also updated many references to the Entry's
key and value to use first() and second instead of getKey{Data,Length,}
and get/setValue - for similar consistency)

Also removes the GetOrCreateValue functions so there's less surface area
to StringMap to fix/improve/change/accommodate move semantics, etc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222319 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-19 05:49:42 +00:00
David Blaikie
8f4a49f41a Make StringSet::insert return pair<iterator, bool> like other self-associative containers
StringSet is still a bit dodgy in that it exposes the raw iterator of
the StringMap parent, which exposes the weird detail that StringSet
actually has a 'value'... but anyway, this is useful for a handful of
clients that want to reference the newly inserted/persistent string data
in the StringSet/Map/Entry/thing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222302 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-19 02:56:00 +00:00
Rui Ueyama
3977e2f696 llvm-readobj: fix off-by-one error in COFFDumper
It printed out base relocation table header as table entry.
This patch also makes llvm-readobj to not skip ABSOLUTE entries
becuase it was confusing.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222299 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-19 02:07:10 +00:00
Rui Ueyama
6272b8c4be llvm-readobj: teach it how to dump COFF base relocation table
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222289 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-19 00:18:07 +00:00
David Majnemer
f0e7ccce9e llvm-readobj: Don't print the Characteristics field as the Subsystem
We claimed that we were printing the Subystem field when we were
actually printing the Characteristics field.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222216 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-18 02:45:28 +00:00
David Majnemer
a18e46cbc9 Object, COFF: Tighten the object file parser
We were a little lax in a few areas:
- We pretended that import libraries were like any old COFF file, they
  are not.  In fact, they aren't really COFF files at all, we should
  probably grow some specialized functionality to handle them smarter.
- Our symbol iterators were more than happy to attempt to go past the
  end of the symbol table if you had a symbol with a bad list of
  auxiliary symbols.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222124 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-17 11:17:17 +00:00
Frederic Riss
b06648fe56 Implement MachODumper::printFileHeaders
Patch by Chilledheart.

Differential Revision: http://reviews.llvm.org/D6163

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222115 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-17 01:34:15 +00:00
David Majnemer
f85959ebc3 yaml2obj, COFF: Consider the DOS stub when laying out section headers
While this program worked correctly with small example programs, larger
ones tickled this bug.  I'm working on a reduction because my program is
quite large.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222078 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-15 02:03:59 +00:00
Kevin Enderby
61ab3a1cc5 Add the code and test cases for 64-bit ARM to llvm-objdump’s Mach-O symbolizer.
FYI, removed the unused MCInstrAnalysis as it does not exist for 64-bit ARM and
was causing a “couldn't initialize disassembler for target” error.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222045 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-14 21:52:18 +00:00
David Majnemer
a9d69424f4 yaml2obj, COFF: Correctly calculate SizeOfImage and SizeOfHeaders
SizeOfHeaders must be aligned to the FileAlignment.
SizeOfImage must be at least the SizeOfHeaders aligned to the
SectionAlignment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222030 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-14 19:35:59 +00:00
Frederic Riss
e26d79386b Reapply "[dwarfdump] Add support for dumping accelerator tables."
This reverts commit r221842 which was a revert of r221836 and of the
test parts of r221837.

This new version fixes an UB bug pointed out by David (along with
addressing some other review comments), makes some dumping more
resilient to broken input data and forces the accelerator tables
to be dumped in the tests where we use them (this decision is
platform specific otherwise).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222003 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-14 16:15:53 +00:00
David Majnemer
237544b16d obj2yaml, yaml2obj: Add support for COFF executables
In support of serializing executables, obj2yaml now records the virtual address
and size of sections.  It also serializes whatever we strictly need from
the PE header, it expects that it can reconstitute everything else via
inference.

yaml2obj can reconstitute a fully linked executable.

In order to get executables correctly serialized/deserialized, other
bugs were fixed as a circumstance.  We now properly respect file and
section alignments.  We also avoid writing out string tables unless they
are strictly necessary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221975 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-14 08:15:42 +00:00
Justin Bogner
d24e90a5de llvm-cov: Sink some reporting logic into CoverageMapping
This teaches CoverageMapping::getCoveredFunctions to filter to a
particular file and uses that to replace most of the logic found in
llvm-cov report.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221962 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-14 01:50:32 +00:00
David Majnemer
4141e003f9 Object, Mach-O: Refactor and clean code up
Don't assert if we can return an error code, reuse existing
functionality like is64Bit().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221915 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 19:48:56 +00:00
David Majnemer
aff22c9200 llvm-readobj: relocAddressLess could potentially lie
On error conditions, relocAddressLess might claim that a value is less
than itself.  Instead, abort llvm-readobj.  No functionality change
intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221872 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 07:54:05 +00:00
David Majnemer
f6a1958f2a llvm-readobj, COFF: Remove an unused variable
printRelocation doesn't use the section contents.  No functionality
change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221871 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 07:42:13 +00:00
David Majnemer
344411bd12 Object, COFF: getRelocationSymbol shouldn't assert
lib/Object is supposed to be robust to malformed object files.  Don't
assert if we don't have a symbol table.  I'll try to come up with a test
case later.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221870 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 07:42:11 +00:00
Rui Ueyama
08f70b58cb llvm-readobj: Print out address table when dumping COFF delay-import table
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221855 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 03:22:54 +00:00
Frederic Riss
8839439547 Revert "[dwarfdump] Add support for dumping accelerator tables."
This reverts commit r221836.

The tests are asserting on some buildbots. This also reverts the
test part of r221837 as it relies on dwarfdump dumping the
accelerator tables.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221842 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 00:15:15 +00:00
Frederic Riss
931e22fd7c [dwarfdump] Add support for dumping accelerator tables.
The class used for the dump only allows to dump for the moment, but
it can (and will) be easily extended to support search also.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221836 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-12 23:48:10 +00:00
Timur Iskhodzhanov
629ba0ac0d [COFF] Make it clearer that the symbols subsection holds function display name rather than just name
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221812 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-12 20:10:09 +00:00
Aaron Ballman
1caf520205 Fixing more -Wcast-qual warnings; NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221782 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-12 14:01:17 +00:00
Rafael Espindola
a48b83ebfd Remove the now unused StringRefMemoryObject.h.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221755 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-12 02:13:27 +00:00
Rafael Espindola
6a222ec893 Pass an ArrayRef to MCDisassembler::getInstruction.
With this patch MCDisassembler::getInstruction takes an ArrayRef<uint8_t>
instead of a MemoryObject.

Even on X86 there is a maximum size an instruction can have. Given
that, it seems way simpler and more efficient to just pass an ArrayRef
to the disassembler instead of a MemoryObject and have it do a virtual
call every time it wants some extra bytes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221751 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-12 02:04:27 +00:00
Duncan P. N. Exon Smith
4f897091e4 libLTO: Allow linker to choose context of modules and codegen
Add API for specifying which `LLVMContext` each `lto_module_t` and
`lto_code_gen_t` is in.

In particular, this enables the following flow:

    for (auto &File : Files) {
      lto_module_t M = lto_module_create_in_local_context(File...);
      querySymbols(M);
      lto_module_dispose(M);
    }

    lto_code_gen_t CG = lto_codegen_create_in_local_context();
    for (auto &File : FilesToLink) {
      lto_module_t M = lto_module_create_in_codegen_context(File..., CG);
      lto_codegen_add_module(CG, M);
      lto_module_dispose(M);
    }
    lto_codegen_compile(CG);
    lto_codegen_write_merged_modules(CG, ...);
    lto_codegen_dispose(CG);

This flow has a few benefits.

  - Only one module (two if you count the combined module in the code
    generator) is in memory at a time.

  - Metadata (and constants) from files that are parsed to query symbols
    but not linked into the code generator don't pollute the global
    context.

  - The first for loop can be parallelized, since each module is in its
    own context.

  - When the code generator is disposed, the memory from LTO gets freed.

rdar://problem/18767512

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221733 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-11 23:19:23 +00:00
Duncan P. N. Exon Smith
5bf8ade9d0 Revert "IR: MDNode => Value"
Instead, we're going to separate metadata from the Value hierarchy.  See
PR21532.

This reverts commit r221375.
This reverts commit r221373.
This reverts commit r221359.
This reverts commit r221167.
This reverts commit r221027.
This reverts commit r221024.
This reverts commit r221023.
This reverts commit r220995.
This reverts commit r220994.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221711 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-11 21:30:22 +00:00
Colin LeMahieu
6d093fd78a [llvm-mc] Fixing case where if a file ended with non-newline whitespace or a comma it would access invalid memory.
Cleaned up parse loop.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221707 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-11 21:03:09 +00:00
Kevin Enderby
5cebd7cd1f Fix a warning about ‘r_type’ may be used uninitialized.
Thanks to Aaron Ballman for noticing this!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221696 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-11 19:16:45 +00:00