Commit Graph

3156 Commits

Author SHA1 Message Date
Rui Ueyama ad87e54f1a ELF: Define ELF{32,64}{LE,BE} types and use them everywhere.
llvm-svn: 234823
2015-04-14 00:31:28 +00:00
Rui Ueyama d610a96d15 ELF: Remove useless templates that takes always the same ELF type.
llvm-svn: 234820
2015-04-14 00:08:09 +00:00
Rui Ueyama 243226852f ELF: Fix headers including each other.
HexagonSectionChunks.h and HexagonTargetHandler.h include each other.
This patch removes the former and merge it with the latter.

llvm-svn: 234817
2015-04-13 23:47:53 +00:00
Rui Ueyama 4bd8ece689 ELF: Move definitions from {Dynamic,ELF}File.h to .cpp files.
DynamicFile and ELFFile are instantiated for four different types,
ELF{32,64}{BE,LE}. Because the classes are instantiated in each
compilation unit, including the header file makes object files
10MB larger.

On Windows, issue of excessive template instantiation is critical,
since the regular COFF file supports only up to 65534 sections.
(We could use the extended COFF file format, but generating that
much COMDAT sections is not a good thing in the first place
because it means long compile time and long link time.)

I confirmed that this change makes AArch64TargetHandler.cpp.o
from 21MB to 8.5MB. It feels still too large, but I think it's
a good start.

llvm-svn: 234808
2015-04-13 22:52:11 +00:00
Rui Ueyama fa92b4c9d8 ELF: Simplify alignment check. NFC.
llvm-svn: 234791
2015-04-13 20:04:50 +00:00
Rui Ueyama cfba8b3481 ELF: s/ELFTy/ELFT/ for consistency.
llvm-svn: 234790
2015-04-13 20:04:48 +00:00
Rui Ueyama 3245a395c1 Remove else after return.
llvm-svn: 234784
2015-04-13 19:56:08 +00:00
Rui Ueyama 09dfd2544e Fix formatting and remove excessive parentheses.
llvm-svn: 234781
2015-04-13 19:24:00 +00:00
Simon Atanasyan 44e904581d [Mips] Rollback explicit instantiation of MipsELFFile template class
This is a follow-up to r234728 and r234729. It looks like explicit
instantiation of `MipsELFFile` is redundant and triggers Visual C++ warning.

llvm-svn: 234756
2015-04-13 15:32:42 +00:00
Adhemerval Zanella cced470374 ELF/Aarch64: Add overflow checks for relocation writes
This patch adds support for overflow checking when processing
R_AARCH64_CALL26, R_AARCH64_JUMP26, R_AARCH64_CONDBR19,
R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21, and R_AARCH64_TLSLE_ADD_TPREL_HI12
relocations.

llvm-svn: 234749
2015-04-13 12:14:14 +00:00
Adhemerval Zanella b79cea9180 ELF/AArch64: Add tests for ADR_PREL_LO21
Add default and overflow checking when processing
R_AARCH64_ADR_PREL_LO21 relocations.

llvm-svn: 234747
2015-04-13 12:11:23 +00:00
Adhemerval Zanella 0c2f3bcd67 [PATCH 08/10] ELF/Aarch64: Add R_AARCH64_ADR_GOT_PAGE and R_AARCH64_LD64_GOT_LO12_NC checks
This patch adds R_AARCH64_ADR_GOT_PAGE overflow and R_AARCH64_LD64_GOT_LO12_NC
unaligned value checks.

llvm-svn: 234746
2015-04-13 12:08:21 +00:00
Adhemerval Zanella 6f6472c41a ELF/Aarch64: Internal variable cleanup
This patch makes the AArch64GotAtomContent, AArch64Plt0AtomContent, and
AArch64PltAtomContent static and also cleanup their formatting.

llvm-svn: 234745
2015-04-13 11:44:44 +00:00
Adhemerval Zanella 9fc8102457 ELF/AArch64: Check linker created dynamic variables
Check the values of _GLOBAL_OFFSET_TABLE_ and _DYNAMIC variables created by
linker.  AArch64 version.

llvm-svn: 234744
2015-04-13 11:43:33 +00:00
Adhemerval Zanella c55179f847 ELF/AArch64: Check ADR_PREL_PG_HI21 for overflow
Add support for overflow checking when processing
R_AARCH64_ADR_PREL_PG_HI21 relocations and add test.

Patch Will Newton.

llvm-svn: 234743
2015-04-13 11:42:06 +00:00
Adhemerval Zanella 3274a849f4 ELF/AArch64: Add support for R_AARCH64_PREL16
Add support for the R_AARCH64_PREL16 relocation type and add tests.

Patch by Will Newton.

llvm-svn: 234742
2015-04-13 11:40:50 +00:00
Adhemerval Zanella 4def013264 ELF/AArch64: Add support for R_AARCH64_PREL64
Add support for the R_AARCH64_PREL64 relocation type and add tests.

Patch by Will Newton.

llvm-svn: 234741
2015-04-13 11:38:41 +00:00
Adhemerval Zanella a5752c73db ELF/AArch64: Add support for checking PREL32 for overflow
Add support for overflow checking when processing R_AARCH64_PREL32
relocations and add tests.

Patch by Will Newton.

llvm-svn: 234740
2015-04-13 11:36:51 +00:00
Adhemerval Zanella 4c9bad3549 ELF/AArch64: Add support for R_AARCH64_ABS16
Add support for the R_AARCH64_ABS16 relocation type and add tests.

Patch by Will Newton.

llvm-svn: 234739
2015-04-13 11:34:06 +00:00
Hans Wennborg 2a76f41511 Speculative build fix for lld on Windows
I can't access my Windows machine at the moment, but the build was breaking with:

c:\b\build\slave\crwinclanglld\build\src\third_party\llvm\tools\lld\lib\readerwriter\elf\mips\MipsTargetLayout.h(38) : error C2440: 'return' : cannot convert from 'lld:🧝:MipsGOTSection<ELFT> *' to 'lld:🧝:AtomSection<ELFT> *'
        with
        [
            ELFT=lld:🧝:Mips32ELType
        ]
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

I think this regressed caused in 234727: that the forward-declarations
of MipsGOTSection<> is not enough.

llvm-svn: 234736
2015-04-13 11:00:22 +00:00
Denis Protivensky f40ef51feb [ARM] Use std::call_once for thread safe initialization
Thanks to r234628 & r234631

llvm-svn: 234733
2015-04-13 10:18:21 +00:00
Denis Protivensky 8830b93fac [ARM] Replace branch to unreachable with assertion
llvm-svn: 234732
2015-04-13 08:47:38 +00:00
Simon Atanasyan da46480c4d [Mips] Explicitly instantiate MipsELFFile template class
Use explicit instantiation to reduce object files size.

llvm-svn: 234729
2015-04-13 08:35:04 +00:00
Simon Atanasyan aaf3df3a00 [Mips] Create MipsTargetHandler class object using factory functions
Right now MIPS instantiates MipsTargetHandler using Mips32ELType and
Mips64ELType. And in the future we can add a couple more types. That
leads to the large object file size because compiler has to create
copies of MipsTargetHandler and all realted classes for each types used
for instantiation.

The patch introduces two factory functions and puts each of them into
the separate cpp file. That allows to reduce size of single object file.

llvm-svn: 234728
2015-04-13 08:34:56 +00:00
Simon Atanasyan 4bc35460df [Mips] Move `MipsTargetLayout` class to the separate header
llvm-svn: 234727
2015-04-13 08:34:46 +00:00
Simon Atanasyan 88698b66c9 [Mips] Support R_MICROMIPS_GOT_HI/LO16 and R_MICROMIPS_CALL_HI/LO16 relocations
llvm-svn: 234726
2015-04-13 08:20:57 +00:00
Simon Atanasyan 62f261b014 [Mips] Support R_MIPS_CALL_HI16 / R_MIPS_CALL_LO16 relocations handling
llvm-svn: 234725
2015-04-13 08:20:48 +00:00
Simon Atanasyan 077372889b [Mips] Support R_MIPS_GOT_HI16 / R_MIPS_GOT_LO16 relocations handling
llvm-svn: 234724
2015-04-13 08:20:34 +00:00
Simon Atanasyan 4b115813d2 [Mips] Add more checkings to the test case
No functional changes.

llvm-svn: 234723
2015-04-13 08:20:26 +00:00
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 942d51a25f Replace a macro with an inline function.
llvm-svn: 234650
2015-04-10 22:05:11 +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 4a576bfd23 Use C++11 non-static member initialization.
llvm-svn: 234648
2015-04-10 21:49:28 +00:00
Rui Ueyama 8330835197 Attempt to fix buildbots.
lldNative was removed in r234641.

llvm-svn: 234646
2015-04-10 21:42:16 +00:00
Rui Ueyama aabd7ca452 Do s/_context/_ctx/g globally.
I believe this patch eliminates all remaining uses of _context
or _linkingContext variable names. Consistent naming improves
readability.

llvm-svn: 234645
2015-04-10 21:40:59 +00:00
Rui Ueyama 08d9520f89 Fix docs-lld-html build.
llvm-svn: 234644
2015-04-10 21:37:42 +00:00
Rui Ueyama aa7b304ea7 Remove the Native file format.
The Native file format was designed to be the fastest on-memory or
on-disk file format for object files. The problem is that no one
is working on that. No LLVM tools can produce object files in
the Native, thus the feature of supporting the format is useless
in the linker.

This patch removes the Native file support. We can add it back
if we really want it in future.

llvm-svn: 234641
2015-04-10 21:23:51 +00:00
Simon Atanasyan 1c1b4366af [Mips] Fix broken test case
llvm-svn: 234639
2015-04-10 21:19:01 +00:00
Rui Ueyama 74c629be81 ELF: Simplify assignments to "result"
This file is not -Wconversion-clean, and seems like we don't care
about that except these lines. Fix these lines for simplicity.

llvm-svn: 234637
2015-04-10 21:03:20 +00:00
Simon Atanasyan 720f52a961 [Mips] Add -pcrel-eh-reloc command line option
This MIPS specific option controls R_MIPS_EH relocation handling.
If -pcrel-eh-reloc is specified R_MIPS_EH relocation should be handled
like R_MIPS_PC32 relocation.

llvm-svn: 234635
2015-04-10 21:00:41 +00:00
Simon Atanasyan 54b1d56c01 [Mips] Support R_MIPS_EH relocation handling
The patch supports just the R_MIPS_EH relocation handling and does not
implement full specification of compact exception tables for MIPS ABIs.

llvm-svn: 234634
2015-04-10 21:00:29 +00:00
Simon Atanasyan ada248cd1c [Mips] Replace MipsTargetHandler member function getGP() by getGPAddr()
When we call getGP() we need in fact _gp symbol address. Let's cache its
value and return it directly from the new getGPAddr() function.

llvm-svn: 234632
2015-04-10 20:55:10 +00:00
Simon Atanasyan 1f50cb1d13 [Mips] Use std::call_once for thread safe initialization
The commit is inspired by r234628. Thanks Rui for the idea.

llvm-svn: 234631
2015-04-10 20:55:04 +00:00
Simon Atanasyan 2bafa8342c [Mips] Fix typo in the comment
llvm-svn: 234630
2015-04-10 20:54:58 +00:00
Rui Ueyama ee0c60679a Fix minor threading issue.
Because calls of applyRelocation is parallelized, all functions
called from that need to be thread-safe. This piece of code
didn't use any synchronization mechanism, so it was not safe.

llvm-svn: 234628
2015-04-10 19:55:35 +00:00
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
Rui Ueyama 752a8c3e55 ELF: Minimum alignment value is 1, not 0. NFC.
Maybe we can interpret alignment 0 as "don't care", but for
consistency, it's good to set 1 instead of 0 where we allow
any alignments.

llvm-svn: 234284
2015-04-07 03:44:26 +00:00
Rui Ueyama 0e46755821 ELF: Add a comment to ELFFile::findAtom.
Also changed the local variable names to avoid line wrapping.

llvm-svn: 234281
2015-04-07 02:52:34 +00:00
Rui Ueyama 11dcc79de1 Fix weird comment line-wrapping.
llvm-svn: 234279
2015-04-07 02:26:42 +00:00
Rui Ueyama f11343e68e Use early continue.
llvm-svn: 234278
2015-04-07 02:20:33 +00:00
Rui Ueyama add2a66c00 ELF: Move more code from createAtoms to handleGnuLinkOnceSection.
So that createAtoms become more readable.

llvm-svn: 234277
2015-04-07 02:11:56 +00:00
Rui Ueyama f122b91a02 ELF: Simplfiy ELFFile::createAtom.
createAtom function did too much in a single for-loop. This patch
splits the for-loop and extract COMDAT handling into a separate
function.

llvm-svn: 234276
2015-04-07 01:56:07 +00:00
Rui Ueyama c9f801504a ELF: Do not return error from handle{CommonSymbol,MergeString}.
llvm-svn: 234273
2015-04-07 01:14:24 +00:00
Rui Ueyama 29e56d06f2 ELF: Do not return error from handleAbsoluteSymbol.
This function never fails.

llvm-svn: 234272
2015-04-07 01:08:16 +00:00
Rui Ueyama 00ecdb53d0 ELF: Do not return error from handleUndefinedSymbol.
This function is not supposed to return an error value.

llvm-svn: 234271
2015-04-07 01:04:15 +00:00
Rui Ueyama 9918155779 ELF: Do not return error from handleDefinedSymbol.
handleDefinedSymbol has return type of ErrorOr<ELFDefinedAtom *>.
However, it never returns an error. We are not checking errors.
It's marked as ErrorOr "just in case". That's a bad engineering
practice.

This patch simplifies the return type of the function.

llvm-svn: 234269
2015-04-07 01:00:20 +00:00
Rui Ueyama 7c869e4821 ELF: Simplify CreateELF.
CreateELF was a combination of templates and C preprocessor macros.
This patch removes uses of macros.

http://reviews.llvm.org/D8810

llvm-svn: 234253
2015-04-06 23:02:47 +00:00
Davide Italiano 8b4956a507 Fix a very silly typo in my previous commit. I need more coffee.
Spotted by Simon Atanasyan.

llvm-svn: 234252
2015-04-06 22:57:58 +00:00
Davide Italiano 553e118147 [GNU] Implement --enable-new-dtags/--disable-new-dtags
PR:		23036
Differential Revision:	http://reviews.llvm.org/D8836

llvm-svn: 234240
2015-04-06 21:45:31 +00:00
Rui Ueyama 0ac129903a ELF: Do not mix link-once and group sections.
Previously, we put both link-once and group sections into the same map
and seaparated them out when we use them. Apparently we should put them
into seaprate maps in the first place.

This piece of code is added recently, and I still don't understand all
of them. Looks like we need to clean this up even more.

llvm-svn: 234223
2015-04-06 21:21:43 +00:00
Simon Atanasyan c437888f5a Replace the `createImplicitFiles` method return type with `void`
All instances of the `createImplicitFiles` always return `true` and this
return value is used nowhere.

llvm-svn: 234205
2015-04-06 20:43:35 +00:00
Rui Ueyama 230d2ec75f Remove return after report_fatal_error which has noreturn attribute.
llvm-svn: 234204
2015-04-06 20:25:18 +00:00
Rui Ueyama 02b5a800c5 Fix weird line-wrapping.
llvm-svn: 234203
2015-04-06 20:10:09 +00:00
Rui Ueyama 0fbf5aa205 Use llvm::cast at where we don't expect a null value.
llvm-svn: 234199
2015-04-06 19:45:32 +00:00
Simon Atanasyan fa58038914 [Mips] Guard modification of register usage masks by mutex
llvm-svn: 234167
2015-04-06 16:07:19 +00:00
Simon Atanasyan 596dae5fc2 [LinkerScript] Handle symbols defined in linker scripts in case of shared lib
This patch is a follow-up to the rL232409 and allows define symbols
in a linker script in case of linking shared library.

llvm-svn: 234163
2015-04-06 15:15:01 +00:00
Simon Atanasyan a19820ddb4 [ELF] Use override keyword instead of virtual
No functional changes.

llvm-svn: 234162
2015-04-06 15:09:39 +00:00
Simon Atanasyan ac17bfd699 [ELF] Use override keyword instead of virtual
No functional changes.

llvm-svn: 234157
2015-04-06 13:26:15 +00:00
Simon Atanasyan 3dac3ba595 [ELF] Remove redundant forward class declarations
No functional changes.

llvm-svn: 234156
2015-04-06 13:26:10 +00:00
Simon Atanasyan cd9f268b50 [Mips] Remove redundant non-template MipsRelocationHandler class
llvm-svn: 234155
2015-04-06 13:26:04 +00:00
Simon Atanasyan 58a7fd48dc [Mips] Replace MipsRelocationHandler::readAddend() by a regular function
The readAddend() does not depend on MipsRelocationHandler and should not
be its member function.

llvm-svn: 234154
2015-04-06 13:25:58 +00:00
Simon Atanasyan 3a8691a27a [Mips] Reformat the code with clang-format
llvm-svn: 234153
2015-04-06 13:25:52 +00:00
Denis Protivensky 2000211ff3 [AArch64] Fix error in AARCH64_ADR_GOT_PAGE handler
The error was introduced during mechanical replacement
of raw memory reads/writes to use readxxle/writexxle functions
in r230725.

Noted and fixed by Suprateeka R Hegde <hegdesmailbox@gmail.com>

llvm-svn: 234144
2015-04-06 07:44:59 +00:00
Davide Italiano fd52bbcf58 Strip .strtab and .symtab when --strip-all is used.
This matches other linkers behaviour. Moreover, there's really
no need to keep them around.

Reported by: Rafael Avila de Espindola

PR:		22890
llvm-svn: 234130
2015-04-05 22:47:54 +00:00
Benjamin Kramer 02613337e3 [elf] Fix a silly memory leak. std::string has a non-trivial dtor.
llvm-svn: 234120
2015-04-05 15:53:20 +00:00
Simon Atanasyan efc006b573 [Mips] Rename MipsLinkingContext class method
getMergeReginfoMask => getMergedReginfoMask

llvm-svn: 234116
2015-04-05 09:01:53 +00:00
Simon Atanasyan 4c5b23f6df [Mips] Support writing .MIPS.options section into the linked file
In case of MIPS N64 ABI linker should merge registers usage masks stored
in the input .MIPS.options sections and save result into the output
.MIPS.options section.

llvm-svn: 234115
2015-04-05 09:01:46 +00:00
Simon Atanasyan b2d1c0c09c [Mips] Add checking of .reginfo section options to the test case
llvm-svn: 234114
2015-04-05 09:01:35 +00:00
Simon Atanasyan 3ceaceb26a [Mips] Do not use array initializer to fix Windows build bots
llvm-svn: 234105
2015-04-04 19:48:29 +00:00
Simon Atanasyan c3899d2234 [Mips] Support writing .reginfo section into the linked file
In case of MIPS O32 ABI linker should merge registers usage masks stored
in the input .reginfo sections and save result into the output .reginfo
section.

The ABI states that the .reginfo section should be put into the separate
segment. This requirement is not implemented in this patch.

llvm-svn: 234103
2015-04-04 19:13:32 +00:00
Simon Atanasyan 1d359d3b5b [Hexagon] Remove duplicated typedef
The `HexagonELFType` is declared in the HexagonLinkingContext.h.

llvm-svn: 234089
2015-04-04 05:19:58 +00:00
Simon Atanasyan 1649aea9c6 [Hexagon][Mips] Rename template arguments <arch>ELFType to ELFT
In all other ELF related classes we use `ELFT` abbreviation.

llvm-svn: 234088
2015-04-04 05:19:51 +00:00
Rui Ueyama a5f1ae1ad0 ELF: Use short variable names in <Arch>RelocationHandlers.cpp.
Functions in the files are hard to read because of line wrapping.
Use shorter names for local variables so that the lines fit
within 80 columns.

llvm-svn: 234087
2015-04-04 04:22:27 +00:00
Rui Ueyama b2e6190aca Remove redundant anonymous namespace.
llvm-svn: 234085
2015-04-04 04:10:08 +00:00
Rui Ueyama 09f8b75b52 ELF: Merge ELFTargets.h with ELFLinkingContext.h.
These functions are "constructors" of the LinkingContexts. We already
have auxiliary classes and functions for ELFLinkingContext in the header.
They fall in the same category.

llvm-svn: 234082
2015-04-04 03:24:42 +00:00
Rui Ueyama 59b0bfef0d ELF: Return TargetRelocationHandler instead of <ArcH>TargetRelocationHandler.
getRelocationHandler is a public interface to get an instance of
TargetRelocationHandler. We don't use any member function other than
applyRelocations to a returned instance. Returning a base class instance
suffices here. (If a return type is a derived class, it looks like we were
using derived classes features.)

llvm-svn: 234081
2015-04-04 02:59:52 +00:00
Rui Ueyama 55f5b2b277 Remove a parameter for file extension from canParse.
canParse took three parameters -- file magic, filename extension and
memory buffer. All but YAMLReader ignored the second parameter.
This patch removes the parameter.

llvm-svn: 234080
2015-04-04 02:44:36 +00:00
Rui Ueyama 103cb33d08 ELF: Make private members private.
llvm-svn: 234077
2015-04-04 02:26:17 +00:00
Rui Ueyama aa1eb0c2a5 ELF: Remove ELF{Object,DSO}Reader alias templates.
Because of the previous change (r234074), ELFObjectReader became just
an alias for ELFReader. We can replace all occurrences of ELFObjectReader
with ELFReader.

In this patch, I also replaced ELFDSOReader to remove the alias template.

llvm-svn: 234076
2015-04-04 02:16:26 +00:00
Rui Ueyama db9e9d83b6 ELF: Teach File classes about their file magics.
So that we can remove one template parameter from ELFReader.
ELF port is heavily templatized, and I want to reduce the usage
where possible.

llvm-svn: 234074
2015-04-04 02:07:30 +00:00
Rui Ueyama 22f0b3f1a5 s/context/ctx/g on lib/Driver/Driver.cpp.
llvm-svn: 234073
2015-04-04 01:37:25 +00:00
Rui Ueyama c6fcfd4178 Remove unused member function declarations.
llvm-svn: 234072
2015-04-04 01:37:23 +00:00
Rui Ueyama 21d22ca11a Remove unused includes and forward declarations.
llvm-svn: 234070
2015-04-04 00:25:22 +00:00
Rui Ueyama 4d200e3859 Remove unused functions.
llvm-svn: 234069
2015-04-04 00:12:27 +00:00
Rui Ueyama 133933bb42 ELF: Define mergeHeaderFlags to ELFLinkingContext.
Only MIPS defined the member function, but this feature is not actually
MIPS-specific. Also, the dependency to the MIPS-only member function
prevented us from merging <Arch>ELF{Object,DSO}Reader classes.

This patch moves the feature from MipsLinkingContext to LinkingContext.

llvm-svn: 234068
2015-04-04 00:10:14 +00:00
Simon Atanasyan a2404f898a [ELF] Remove unused typedef
llvm-svn: 234066
2015-04-03 23:07:18 +00:00
Simon Atanasyan c36c80c2f2 [ELF] Merge Layout and TargetLayout class
It is enough to have single TargetLayout class.

llvm-svn: 234065
2015-04-03 23:07:13 +00:00
Rui Ueyama 25a0d3dd64 ELF: Merge ELF{Object,DSO}Reader implementations.
The two classes are the same other than a few exceptions.
This patch merges them using templates.

llvm-svn: 234060
2015-04-03 22:12:18 +00:00
Rui Ueyama fdcfe466e3 ELF: Remove <Arch>ELFReader.h. NFC.
<Arch>ELFReader.h contains only a few typedefs. The typedefs are used
only by one class in <Arch>TargetHandler.h. Thus, the headers don't
worth to be independent files.

Since MipsELFReader.h contains code other than the boilerplate, I didn't
touch that file in this patch.

llvm-svn: 234056
2015-04-03 21:22:20 +00:00
Simon Atanasyan 2181c10b5b [ELF] Delete empty TargetLayout class and rename DefaultLayout to TargetLayout
No functional changes.

llvm-svn: 234052
2015-04-03 21:01:07 +00:00
Rui Ueyama 3fbed259b6 ELF: Fix header file dependencies.
<Arch>TargetHandler.h and <ArcH>RelocationHandler.h include each other.
This patch breaks the circular dependencies.

llvm-svn: 234050
2015-04-03 20:56:22 +00:00