Commit Graph

6020 Commits

Author SHA1 Message Date
JF Bastien
6a829ed9d4 Fix llvm-config to emit the linker flag for the combined shared object built by autoconfig/make instead of the individual components.
Summary:
When LLVM is configured to build shared libraries, CMake builds each component as it's own shared object, while autoconfig/make builds them statically and then links them all together to create a single shared object. This change adds compile time config flags to `llvm-config` so it can know whether LLVM's components are separated or not and act accordingly.

This fixes `llvm-config` instead of fixing the makefiles to behave like CMake because, AIUI, LLVM's autoconfig/make build system is on the way out anyway.

This change only affects `llvm-config` from builds that use autoconfig/make.

Reviewers: jfb

Subscribers: echristo, dschuff, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243297 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-27 18:26:30 +00:00
Tobias Grosser
6db2ad6004 bugpoint: make the number of trim iterations a compile-time constant
Around 10 year ago Chris limited this code to a single iteration by just
dropping a break into the loop body. We now make the number of trim iterations
a compile time constant to be able to play with it and see if this can
improve the bugpoint results. We currently use with '3' still a small and
conservative value, but this can be adjusted in the future, if needed.

I tried to look for a trivial test case, but did not succeed yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243247 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-26 15:18:45 +00:00
Davide Italiano
5e7aab0de2 [llvm-dwarfump] Don't rely on global state, part 3.
Some tools used to rely on a global static variable to keep track of the 
return value for main(). I changed llvm-cxxdump to use exit(1)
and Rafael shortly after did the same with llvm-readobj. This is
(yet) another step towards the goal.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243240 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-26 05:35:59 +00:00
Chandler Carruth
5da92333c3 Update for r243115 which changed the DataLayout API on TargetMachine but
didn't update the gold-plugin.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243121 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 17:23:09 +00:00
Mehdi Amini
15e1e7f179 Remove access to the DataLayout in the TargetMachine
Summary:
Replace getDataLayout() with a createDataLayout() method to make
explicit that it is intended to create a DataLayout only and not
accessing it for other purpose.

This change is the last of a series of commits dedicated to have a
single DataLayout during compilation by using always the one owned
by the module.

Reviewers: echristo

Subscribers: jholewinski, llvm-commits, rafael, yaron.keren

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

(cherry picked from commit 5609fc56bca971e5a7efeaa6ca4676638eaec5ea)

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243114 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 16:04:22 +00:00
Frederic Riss
fa7f7bd017 [dsymutil] Implement support for universal mach-o object files.
This patch allows llvm-dsymutil to read universal (aka fat) macho object
files and archives. The patch touches nearly everything in the BinaryHolder,
but it is fairly mechinical: the methods that returned MemoryBufferRefs or
ObjectFiles now return a vector of those, and the high-level access function
takes a triple argument to select the architecture.

There is no support yet for handling fat executables and thus no support for
writing fat object files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243096 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 06:41:11 +00:00
Frederic Riss
1556296615 [dsymutil] Make the triple detection more strict.
MachOObjectFile offers a method for detecting the correct triple, use
it instead of the previous approximation. This doesn't matter right
now, but it will become important for mach-o universal (fat) binaries.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243095 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 06:41:04 +00:00
Frederic Riss
e10885312d [dsymutil] Refactor BinaryHolder internals. NFC
Call a helper that resets all the internal state of the BinaryHolder
when we change the underlying memory buffer. Makes a followup patch
a tiny bit smaller.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243094 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 06:40:59 +00:00
Mehdi Amini
26be214232 Revert "Remove access to the DataLayout in the TargetMachine"
This reverts commit 0f720d984f.

It breaks clang too badly, I need to prepare a proper patch for clang
first.

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243089 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 03:36:55 +00:00
Davide Italiano
c46ea19bd3 [llvm-reaobj] Display COFF-specific sections/tables only if the object is COFF.
Just skip them otherwise.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243086 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 02:14:20 +00:00
Mehdi Amini
0f720d984f Remove access to the DataLayout in the TargetMachine
Summary:
Replace getDataLayout() with a createDataLayout() method to make
explicit that it is intended to create a DataLayout only and not
accessing it for other purpose.

This change is the last of a series of commits dedicated to have a
single DataLayout during compilation by using always the one owned
by the module.

Reviewers: echristo

Subscribers: jholewinski, llvm-commits, rafael, yaron.keren

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

(cherry picked from commit 5609fc56bca971e5a7efeaa6ca4676638eaec5ea)

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243083 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 01:44:39 +00:00
Colin LeMahieu
ea8050283f [llvm-objdump] Add -D and --disassemble-all flags that attempt disassembly on all sections instead of just text sections.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243041 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 20:58:49 +00:00
Rafael Espindola
52f969b029 Use helper function. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243012 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 12:51:44 +00:00
Rafael Espindola
a7616cd14c Add a version of getSymbol with an explicit symbol table. Use it. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243011 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 12:49:40 +00:00
Rafael Espindola
2b11aef2f4 Support printing relocations in files with no section table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242998 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 09:11:05 +00:00
Rafael Espindola
7528c1963f Use typdef to simplify the code. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242995 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 08:48:14 +00:00
Frederic Riss
00d14ddf9d [dsymutil] Check archive members timestamps.
The debug map contains the timestamp of the object files in references.
We do not check these in the general case, but it's really useful if
you have archives where different versions of an object file have been
appended. This allows llvm-dsymutil to find the right one.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242965 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 23:24:00 +00:00
Rafael Espindola
55b052ae66 Delete ELFEntityIterator. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242901 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 14:09:20 +00:00
Benjamin Kramer
55556435fd [dsymutil] Remove extra semicolon. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242894 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 11:54:19 +00:00
Frederic Riss
309fcf84b8 [dsymutil] Implement ODR uniquing for C++ code.
This optimization allows the DWARF linker to reuse definition of
types it has emitted in previous CUs rather than reemitting them
in each CU that references them. The size and link time gains are
huge. For example when linking the DWARF for a debug build of
clang, this generates a ~150M dwarf file instead of a ~700M one
(the numbers date back a bit and must not be totally accurate
these days).

As with all the other parts of the llvm-dsymutil codebase, the
goal is to keep bit-for-bit compatibility with dsymutil-classic.
The code is littered with a lot of FIXMEs that should be
addressed once we can get rid of the compatibilty goal.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242847 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 22:41:43 +00:00
Rafael Espindola
c22eb2bea6 Don't iterate over the program headers in the constructor of ELFFile.
Not every program needs this information.

In particular, it is necessary and sufficient for a static linker to scan the
section table.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242833 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 20:50:53 +00:00
Rafael Espindola
ca7fac9a29 Make printValue a member function.
We were already passing 3 values it can get from ELFDumper.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242829 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 19:57:43 +00:00
Rafael Espindola
961b7c2b52 Remove always null argument.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242828 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 19:38:32 +00:00
Rafael Espindola
9ed0d629ce Remove getStaticSymbolName.
Every user now keeps track of the correct string table to use.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242818 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 18:04:29 +00:00
Rafael Espindola
a33feabe7a Remove always false parameter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242802 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 16:42:01 +00:00
Rafael Espindola
51ac821430 Use range loop. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242801 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 16:40:14 +00:00
Rafael Espindola
7eeb71ddc3 Replace the last uses of ELF::getSymbolName in llvm-readobj.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242798 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 16:26:21 +00:00
Rafael Espindola
9ea117379c Use helper function. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242795 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 16:05:53 +00:00
Rafael Espindola
fcadda639e llvm-readobj: use the associated string table to print symbols. NFI.
This just removes some cases that require ELFFile to eagerly parse the ELF
file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242794 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 16:02:10 +00:00
Chris Bieneman
791500fa0d [CMake] Projects supported via LLVM_EXTERNAL_*_SOURCE_DIR need to be explicitly specified.
One part of my refactoring from r242705 is untenable due to how CMake caches variables. There is no way other than caching to allow variables to be set in one directory and globally readable, but we really don't want to cache the temporary value marking that a directory has already been included.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242793 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 15:53:09 +00:00
Rafael Espindola
71e35258cb Simplify printing the soname. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 13:48:41 +00:00
Rafael Espindola
ed3c543ddb Add missing c++ marker to .h file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242784 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 13:42:38 +00:00
Rafael Espindola
bb418bc23b Remove duplicated code.
Both ELFObjectFile and ELFFile had an implementation of getLoadName.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242725 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 22:41:44 +00:00
Rafael Espindola
0377a22491 Simplify now that we can iterate backwards. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242715 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 21:45:56 +00:00
Chris Bieneman
4ee8a184ee [CMake] Cleanup tools/CMakeLists.txt to take advantage of the auto-registration that was already partially working.
Re-landing r242059 which re-landed r241621... I'm really bad at this.

Summary (r242059):
This change re-lands r241621, with an additional fix that was required to allow tool sources to live outside the llvm checkout. It also no longer renames LLVM_EXTERNAL_*_SOURCE_DIR. This change was reverted in r241663, because it renamed several variables of the format LLVM_EXTERNAL_*_* to LLVM_TOOL_*_*.

Summary (r241621):
The tools CMakeLists file already had implicit tool registration, but there were a few things off about it that needed to be altered to make it work. This change addresses all that. The changes in this patch are:

* factored out canonicalizing tool names from paths to CMake variables * removed the LLVM_IMPLICIT_PROJECT_IGNORE mechanism in favor of LLVM_EXTERNAL_${nameUPPER}_BUILD which I renamed to LLVM_TOOL_${nameUPPER}_BUILD because it applies to internal and external tools
* removed ignore_llvm_tool_subdirectory() in favor of just setting LLVM_TOOL_${nameUPPER}_BUILD to Off
* Added create_llvm_tool_options() to resolve a bug in add_llvm_external_project() - the old LLVM_EXTERNAL_${nameUPPER}_BUILD would not work on a clean CMake directory because the option could be created after it was set in code.
* Removed all but the minimum required calls to add_llvm_external_project from tools/CMakeLists.txt

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242705 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 20:36:06 +00:00
Rafael Espindola
1c12cc02fd Remove Elf_Rela_Iter and Elf_Rel_Iter.
Use just the pointers and check for invalid relocation sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242700 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 20:07:50 +00:00
Rafael Espindola
9a4133e1ee Simplify iterating over program headers and detect corrupt ones.
We now use a simple pointer and have range loops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242669 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 13:35:33 +00:00
Rafael Espindola
fa1a4b2275 llvm-readobj: Handle invalid references to the string table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242658 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 03:38:17 +00:00
Rafael Espindola
d60ced8e08 llvm-readobj: call exit(1) on error.
llvm-readobj exists for testing llvm. We can safely stop the program
the first time we know the input in corrupted.

This is in preparation for making it handle a few more broken files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242656 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 03:23:55 +00:00
Rafael Espindola
b9adbd998f Refactor duplicated code. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242655 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-20 03:01:49 +00:00
Davide Italiano
ac018543f8 [llvm-cxxdump] Don't rely on global state
Differential Revision:	http://reviews.llvm.org/D11227


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242509 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-17 06:18:36 +00:00
Rafael Espindola
5404f6983a Delete an unused function.
Patch by Xan López!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242429 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-16 18:41:41 +00:00
Rafael Espindola
ba7661d294 For new archive member we only need to store the full path.
We were storing both the path and the file name, which was redundant
and easy to get confused up with.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242347 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-15 22:46:53 +00:00
Rafael Espindola
a0458b67ae Simplify a few uses of remove_filename by using parent_path instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242334 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-15 21:24:07 +00:00
Rafael Espindola
8d1daf644b Handle the error of trying to convert a regular archive to a thin one.
While at it, test that we can add to a thin archive.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242330 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-15 20:45:56 +00:00
Rafael Espindola
4c9cd28947 Initial support for writing thin archives.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242269 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-15 05:47:46 +00:00
Rafael Espindola
7a6e3434ba Add support for reading members out of thin archives.
For now the Archive owns the buffers of the thin archive members.
This makes for a simple API, but all the buffers are destructed
only when the archive is destructed. This should be fine since we
close the files after mmap so we should not hit an open file
limit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242215 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 22:18:43 +00:00
Rafael Espindola
6e9f427cb2 llvm-ar: Don't try to extract from thin archives.
This matches the gnu ar behavior.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242162 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 16:55:13 +00:00
Rafael Espindola
4daa23f9a7 llvm-ar: print an error when the requested member is not found.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242156 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 16:02:40 +00:00
Rafael Espindola
7ad2fa37a9 Use a range loop. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242153 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-14 15:22:42 +00:00