Commit Graph

2929 Commits

Author SHA1 Message Date
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
Rui Ueyama 72553767d5 ELF: Pass file types instead of type traits to ELFObjectReader.
All <Arch>ELFFileCreateFileTraits structs are the same except its file type.
That means that we don't need to pass the type traits. Instead, we can only
pass file types. By doing this, we can remove copy-pasted boilerplates.

llvm-svn: 234047
2015-04-03 20:29:37 +00:00
Rui Ueyama 077b2bf0c9 Inline typedef'ed type that's used only once. NFC.
result_type is no longer part of the type traits, so keeping it here
is confusing.

llvm-svn: 234044
2015-04-03 19:46:56 +00:00
Simon Atanasyan 400c9852cb [ELF] Fix Layout class name in the comment
No functional changes.

llvm-svn: 234040
2015-04-03 19:35:12 +00:00
Rui Ueyama bba452f23e ELF: Remove partial class definitions of <Arch>LinkingContexts.
What we are doing in ELFTarget.h was dubious. In the file, we define
partial classes of <Arch>LinkingContexts to declare only static member
functions. We have different (complete) class definitions in other files.
They would conflict if they exist in the same compilation unit (because
the ones defined in ELFTarget.h has only static member functions).
I don't think this was valid C++.

http://reviews.llvm.org/D8797

llvm-svn: 234039
2015-04-03 19:32:31 +00:00
Leny Kholodov a0ccf1abb7 Fix for revision r234009 (gcc/msvc compilation differences)
llvm-svn: 234014
2015-04-03 14:44:33 +00:00
Leny Kholodov 95ed78b85a [ARM] Implementation of R_ARM_TARGET1 relocation
This patch provides implementation of R_ARM_TARGET1 relocation with
configuration of its behaviour from a command line. This patch provides
two command line options for GnuLd driver: --arm-target1-rel and
--arm-target1-abs (similar to ld option names with extra prefix 'arm-').
So user may choose which behaviour of R_ARM_TARGET1 is preferred for his
implementation of libc.

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

llvm-svn: 234009
2015-04-03 12:03:47 +00:00
Denis Protivensky ee3261834e [ARM] Avoid potential error in test because of name collision
llvm-svn: 234001
2015-04-03 08:03:23 +00:00
Denis Protivensky c04fbb7340 [ARM] Test wrong ARM entry point address align
llvm-svn: 234000
2015-04-03 07:57:27 +00:00
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