Commit Graph

289 Commits

Author SHA1 Message Date
Nico Weber d9a21bf93a Revert r234649 "PECOFF: Use C++11 braced init list to make Version objects."
This doesn't compile with MSVC 2013:
include\lld/ReaderWriter/PECOFFLinkingContext.h(356) : error C2797:
    'lld::PECOFFLinkingContext::_imageVersion': list initialization
    inside member initializer list or non-static data member initializer
    is not implemented
include\lld/ReaderWriter/PECOFFLinkingContext.h(357) : error C2797:
    'lld::PECOFFLinkingContext::_imageVersion': list initialization
    inside member initializer list or non-static data member initializer
    is not implemented

llvm-svn: 234676
2015-04-11 01:32:52 +00:00
Rui Ueyama 4d57247236 PECOFF: Use C++11 braced init list to make Version objects.
llvm-svn: 234649
2015-04-10 21:57:06 +00:00
Rui Ueyama 9842a965f6 Remove unused typedefs.
llvm-svn: 234415
2015-04-08 16:59:03 +00:00
Rui Ueyama 24f2d2a9d5 Remove Makefiles.
Most developers prefer to not have them, and we agreed to
remove them from LLD.
http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-March/083368.html

llvm-svn: 233313
2015-03-26 20:09:47 +00:00
Rui Ueyama 629f964d50 Use arithmetic type to represent alignments (not in log2) everywhere.
This is the final step of conversion. Now log2 numbers are removed
from everywhere!

llvm-svn: 233246
2015-03-26 02:20:25 +00:00
Rui Ueyama f217ef0d75 Use alignment values everywhere instead of log2.
This patch defines implicit conversion between integers and PowerOf2
instances, so uses of the classes is now implicit and look like
regular integers. Now we are ready to remove the scaffolding.

llvm-svn: 233245
2015-03-26 02:03:44 +00:00
Rui Ueyama f006f4d62c Define an implicit constructor which takes actual alignment value to PowerOf2.
The new constructor's type is the same, but this one takes not a log2
value but an alignment value itself, so the meaning is totally differnet.

llvm-svn: 233244
2015-03-26 01:44:01 +00:00
Rui Ueyama 48865ca64d Make PowerOf2's constructor private.
Ban conversion from integers to PowerOf2 even if explicit
to make all places we create PowerOf2 instances visible.

llvm-svn: 233243
2015-03-26 01:29:06 +00:00
Rui Ueyama c3d18f5120 Remove implicit constructor and operator int from PowerOf2.
This patch is to make instantiation and conversion to an integer explicit,
so that we can mechanically replace all occurrences of the class with
integer in the next step.

Now get() returns an alignment value rather than its log2 value.

llvm-svn: 233242
2015-03-26 01:12:32 +00:00
Rafael Auler 9a7e211e8f [LinkerScript] Implement semantics for simple sections mappings
This commit implements the behaviour of the SECTIONS linker script directive,
used to not only define a custom mapping between input and output sections, but
also order input sections in the output file. To do this, we modify
DefaultLayout with hooks at important places that allow us to re-order input
sections according to a custom order. We also add a hook in SegmentChunk to
allow us to calculate linker script expressions while assigning virtual
addresses to the input sections that live in a segment.

Not all SECTIONS constructs are currently supported, but only the ones that do
not use special sort orders. It adds two LIT test as practical examples of
which sections directives are currently supported.

In terms of high-level changes, it creates a new class "script::Sema" that owns
all linker script ASTs and the logic for linker script semantics as well.
ELFLinkingContext owns a single copy of Sema, which will be used throughout
the object file writing process (to layout sections as proposed by the linker
script).

Other high-level change is that the writer no longer uses a "const" copy of
the linking context. This happens because linker script expressions must be
calculated *while* calculating final virtual addresses, which is a very late
step in object file writing. While calculating these expressions, we need to
update the linker script symbol table (inside the semantics object), and, thus,
we are "modifying our context" as we prepare to write the file.

http://reviews.llvm.org/D8157

llvm-svn: 232402
2015-03-16 19:55:15 +00:00
Iain Sandoe 832472a2ad Fix configure & make build by adding support for the ExampleSubTarget.
llvm-svn: 232030
2015-03-12 11:47:51 +00:00
Rafael Auler ad11d4c196 [LinkerScript] Implement linker script expression evaluation
The expression evaluation is needed when interpreting linker scripts, in order
to calculate the value for new symbols or to determine a new position to load
sections in memory. This commit extends Expression nodes from the linker script
AST with evaluation functions, and also contains a unit test.

http://reviews.llvm.org/D8156

llvm-svn: 231707
2015-03-09 21:43:35 +00:00
Rui Ueyama 53a93c6c39 PECOFF: allow more than one /alternatename for the same symbol.
Previously we have a string -> string map to keep the weak alias
symbol mapping. Naturally we can't define more than one weak alias
with that data structure.

This patch is to allow multiple aliases for the same symbol by
changing the map type to string -> set of string map.

llvm-svn: 230702
2015-02-26 23:43:04 +00:00
Rui Ueyama 2c64aef35f Remove YAML/Native round-trip passes.
The round-trip passes were introduced in r193300. The intention of
the change was to make sure that LLD is capable of reading end
writing such file formats.

But that turned out to be yet another over-designed stuff that had
been slowing down everyday development.

The passes ran after the core linker and before the writer. If you
had an additional piece of information that needs to be passed from
front-end to the writer, you had to invent a way to save the data to
YAML/Native. These passes forced us to do that even if that data
was not needed to be represented neither in an object file nor in
an executable/DSO. It doesn't make sense. We don't need these passes.

http://reviews.llvm.org/D7480

llvm-svn: 230069
2015-02-20 22:10:28 +00:00
Aaron Ballman d816003d2b MSVC 2013 appears to be able to compile make_ptr_range without issue, so removing that guard in the unit test.
llvm-svn: 229410
2015-02-16 18:00:11 +00:00
Rui Ueyama ea6c8e9c1f Unittest: Do s/_context/_ctx/g.
llvm-svn: 228750
2015-02-10 21:28:52 +00:00
Rui Ueyama 2050b61451 GNU: Add --no-export-dynamic command line option.
llvm-svn: 228749
2015-02-10 21:27:31 +00:00
Rui Ueyama 4c30cb3d2f Use override rather than virtual.
llvm-svn: 228723
2015-02-10 18:59:37 +00:00
Rui Ueyama 375c5e2353 GNU: Use StringRef::empty instead of a boolean flag.
This local variable name did not follow the style guide,
and it is not actually needed.

llvm-svn: 228722
2015-02-10 18:55:39 +00:00
Shankar Easwaran 2ba4f5d9e3 [Cleanup] Remove member functions added to support nostdlib
No change in functionality.

llvm-svn: 228379
2015-02-06 05:01:38 +00:00
Shankar Easwaran e315edd747 [ELF] Fix -nostdlib option.
Only search library directories explicitly specified
on the command line. Library directories specified in linker
scripts (including linker scripts specified on the command
line) are ignored.

llvm-svn: 228375
2015-02-06 04:15:00 +00:00
Eric Christopher 8e4f68b141 The PPC lld backend has been removed, don't require it here.
llvm-svn: 228251
2015-02-05 01:10:10 +00:00
Rui Ueyama 2a96704b33 ELF: Support INPUT linker script directive
INPUT directive is a variant of GROUP in the sense that that specifies
a list of input files. The only difference is whether the entire file
list is wrapped with a --start-group/--end-group or not.

http://reviews.llvm.org/D7390

llvm-svn: 228060
2015-02-03 23:00:19 +00:00
Rui Ueyama a6d38a326a ELF: Improve linker script unit tests.
This patch is to enable to write unit tests for linker script with
less boilerplate code.

llvm-svn: 227902
2015-02-03 00:42:36 +00:00
Davide Italiano 104949df73 [ELF] Implement action for OUTPUT linker script command
Reviewed by:	ruiu, shankarke

llvm-svn: 227787
2015-02-02 06:28:12 +00:00
Davide Italiano 1ecdf4ad30 [ELF] Implement semantic action for ENTRY linker script command.
Reviewed by:	shankarke, ruiu

llvm-svn: 227708
2015-02-01 03:27:25 +00:00
Rafael Auler 8251d741f4 Implement semantic action for SEARCH_DIR linker script command
This is needed, among others by the FreeBSD kernel linker script.

Patch by Davide Italiano!

Reviewers: ruiu, rafaelauler

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

llvm-svn: 227694
2015-01-31 22:42:19 +00:00
Rui Ueyama 48eec8a90d ELF: add a unit test for --as-needed.
llvm-svn: 227367
2015-01-28 21:01:24 +00:00
Rui Ueyama 0b55151d3e Add a unit test for LinkerScript.
llvm-svn: 227341
2015-01-28 18:38:50 +00:00
Greg Fitzgerald 0dc86722f5 Fix shared library build
* Removed cyclic dependency between lldPECOFF and lldDriver
* Added missing dependencies in unit tests

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

llvm-svn: 227134
2015-01-26 20:46:47 +00:00
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