Commit Graph

2898 Commits

Author SHA1 Message Date
Rui Ueyama 69af2e717e ELF: Remove <Arch>ELFFileCreateELFTraits::result_type.
result_type is always ErrorOr<unique_ptr<File>>, and since the type traits
is for instantiating ELF files, it's unlikely that we want to return
something else. This patch removes that type.

llvm-svn: 233948
2015-04-02 21:14:33 +00:00
Simon Atanasyan 8189ee9a1e [Mips] Inline the MipsELFWriter::hasGlobalGOTEntry function
No functional changes.

llvm-svn: 233924
2015-04-02 16:44:26 +00:00
Rui Ueyama b709f8b6ef ELF: Always use variadic templates in CreateELF.h.
Since we no longer support MSVC 2012, we can assume that variadic
templates are always supported. This patch removes an #ifdef for
C++ compilers that don't support variadic templates.

llvm-svn: 233901
2015-04-02 07:28:19 +00:00
Denis Protivensky 2fc953bb98 [ARM] Generate PLT entries for calls from ARM and Thumb code
The function call that goes through PLT table may be performed
from both ARM and Thumb code.
This situation requires adding a veneer to original PLT code
(which is always ARM) to effect Thumb-to-ARM transition.

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

llvm-svn: 233900
2015-04-02 07:23:11 +00:00
Denis Protivensky ff51abcc52 [ARM] Report fatal error for wrong ARM entry point
The case is possible with wrong input, so report
an error instead of using llvm_unreachable.

llvm-svn: 233899
2015-04-02 07:03:44 +00:00
Rui Ueyama 0ee57cede0 ELF: Remove {AArch64,X86,X86_64}ELFFile because they are empty.
llvm-svn: 233897
2015-04-02 06:50:29 +00:00
Rui Ueyama 0a1fbb7b0c ELF: Replace empty classes with typedefs.
llvm-svn: 233896
2015-04-02 06:00:42 +00:00
Rui Ueyama b965ac5dc9 ELF: Remove a template parameter from ELF{Object,DOS}Reader constructors.
There is one-to-one correspondence between ELF machine type and a
LinkingContext. We passed them as separate arguments to the constructor.
This patch is to teach the LinkingContexts about their machine types,
so that we don't need to pass that data as separate arguments.

llvm-svn: 233894
2015-04-02 05:19:36 +00:00
Rui Ueyama 4229b946a8 ELF: Mips: Remove unused field and almost-empty class.
Looks like MipsTargetHandler::_runtimeFile is unused.
MipsRuntimeFile doesn't seem to add values to the base class,
so I removed that class too.

llvm-svn: 233888
2015-04-02 04:48:30 +00:00
Rui Ueyama 7d5492d9ab ELF: Move registerRelocationNames() from TargetHandler to <Arch>ELFLinkingContext.
registerRelocationNames() function is called to register all known
ELF relocation types to the central registry. Since we have separate
LinkingContext class for each ELF machine type, we need to call the
function for each LinkingContext.

However, the function belonged to TargetHandler instead of LinkingContext.
So we needed to do ctx.getTargetHandler().registerRelocationNames().
This patch removes that redundant getTargetHandler call by moving the
function from TargetHandler to LinkingContext.

Conceptually this patch is small, but in reality it's not that small.
It's because the same code is copied to each architecture.
Most of this patch is just repetition. We need to merge them, but
that cannot be done in this patch.

llvm-svn: 233883
2015-04-02 04:18:54 +00:00
Rui Ueyama 0052736eb1 ELF: Move x86-64-only function from DefaultLayout to X86_64TargetLayout.
Also removed some over-generalization added in r232866, such as
making a function take two parameters and pass two equivalent
arguments to the function.

llvm-svn: 233882
2015-04-02 01:36:02 +00:00
Rui Ueyama a9b549f924 ELF: Remove empty classes.
llvm-svn: 233880
2015-04-02 01:22:23 +00:00
Rui Ueyama 8ecb0b68c1 ELF: Make createWriterELF's type consistent with other functions.
Other createWriter<Arch> functions take <Arch>LinkingContext as arguments.
Only createWriterELF was an exception. This patch makes it consistent with
others.

llvm-svn: 233878
2015-04-02 01:02:58 +00:00
Rui Ueyama 943206da8e ELF: x86, x86-64, ARM, AArch64: Remove architecture name prefixes from class members.
llvm-svn: 233873
2015-04-02 00:19:04 +00:00
Rui Ueyama 4e725665b0 Remove unused varaible.
llvm-svn: 233872
2015-04-02 00:18:58 +00:00
Rui Ueyama 4507003622 ELF: Remove <Arch>TargetHandler::kindString.
<Arch>TargetHandler::kindString is a static member variable
containg a list of names of relocation types.

The member is used only by one function, registerRelocationNames,
so they don't have to be a static member.

This patch makes the visibility of the data narrower by making
them file-scoped variables in small files.

llvm-svn: 233867
2015-04-01 23:55:10 +00:00
Rui Ueyama cb15900a7f Remove unused variable.
llvm-svn: 233864
2015-04-01 22:55:16 +00:00
Rui Ueyama 5c9709f956 Use llvm::make_unique.
llvm-svn: 233863
2015-04-01 22:51:46 +00:00
Rui Ueyama 0d83d61297 Use C++ non-static member initialization.
llvm-svn: 233859
2015-04-01 22:28:00 +00:00
Simon Atanasyan 2948dfe89f [Mips] Remove 'mips' prefix from class member fields names
No functional changes.

llvm-svn: 233812
2015-04-01 15:30:53 +00:00
Denis Protivensky 5466b1c0d2 [ARM] Set specific flags in ELF header
llvm-svn: 233799
2015-04-01 11:39:53 +00:00
Denis Protivensky b538262646 [ARM] Enhance checks for entry point
llvm-svn: 233798
2015-04-01 11:36:58 +00:00
Shankar Easwaran 83aa6d02d8 [ELF][Hexagon] Add comments related to hexagon relocations.
No functional changes.

llvm-svn: 233783
2015-04-01 03:07:01 +00:00
Shankar Easwaran ee39d33175 [Gnu] Support an other form of defsym option
llvm-svn: 233782
2015-04-01 03:06:59 +00:00
Rui Ueyama 514db75180 ELF: Update comments.
This patch updates comments in the ELFLinkingContext to use
non-question sentences as brief descriptions of functions.

llvm-svn: 233774
2015-04-01 00:31:41 +00:00
Rui Ueyama c8dad8e324 ELF: Remove TargetHandlerBase by merging it with TargetHandler.
In r233772, I removed an empty class, DefaultTargetHandler, from
the class hierarchy by merging the class with TargetHandler. I then
found that TargetHandler and its base class, TargetHandlerBase,
are also almost the same.

We need to go deeper.

In this patch, I merged TargetHandlerBase with TargetHandler.
The only difference between them is the existence (or absense)
of a pure virtual function registerRelocationName(). I added that
function to the (new) TargetHandler.

One more thing is that TargetHandler was templated for no reason.
I made it non-templated class.

llvm-svn: 233773
2015-04-01 00:00:36 +00:00
Rui Ueyama c2cf52ae24 ELF: Remove dead class that does nothing in class hierarchy.
DefaultTargetHandler is the base class of all <Arch>TargetHandler classes,
and it's the only derived class of TargetHandler class.

TargetHandler and DefaultTargetHandler are actually the same. They define
the same set of pure virtual functions. DefaultTargetHandler is a useless
class in the class hierarchy -- it shouldn't have been added in the first place.

This patch makes all <Arch>TargetHandler classes directly derive from
TargetHandler and removes DefaultTargetHandler.

llvm-svn: 233772
2015-03-31 23:01:19 +00:00
Rui Ueyama 5d2939302a ELF: Make findAbsoluteAtom return AtomLayout* instead of an iterator.
All calls of findAbsoluteAtoms seem a bit awkward because of the type
of the function. It semantically returns a pointer to an AtomLayout or
nothing, so I made the function return AtomLayout*.

In this patch, I also expanded some "auto"s because their actual type
were not obvious in their contexts.

llvm-svn: 233769
2015-03-31 22:37:59 +00:00
Rui Ueyama 6a75d842c9 ELF: Fix dereferencing end() iterator.
findAbsoluteAtom() returns absoluteAtom().end() if no atom is found.
Dereferencing end() value results an undefined behavior.

llvm-svn: 233765
2015-03-31 22:08:43 +00:00
Rui Ueyama 1490b3512e ELF: Remove TargetHandler::getTargetLayout.
Only MIPS used that member function, and by removing the use of the
function, I removed a static_cast. Seems like it's a win.

llvm-svn: 233748
2015-03-31 20:31:48 +00:00
Rui Ueyama b99d9a0a81 Remove "_hexagon" prefix from some member variables.
At least in Mips we don't have a prefix for member variables.
Repeating the architecture is verbose.

llvm-svn: 233746
2015-03-31 20:29:08 +00:00
Rui Ueyama d3eee4c95c Replace *(uniqueptr.get()) with *uniqueptr.
Apparently they are copy-pastes. They need to be merged, or otherwise
they will diverge needlessly as I did in r233723...

llvm-svn: 233741
2015-03-31 19:55:39 +00:00
Rui Ueyama 73ee010d2d Use C++ non-static member initialization.
llvm-svn: 233739
2015-03-31 19:37:33 +00:00
Rui Ueyama 1f0cd04df9 Rename _AArch64TargetLayout.
This change should have been done in r233737, but I made a mistake to
not include into that.

llvm-svn: 233738
2015-03-31 19:35:35 +00:00
Rui Ueyama efaf6a77d1 Rename identifiers starting with an underscore and a uppercase letter.
Identifiers starting with _[A-Z] is reserved for the language.
User programs shouldn't use such identifiers.

llvm-svn: 233737
2015-03-31 19:33:25 +00:00
Rui Ueyama 537287041b Remove virtual and add override.
llvm-svn: 233735
2015-03-31 19:21:43 +00:00
Simon Atanasyan f00d85a809 [Mips] Use llvm::make_unique
No functional changes.

llvm-svn: 233727
2015-03-31 19:00:54 +00:00
Rui Ueyama 2b28b59311 If x is a unique_ptr, *x.get() is equivalent to *x.
llvm-svn: 233723
2015-03-31 18:26:31 +00:00
Rui Ueyama 07269cc91d Use llvm::make_unique.
llvm-svn: 233721
2015-03-31 18:19:06 +00:00
Rui Ueyama 6814d4f52d ELF: Replace a macro with an inlined function.
FINDV4BITMASK macro is defined as a macro so that the macro body is inlined.
We should use inlined functions instead of macros.

llvm-svn: 233719
2015-03-31 18:15:05 +00:00
Rui Ueyama ace9717a9b ELF: Do not use multiple inheritance.
Multiple inheritance is casually used here. Rewriting to not
using multiple inheritance reduces the complexity of the code
and also makes it shorter.

llvm-svn: 233718
2015-03-31 18:10:24 +00:00
Rui Ueyama c351f9563a Use DEBUG_TYPE and DEBUG instead of DEBUG_WITH_TYPE.
llvm-svn: 233710
2015-03-31 16:48:57 +00:00
Simon Atanasyan 1b2a089951 [Mips] Remove redundant #include
No functional changes.

llvm-svn: 233692
2015-03-31 13:04:08 +00:00
Simon Atanasyan 0d26edab09 [Mips] Do not use MIPS assembler and disassembler in the tests
No functional changes.

llvm-svn: 233691
2015-03-31 13:04:01 +00:00
Simon Atanasyan cb576ef415 [Mips] Move the `Elf_RegInfo` structure declaration to the separate file
No functional changes.

llvm-svn: 233618
2015-03-30 22:36:07 +00:00
Simon Atanasyan 2693b5a36c [ELF] Change type of `OutputSection::setType()` argument to int64_t
Type of `OutputSection::_type` field is int64_t. This change makes
the field's and the argument's types consistent and allows to assign
full range of values to the `OutputSection::_type` field.

llvm-svn: 233617
2015-03-30 22:36:01 +00:00
Simon Atanasyan d484653fed [Mips] clang-format the code
No functional changes.

llvm-svn: 233616
2015-03-30 22:35:56 +00:00
Simon Atanasyan 8d08bb2154 [ELF] Use override keyword instead of virtual
No functional changes.

llvm-svn: 233550
2015-03-30 15:07:16 +00:00
Simon Atanasyan 6dec97f2c3 [Mips] Do not use llvm::Optional for GP0 value and TLS section address
Use of llvm::Optional is redundant here. Initializing by default value 0
is enough.

No functional changes.

llvm-svn: 233549
2015-03-30 15:07:11 +00:00
Simon Atanasyan a341e38e39 [Mips] Rename class method merge => mergeHeaderFlags
No functional changes.

llvm-svn: 233548
2015-03-30 15:07:05 +00:00