Commit Graph

2747 Commits

Author SHA1 Message Date
Simon Atanasyan 3c1818c8c0 [Mips] clang-format the code
No functional changes.

llvm-svn: 232364
2015-03-16 09:14:47 +00:00
Simon Atanasyan a1abb2e2c7 [Mips] Do not check the relocation type twice
No functional changes.

llvm-svn: 232363
2015-03-16 09:14:40 +00:00
Simon Atanasyan 622a4bc83b [Mips] Add `const` qualifier to some member functions
No functional changes.

llvm-svn: 232362
2015-03-16 09:14:34 +00:00
Simon Atanasyan 44e9b094e0 [Mips] Implement R_MIPS_TLS_xxx relocation handling in case of N64 ABI
llvm-svn: 232361
2015-03-16 09:14:28 +00:00
Simon Atanasyan 256407d9e2 [Mips] Implement R_MIPS_GOT_DISP/PAGE/OFST relocations handling
llvm-svn: 232360
2015-03-16 09:14:17 +00:00
Simon Atanasyan 08b19d67fa [Mips] Group some cases in the switch statement
No functional changes.

llvm-svn: 232359
2015-03-16 09:14:06 +00:00
Shankar Easwaran 9fdb81d09b [ELF][ARM] Make gotSymbol a member.
The gotSymbol need not be a global static variable. Apart from this reason, This
variable was creating an issue with self hosting lld, as there seems to be an
issue running global initializers, when initializing the guard for this static
variable.

Program received signal SIGTRAP, Trace/breakpoint trap.

llvm-svn: 232341
2015-03-16 00:54:03 +00:00
Davide Italiano de42c18889 Use setVisibility() rather than assigning the value directly.
We don't want to risk to override wrong st_other bits, and when
we need to zero, we can do that explictly.

llvm-svn: 232282
2015-03-14 21:57:15 +00:00
Shankar Easwaran 5d34ad79b4 Revert "[ELF] Change few static functions."
This reverts commit r232253.

Fix comments from dblaikie. Since these functions dont access member state, its ok to be static.

llvm-svn: 232271
2015-03-14 19:41:24 +00:00
Denis Protivensky cd61715564 [ELF] Ability to resolve undefined symbols lazily
Handle resolution of symbols coming from linked object files lazily.
Add implementation of handling _GLOBAL_OFFSET_TABLE_ and __exidx_start/_end symbols for ARM platform.

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

llvm-svn: 232261
2015-03-14 10:34:43 +00:00
Shankar Easwaran 6d812fa9ca [ELF] Change few static functions.
Functions hasOutputSegment/maybeGetSOName doesnot need not be static.

llvm-svn: 232253
2015-03-14 05:27:01 +00:00
Shankar Easwaran 48578e7124 [ELF] Rename .got.dyn to .got
Gnu doesnot creates only a .got section.

llvm-svn: 232252
2015-03-14 05:26:58 +00:00
Shankar Easwaran c1e146e024 [ELF] Fix DenseMapInfo for StringRef
llvm-svn: 232251
2015-03-14 05:26:55 +00:00
Shankar Easwaran 9f9f2ddb86 [ELF] Remove ambiguity
Fix ambiguous finalize function.

llvm-svn: 232250
2015-03-14 05:26:53 +00:00
Shankar Easwaran 729a79a1c4 [ELF] Simplify appending chunks to segments.
The Segment Chunk had two functions one to append a section and one to append a
chunk. A section is a subclass of a chunk and clearly this can be merged into
one single function.

llvm-svn: 232249
2015-03-14 05:26:50 +00:00
Rui Ueyama 65c1704604 Windows: Include <eh.h> instead of declarating __uncaught_exception.
llvm-svn: 232204
2015-03-13 19:52:39 +00:00
Meador Inge 84f613532f LinkerScript: Add -T <scriptfile> option
GNU LD has an option named -T/--script which allows a user to specify
a linker script to be used [1].  LLD already accepts linker scripts
without this option, but the option is widely used.  Therefore it is
best to support it in LLD as well.

[1] https://sourceware.org/binutils/docs/ld/Options.html#Options

llvm-svn: 232183
2015-03-13 18:15:01 +00:00
Meador Inge 28dac858cd LinkerScript: Add evaluation of the EXTERN command
This patch implements evaluation of the GNU ld EXTERN command.

llvm-svn: 232111
2015-03-12 21:55:55 +00:00
Meador Inge 748a71b8de LinkerScript: Add parsing of the EXTERN command
This patch implements parsing of the GNU ld EXTERN command [1].
Evaluation will be added at a later point in time.

[1] https://sourceware.org/binutils/docs/ld/Miscellaneous-Commands.html#Miscellaneous-Commands

llvm-svn: 232110
2015-03-12 21:55:50 +00:00
David Blaikie f1f52512ea Make the atom_iterator copy assignable
This makes it a bit more like a 'real' iterator though I still haven't
gone through to make sure it meets the full requirements. Copy
assignability seems to be required by MSVC's std::find_if, which is its
right.

llvm-svn: 232097
2015-03-12 20:18:10 +00:00
Renato Golin 7f29cf5770 Update copyright year to 2015.
llvm-svn: 232096
2015-03-12 20:14:35 +00:00
David Blaikie 72da9ae924 Rephrase find loop to use std::find_if
Avoids the need for an assert-only variable, among other benefits.

llvm-svn: 232088
2015-03-12 19:46:21 +00:00
Simon Atanasyan 9a0263aad7 [Mips] Make `readAddend` a virtual member function to escape explicit
template class instantiation

No functional changes.

llvm-svn: 232081
2015-03-12 18:53:06 +00:00
Chris Bieneman d24e65895d Fixing CMake developer warning.
LLDUnitTests target doesn't exist unless LLVM_INCLUDE_TESTS is On.

llvm-svn: 232058
2015-03-12 16:49:52 +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
Justin Bogner 14d34ef050 Avoid an unused variable warning when assertions are off
Patch by Mike Edwards. Thanks!

llvm-svn: 232015
2015-03-12 06:50:54 +00:00
Chandler Carruth cd632dc486 Don't rely on the elf test suites inputs when testing the driver. We
already have a perfectly cromulent test archive in the driver inputs.

llvm-svn: 231976
2015-03-11 22:12:40 +00:00
Chandler Carruth 5ad16c2ad0 Move the 'linker-script-test' binary to the tools directory.
The canonical LLVM directory arrangement places binaries in the 'utils/'
tree when they are used as part of building the project. For example,
the tblgen binaries are built out of 'utils/' trees.

Tools which are not used by any other part of the build, including
testing utilities, are just in the 'tools' directory. For example, in
Clang we have 'c-index-test' which is exactly the same kind of thing as
'linker-script-test'.

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

llvm-svn: 231973
2015-03-11 22:05:49 +00:00
Chandler Carruth c9cdc502f3 Fix a comparison function to actually be a SWO so that it conforms to
the spec required by std::sort and friends.

Ordering things this way also dramatically simplifies the code as
short-circuit ensures we can skip all of the negative tests.

I've left one FIXME where we're establishing a fairly arbitrary
ordering. Previously, the function compared all types as equal except
for the ones it explicitly handled, but it didn't delegate correctly to
the atomflags when doing so, and so it would fail to be a SWO. The two
possible fixes are to stop comparing the atom flags entirely, or to
establish some arbitrary ordering of the types.

Since it was pure luck which ordering of unequal types we ended up with
previously (the caller was std::sort, not std::stable_sort) I chose to
make the ordering explicit and guaranteed. This seems like the best
conservative approach as I suspect we would want to switch to
stable_sort otherwise in order to have deterministic output.

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

llvm-svn: 231968
2015-03-11 21:34:33 +00:00
Meador Inge 2ce1ea86d0 LinkerScript: Add parsing of the MEMORY command
This patch implements parsing of the GNU ld MEMORY command [1].
The command and the memory block definitions are parsed as
specified (including the slightly strange "o" and "l" keywords).
Evaluation will be added at a later point in time.

[1] https://sourceware.org/binutils/docs-2.25/ld/MEMORY.html

llvm-svn: 231928
2015-03-11 15:34:44 +00:00
Davide Italiano 243e03d819 Garbage collect an unused class in Atoms.h
This will be replaced by a more generic class to handle
all the default symbols in an executable, e.g. __init_array.

Differential Revision:	 http://reviews.llvm.org/D8234
Reviewed by:	shankare

llvm-svn: 231906
2015-03-11 05:31:07 +00:00
Chandler Carruth 96f02da75a The LLD tests require 'llvm-nm' to run as well, ensure that this is
built before running the test suite.

llvm-svn: 231770
2015-03-10 08:08:58 +00:00
Chandler Carruth 8300c76b15 Don't write output to 'a.out', write it to a temporary file. This fixes
the test when run frem a read-only checkout of the source tree.

llvm-svn: 231769
2015-03-10 08:06:49 +00:00
Chandler Carruth 1bdbf48fff Fix the local variable naming I used in r231765 to follow the LLD coding
conventions. Sorry for missing this before I committed the patch!

llvm-svn: 231766
2015-03-10 07:54:34 +00:00
Chandler Carruth b952e2287b Fix a bug where the code would use subscript a std::vector with the size
of the vector. For a vector 'v', '&v[v.size()]' isn't a valid way to
compute a pointer one-past-the-end of the vector. Instead, write the
loop in terms of iterators and save the beginning iterator. Once we have
that we can compute the beginning pointer from the beginning iterator,
and compute the distance which we should increment the beginning pointer
by subtracting the iterators.

What might be simpler would be to convert the function accepting a raw
pointer for begin and end to accept iterators or a range or some other
construct, but I wanted to keep this to a minimal bug-fix change.

This fixes a crash on any debug STL implementation which checks for
indexing out of bounds.

llvm-svn: 231765
2015-03-10 07:53:02 +00:00
Rui Ueyama 81ad639ed3 Use template aliases.
We dropped Visual Studio 2012 support, so we can use template aliases.

llvm-svn: 231756
2015-03-10 05:14:24 +00:00
Rui Ueyama 4a8821d48d Add SimpleAbsoluteAtom which is analogous to other Simple* atoms.
llvm-svn: 231718
2015-03-09 22:34:59 +00:00
Rui Ueyama bf3ac0b878 Remove COFFReference and use SimpleReference instead.
SimpleReference, which is defined in Core, provides the same functionality
as COFFReference does, so we don't need a custom class.

llvm-svn: 231715
2015-03-09 22:18: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 6a3167d35a Remove dead code.
llvm-svn: 231688
2015-03-09 18:59:55 +00:00
Simon Atanasyan b9a1443576 [Mips] Remove unused include
No functional changes.

llvm-svn: 231646
2015-03-09 10:54:11 +00:00
Simon Atanasyan 01396035a2 [Mips] Remove redundant namespace qualifiers
No functional changes.

llvm-svn: 231645
2015-03-09 10:54:05 +00:00
Simon Atanasyan 45354087b1 [Mips] Rename local variables
No functional changes.

llvm-svn: 231644
2015-03-09 10:53:58 +00:00
Simon Atanasyan d3388cc9b6 [Mips] Implement R_MIPS_SUB relocation handling
llvm-svn: 231643
2015-03-09 10:53:50 +00:00
Simon Atanasyan 1397f520d4 [Mips] Implement R_MIPS_64 relocation handling
llvm-svn: 231642
2015-03-09 10:53:41 +00:00
Simon Atanasyan cc0ed289b4 [Mips] Refactoring of relocation handling functions
1. Move relocation addendum reading code to the MipsRelocationHandler
class to reduce code duplication.
2. Factor out the relocations calculation code into the separate
function to be ready to handle MIPS N64 ABI relocation chains.

No functional changes.

llvm-svn: 231641
2015-03-09 10:53:32 +00:00
Simon Atanasyan e604e8f970 [Mips] Show error message and stop linking in case of cross mode jump errors
llvm-svn: 231640
2015-03-09 10:53:24 +00:00
Simon Atanasyan 9af798f5e4 [Mips] Fix incorrect handling of cross mode jumps
We should not take in account a type of "source" symbol. Cross mode jump
adjustment is requred when target symbol and relocation belong to
different (regular/microMIPS) instruction sets.

llvm-svn: 231639
2015-03-09 10:53:15 +00:00
Davide Italiano 7b68b90c15 [MachO] Use setter for globalsAreDeadStripRoots. NFC intended.
llvm-svn: 231629
2015-03-09 06:05:42 +00:00
Rui Ueyama 5768e9fde9 Test: Use layout-after instead of layout-before.
Update the tests so that they use layout-after instead of layout-before.
In all other places, we use layout-afters as primary edges.

llvm-svn: 231627
2015-03-09 04:00:29 +00:00