Commit Graph

497 Commits

Author SHA1 Message Date
Bob Haarman b8a59c8aa5 [lld] unified COFF and ELF error handling on new Common/ErrorHandler
Summary:
The COFF linker and the ELF linker have long had similar but separate
Error.h and Error.cpp files to implement error handling. This change
introduces new error handling code in Common/ErrorHandler.h, changes the
COFF and ELF linkers to use it, and removes the old, separate
implementations.

Reviewers: ruiu

Reviewed By: ruiu

Subscribers: smeenai, jyknight, emaste, sdardis, nemanjai, nhaehnle, mgorny, javed.absar, kbarton, fedor.sergeev, llvm-commits

Differential Revision: https://reviews.llvm.org/D39259

llvm-svn: 316624
2017-10-25 22:28:38 +00:00
Rui Ueyama cfa171d68c Simplify.
ArrayRef<T>() equals to ArrayRef<T>(nullptr, 0), so it looks like
we don't need to handle size 0 as a special case.

llvm-svn: 316600
2017-10-25 18:09:54 +00:00
Rui Ueyama d96724db42 Remove a fast lookup table from MergeInputSection.
We used to have a map from section piece offsets to section pieces
as a cache for binary search. But I found that the map took quite a
large amount of memory and didn't make linking faster. So, in this
patch, I removed the map.

This patch saves 566 MiB of RAM (2.019 GiB -> 1.453 GiB) when linking
clang with debug info, and the link time is 4% faster in that test case.

Thanks for Sean Silva for pointing this out.

llvm-svn: 316305
2017-10-22 23:02:07 +00:00
Rui Ueyama 53a9aff93e Simplify.
llvm-svn: 316281
2017-10-22 01:58:30 +00:00
Rui Ueyama 95bf509873 Assume that mergeable input sections are smaller than 4 GiB.
By assuming that mergeable input sections are smaller than 4 GiB,
lld's memory usage when linking clang with debug info drops from
2.788 GiB to 2.019 GiB (measured by valgrind, and that does not include
memory space for mmap'ed files). I think that's a reasonable assumption
given such a large RAM savings, so this patch.

According to valgrind, gold needs 3.54 GiB of RAM to do the same thing.

NB: This patch does not introduce a limitation on the size of
output sections. You can still create sections larger than 4 GiB.

llvm-svn: 316280
2017-10-21 23:20:13 +00:00
Rafael Espindola 849d499e6d Don't call buildSectionOrder multiple times.
This takes linking the linux kernel from 1.52s to 0.58s.

llvm-svn: 316251
2017-10-21 00:05:01 +00:00
Rafael Espindola 4516caef8e Use existing helper. NFC.
llvm-svn: 315654
2017-10-13 00:44:33 +00:00
Rui Ueyama be85529d2b Remove one parameter from Target::getRelExpr.
A section was passed to getRelExpr just to create an error message.
But if there's an invalid relocation, we would eventually report it
in relocateOne. So we don't have to pass a section to getRelExpr.

llvm-svn: 315552
2017-10-12 03:14:06 +00:00
Rui Ueyama 67533a2cb3 Define RelType to represent relocation types.
We were using uint32_t as the type of relocation kind. It has a
readability issue because what Type really means in `uint32_t Type`
is not obvious. It could be a section type, a symbol type or a
relocation type.

Since we do not do any arithemetic operations on relocation types
(e.g. adding one to R_X86_64_PC32 doesn't make sense), it would be
more natural if they are represented as enums. Unfortunately, that
is not doable because relocation type definitions are spread into
multiple header files.

So I decided to use typedef. This still should be better than the
plain uint32_t because the intended type is now obvious.

llvm-svn: 315525
2017-10-11 22:49:24 +00:00
Rui Ueyama 2b714b56a9 Split decompressAndMergeSection into two separate functions.
Even though they are called sequentially, they are separate
operations, so it is better to split it.

llvm-svn: 315422
2017-10-11 03:12:53 +00:00
Rui Ueyama a1b79dff2a Handle input section liveness only in MarkLive.cpp.
The condition whether a section is alive or not by default
is becoming increasingly complex, so the decision of garbage
collection is spreading over InputSection.h and MarkLive.cpp,
which is not a good state.

This moves the code to MarkLive.cpp, to keep the file the central
place to make decisions about garbage collection.

llvm-svn: 315384
2017-10-10 22:59:32 +00:00
George Rimar 7e9c5610c9 [ELF] - Improve "has non-ABS reloc" error.
It did not contain information about relocation type and symbol.

Differential revision: https://reviews.llvm.org/D38623

llvm-svn: 315280
2017-10-10 07:55:07 +00:00
Rui Ueyama c04a91aa39 Make a local variable name shorter. NFC.
llvm-svn: 315271
2017-10-10 04:53:14 +00:00
Rui Ueyama ce135ff6f3 Simplify.
llvm-svn: 315270
2017-10-10 04:45:48 +00:00
Rui Ueyama 124bedbd50 Add comment to InputSectionBase::File.
This patch also moves declarations so that related declarations next
to each other.

llvm-svn: 315266
2017-10-10 03:22:29 +00:00
Rui Ueyama e41f9e0651 Inline a small function. NFC.
llvm-svn: 315096
2017-10-06 20:08:51 +00:00
Shoaib Meenai 50d7b36f5e [ELF] Decompress debug info sections early
When reporting a symbol conflict, LLD parses the debug info to report
source location information. Sections have not been decompressed at this
point, so if an object file contains zlib compressed debug info, LLD
ends up passing this compressed debug info to the DWARF parser, which
causes debug info parsing failures and can trigger assertions in the
parser (as the test case demonstrates).

Decompress debug sections when constructing the LLDDwarfObj to avoid
this issue. This doesn't handle GNU-style compressed debug info sections
(.zdebug_*), which at present are simply ignored by LLDDwarfObj; those
can be done in a follow-up.

Differential Revision: https://reviews.llvm.org/D38491

llvm-svn: 314866
2017-10-04 00:19:41 +00:00
Rui Ueyama 43ca7167ad Inline hot functions.
llvm-svn: 314637
2017-10-01 23:46:31 +00:00
Rui Ueyama 46557f94d0 Fix 32-bit buildbots.
The result of hash_value(StringRef) depends on sizeof(size_t).
That causes lld to create different mergeable table contents on
32-bit machines.

This patch is to use xxHash64 so that we get the same hash values
on 32-bit machines.

llvm-svn: 314603
2017-09-30 21:28:49 +00:00
George Rimar 0b4d10c8b3 [ELF] - Change error message text. NFC.
As suggested in review comments of D38170.

llvm-svn: 314392
2017-09-28 09:29:03 +00:00
George Rimar 5d6efd100b [ELF] - Speedup -r and --emit-relocs
This is "Bug 34688 - lld much slower than bfd when linking the linux kernel"

Inside copyRelocations() we have O(N*M) algorithm, where N - amount of
relocations and M - amount of symbols in symbol table. It isincredibly slow
for linking linux kernel.

Patch creates local search tables to speedup.
With this fix link time goes for me from 12.95s to 0.55s what is almost 23x
faster. (used release LLD).

Differential revision: https://reviews.llvm.org/D38129

llvm-svn: 314282
2017-09-27 09:08:53 +00:00
Davide Italiano f681a8fa3a [AArch64] Implement R_AARCH64_ LD_PREL_LO19.
Fixes PR34660.

Differential Revision:  https://reviews.llvm.org/D38053

llvm-svn: 313841
2017-09-20 23:49:50 +00:00
NAKAMURA Takumi 169dbde262 Revert rL313697, "Compact EhSectionPiece from 32 bytes to 16 bytes."
It broke selfhosting.
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/4896

llvm-svn: 313731
2017-09-20 08:03:18 +00:00
Rui Ueyama 014b0f24ae Compact EhSectionPiece from 32 bytes to 16 bytes.
EhSectionPiece used to have a pointer to a section, but that pointer was
mostly redundant because we almost always know what the section is without
using that pointer. This patch removes the pointer from the struct.

This patch also use uint32_t/int32_t instead of size_t to represent
offsets that are hardly be larger than 4 GiB. At the moment, I think it is
OK even if we cannot handle .eh_frame sections larger than 4 GiB.

Differential Revision: https://reviews.llvm.org/D38012

llvm-svn: 313697
2017-09-19 23:36:48 +00:00
George Rimar af52534e8a [ELF] - Don't crash when --emit-relocs is used with --gc-sections
We crashed when --emit-relocs was used
and relocated section was collected by GC.

Differential revision: https://reviews.llvm.org/D37561

llvm-svn: 313620
2017-09-19 09:28:03 +00:00
George Rimar 696a7f9ac6 [ELF] - Introduce std::vector<InputFile *> global arrays.
This patch removes lot of static Instances arrays from different input file 
classes and introduces global arrays for access instead. Similar to arrays we
have for InputSections/OutputSectionCommands.

It allows to iterate over input files in a non-templated code.

Differential revision: https://reviews.llvm.org/D35987

llvm-svn: 313619
2017-09-19 09:20:54 +00:00
Rafael Espindola 3d9f1c032a Add a helper for checking for weak undef. NFC.
llvm-svn: 313188
2017-09-13 20:43:04 +00:00
Simon Atanasyan 4f70b30d6f [MIPS] Initial support of microMIPS code linking
The patch implements initial support of microMIPS code linking:
  - Handle microMIPS specific relocations.
  - Emit both R1-R5 and R6 microMIPS PLT records.

For now linking mixed set of regular and microMIPS object files is not
supported. Also the patch does not handle (setup and clear) the
least-significant bit of an address which is utilized as the ISA mode
bit and allows to make jump between regular and microMIPS code without
any thunks.

Differential revision: https://reviews.llvm.org/D37335

llvm-svn: 313028
2017-09-12 13:08:24 +00:00
George Rimar 6823c5f0c0 [ELF] - Rename PhdrEntry::First/Last to FirstSec/LastSec. NFC.
As was suggested in D34956 thread.

llvm-svn: 312712
2017-09-07 11:01:10 +00:00
George Rimar 582ede8922 [ELF] - Store pointer to PT_LOAD instead of pointer to first section in OutputSection
It is a bit more convinent and helps to simplify logic 
of program headers allocation a little.

Differential revision: https://reviews.llvm.org/D34956

llvm-svn: 312711
2017-09-07 10:53:07 +00:00
Rafael Espindola 17e93d28f2 Simplify type. NFC.
llvm-svn: 312675
2017-09-06 22:16:32 +00:00
George Rimar e89c5bfbc2 [ELF] - Never call splitIntoPieces() twice. NFC.
Previously it was called twice for .comment synthetic section.
That created 2 pieces of data, which was deduplicated anyways,
but was not clean.

llvm-svn: 312327
2017-09-01 12:04:52 +00:00
Sam Clegg 7dbd1fd73b Update comments: parallel_for_each -> parallelForEach
Also remove unused include of raw_ostream.h

Differential Revision: https://reviews.llvm.org/D37048

llvm-svn: 311587
2017-08-23 19:03:20 +00:00
Rui Ueyama 314a005002 Remove a lock and use a std::unique_ptr instead.
We had a lock to guard BAlloc from being used concurrently, but that
is not very easy to understand. This patch replaces it with a
std::unique_ptr.

llvm-svn: 311056
2017-08-17 00:27:55 +00:00
Rafael Espindola 3bab91332f Fix which file is in an error message.
When reporting an invalid relocation we were blaming the destination
file instead of the file with the relocation.

llvm-svn: 310084
2017-08-04 18:33:16 +00:00
George Rimar d6bcde389a [ELF] - Fix "--symbol-ordering-file doesn't work with linker scripts"
This is PR33889,

Patch adds support of combination of linkerscript and
-symbol-ordering-file option.

If no sorting commands are present in script inside section declaration
and no --sort-section option specified, code uses sorting from ordering 
file if any exist.

Differential revision: https://reviews.llvm.org/D35843

llvm-svn: 310045
2017-08-04 10:25:29 +00:00
Rui Ueyama 709fb2bb10 Rename ObjectFile -> ObjFile.
Rename it because it was too easy to conflict with llvm::object::ObjectFile
which broke buildbots several times.

llvm-svn: 309199
2017-07-26 22:13:32 +00:00
Rafael Espindola 2bd185bcde Fix symbol type with icf.
We were not looking at Repl and so thinking there was no output
section associated with the merged symbol. Because of that it was
produced as absolute.

This was found by an internal round of testing.

llvm-svn: 308681
2017-07-20 21:55:40 +00:00
Rui Ueyama 106179a257 Remove redundant newline.
llvm-svn: 307750
2017-07-12 01:43:01 +00:00
Sean Eveson d54759b236 [ELF] Fix nullptr dereference when creating an error message for a synthetic section.
Differential Revision: https://reviews.llvm.org/D34752

llvm-svn: 307162
2017-07-05 14:55:43 +00:00
Peter Smith 9873c4b509 [ELF] make default for get{ARM,AArch64}UndefinedRelativeWeakVA unreachable
The get{ARM,AArch64}UndefinedRelativeWeakVA() functions should only be
called for PC-relative relocations. Complete the supported pc-relative
relocations in the switch statement and make the default case unreachable.

The R_ARM_TARGET relocation can be evaluated as R_ARM_REL32 but it is only
used in the context of exception tables, and is never output with respect
to a weak reference so it does not appear in the switch statement.
    
Differential Revision: https://reviews.llvm.org/D34138

llvm-svn: 305673
2017-06-19 09:43:43 +00:00
Rafael Espindola f846ce259a Fix weak symbols on arm and aarch64.
Given

.weak target
 .global _start
_start:
 b target

The intention is that the branch goes to the instruction after the
branch, effectively turning it on a nop.  The branch adds the runtime
PC, but we were adding it statically too.

I noticed the oddity by inspection, but llvm-objdump seems to agree,
since it now prints things like:

b       #-4 <_start+0x4>

llvm-svn: 305212
2017-06-12 18:05:01 +00:00
Rui Ueyama 1c837b5fb1 [ICF] Ignore SHF_GROUP flag when comparing two sections.
SHF_GROUP bit doesn't make sense in executables or DSOs, so linkers are
expected to remove that bit from section flags. We did that when we create
output sections.

This patch is to do that earlier than before. Now the flag is dropped when
we instantiate input section objects.

This change improves ICF. Previously, two sections that differ only in
SHF_GROUP flag were not merged, because when the control reached ICF,
the flag was still there. Now the flag is dropped before reaching to ICF,
so the difference is ignored naturally.

This issue was found by pcc.

Differential Revision: https://reviews.llvm.org/D34074

llvm-svn: 305134
2017-06-10 00:38:55 +00:00
Rui Ueyama f08b38cbe1 Simplify. NFC.
llvm-svn: 305048
2017-06-09 03:19:08 +00:00
Rui Ueyama 38a2841665 Use LLVM_FALLTHROUGH.
llvm-svn: 305010
2017-06-08 20:16:21 +00:00
Rafael Espindola db5e56f7b2 Store a single Parent pointer for InputSectionBase.
Before InputSectionBase had an OutputSection pointer, but that was not
always valid. For example, if it was a merge section one actually had
to look at MergeSec->OutSec.

This was brittle and caused bugs like the one fixed by r304260.

We now have a single Parent pointer that points to an OutputSection
for InputSection, but to a SyntheticSection for merge sections and
.eh_frame. This makes it impossible to accidentally access an invalid
OutSec.

llvm-svn: 304338
2017-05-31 20:17:44 +00:00
Rafael Espindola b47c6e5cbd Fix a crash.
We would crash if a SHF_LINK_ORDER section pointed to a non
InputSection section. Since those sections are not merged in order,
SHF_LINK_ORDER is pretty meaningless and we can error on that case.

llvm-svn: 304327
2017-05-31 19:09:52 +00:00
George Rimar 3b189d1643 [ELF] - Do not allow -r to eat comdats.
This is PR33052, "Bug 33052 - -r eats comdats ".

To fix it I stop removing group section from out when -r is given
and fixing SHT_GROUP content when writing it just like we do some
other fixup, e.g. for Rel[a]. (it needs fix for section indices that
are in group).

Differential revision: https://reviews.llvm.org/D33485

llvm-svn: 304140
2017-05-29 08:37:50 +00:00
Rui Ueyama 2f106b4690 When uncompressing sections, remove SHF_COMPRESSED bits. NFC.
In this way, the content and the flag is always consistent, which I
think better than removing the bit when input sections reaches the Writer.

llvm-svn: 303926
2017-05-25 22:00:36 +00:00
Kamil Rytarowski e739e49c0f Replace std::call_once with llvm:call_once
Summary:
This is required on some platforms, as GNU libstdc++ std::call_once is known to be buggy.

This fixes operation of LLD on at least NetBSD and perhaps OpenBSD and Linux PowerPC.

The same change has been introduced to LLVM and LLDB.

Reviewers: ruiu

Reviewed By: ruiu

Subscribers: emaste, #lld

Tags: #lld

Differential Revision: https://reviews.llvm.org/D33508

llvm-svn: 303788
2017-05-24 18:31:48 +00:00
Rafael Espindola a6465bbb72 Alternative way to detemplate GotSection.
GetSection is a template because write calls relocate.

relocate has two parts. The non alloc code really has to be a
template, as it is looking a raw input file data.

The alloc part is only a template because of getSize.

This patch folds the value of getSize early, detemplates
getRelocTargetVA and splits relocate into a templated non alloc case
and a regular function for the alloc case. This has the nice advantage
of making sure we collect all the information we need for relocations
before getting to InputSection::relocateNonAlloc.

Since we know got is alloc, it can just call the function directly and
avoid the template.

llvm-svn: 303355
2017-05-18 16:45:36 +00:00
Peter Smith d54f368e6a [ELF] Support R_ARM_SBREL32 Relocation
This change adds support for the R_ARM_SBREL32 relocation. The relocation
is a base relative relocation that is produced by clang/llvm when -frwpi
is used. The use case for the -frwpi option is position independent data
for embedded systems that do not have a GOT. With -frwpi all data is
accessed via an offset from a base register (usually r9), where r9 is set
at run time to where the data has been loaded. The base of the data is
known as the static base.

The ARM ABI defines the static base as:
B(S) is the addressing origin of the output segment defining the symbol S.
The origin is not required to be the base address of the segment. For
simplicity we choose to use the base address of the segment.

The ARM procedure call standard only defines a read write variant using
R_ARM_SBREL32 relocations. The read-only data is accessed via pc-relative
offsets from the code, this is implemented in clang as -fropi.

Fixes PR32924

Differential Revision: https://reviews.llvm.org/D33280

llvm-svn: 303337
2017-05-18 09:12:21 +00:00
George Rimar 69b17c35d9 [ELF] - Detemplate access to SymTab, DynSymTab, GnuHashTab. NFC.
Follow up for r303150.

llvm-svn: 303153
2017-05-16 10:04:42 +00:00
Rafael Espindola f9e3c9cc22 Detemplate SymbolBody::getGotVA. NFC.
llvm-svn: 302846
2017-05-11 23:28:49 +00:00
Rafael Espindola 88ab9fb163 Detemplate the got.
This is a bit hackish, but allows for a lot of followup cleanups.

llvm-svn: 302845
2017-05-11 23:26:03 +00:00
Rafael Espindola b3aa2c9b9e Reduce template usage. NFC.
llvm-svn: 302828
2017-05-11 21:33:30 +00:00
Rui Ueyama 8a3ef95fc9 Use toString(Inputfile*) to format a file object.
llvm-svn: 301674
2017-04-28 20:00:09 +00:00
Rui Ueyama 0faa53aaab Remove useless local variable.
llvm-svn: 300294
2017-04-14 01:35:04 +00:00
Rui Ueyama c49bdd6d5d Replace uintX_t with uint64_t.
We generally want to use uint64_t instead of uintX_t if the 64-bit
type works for both 32-bit and 64-bit because it is simpler than
the variable-size type.

llvm-svn: 300293
2017-04-14 01:34:45 +00:00
George Rimar e7bf968803 [ELF] - Stop producing broken output for R_386_GOT32[X] relocations.
Previously we silently produced broken output for R_386_GOT32X/R_386_GOT32 
relocations if they were used to compute the address of the symbol’s global
offset table entry without base register when position-independent code is disabled.

Situation happened because of recent ABI changes. Released ABI mentions that
R_386_GOT32X can be calculated in a two different ways (so we did not follow ABI here 
before this patch), but draft ABI also mentions R_386_GOT32 relocation here. 
We should use the same calculations for both relocations.

Problem is that we always calculated them as G + A - GOT (offset from end of GOT),
but for case when PIC is disabled, according to i386 ABI calculation should be G + A,
what should produce just an address in GOT finally.

ABI: https://github.com/hjl-tools/x86-psABI/wiki/intel386-psABI-draft.pdf (p36, p60).
llvm-svn: 299812
2017-04-08 06:14:14 +00:00
Rui Ueyama b87602032a Change the error message format for undefined symbols.
Previously, undefined symbol errors are one line like this
and wasn't easy to read.

  /ssd/clang/bin/ld.lld: error: /ssd/llvm-project/lld/ELF/Writer.cpp:207: undefined symbol 'lld:🧝:EhFrameSection<llvm::object::ELFType<(llvm::support::endianness)0, true> >::addSection(lld:🧝:InputSectionBase*)'

This patch make it more structured like this.

  bin/ld.lld: error: undefined symbol: lld:🧝:EhFrameSection<llvm::object::ELFType<(llvm::support::endianness)0, true>
  >>> Referenced by Writer.cpp:207 (/ssd/llvm-project/lld/ELF/Writer.cpp:207)
  >>>               Writer.cpp.o in archive lib/liblldELF.a

Discussion thread:
http://lists.llvm.org/pipermail/llvm-dev/2017-March/111459.html

Differential Revision: https://reviews.llvm.org/D31481

llvm-svn: 299097
2017-03-30 19:13:47 +00:00
Rui Ueyama 8d753caa78 Remove parameter names from template instantiations to make them compact. NFC.
llvm-svn: 299025
2017-03-29 20:15:29 +00:00
Rui Ueyama ff524bf739 Sort. NFC.
llvm-svn: 298797
2017-03-26 04:10:43 +00:00
Rui Ueyama 34e3d50d18 Force @{init,fini}_array if section name starts with ".{init,fini}_array.".
Fixes https://bugs.llvm.org/show_bug.cgi?id=32307.

Differential Revision: https://reviews.llvm.org/D31255

llvm-svn: 298569
2017-03-23 01:00:41 +00:00
Rui Ueyama 7ab38c3a12 Define Config::Is64.
This is a shorthand for Config->Wordsize == 8. So this is not strictly
necessary but seems handy. "Is 64 bit?" is easier to read than "Is
wordsize 8 byte?"

llvm-svn: 298463
2017-03-22 00:01:11 +00:00
George Rimar 1ec03e46a7 [ELF] - Detemplate InputSection::getRelocatedSection(). NFC.
llvm-svn: 298353
2017-03-21 09:13:27 +00:00
George Rimar 76e562ab1b [ELF] - Detemplate InputSectionBase::uncompress(). NFC
llvm-svn: 298351
2017-03-21 09:08:58 +00:00
George Rimar 9353e2dbfb [ELF] - Detemplate InputSectionBase::getLinkOrderDep(). NFC.
llvm-svn: 298346
2017-03-21 08:29:48 +00:00
Simon Atanasyan d34a3631b2 [ELF][MIPS] Calculate relocations agains _gp_disp / __gnu_local_gp using dedicated 'expressions'
The patch introduces two new relocations expressions R_MIPS_GOT_GP and
R_MIPS_GOT_GP_PC. The first one represents a current value of `_gp`
pointer and used to calculate relocations against the `__gnu_local_gp`
symbol. The second one represents the offset between the beginning of
the function and the `_gp` pointer's value.

There are two motivations for introducing new expressions:
- It's better to keep all non-trivial relocation calculations in the
  single place - `getRelocTargetVA` function.
- Relocations against both `_gp_disp` and `__gnu_local_gp` symbols
  depend on the `_gp` value. It's a magical value points to the "middle"
  of GOT. Now all relocations use a common `_gp` value. But in fact,
  under some conditions each input file might require its own `_gp`
  value. I'm going to implement it in the future patches. So it's
  better to make `MipsGotSection` responsible for calculation of
  the `_gp` value.

llvm-svn: 298306
2017-03-20 21:03:43 +00:00
Rui Ueyama d57e74b7d3 Compute Config member function return values only once.
We had a few Config member functions that returns configuration values.
For example, we had is64() which returns true if the target is 64-bit.
The return values of these functions are constant and never change.

This patch is to compute them only once to make it clear that they'll
never change.

llvm-svn: 298168
2017-03-17 23:29:01 +00:00
George Rimar 4afe42e5c4 [ELF] - Detemplate SymbolBody::getGotOffset(). NFC.
llvm-svn: 298091
2017-03-17 14:12:51 +00:00
George Rimar f64618a621 [ELF] - Detemplate SymbolBody::getVA and SymbolBody::getPltVA. NFC.
llvm-svn: 298071
2017-03-17 11:56:54 +00:00
Eugene Leviant 2968547997 [ELF] Fix error reporting for synthetic sections
Synthetic sections don't belong to any input file, but still they
are input sections. Whenever problem occurs with relocations in
these sections lld crashes in error reporting, trying to print
input file name.

Differential revision: https://reviews.llvm.org/D30889

llvm-svn: 297711
2017-03-14 08:33:45 +00:00
Rafael Espindola 5616adf655 Remove DefinedSynthetic.
With this we have a single section hierarchy. It is a bit less code,
but the main advantage will be in a future patch being able to handle

foo = symbol_in_obj;

in a linker script. Currently that fails since we try to find the
output section of symbol_in_obj.  With this we should be able to just
return an InputSection from the expression.

llvm-svn: 297313
2017-03-08 22:36:28 +00:00
Rafael Espindola fcd208fdb3 Use uint32_t for alignment in more places, NFC.
llvm-svn: 297305
2017-03-08 19:35:29 +00:00
Rafael Espindola 5e434b3f11 Remove unnecessary template.
llvm-svn: 297293
2017-03-08 16:08:36 +00:00
Rafael Espindola e1294091d3 Remove unnecessary template. NFC.
llvm-svn: 297292
2017-03-08 16:03:41 +00:00
Rafael Espindola 35ae65ee2b Rename one of the getOffset methods.
It is sufficiently different in that it returns an offset in the input
file, not the output section.

llvm-svn: 297290
2017-03-08 15:57:17 +00:00
Rafael Espindola 76b6bd355d Remove unnecessary template. NFC.
llvm-svn: 297287
2017-03-08 15:44:30 +00:00
Rafael Espindola c86b2cddc8 Convert a few more uses of uintX_t to uint64_t.
llvm-svn: 297286
2017-03-08 15:34:04 +00:00
Rafael Espindola bdd2e3e36c Remove redundant member of InputSectionBase. NFC.
With this InputSectionBase is now 144 bytes.

llvm-svn: 297278
2017-03-08 14:12:52 +00:00
Rafael Espindola c8de15bdda Rename remaining uses of Addralign to Alignment.
llvm-svn: 297146
2017-03-07 15:11:21 +00:00
Rui Ueyama af6198d96d Remove Config->Rela and define Config->isRela() instead.
llvm-svn: 297108
2017-03-07 00:43:53 +00:00
Rui Ueyama df8eb17d21 Remove Config->Mips64EL and define Config->isMips64EL() instead.
llvm-svn: 297107
2017-03-07 00:43:33 +00:00
Rafael Espindola 2a80e1180e Make Discarded a InputSectionBase.
NFC, just a bit simpler.

llvm-svn: 297087
2017-03-06 22:36:19 +00:00
Rafael Espindola 5c02b741eb Detemplate EhInputSection. NFC.
llvm-svn: 297077
2017-03-06 21:17:18 +00:00
Rafael Espindola 6119b865ec Detemplate merge (input and synthetic) sections. NFC.
llvm-svn: 297061
2017-03-06 20:23:56 +00:00
Rui Ueyama 80474a26b9 De-template DefinedRegular.
Differential Revision: https://reviews.llvm.org/D30348

llvm-svn: 296508
2017-02-28 19:29:55 +00:00
Rui Ueyama 9320cb0719 De-template SyntheticSection.
This class didn't use ELFT.

llvm-svn: 296313
2017-02-27 02:56:02 +00:00
Rui Ueyama 536a26706f Move SymbolTable<ELFT>::Sections out of the class.
The list of all input sections was defined in SymbolTable class for a
historical reason. The list itself is not a template. However, because
SymbolTable class is a template, we needed to pass around ELFT to access
the list. This patch moves the list out of the class so that it doesn't
need ELFT.

llvm-svn: 296309
2017-02-27 02:32:08 +00:00
Rui Ueyama 9d1bacb1b4 Remove useless template so that Out<ELFT> becomes just Out.
llvm-svn: 296307
2017-02-27 02:31:26 +00:00
Rafael Espindola 24e6f363c5 Merge OutputSectionBase and OutputSection. NFC.
Now that all special sections are SyntheticSections, we only need one
OutputSection class.

llvm-svn: 296127
2017-02-24 15:07:30 +00:00
Rafael Espindola 66b4e21534 Convert EhOutputSection to be a synthetic section.
With this we complete the transition out of special output sections,
and with the previous patches it should be possible to merge
OutputSectionBase and OuputSection.

llvm-svn: 296023
2017-02-23 22:06:28 +00:00
Rafael Espindola 774ea7d0a9 Make InputSection a class. NFC.
With the current design an InputSection is basically anything that
goes directly in a OutputSection. That includes plain input section
but also synthetic sections, so this should probably not be a
template.

llvm-svn: 295993
2017-02-23 16:49:07 +00:00
Petr Hosek b27bb59a5d [ELF] Ignore R_*_NONE relocs when relocating non-alloc sections
We shouldn't report an error for R_*_NONE relocs since we're emitting
them when writing relocations to discarded sections.

Differential Revision: https://reviews.llvm.org/D30279

llvm-svn: 295936
2017-02-23 06:22:28 +00:00
Rafael Espindola c8d0c7a0e3 Add another missing instantiation.
llvm-svn: 295932
2017-02-23 03:38:14 +00:00
Rafael Espindola 277155b054 Add missing template instantiations.
llvm-svn: 295929
2017-02-23 03:18:03 +00:00
Rafael Espindola 4b8baab907 Trying to fix the windows build.
llvm-svn: 295925
2017-02-23 02:50:50 +00:00
Rafael Espindola c404d50d7c Merge InputSectionData and InputSectionBase.
Now that InputSectionBase is not a template there is no reason to have
the two.

llvm-svn: 295924
2017-02-23 02:32:18 +00:00
Rafael Espindola b4c9b81aad Convert InputSectionBase to a class.
Removing this template is not a big win by itself, but opens the way
for removing more templates.

llvm-svn: 295923
2017-02-23 02:28:28 +00:00