Commit Graph

259 Commits

Author SHA1 Message Date
Greg Fitzgerald 77337ef798 Add ARM backend to the autotools build
From: Greg Fitzgerald <garious@gmail.com>
llvm-svn: 226782
2015-01-22 05:12:46 +00:00
Rui Ueyama cf14b63116 [ELF] Do not error on non-existent file in the driver.
This change makes it easy to write unit tests for the GNU driver.
No more "empty group" hack is needed. No change in functionality.

llvm-svn: 226150
2015-01-15 08:49:19 +00:00
Rui Ueyama 883afba228 Remove InputGraph and use std::vector<Node> instead.
In total we have removed more than 1000 lines!

llvm-svn: 226149
2015-01-15 08:46:36 +00:00
Rui Ueyama 61635440a9 Rename InputElement Node.
InputElement was named that because it's an element of an InputGraph.
It's losing the origin because the InputGraph is now being removed.
InputElement's subclass is FileNode, that naming inconsistency needed
to be fixed.

llvm-svn: 226147
2015-01-15 08:31:46 +00:00
Rui Ueyama 7c4ba12769 Remove FileNode::getPath().
Previously both FileNode and File keep filename. This patch removed
that redundancy.

llvm-svn: 226143
2015-01-15 07:38:32 +00:00
Rui Ueyama cdb1071be5 Remove InputGraph::size().
llvm-svn: 226140
2015-01-15 07:20:39 +00:00
Rui Ueyama 5a831ee5fd [PECOFF] Remove an InputElement placeholder for the entry name.
llvm-svn: 226133
2015-01-15 06:56:26 +00:00
Rui Ueyama 80c04431ca Re-commit r225766, r225767, r225769, r225814, r225816, r225829, and r225832.
These changes depended on r225674 and had been rolled back in r225859.
Because r225674 has been re-submitted, it's safe to re-submit them.

llvm-svn: 226132
2015-01-15 06:49:21 +00:00
Rui Ueyama df230b21e3 Re-commit r225674: Convert other drivers to use WrapperNode.
The original commit had an issue with Mac OS dylib files. It didn't
handle fat binary dylib files correctly. This patch includes a fix.
A test for that case has already been committed in r225764.

llvm-svn: 226123
2015-01-15 04:34:31 +00:00
Rui Ueyama cfb2534ef8 Revert "Convert other drivers to use WrapperNode" and subsequent commits.
r225764 broke a basic functionality on Mac OS. This change reverts
r225764, r225766, r225767, r225769, r225814, r225816, r225829, and r225832.

llvm-svn: 225859
2015-01-14 00:21:34 +00:00
Rui Ueyama b34838424a Remove InputGraph::getNextFile().
getNextFile used to have a complex logic to determine which file
should be processed by the Resolver on next iteration.
Now, it is just a sequential accessor to the internal array and
provides no sensible feature.

This patch also removes InputGraph::getGroupSize and InputGraph::
skipGroup to simplify the code.

llvm-svn: 225832
2015-01-13 21:27:12 +00:00
Rui Ueyama d5bb5c2bfe Remove dead code.
Now every InputElement has exactly one File in it, so "expand"
method is now no-op.

llvm-svn: 225769
2015-01-13 05:59:17 +00:00
Rui Ueyama 64e3dedf3b Remove InputGraph::registerObserver.
PECOFF was the only user of the API, and the reason why we created
the API is because, although the driver creates a list of input files,
it has no knowledge on what files are being created. It was because
everything was hidden behind the InputGraph abstraction.

Now the driver knows what that's doing. We no longer need this
indirection to get the file list being processed.

llvm-svn: 225767
2015-01-13 05:24:53 +00:00
Rui Ueyama e8ecb2b144 Convert other drivers to use WrapperNode.
llvm-svn: 225764
2015-01-13 04:33:07 +00:00
Rui Ueyama e9b455184f Simplify InputGraph API.
These member functions returns either no_more_files error or a File object.
We could simply return a nullptr instead of a no_more_files.
This function will be removed soon as a part of InputGraph cleanup.
I had to do that step by step.

llvm-svn: 224208
2014-12-14 02:04:01 +00:00
Rui Ueyama 83220a00ea Remove dead code.
llvm-svn: 224207
2014-12-14 02:03:54 +00:00
Simon Atanasyan 04da06ccee [ELF] Make -init/-fini options compatible with the gnu linker
The LLD linker searches initializer and finalizer function names
and emits DT_INIT/DT_FINI dynamic table tags to point to these symbols.
The -init/-fini command line options override initializer ("_init") and
finalizer ("_fini") function names used by default.

Now the -init/-fini options do not affect .init_array/.fini_array
sections. The corresponding code has been removed.

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

llvm-svn: 223917
2014-12-10 05:38:46 +00:00
Rui Ueyama 00eb257f2e Re-commit r223330: Rewrite InputGraph's Group
llvm-svn: 223867
2014-12-10 00:33:00 +00:00
Rui Ueyama 5ae2050420 Revert "Rewrite InputGraph's Group"
This reverts commit r223330 because it broke Darwin and ELF
linkers in a way that we couldn't have caught with the existing
test cases.

llvm-svn: 223373
2014-12-04 18:29:03 +00:00
Rui Ueyama 60df72ff61 Rewrite InputGraph's Group
The aim of this patch is to reduce the excessive abstraction from
the InputGraph. We found that even a simple thing, such as sorting
input files (Mach-O) or adding a new file to the input file list
(PE/COFF), is nearly impossible with the InputGraph abstraction,
because it hides too much information behind it. As a result,
we invented complex interactions between components (e.g.
notifyProgress() mechanism) and tricky code to work around that
limitation. There were many occasions that we needed to write
awkward code.

This patch is a first step to make it cleaner. As a first step,
this removes Group class from the InputGraph. The grouping feature
is now directly handled by the Resolver. notifyProgress is removed
since we no longer need that. I could have cleaned it up even more,
but in order to keep the patch minimum, I focused on Group.

SimpleFileNode class, a container of File objects, is now limited
to have only one File. We shold have done this earlier.
We used to allow putting multiple File objects to FileNode.
Although SimpleFileNode usually has only one file, the Driver class
actually used that capability. I modified the Driver class a bit,
so that one FileNode is created for each input File.

We should now probably remove SimpleFileNode and directly store
File objects to the InputGraph in some way, because a container
that can contain only one object is useless. This is a TODO.

Mach-O input files are now sorted before they are passe to the
Resolver. DarwinInputGraph class is no longer needed, so removed.

PECOFF still has hacky code to add a new file to the input file list.
This will be cleaned up in another patch.

llvm-svn: 223330
2014-12-04 01:09:06 +00:00
Rui Ueyama 24a7f7eed8 [PECOFF] Ignore /maxilkfile option.
.ilk file is a file for incremental linking. We don't create nor use
that file.

/MAXILKFILE is an undocumented option to specify the maximum size
of the .ilk file, IIUC. We should just ignore the option.

llvm-svn: 222777
2014-11-25 19:51:28 +00:00
Rui Ueyama 0d9a181d9d [PECOFF] Create an empty PDB file if debug option is enabled.
There are many build files in the wild that depend on the fact that
link.exe produces a PDB file if /DEBUG option is given. They fail
if the file is not created.

This patch is to make LLD create an empty (dummy) file to satisfy
such build targets. This doesn't do anything other than "touching"
the file.

If a target depends on the content of the PDB file, this workaround
is no help, of course. Otherwise this patch should help build some
stuff.

llvm-svn: 222773
2014-11-25 19:01:01 +00:00
Rui Ueyama 4a259cf4a5 [PECOFF] Enable dead-stripping even if /debug option is given.
/debug makes MSVC link.exe to not remove unused sections from
the resulting executable. We did the same thing before. However,
I realized that the removal of associative section depends on
the dead-stripping pass in LLD, so we cannot disable that. Or
LLD may produce slightly broken executables that have too much
data in it (which could result in nasty subtle bugs).

This patch is a temporary measure to create correct executable.
Currently /debug does not have any real effect for LLD anyway.

I'll improve associative section handling in another patch, so that
they are removed from output without depending on the dead-stripping
pass.

llvm-svn: 222483
2014-11-20 23:59:40 +00:00
Shankar Easwaran 48b9fc7981 Revert "Add support library."
This reverts commit r221583.

llvm-svn: 221649
2014-11-11 00:40:36 +00:00
Shankar Easwaran c937b4923e Add support library.
The parsing routines in the linker script to parse strings encoded in various
formats(hexadecimal, octal, decimal, etc), is needed by the GNU driver too. This
library provides helper functions for all flavors and flavors to add helper
functions which other flavors may make use of.

llvm-svn: 221583
2014-11-10 14:54:34 +00:00
Rui Ueyama a81cb0594b Fix Mach-O unit tests breakage on Windows
Mach-O normalized file reader assumes that the entire file is aligned
to a large boundary. If the in-memory file is not aligned properly, it will
abort with an assertion failure in read32/read64. This patch forces the
in-memory file for the unit test to be aligned at 64-byte boundary.

I found these tests are failing on Windows, but theoretically they could
fail on other platform.

llvm-svn: 221508
2014-11-07 02:54:52 +00:00
Eric Christopher 6d10178ba3 Use LLVMLIBS here since these are produced by the
llvm build and not supposed to be resident on
the system.

llvm-svn: 221314
2014-11-04 23:27:52 +00:00
Rui Ueyama 2f28686ca0 [PECOFF] Fix /nodefaultlib option.
/nodefaultlib argument is a path name, so that needs to be compared
case-insensitive way. Also the ".lib" extension should be ignored.

llvm-svn: 220508
2014-10-23 20:42:07 +00:00
Shankar Easwaran 2b67fca033 Sort include files according to convention.
llvm-svn: 220131
2014-10-18 05:33:55 +00:00
Rui Ueyama ecbb309e5e [PECOFF] Remember DLL names given with /delayload option.
This is a step toward full support of /delayload.

llvm-svn: 219344
2014-10-08 21:38:10 +00:00
Shankar Easwaran c3550f9231 Add support to print version.
Summary: Add support in the universal driver to print the lld version and the
repository version.

Test Plan: A driver test is added

Reviewers: kledzik, ruiu

Reviewed By: ruiu

Subscribers: llvm-commits

Projects: #lld

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

llvm-svn: 219277
2014-10-08 03:47:51 +00:00
Nick Kledzik a4ff361c6f update library dependency
llvm-svn: 218646
2014-09-29 23:52:50 +00:00
Rui Ueyama 251d9a34e2 [PECOFF] Simplify /machine option handling
/machine:ebc was previously recognized but rejected. Unknown architecture
names were handled differently but eventually rejected too. We don't need
to distinguish them.

llvm-svn: 218344
2014-09-24 00:21:45 +00:00
Rui Ueyama 75c0127bb3 [PECOFF] Change export table type.
This patch changes the type of export table set from std::set to
std::vector. The new code is slightly inefficient, but because
export table elements are actually mutable, std::vector is better
here. No functionality change.

llvm-svn: 218343
2014-09-24 00:09:36 +00:00
Rui Ueyama 7ea46bab26 [PECOFF] Fix duplicate /export options
If two or more /export options are given for the same symbol, we should
always print a warning message and use the first one regardless of other
parameters.
Previously there was a case that the first parameter is not used.

llvm-svn: 218342
2014-09-23 23:49:41 +00:00
Saleem Abdulrasool c2c2937d55 Driver: accept /machine:arm for Windows linker
Accept /machine:arm as an argument.  This is changed to support ARM NT.
Although there is no way to differentiate between ARM (Windows CE) and ARM NT
(Windows on ARM), since LLVM currently only supports Windows on ARM, simply take
/machine:arm to mean Windows on ARM.

llvm-svn: 218105
2014-09-19 06:09:30 +00:00
Nick Kledzik 635f9c7158 [mach-o] Let darwin driver infer arch from .o files if -arch not used.
Mach-O has a "fat" (or "universal") variant where the same contents built for
different architectures are concatenated into one file with a table-of-contents
header at the start.  But this leaves a dilemma for the linker - which
architecture to use.

Normally, the linker command line -arch is used to force which slice of any fat
files are used.  The clang compiler always passes -arch to the linker when
invoking it.  But some Makefiles invoke the linker directly and don’t specify
the -arch option.  For those cases, the linker scans all input files in command
line order and finds the first non-fat object file.  Whatever architecture it
is becomes the architecture for the link.

llvm-svn: 217189
2014-09-04 20:08:30 +00:00
Nick Kledzik 54e0614efd Fix unit test now that 'ld' is host specific
llvm-svn: 217114
2014-09-04 00:16:04 +00:00
Nick Kledzik 77afc71426 [mach-o] Fix initial live atoms with -dead_strip
When -dead_strip is used with -exported_symbols_list the initial set of
live atoms are those in the export list.

llvm-svn: 216213
2014-08-21 20:25:50 +00:00
Chad Rosier 69e2881070 [AArch64] Initial ELF/AArch64 Support
This patch adds the initial ELF/AArch64 support to lld. Only a basic "Hello
World" app has been successfully tested for both dynamic and static compiling.

Differential Revision: http://reviews.llvm.org/D4778
Patch by Daniel Stewart <stewartd@codeaurora.org>!

llvm-svn: 215544
2014-08-13 13:16:38 +00:00
Rui Ueyama bff29b78b5 [PECOFF] Fix /profile option.
/profile implies /fixed:no -- so we had to *enable* base
relocations rather than disabling it.

llvm-svn: 215389
2014-08-11 21:31:07 +00:00
Rui Ueyama 55a6e762ee [PECOFF] Add /profile command line option.
llvm-svn: 213984
2014-07-25 22:28:49 +00:00
Rui Ueyama 7c60a98f16 [PECOFF] Add the entry point file at the right place.
The entry point file needs to be processed after all other
object files and before all .lib files. It was processed
after .lib files. That caused an issue that the entry point
function was not resolved from the standard library files.

llvm-svn: 213804
2014-07-23 21:41:20 +00:00
Rui Ueyama a27bb08e73 [PECOFF] Fix entry point functions selection
On Windows there are four "main" functions -- main, wmain, WinMain,
or wWinMain. Their parameter types are diffferent. The standard
library provides four different entry functions (i.e.
{w,}{WinMain,main}CRTStartup) for them. You need to use the right
entry routine for your "main" function.

If you give an /entry option, the specified name is used
unconditionally.

Otherwise, the linker needs to select the right one based on
user-supplied entry point function. This can be done after the
linker reads all the input files.

This patch moves the code to determine the entry point function
from the driver to a virtual input file. It also implements the
correct logic for the entry point function selection.

llvm-svn: 213713
2014-07-23 00:57:57 +00:00
Rui Ueyama 31fd9d09b2 [PECOFF] Invoke cvtres.exe in the driver.
Previously we invoked cvtres.exe for each compiled Windows
resource file. The generated files were then concatenated
and embedded to the executable.

That was not the correct way to merge compiled Windows
resource files. If you just concatenate generated files,
only the first file would be recognized and the rest would
be ignored as trailing garbage.

The right way to merge them is to call cvtres.exe with
multiple input files. In this patch we do that in the
Windows driver.

llvm-svn: 212763
2014-07-10 20:53:37 +00:00
Rafael Espindola c2199ecf1e Update for llvm api change.
llvm-svn: 212407
2014-07-06 17:43:22 +00:00
Iain Sandoe 9734a53cf0 Fix build of DriverTests for config & make.
This adjusts the USED library list following recent changes in the object
file heirarchy.

llvm-svn: 212400
2014-07-06 11:28:56 +00:00
Tim Northover d30a1f2cb2 MachO: rename _outputFileType to avoid shadowing parent field.
llvm-svn: 211367
2014-06-20 15:59:00 +00:00
Rafael Espindola 6400ed4e75 Refer to error_code with an std prefix.
llvm-svn: 210820
2014-06-12 20:42:12 +00:00
Rafael Espindola 54427ccef3 include system_error directly.
llvm-svn: 210801
2014-06-12 17:15:58 +00:00