Commit Graph

539 Commits

Author SHA1 Message Date
Rui Ueyama eb0cc96e4b [PECOFF][Driver] Add -stack command line option.
llvm-svn: 183604
2013-06-08 03:59:00 +00:00
Rui Ueyama 7b5592bc0b [WinLink] Fix use-after-return.
llvm-svn: 183603
2013-06-08 03:39:35 +00:00
Rafael Espindola a0af48fc93 Fix handling of files without a symbol table.
This fixes a recent regression (r183338). Stripped elf files (like installed
crtn.o for example), are not required to have a symbol table. Handle that
correctly.

llvm-svn: 183573
2013-06-07 21:08:19 +00:00
Rui Ueyama a6b71cabb3 [LayoutPass] Add a method to check the followon graph structure.
Found that having a method to check the strucutre of the followon graph makes
it easy to debug file readers. The method checks if there's no wrong edge in
followOnNexts and followOnRoots. It is called only when debuggging is enabled
for LayoutPass.

Reviewers: shankarke

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D922

llvm-svn: 183553
2013-06-07 20:18:39 +00:00
Rui Ueyama 8d6151fd29 [PECOFF][Writer] Implement the writer that can emit text section.
lld can now output a valid Windows executable with a text section that does nothing
but just returns immediately. It's not able to handle relocations, symbol tables,
data sections, etc, so it still can't do anything practical, though.

Reviewers: Bigcheese

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D892

llvm-svn: 183478
2013-06-07 01:31:51 +00:00
Rui Ueyama 911d60a1e4 [Driver][Core] Handle -mllvm option.
llvm-svn: 183347
2013-06-05 23:19:18 +00:00
Rafael Espindola 0b87956542 Update for llvm's r183337.
llvm-svn: 183338
2013-06-05 20:35:36 +00:00
Rafael Espindola e699c60021 Now that llvm-readobj is fixed, enable this test.
llvm-svn: 183285
2013-06-05 01:38:12 +00:00
Rui Ueyama 143672c7e5 [lld][ELF] Add parser for linker script ENTRY command
This is the parser for the ENTRY command. Note that because the parsing result
is currentlyd discarded, lld can parse but just ignore the command.

Reviewers: Bigcheese

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D833

llvm-svn: 183141
2013-06-03 18:05:21 +00:00
Rui Ueyama feaa72a4b0 Fix typo in comment.
llvm-svn: 183050
2013-05-31 22:08:30 +00:00
Rui Ueyama 739730e299 [WinLink][Driver] Add -entry command line option.
llvm-svn: 183034
2013-05-31 19:34:29 +00:00
Rui Ueyama ce42bcc304 [WinLink][Driver] Add support for -subsystem optional OS version number.
llvm-svn: 182988
2013-05-31 06:30:10 +00:00
Rui Ueyama d752c9cc89 Fix typo in file header.
llvm-svn: 182985
2013-05-31 04:46:44 +00:00
Rui Ueyama 7eb1d49a58 [Driver] Add unit tests for GnuLdDriver.
llvm-svn: 182980
2013-05-31 02:12:34 +00:00
Michael J. Spencer 615c076fc1 Revert "[Passes] Parallelize the layout pass sort."
Inconsistent (and wrong) sort order on non-Windows.

llvm-svn: 182975
2013-05-31 00:05:49 +00:00
Rui Ueyama a21397fb01 [WinLink] Add a test for Windows-style command line options.
llvm-svn: 182971
2013-05-30 23:29:28 +00:00
Rui Ueyama 5f037590de [lld][WinLink] Fix use-after-return and add unit tests.
llvm-svn: 182970
2013-05-30 23:17:58 +00:00
Rui Ueyama b33e8bcef8 [WinLink][Driver] Handle file extensions and defualt output file name.
llvm-svn: 182912
2013-05-30 06:00:10 +00:00
Shankar Easwaran a5008e3a63 [lld][elf] Add --dynamic-linker option to the ELF linker.
Users can override the default value of the dynamic linker to be set to the
one that appears in the command line. The path can even be empty!. 

Added a test for the option.

llvm-svn: 182889
2013-05-29 22:51:01 +00:00
Rui Ueyama 81247063bf [WinLink] Add -subsystem and -out command line option parsing.
The code to actually consume these flags will be added soon.

llvm-svn: 182824
2013-05-29 05:07:49 +00:00
Michael J. Spencer 20cd8b6114 Parallel write.
llvm-svn: 182795
2013-05-28 19:09:56 +00:00
Michael J. Spencer 5b904eccad [Core] Add parallel_for_each.
llvm-svn: 182794
2013-05-28 19:09:39 +00:00
Michael J. Spencer 9ae1408556 [ELF] Make addressOfAtom thread safe.
The expression _atomToAddressMap[atom] may modify _atomToAddressMap.

llvm-svn: 182793
2013-05-28 19:09:25 +00:00
Michael J. Spencer 0d9d3110c7 [Passes] Parallelize the layout pass sort.
llvm-svn: 182792
2013-05-28 19:03:29 +00:00
Michael J. Spencer bd66d04f34 Instrument things.
llvm-svn: 182789
2013-05-28 18:55:39 +00:00
Michael J. Spencer 427354ee21 [ELF][Reader] Kind in this context refers to File::Kind. Qualify with Reference::Kind.
llvm-svn: 182787
2013-05-28 18:43:17 +00:00
Michael J. Spencer e5b8fe1274 [Driver] Parallelize reading initial object files.
llvm-svn: 182786
2013-05-28 18:37:39 +00:00
Rui Ueyama 9e56839a83 [lld][PECOFF] Add WinLinkDriver and PECOFFTargetInfo.
Add WinLinkDriver and connect it to the existing COFF reader. Remaining
parts are still stubs, so while it can now read a COFF file, it still
cannot link or output PE/COFF files yet.

Reviewers: Bigcheese

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D865

llvm-svn: 182784
2013-05-28 18:13:31 +00:00
Rui Ueyama 4cf437a1e9 [PECOFF] Skip section names in the symbol table because they are not atoms.
llvm-svn: 182721
2013-05-26 23:09:01 +00:00
Rui Ueyama 37645e5953 Remove unreachable statement.
llvm-svn: 182714
2013-05-26 01:25:39 +00:00
Rui Ueyama f52a930cfb Fix indentation.
llvm-svn: 182709
2013-05-25 04:59:32 +00:00
Michael J. Spencer e24b872188 Use new version of countLeadingZeros.
llvm-svn: 182697
2013-05-25 00:25:21 +00:00
Rui Ueyama 25c208c020 [lld][LayoutPass] Add comment on _followOn{Nexts,Roots}.
Reviewers: shankarke

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D847

llvm-svn: 182595
2013-05-23 17:43:39 +00:00
Rui Ueyama 9c4f89ad2d [lld][LayoutPass] Consolidate debug flags, removing "layout" flag.
DEBUG_TYPE is already defined at the beginning of this file. We don't
want to have two different debug flags for a single pass.

Reviewers: shankarke

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D845

llvm-svn: 182543
2013-05-23 01:31:25 +00:00
Rui Ueyama 972b0d3b0c [lld] Fix wrong content permission bit.
Summary: "W" bit value was not consistent in ContentPermissions enum. It should always be 2.

Reviewers: kledzik

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D810

llvm-svn: 182515
2013-05-22 21:13:21 +00:00
Shankar Easwaran d8da989e78 [lld][LayoutPass] An earlier commit moved the functionality so that Atoms would
be laid out by their ordinal overrides first, there was a bug that two atoms may 
get the same override index due to which atoms were not ordered properly. This
commit fixes the problem.

Now the atoms are ordered by 

- Section Position hints
- Atom override (Using layout-after/layout-before/in-group)
- Content Permissions
- Content Type
- File Ordinal

This also fixes the problem of running c++ static executables that 
was broken by an earlier patch.

llvm-svn: 182494
2013-05-22 17:41:04 +00:00
Shankar Easwaran 4df05caadb [lld][ELF] Inline header files into the one file using it
llvm-svn: 182427
2013-05-21 21:47:33 +00:00
Rui Ueyama 0e171fe3c4 [lld] Update a test file for r180209.
This binary file is created from shared.c.

llvm-svn: 182410
2013-05-21 20:05:55 +00:00
Shankar Easwaran 87a594835f [lld][ELF][x86_64,hexagon] Changed dynamic atoms to live in anonymous namespace
so that their names are hidden.

This addresses comments raised by Sean/Rafael.

llvm-svn: 182230
2013-05-20 03:57:01 +00:00
Shankar Easwaran 9af77a2cab [lld][ELF][All Archs] Addend is used by dynamic relocations
only if they are relative. This removes the FIXME when the
relocations are being emitted and checks if the relocation
is relative and only then populates the addend information.

I couldnt add a testcase for this as llvm-readobj lacks     
functionality of printing dynamic relocations.              

When the functionality is added, remove the commented lines
from elf/ifunc.test to test functionality.

llvm-svn: 182077
2013-05-17 05:10:30 +00:00
Shankar Easwaran f9a7933d90 [lld][ELF][X86_64] Reorganize X86_64 Target specific code
This patch splits X86_64Target specific code so that 
the dynamic atoms and the Relocation handlers are in seperate 
files for easier maintenace. The files are sure to grow and this 
makes it easier to work with.

* There is no change in functionality *

llvm-svn: 182076
2013-05-17 04:19:53 +00:00
Rui Ueyama d819aa5c54 [lld] Do not create a temporary pair.
llvm-svn: 182033
2013-05-16 17:58:14 +00:00
Rui Ueyama bd314482e1 [lld] Fix inconsistent style and do cleanup.
llvm-svn: 182031
2013-05-16 17:53:34 +00:00
Rui Ueyama 5f689e24de [lld] Fix compiler warning that shift count is too big on P64.
llvm-svn: 181852
2013-05-14 23:51:50 +00:00
Rui Ueyama fe81cf8f91 [lld] Allow flags other than -std= in CMAKE_CXX_FLAGS. Also simplify the IF conditions.
llvm-svn: 181822
2013-05-14 19:53:41 +00:00
Rui Ueyama 0196d1062f [lld][LayoutPass] Cleanup: replace (*atom).size() with atom->size().
llvm-svn: 181804
2013-05-14 16:53:59 +00:00
Rui Ueyama 5ec6d1a9cd [lld][LayoutPass] Fix a bug that caused buildbot to fail on some platforms.
llvm-svn: 181752
2013-05-14 01:51:56 +00:00
Rui Ueyama ca8ca55b52 [lld][LayoutPass] Split buildFollowOnTable for readability.
Summary:
Split buildFollowOnTable to small functions to improve
code readability and remove code duplication. No change
in functionality.

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D790

llvm-svn: 181749
2013-05-14 00:41:52 +00:00
Rui Ueyama deb979bf7a [lld] Add help text for -flavor option.
llvm-svn: 181655
2013-05-11 01:24:38 +00:00
Rui Ueyama 0227be6b0e [lld] Fix typo in document.
llvm-svn: 181652
2013-05-11 00:26:26 +00:00
Rui Ueyama eaadec3a39 [lld] Document about how to enable debug output.
llvm-svn: 181640
2013-05-10 22:19:28 +00:00
Shankar Easwaran bd525a3f63 [lld][ELF] set ordinals for mergeAtoms and fix testcase
llvm-svn: 181622
2013-05-10 18:52:29 +00:00
Shankar Easwaran 3c5d2c8a24 [lld][LayoutPass] This commit fixes a problem in the
Layoutpass by ordering atoms if they appear in the override
list first and then looking at the way of ordering atoms in
the default way.

The fix also fixes issues with the sizes of the sections,
that appear in the output properly too.

The commit also adds a testcase(orderatoms-by-override.test)
to test it and fixes all the other relevant testcases.

llvm-svn: 181605
2013-05-10 16:44:02 +00:00
Rui Ueyama eb6b6e4857 [lld] Fix broken test. -layout-pass option does not exist.
Also shuffle the atoms so that it can verify the layout pass
actually changed the layout.

llvm-svn: 181573
2013-05-10 00:50:33 +00:00
Rui Ueyama 4689326d4c [lld] Fix wrong comment.
llvm-svn: 181547
2013-05-09 21:14:02 +00:00
Rui Ueyama 90b3b92a8b [lld] Use range based for loop instead of explicit iterators (no functionality change)
llvm-svn: 181503
2013-05-09 04:00:44 +00:00
Rui Ueyama 60f5f30687 [lld] Add comments to InputFiles::searchLibraries() arguments.
llvm-svn: 181492
2013-05-08 23:54:10 +00:00
Rui Ueyama 980e52d7ae [lld][Core] Fix latch synchronization bug.
We need to acquire a lock before signal a condition.
Otherwise threads waiting on a condition variable can
miss a signal.

Consider two threads: Thread A executing dec() and thread
B executing sync(). The initial value of _count is 1. If
these two threads are interleaved in the following order,
thread B misses the signal sent by thread A, because at the
time thread A sends a signal, B is not waiting for it.

  Thread A                 |   Thread B
                           |   std::unique_lock<std::mutex> lock(_condMut);
                           |   while (!(_count == 0)) {
  if (--_count == 0)       |
    _cond_notify_all()     |
                           |     _cond.wait();
                           |   }

Note that "wait(lock, pred)" is equivalent to "while(!pred())
wait(lock)", so I expanded it in the above example.

Reviewers: Bigcheese

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D764

llvm-svn: 181484
2013-05-08 23:29:24 +00:00
Rui Ueyama ec504cfffd [lld] Add "explicit" to constructors where appropriate.
Summary:
Add the explicit keyword to one-parameter
constructors to prevent unintended type conversions.

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D765

llvm-svn: 181483
2013-05-08 23:20:53 +00:00
Nick Kledzik 80d8308b57 Use anonymous namespace for local classes. Patch by Rui Ueyama
llvm-svn: 181473
2013-05-08 21:34:11 +00:00
Shankar Easwaran e796006333 [lld][ELF] fix build failure
llvm-svn: 181325
2013-05-07 15:27:02 +00:00
Shankar Easwaran 790ede43de [lld][ELF] split ELF reader into multiple functions for readability (no change in functionality)
llvm-svn: 181288
2013-05-07 04:58:09 +00:00
Michael J. Spencer 75ed350132 [ELF] Initialize readers and writers on creation.
This makes the target handler a constructor argument because the constructor of
OutputELFWriter relies on it being initialized.

llvm-svn: 181280
2013-05-07 00:28:07 +00:00
Michael J. Spencer b5fb0dee0c [Core] Properly stop the ThreadPoolExecutor and use the ConcRT memory allocator.
llvm-svn: 181279
2013-05-07 00:27:40 +00:00
Shankar Easwaran c8858b3469 [lld]remove lld-core
llvm-svn: 181244
2013-05-06 20:24:39 +00:00
Tim Northover d11e5bc03c [lld][ELF] fix header comment typos
llvm-svn: 181188
2013-05-06 08:31:58 +00:00
Shankar Easwaran 6e1f5b7d1a [lld][ELF] reduce the number of symbols emitted in the symbol table
llvm-svn: 180872
2013-05-01 19:36:38 +00:00
Shankar Easwaran 02078464e1 [lld][ELF] continue on finding a section with no symbols, tests already present
llvm-svn: 180769
2013-04-30 03:14:01 +00:00
Shankar Easwaran cc06891c42 [lld][ELF] (no testable functionality change) resize the number of entries in the string table for static linking
llvm-svn: 180692
2013-04-29 04:10:42 +00:00
Shankar Easwaran d846d9852e [lld][ELF] (no testable functionality change) resize the number of entries in the string table for static linking
llvm-svn: 180691
2013-04-29 04:10:11 +00:00
Shankar Easwaran 45a5f93517 [lld][LayoutPass] initialize the number of entries for the densehash (no functionality change)
llvm-svn: 180690
2013-04-29 03:27:57 +00:00
Michael J. Spencer 9d70cef481 [Core] Allow weak symbols in shared library when linking.
Patch by Rui Ueyama.

llvm-svn: 180209
2013-04-24 19:00:26 +00:00
Andy Gibbs 93383381d7 Distinguish between unsupported and unrecognised flavours.
Suggested by Nick Kledzik in reference to r179590.

llvm-svn: 179617
2013-04-16 19:24:13 +00:00
Andy Gibbs bab932b850 Moved llvm_unreachable out of switch blocks to avoid the "control reaches end of non-void function" warning.
llvm-svn: 179590
2013-04-16 11:52:34 +00:00
Michael J. Spencer 1eb3b89d92 [Core] Add parallel infrastructure to lld.
Uses ConcRT and PPL on Windows.

llvm-svn: 179397
2013-04-12 18:40:39 +00:00
Nico Rieck bdfd4eb223 Replace elf-dump with llvm-readobj in lld tests
llvm-svn: 179364
2013-04-12 04:29:01 +00:00
Shankar Easwaran bba9fe8495 [test] missing underscore while checking for test output
llvm-svn: 179264
2013-04-11 04:20:21 +00:00
Shankar Easwaran 4cb24b38f6 [test] fix failing test, the test was not accounting for - in the path
llvm-svn: 179260
2013-04-11 04:08:11 +00:00
Shankar Easwaran eeee23e60a This adds functionality for undefined atoms from dynamic libraries to be added
to the list of undefined atoms. 

The processing of undefined atoms from dynamic libraries is controlled by
use-shlib-undefines command line option. 

This patch also adds additional command line arguments to allow/disallow
unresolved symbols from shared libraries and mimics GNU ld behavior.

llvm-svn: 179257
2013-04-11 02:56:30 +00:00
Michael J. Spencer d4eb47c110 Add VTune as an optional external dependency and add task tracking.
llvm-svn: 178940
2013-04-06 00:56:40 +00:00
Michael J. Spencer e6d5609de4 Revert "Correctly pass ownership of MemoryBuffers."
llvm-svn: 178918
2013-04-05 22:04:44 +00:00
Michael J. Spencer ce1e53e19c Correctly pass ownership of MemoryBuffers.
llvm-svn: 178914
2013-04-05 21:08:30 +00:00
Michael J. Spencer 096ea03f31 Fix uninitialized variables. Found by ubsan.
llvm-svn: 178913
2013-04-05 21:07:44 +00:00
Shankar Easwaran f4a5e2f439 [ELF][test] add dynamic library search
llvm-svn: 178840
2013-04-05 04:34:57 +00:00
Shankar Easwaran a4323a5cca This fixes a SIGSEGV failure in ReaderArchive while trying to trace what
InputFile is being pulled from the Archive library to resolve a symbol. 

The buffer which was being used was already being handed over to the
MemoryBuffer object and was being accessed after the hand over. 

Moving it before the buffer is handed over.

llvm-svn: 178838
2013-04-05 03:50:15 +00:00
Shankar Easwaran 831b4a0503 [test] remove printing the file to stdout
llvm-svn: 178817
2013-04-04 23:53:46 +00:00
Shankar Easwaran d953d66ee9 [ELF] fix atom order
llvm-svn: 178815
2013-04-04 23:51:36 +00:00
Michael J. Spencer dfe85483d5 [Driver] Fix symlinked universal driver behavior and add a test.
llvm-svn: 178798
2013-04-04 22:04:16 +00:00
Nick Kledzik 563d9dc1b2 temp change to test case to debug buildbot failure
llvm-svn: 178788
2013-04-04 20:34:37 +00:00
Nick Kledzik f4fa8c0a75 fix DEBUG_WITH_TYPE to build without warnings in non-debug builds
llvm-svn: 178787
2013-04-04 20:32:18 +00:00
Michael J. Spencer 3ab4db67f7 Fix MSVC build.
llvm-svn: 178781
2013-04-04 19:45:34 +00:00
Nick Kledzik be7b005d83 fix darwin driver to validate command line options
llvm-svn: 178778
2013-04-04 19:26:14 +00:00
Nick Kledzik 9a632dbe0c fix command line option to use -o
llvm-svn: 178777
2013-04-04 19:17:58 +00:00
Nick Kledzik c314b46e71 This is my Driver refactoring patch.
The major changes are:
1) LinkerOptions has been merged into TargetInfo
2) LinkerInvocation has been merged into Driver
3) Drivers no longer convert arguments into an intermediate (core) argument 
   list, but instead create a TargetInfo object and call setter methods on 
   it. This is only how in-process linking would work. That is, you can 
   programmatically set up a TargetInfo object which controls the linking.
4) Lots of tweaks to test suite to work with driver changes
5) Add the DarwinDriver
6) I heavily doxygen commented TargetInfo.h

Things to do after this patch is committed:
a) Consider renaming TargetInfo, given its new roll. 
b) Consider pulling the list of input files out of TargetInfo. This will 
   enable in-process clients to create one TargetInfo the re-use it with 
   different input file lists.
c) Work out a way for Drivers to format the warnings and error done in 
   core linking.

llvm-svn: 178776
2013-04-04 18:59:24 +00:00
Rafael Espindola 26cf0b5130 Update for API change for handling mips64el.
llvm-svn: 178695
2013-04-03 21:03:19 +00:00
Rafael Espindola 13de1566d0 Update the lld testsuite for the llvm-readobj format change.
llvm-svn: 178693
2013-04-03 20:53:45 +00:00
Shankar Easwaran 34353270a0 [ELF][Hexagon] fix few relocations and add test
llvm-svn: 178495
2013-04-01 20:20:11 +00:00
Shankar Easwaran 1d9e531856 [ELF][Hexagon] Create .got.plt entries with the appropriate alignment
llvm-svn: 178467
2013-04-01 15:14:34 +00:00
Shankar Easwaran cbe06ca340 [ELF] Set the symbol type for undefined atoms properly
llvm-svn: 178466
2013-04-01 15:12:54 +00:00
Shankar Easwaran bb9d4a5ca0 [ELF] Add dynamic hash table and get simple dynamic libraries working with Hexagon
llvm-svn: 178323
2013-03-29 00:53:25 +00:00