Commit Graph

3011 Commits

Author SHA1 Message Date
Denis Protivensky fb8afb8f81 [ARM] Implement PLT for dynamic pass
This includes implementation of PLT0 entry.

For testing, libfn.so binary is added since
there's no way to link shared objects with lld yet.

llvm-svn: 234588
2015-04-10 11:41:27 +00:00
Denis Protivensky e9c336aeb5 [ARM] Rework GOT/PLT entry generation
Use consistent naming: commonly used generator methods
don't have 'Entry' suffices.

llvm-svn: 234585
2015-04-10 11:05:11 +00:00
Denis Protivensky 8ad3627e19 [ARM] Replace dyn_cast with isa check
llvm-svn: 234582
2015-04-10 10:30:04 +00:00
Denis Protivensky b56dff5729 [ARM] Improve veneer handling and introduce handlePlain method
Handle veneers only for call-like relocations.

llvm-svn: 234580
2015-04-10 09:54:10 +00:00
Denis Protivensky 4dae7b02be [ARM] Remove unused variable in dynamic pass
llvm-svn: 234576
2015-04-10 07:53:18 +00:00
Denis Protivensky 7fc8aa9f1c [ARM] Add skeleton for dynamic relocation pass
llvm-svn: 234573
2015-04-10 07:42:08 +00:00
Rui Ueyama 17a2fa1e32 Remove redundant parentheses.
llvm-svn: 234558
2015-04-10 02:18:23 +00:00
Rui Ueyama 27bfbed359 Do not use default arguments for trivial functions.
llvm-svn: 234557
2015-04-10 02:15:13 +00:00
Rui Ueyama 709a0ecc87 Remove unused return values.
llvm-svn: 234556
2015-04-10 02:06:28 +00:00
Davide Italiano b63c9c32dc Reapply r234378, with test fixed (by emaste).
Hopefully this time the build won't be broken.

llvm-svn: 234553
2015-04-10 01:40:25 +00:00
Rui Ueyama ab5d90568e ELF: Don't use APPLY_RELOC macro.
In other ELF ports, we don't use the macro. This patch removes the
macro for consistency and readability.

llvm-svn: 234552
2015-04-10 00:19:41 +00:00
Rui Ueyama 84f93415f4 ELF: Move Hexagon linker helper function to Hexagon directory.
Because no one except Hexagon uses the header, we don't need to maintain
the header in the common directory. Also de-template the function for
readability.

llvm-svn: 234551
2015-04-10 00:11:54 +00:00
Rui Ueyama 6d1a121b55 Remove dead code.
llvm-svn: 234548
2015-04-10 00:04:44 +00:00
Rui Ueyama 0a997cbd3f Fix undefined behavior.
Having std:move(mb) and mb->getBuffer() in the same argument list is not safe
because the order of evaluation is not defined.

llvm-svn: 234541
2015-04-09 22:04:45 +00:00
Rui Ueyama 2e8cb722de ELF: Move CreateELF() from its own file to ELFReader.h.
CreateELF.h was included only by ELFReader.h, and it was used only
by ELFReader class. By making the function a member of the class,
we can remove template parameters.

llvm-svn: 234540
2015-04-09 21:55:47 +00:00
Rui Ueyama adafac6549 Update design.rst to remove a mention about round-trip tests.
llvm-svn: 234534
2015-04-09 20:43:38 +00:00
Denis Protivensky 455e44b0e4 [ARM] clang-format ARM sources
llvm-svn: 234474
2015-04-09 10:17:22 +00:00
Denis Protivensky 6b3a33ff00 [ARM] Add mapping symbols to veneers
This required splitting up veneer atoms into pieces,
where every piece is paired with mapping atom of
the corresponding type.

llvm-svn: 234473
2015-04-09 09:59:18 +00:00
Rui Ueyama 2effbd6b68 AtomVector: Reorder member orders to use template alias in AtomRange.
llvm-svn: 234453
2015-04-08 23:12:48 +00:00
Rui Ueyama de40bd4cf9 Rename atom_collection -> AtomVector.
Type names should start with an uppercase letter in the LLVM coding style.

llvm-svn: 234452
2015-04-08 23:05:59 +00:00
Rui Ueyama b0db07bf90 Separate atom_collection type into two different types. NFC.
atom_collection is basically a wrapper for std::vector. The class
provides begin and end member functions, so that it "hides" the
other member functions provided by std::vector. However, you can
still directly access _atoms member since the member is not
protected.

We cannot simply make the member private because we need that member
when we are constructing atom vectors.

This patch splits atom_collection into two types: std::vector<Atom *>
and AtomRange. When we are constructing atom vectors, we use the
former class. We return instances of the latter class from File
objects so that callers cannot add or remove atoms from the lists.

std::vector<Atom *> is automatically converted to AtomRange.

llvm-svn: 234450
2015-04-08 23:02:11 +00:00
Rui Ueyama 42a3dfb22c Add begin() and end() to atom_collection that returns non-const iterators.
llvm-svn: 234445
2015-04-08 21:59:08 +00:00
Rui Ueyama ae0299f040 Replace atom_iterator with a template alias.
llvm-svn: 234444
2015-04-08 21:59:06 +00:00
Rui Ueyama 1a6ec93616 Merge atom_collection_vector with atom_collection.
atom_collection_vector is the only derived class of atom_collection.
This patch merges the two.

llvm-svn: 234443
2015-04-08 21:59:04 +00:00
Rui Ueyama 2f05640409 Remove atom_collection_empty class.
llvm-svn: 234442
2015-04-08 21:59:00 +00:00
Rui Ueyama 5d6ff3d2ee vec.data() and vec.data() + vec.size() are both safe even if the vector is empty.
llvm-svn: 234436
2015-04-08 21:13:23 +00:00
Rui Ueyama 1e67707a66 YAML: Remove blank class using alias template.
llvm-svn: 234435
2015-04-08 21:05:45 +00:00
Rui Ueyama df666170ae Native: Remove AtomArray and use atom_collection_vector instead.
llvm-svn: 234434
2015-04-08 21:00:33 +00:00
Rui Ueyama d3165af756 Native: Use tempalte to remove duplicate code. NFC.
llvm-svn: 234432
2015-04-08 20:40:46 +00:00
Rui Ueyama 0d69284bec Native: Simplify expressions. NFC.
llvm-svn: 234431
2015-04-08 20:40:45 +00:00
David Blaikie 71df405895 Remove redundant virtual on member functions marked 'override'.
llvm-svn: 234419
2015-04-08 17:08:27 +00:00
Rui Ueyama 9842a965f6 Remove unused typedefs.
llvm-svn: 234415
2015-04-08 16:59:03 +00:00
Rui Ueyama e3efa415de Revert "Allow undefined symbols in shared library by default."
This reverts commit r234378 because it broke buildbots.

llvm-svn: 234414
2015-04-08 16:55:03 +00:00
Simon Atanasyan d42488a637 [ELF] Remove redundant GOTFile classes
llvm-svn: 234397
2015-04-08 10:06:28 +00:00
Simon Atanasyan 8e951ce392 [ELF] Do not save a reference to GOTFile instance in xxxWriter classes
It's a follow-up to r234347. We do not need to keep a reference to
`GOTFile` instance in a xxxWriter class after ownership is transferred
to the caller of the `createImplicitFiles` method.

llvm-svn: 234396
2015-04-08 09:19:45 +00:00
Davide Italiano 0e6a264673 Allow undefined symbols in shared library by default.
It's not our business to resolve those undefined symbols.
We just trust the linker will load the library and its dependencies
correctly, which is actually what happens, modulo bugs in the dynamic
linker itself.

PR:		23035
Differential Revision:	http://reviews.llvm.org/D8886

llvm-svn: 234378
2015-04-08 01:00:19 +00:00
Rui Ueyama 9a736cf29f ELF: Minor simplification.
MergeSectionKey is a tiny struct. We don't need a constructor for that.
The good old way to initialize a struct works fine.

llvm-svn: 234371
2015-04-07 22:46:01 +00:00
Rui Ueyama 3b9a91a18d MachO: Remove unused vectors from MachHeaderAliasFile. NFC.
llvm-svn: 234369
2015-04-07 22:35:29 +00:00
Rui Ueyama 142877f450 Remove unused vectors from FileArchive.
Archive files don't have any symbols (their members do).
The vectors deleted here were always empty.

llvm-svn: 234368
2015-04-07 22:32:19 +00:00
Rui Ueyama 5a79fbeb2e ELF: Simplify ELFFile by deriving from SimpleFile instead of File.
SimpleFile defines defined(). undefined(), sharedLibrary() and absolute().
We should use the class instead of deriving from the base class and
re-defining the member functions in ELFFile.

llvm-svn: 234367
2015-04-07 22:27:43 +00:00
Rui Ueyama 18cd75cc47 Define SimpleFile::addAtom for concrete atom types.
Previously, addAtom always used dynamic dispatching mechanism to
bin atoms. This patch eliminates dynamic dispatching in most cases.

llvm-svn: 234365
2015-04-07 22:21:18 +00:00
Simon Atanasyan 64bcb690e9 [ELF] Set `addAbsoluteAtom` and `addUndefinedAtom` functions return type to void
We do not use values returned by these functions anywhere.
So let's return nothing.

llvm-svn: 234358
2015-04-07 21:12:28 +00:00
Simon Atanasyan 3dba8a2d96 [ELF] Remove unused xxxWriter class fields
llvm-svn: 234357
2015-04-07 21:12:18 +00:00
Simon Atanasyan 073e9fb5e1 [ELF] Remove redundant override methods which just call base class functions
llvm-svn: 234356
2015-04-07 21:12:02 +00:00
Rui Ueyama 3c45cffd68 Merge MutableFile with SimpleFile.
SimpleFile is the only derived class of MutableFile.
This patch reduces the height of class hierarchy by removing
MutableFile class.

llvm-svn: 234354
2015-04-07 20:43:38 +00:00
Simon Atanasyan 64e36b67e2 [ELF] Simplify adding default atoms
Now 'writer' creates an instance of `RuntimeFile` in the constructor, then
populates the file in the virtual function `addDefaultAtoms`, then pass
owning of this file to the caller of virtual function `createImplicitFiles`.

First, we do not need to keep an instance of `RuntimeFile` so long. It is
enough to create the file, right after that populate it and pass the owning.

Second, relationship between `createImplicitFiles` and `addDefaultAtoms`
is complicated. The `createImplicitFiles` might call `addDefaultAtoms`,
overridden version of `addDefaultAtoms` might call base class `addDefaultAtoms`,
and overridden version of `createImplicitFiles` might call base class
`createImplicitFiles` as well as `addDefaultAtoms`.

The patch solves both problems above. It creates and populates runtime files
right in the createImplicitFiles(), removes `addDefaultAtoms` at all and
does not keep references to runtime files in class fields.

llvm-svn: 234347
2015-04-07 20:11:38 +00:00
Denis Protivensky 14ed198ff7 [ARM] Use getMappingAtomName in Release only
llvm-svn: 234311
2015-04-07 11:51:39 +00:00
Denis Protivensky dd7adf7a18 [ARM] Rename applyThmReloc => applyThumb32Reloc
llvm-svn: 234302
2015-04-07 07:14:13 +00:00
Denis Protivensky 6c50e88c0d [ARM] Add mapping symbols to PLT entries
Make PLT entry atoms represent mapping symbols in the Release mode,
while in the Debug mode they are still function-like symbols
with regular names.
It's legal that mapping symbols denote unnamed parts of code,
and PLT entries are not required to have function-like names.

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

llvm-svn: 234301
2015-04-07 07:04:42 +00:00
Simon Atanasyan d526486763 [ELF] Remove redundant const_cast
No functional changes.

llvm-svn: 234293
2015-04-07 04:38:30 +00:00