Commit Graph

8155 Commits

Author SHA1 Message Date
George Rimar 35e846e14d [ELF] - Detemplate GdbIndexSection.
Patch moves Sections array to
InputFile (root class for input files).

That allows to detemplate GdbIndexSection.

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

llvm-svn: 298345
2017-03-21 08:19:34 +00:00
Reid Kleckner 7668182e44 [COFF] Don't let /def override /out filename
Summary:
This also delays setting the output filename based on the first input
argument until after processing /def.

Fixes PR32354

Reviewers: ruiu, pcc

Subscribers: llvm-commits

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

llvm-svn: 298327
2017-03-21 00:12:51 +00:00
Rafael Espindola b57e496dfa Move OffsetInArchive to BitcodeFile.
It is the only file type that needs it.

llvm-svn: 298323
2017-03-20 23:47:06 +00:00
Zachary Turner 82a0c97b32 Add a function to MD5 a file's contents.
In doing so, clean up the MD5 interface a little.  Most
existing users only care about the lower 8 bytes of an MD5,
but for some users that care about the upper and lower,
there wasn't a good interface.  Furthermore, consumers
of the MD5 checksum were required to handle endianness
details on their own, so it seems reasonable to abstract
this into a nicer interface that just gives you the right
value.

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

llvm-svn: 298322
2017-03-20 23:33:18 +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
Simon Atanasyan 5378e423e5 [ELF][MIPS] Follow-up to r298272. Fix typo to fix buildbot.
llvm-svn: 298304
2017-03-20 20:49:44 +00:00
George Rimar 14534eb8a2 [ELF] - Detemplate MipsGotSection<ELFT>
This continues detemplation process.

Detemplating MipsGotSection<ELFT> is helpfull because can
help to detemplate getRelocTargetVA. (one more change is required)
It opens road to detemplation of GotSection<ELFT> and probably
something else after that.

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

llvm-svn: 298272
2017-03-20 16:44:28 +00:00
Peter Collingbourne 25a17ba4c7 Support, LTO: When pruning a directory, ignore files matching a prefix.
This is a safeguard against data loss if the user specifies a directory
that is not a cache directory. Teach the existing cache pruning clients
to create files with appropriate names.

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

llvm-svn: 298271
2017-03-20 16:41:57 +00:00
George Rimar 6c2949da39 [ELF] - Detemplate BuildIdSection section.
Does not introduce anything new,
just performs detemplate, using methods we
already have.

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

llvm-svn: 298269
2017-03-20 16:40:21 +00:00
Rafael Espindola 195f23c53b Inline a few functions.
I don't foresee having to makes these functions any stricter or
fancier, so it probably makes sense to inline them.

llvm-svn: 298252
2017-03-20 14:35:41 +00:00
Rafael Espindola 49592cf679 Initialize dot.
This would fix an initialized error found by msan. The error is not
showing after r298241, but it is not clear why.

llvm-svn: 298251
2017-03-20 14:33:33 +00:00
George Rimar 05423488a1 [ELF] - Simplify redundant templated call. NFC.
llvm-svn: 298244
2017-03-20 10:47:00 +00:00
George Rimar f6abfd7a53 [ELF] - Get rid of uintX_t in GdbIndexSection. NFC.
llvm-svn: 298243
2017-03-20 10:40:40 +00:00
George Rimar b17d16a2a1 [ELF] - Reuse Config->IsLE. NFC.
llvm-svn: 298242
2017-03-20 10:16:57 +00:00
George Rimar a8dba48762 [ELF] - Combine LinkerScriptBase and LinkerScript<ELFT>
Patch removes templated linkerscript class.

Unfortunately that required 2 additional static methods
findSymbol() and addRegularSymbol() because code
depends on Symtab<ELFT>::X

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

llvm-svn: 298241
2017-03-20 10:09:58 +00:00
George Rimar 009833d377 [ELF] - Apply clang-format. NFC.
llvm-svn: 298240
2017-03-20 09:51:18 +00:00
Simon Atanasyan 8c75311906 [ELF] clang-format sortMipsSymbols. NFC
llvm-svn: 298230
2017-03-19 19:32:51 +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
Rui Ueyama fd06b73466 Define Config::isLE and Config::wordsize.
isLE() return true if the target is little-endian.
wordsize() returns 8 for 64-bit and 4 for 32-bit.

llvm-svn: 298167
2017-03-17 23:28:41 +00:00
Peter Collingbourne 5758b2e488 ELF: Change check(Expected<T>, const Twine &) to call toString instead of converting to an error code.
llvm-svn: 298155
2017-03-17 22:06:36 +00:00
Evgeniy Stepanov 4b78036ba8 [ELF] Restore GC handling of LINK_ORDER, C-named sections.
__start_xxx symbol keeps section xxx alive only if it is not
SHF_LINK_ORDER. Such sections can be used for user metadata, when
__start_xxx is used to iterate over section contents at runtime, and
the liveness is determined solely by the linked (associated) section.

This was earlier implemented in r294592, and broken in r296723.

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

llvm-svn: 298154
2017-03-17 22:04:52 +00:00
Bob Haarman f790f788b6 recommend using llvm-ar when finding undefined references and empty archives
Summary:
When we perform LTO builds with a version of ar that does not
understand LLVM bitcode objects, we end up with undefined references,
because our archive files do not list the bitcode symbols in their
indices. The error messages do not make it clear what the real problem
is. This change adds a note that points out the likely problem and
solution. It is similar in spirit to r282633, but aims to avoid false
positives by only triggering when we see both undefined references and
archives without symbols in their indices.

Fixes PR32281.

Reviewers: davide, ruiu, tejohnson

Subscribers: llvm-commits

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

llvm-svn: 298124
2017-03-17 21:32:49 +00:00
George Rimar a918957b05 [ELF] - Move template instantiations to the end of file. NFC.
To be consistent with other code, addresses post 
commit review comments.

llvm-svn: 298102
2017-03-17 16:50:07 +00:00
Rafael Espindola 7ba5f47eb8 Handle & and | of non abs values.
Handling & in particular is probably important because of its use in
aligning addresses.

llvm-svn: 298096
2017-03-17 14:55:36 +00:00
Rafael Espindola 5f08a1dca8 Refuse to add two non absolute symbols.
Since there is no way to produce the correct answer at runtime, it is
probably better to just err.

llvm-svn: 298094
2017-03-17 14:51:07 +00:00
Simon Atanasyan 462f84a736 [ELF][MIPS] Always collect .reginfo, .MIPS.options, and .MIPS.abiflags input sections
Do not take in account the `Live` flag while collecting .reginfo, .MIPS.options,
and .MIPS.abiflags input sections to produce corresponding output sections.
These sections have information purpose and should be always produced per
ABI requirements.

llvm-svn: 298093
2017-03-17 14:27:55 +00:00
George Rimar 4afe42e5c4 [ELF] - Detemplate SymbolBody::getGotOffset(). NFC.
llvm-svn: 298091
2017-03-17 14:12:51 +00:00
Rafael Espindola f2115f04c8 Support non abs values in the rhs of +.
llvm-svn: 298088
2017-03-17 13:45:36 +00:00
George Rimar 8fe7aea527 [ELF] - Detemplate findSection() global static method. NFC.
llvm-svn: 298087
2017-03-17 13:43:24 +00:00
George Rimar 176d606020 [ELF] - Recommit r298078 "[ELF] - Simplify logic of creating "COMMON" section."
With fix of next warning:
Writer.cpp:361:3: warning: suggest parentheses around assignment used as truth value [-Wparentheses]

Original commit message:

Patch reuses BssSection section to simplify creation of 
COMMON section.

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

llvm-svn: 298086
2017-03-17 13:31:07 +00:00
George Rimar 4ddd9c9bd6 [ELF] - Revert r298078 and 298082
It segfaults.

llvm-svn: 298084
2017-03-17 13:21:22 +00:00
Rafael Espindola 5d5a267830 Add a test that now passes.
llvm-svn: 298083
2017-03-17 13:19:15 +00:00
George Rimar 69739e6d1d [ELF] - Fix warning.
Writer.cpp:361:3: warning: suggest parentheses around assignment used as truth value [-Wparentheses]

llvm-svn: 298082
2017-03-17 13:15:35 +00:00
Rafael Espindola 72dc195d78 Change our linker script expr representation.
This fixes pr32031 by representing the expressions results as a
SectionBase and offset. This allows us to use an input section
directly instead of getting lost trying to compute an offset in an
outputsection when not all the information is available yet.

This also creates a struct to represent the *value* of and expression,
allowing the expression itself to be a simple typedef. I think this is
easier to read and will make it easier to extend the expression
computation to handle more complicated cases.

llvm-svn: 298079
2017-03-17 13:05:04 +00:00
George Rimar f6c300e86d [ELF] - Simplify logic of creating "COMMON" section.
Patch reuses BssSection section to simplify creation of 
COMMON section.

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

llvm-svn: 298078
2017-03-17 13:04:06 +00:00
Rafael Espindola 490fccb170 Remove unnecessary (). NFC.
llvm-svn: 298076
2017-03-17 13:00:45 +00:00
George Rimar 97def8c2ff [ELF] - Detemplate DynamicReloc class. NFC.
llvm-svn: 298072
2017-03-17 12:07:44 +00:00
George Rimar f64618a621 [ELF] - Detemplate SymbolBody::getVA and SymbolBody::getPltVA. NFC.
llvm-svn: 298071
2017-03-17 11:56:54 +00:00
George Rimar 5a5c54f78e [ELF] - Fix linux build bot.
Error was:
Relocations.cpp:792:38: error: expected primary-expression before ‘>’ token
         In<ELFT>::Iplt->addEntry<ELFT>(Body);

llvm-svn: 298070
2017-03-17 11:41:56 +00:00
George Rimar dfc020e9f9 [ELF] - Detemplate PltSection. NFC.
Alternative approach can be remove templated method
either, like D31028 do.

llvm-svn: 298065
2017-03-17 11:01:57 +00:00
George Rimar fe93282a1b [ELF] - Fixed cache.ll testcase.
It failed for me under windows,
touch reported invalid date format.

Seems related to 12h/24h format, though
I don't understant why 197001010200 does not work, 
but 197001010300 works, I see no logic here.

Changed to 197001011200.

llvm-svn: 298064
2017-03-17 10:32:10 +00:00
George Rimar 1ab9cf49d0 [ELF] - Recommit "[ELF] - Make Bss and BssRelRo sections to be synthetic (#3)."
Was fixed, details on review page.

Original commit message:

That removes CopyRelSection class completely, making
Bss/BssRelRo to be just regular synthetics.

This is splitted from D30541 and polished.
Difference from D30541 that all logic of SharedSymbol
converting to DefinedRegular was removed for now and
probably will be posted as separate patch.

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

llvm-svn: 298062
2017-03-17 10:14:53 +00:00
Andre Vieira d74f31bf13 [ARM] Change tests after fixing branch label for Thumb targets
Patch to fix lld tests after my llvm-objdump patch to fix branch labels for
Thumb targets.

Reviewed by: emaste

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

llvm-svn: 298055
2017-03-17 09:37:02 +00:00
Peter Collingbourne a3abce911a Fix the touch command to be Darwin-compatible.
llvm-svn: 298038
2017-03-17 02:44:23 +00:00
Peter Collingbourne ee59e43f92 ELF: Add cache pruning support.
This patch causes us to use pruneCache() to prune the ThinLTO cache after
completing LTO. A new flag --thinlto-cache-policy allows users to configure
the policy.

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

llvm-svn: 298036
2017-03-17 02:24:16 +00:00
Peter Collingbourne 8713bf69b6 COFF: Strip /lldsavetemps from MSVC command line during /msvclto.
llvm-svn: 298035
2017-03-17 02:11:09 +00:00
Peter Collingbourne db7447deed COFF: Do not create empty temporary archives for /msvclto.
The MSVC linker doesn't support them.

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

llvm-svn: 298034
2017-03-17 02:04:22 +00:00
Peter Collingbourne a6ffbdd922 COFF: Fix use-after-free in /msvclto implementation.
The Archive object owns the memory buffers of any thin archive members, so we
need to make sure the object is still in scope when we access archive members.

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

llvm-svn: 298033
2017-03-17 02:03:20 +00:00
Peter Collingbourne 128423f99b LTO: Fix a potential race condition in the caching API.
After the call to sys::fs::exists succeeds, indicating a cache hit, we call
AddFile and the client will open the file using the supplied path. If the
client is using cache pruning, there is a potential race between the pruner
and the client. To avoid this, change the caching API so that it provides
a MemoryBuffer to the client, and have clients use that MemoryBuffer where
possible.

This scheme won't work with the gold plugin because the plugin API expects a
file path. So we have the gold plugin use the buffer identifier as a path and
live with the race for now. (Note that the gold plugin isn't actually affected
by the problem at the moment because it doesn't support cache pruning.)

This effectively reverts r279883 modulo the change to use the existing path
in the gold plugin.

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

llvm-svn: 298020
2017-03-17 00:34:07 +00:00
Rui Ueyama 98e55de699 Revert r297850: [ELF] - Linkerscript: make Dot public and remove getDot(). NFC.
This reverts commit r297850 because this change was made
based on a miscommunication.

llvm-svn: 298001
2017-03-16 21:50:30 +00:00
Rui Ueyama e1bf1365d7 Do not pass archive files containing non-native object files.
The MSVC linker doesn't like archive files containing non-native object
files.

When we are doing an LTO build, we may create archive files containing
both LLVM bitcode files and native object files. For example, if a
project contains assembly files and C++ files, we create native object
files for the assembly files and LLVM bitcode files for the C++ files.

With the /msvclto option, LLD passes archive files to the MSVC linker.
Previously, we didn't pass archive files if they contain at least one
bitcode files. That wasn't correct because the native object files that
weren't passed to the MSVC linker may be needed to complete linking.

In this patch, we create new temporary archive files to strip bitcode
files.

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

llvm-svn: 297997
2017-03-16 21:19:36 +00:00
George Rimar 7385d4358a [ELF] - Rename Config->Is64Bit() to is64(). NFC.
Addresses post commit review comment.

llvm-svn: 297953
2017-03-16 13:41:29 +00:00
George Rimar 4670bb00b5 [ELF] - Detemplate SymbolBody::getGotPltVA and SymbolBody::getGotPltOffset(). NFC.
That opens road to detemplate PltSection<ELFT>,
what allows then to detemplate all methods of SymbolBody.

llvm-svn: 297950
2017-03-16 12:58:11 +00:00
George Rimar f00c183847 [ELF] Fix builbot.
Excessive typename keyword.

llvm-svn: 297949
2017-03-16 12:20:19 +00:00
George Rimar 5781338f0e [ELF] - Added test for versioned symbols involved in copy relocations.
This test would have been broken if we convert SharedSymbols
to DefinerRegular without saving the symbol version information when
creating .bss/.bss.rel.ro sections for copy relocations.

Relative to D30541, PR32167

llvm-svn: 297948
2017-03-16 12:17:49 +00:00
George Rimar a0b1e2c3d8 [ELF] - Don't use uintX_t in DynamicReloc<ELFT>. NFC.
That allows to detemplate getGotPltOffset/getGotPltVA
methods of SymbolBody and also will help to detemplate
DynamicReloc itself later.

llvm-svn: 297946
2017-03-16 11:42:16 +00:00
George Rimar 7702bc237e [ELF] - Removed unused templates #4. NFC.
llvm-svn: 297944
2017-03-16 11:20:02 +00:00
George Rimar 69268a8ab3 [ELF] - Detemplate SymbolBody::getOutputSection(). NFC.
llvm-svn: 297943
2017-03-16 11:06:13 +00:00
George Rimar a92dc2bbd3 [ELF] - Removed unused template #3. NFC.
llvm-svn: 297942
2017-03-16 10:55:45 +00:00
George Rimar d3ea775894 [ELF] - Removed unused template #2. NFC.
llvm-svn: 297941
2017-03-16 10:48:40 +00:00
George Rimar 7b8270424e [ELF] Detemplate ThunkSection and Thunk classes. NFC.
llvm-svn: 297939
2017-03-16 10:40:50 +00:00
George Rimar 49a47f2a6d [ELF] - Removed unused template #1. NFC
llvm-svn: 297938
2017-03-16 10:29:44 +00:00
George Rimar f98c5c126c [ELF] - Detemplate OutputSection::assignOffsets. NFC.
llvm-svn: 297937
2017-03-16 10:24:54 +00:00
George Rimar 47bed8c9f7 Revert r297813 "[ELF] - Make Bss and BssRelRo sections to be synthetic (#3)."
I suppose it is the reason of BB fail:
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/921

https://bugs.llvm.org/show_bug.cgi?id=32167

llvm-svn: 297933
2017-03-16 08:44:53 +00:00
Zachary Turner 337e884643 Fix lld pdb test.
It was assuming various things about the PDB like file size
which are going to be too high maintenance to maintain in
a test.

llvm-svn: 297908
2017-03-15 22:58:10 +00:00
Zachary Turner ea4e60754e [pdb] Write the module info and symbol record streams.
Previously we did not have support for writing detailed
module information for each module, as well as the symbol
records.  This patch adds support for this, and in doing
so enables the ability to construct minimal PDBs from
just a few lines of YAML.  A test is added to illustrate
this functionality.

llvm-svn: 297900
2017-03-15 22:18:53 +00:00
George Rimar 20055d4cd2 [ELF] - Linkerscript: make Dot public and remove getDot(). NFC.
Suggested by Rui Ueyama,
also groups member variables in a single place, while I am here.

llvm-svn: 297850
2017-03-15 16:07:02 +00:00
George Rimar 503206c567 [ELF] - Move LinkerScript::discard to LinkerScriptBase. NFC.
Became possible after r297844

llvm-svn: 297848
2017-03-15 15:42:44 +00:00
George Rimar 9782ca5b68 [ELF] - Split struct In<ELFT> to have templated and non-templated sections areas.
Patch splits In<ELFT> into 2 classes: one for non-templated sections, 
second contains ELFT templated ones.
That allows to code that was detemplated to access non-templated sections freely,
and should open road for futher detemplation proccess.

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

llvm-svn: 297844
2017-03-15 15:29:29 +00:00
Rafael Espindola 4820060dc6 Use uint32_t for alignment.
llvm-svn: 297831
2017-03-15 12:43:54 +00:00
Rafael Espindola a156555b5e simplify. NFC
llvm-svn: 297829
2017-03-15 12:31:54 +00:00
George Rimar 42886c4b47 [ELF] - Detemplate MipsRldMapSection. NFC.
After introducing Config->is64Bit() and 
recent changes in LinkerScriptBase, some
sections can be detemplated trivially. This 
is one of such cases.

llvm-svn: 297825
2017-03-15 12:02:31 +00:00
George Rimar 49648004ed [ELF] - Detemplate StringTableSection.
StringTableSection was <ELFT> templated previously,

It disallow to de-template code that uses it,
for example LinkerScript<ELFT>::discard uses it as:
if (S == In<ELFT>::ShStrTab)
  error("discarding .shstrtab section is not allowed");

It seems we can try to detemplate some of synthetic sections
and somehow make them available for non-templated calls.
(move out of In<ELFT> struct probably).

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

llvm-svn: 297815
2017-03-15 09:32:36 +00:00
George Rimar 22e3e7d165 [ELF] - Make Bss and BssRelRo sections to be synthetic (#3).
That removes CopyRelSection class completely, making
Bss/BssRelRo to be just regular synthetics.

This is splitted from D30541 and polished.
Difference from D30541 that all logic of SharedSymbol
converting to DefinedRegular was removed for now and
probably will be posted as separate patch.

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

llvm-svn: 297814
2017-03-15 09:21:29 +00:00
George Rimar 10f74fc10b [ELF] - Detemplate GotPltSection and IgotPltSection sections.
Patch introduces Config->is64Bit() and with help of that detemplates
GotPltSection and IgotPltSection sections

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

llvm-svn: 297813
2017-03-15 09:12:56 +00:00
Petr Hosek 3b4e29ba68 [ELF] Update tests to work even with modified defaults
D30229 changes the defaults based on section names to match the
GAS behavior, which breaks some of the tests that rely on the old
defaults.

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

llvm-svn: 297803
2017-03-15 03:38:48 +00:00
Petr Hosek 02ad516b2e Support ABSOLUTE on the right hand side in linker scripts
This also requires postponing the assignment the assignment of
symbols defined in input linker scripts since those can refer to
output sections and in case we don't have a SECTIONS command, we
need to wait until all output sections have been created and
assigned addresses.

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

llvm-svn: 297802
2017-03-15 03:33:23 +00:00
Rafael Espindola d3c22f08b3 Don't create copy relocs or dummy plt's if given -z notext.
Being passed -z notext is a pretty strong indication that the user is
OK with text relocations. This is not the same behavior as bfd, but
bfd defaults to -z notext, so it has to try to avoid text relocations
and use them as a last resort.

llvm-svn: 297789
2017-03-14 22:50:07 +00:00
George Rimar a2a1ef1abc [ELF] - Move members of LinkerScript to LinkerScriptBase. NFC.
That moves all members that s possible to move for now (all which
does not depend on ELFT templating).

After that change LinkerScript contains only 8 methods in total,
and I believe it is possible to move them all after tweaking other
parts of linker. And we will be able to have single class for 
linkerscript at the end.

llvm-svn: 297735
2017-03-14 12:03:34 +00:00
George Rimar 23e6a02450 [ELF] - Remove unnecessary template #6. NFC.
llvm-svn: 297734
2017-03-14 11:31:28 +00:00
George Rimar f7f0d08827 [ELF] - Remove unnecessary template #5. NFC.
llvm-svn: 297732
2017-03-14 11:23:33 +00:00
George Rimar d83ce1b49d [ELF] - Devirtualize LinkerScriptBase::getOutputSectionSize. NFC.
It does not use ELFT templates so can be non-virtual.

llvm-svn: 297727
2017-03-14 10:24:47 +00:00
George Rimar 851dc1e84d [ELF] - Devirtualize LinkerScriptBase::getOutputSection
It does not use ELFT templates so can be non-virtual.

llvm-svn: 297725
2017-03-14 10:15:53 +00:00
George Rimar d0bee506a0 [ELF] - Simplify LinkerScriptBase::getDot(). NFC.
That makes it not dependent on virtual call,
keeping logic the same.

llvm-svn: 297723
2017-03-14 10:05:43 +00:00
George Rimar 0c1c8085bc [ELF] - Move ThreadBssOffset and Dot to LinkerScriptBase. NFC.
One more step to combine LinkerScript and LinkerScriptBase.

llvm-svn: 297722
2017-03-14 10:00:19 +00:00
George Rimar e21c3af7e9 [ELF] - Remove unnecessary template #4. NFC.
OutputSectionFactory has no ELFT templates anymore.

llvm-svn: 297720
2017-03-14 09:30:25 +00:00
George Rimar 09268b7b1e [ELF] - Remove unnecessary template #3. NFC.
llvm-svn: 297719
2017-03-14 09:25:03 +00:00
George Rimar f08b592390 [ELF] - Remove unnecessary template #2. NFC.
llvm-svn: 297718
2017-03-14 09:19:34 +00:00
George Rimar 788fe38f99 [ELF] - Remove unnecessary template. NFC.
llvm-svn: 297717
2017-03-14 09:14:28 +00:00
George Rimar 2d2621090d [ELF] - Step to combine LinkerScript and LinkerScriptBase
We can move all not templated functionality to LinkerScriptBase.
Patch do that for hasPhdrsCommands() and shows how it helps to detemplate
things in other places.

Probably we should be able to merge these 2 classes into single one after such steps.
Even if not, it still looks as reasonable cleanup for me.

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

llvm-svn: 297714
2017-03-14 09:03:53 +00:00
Eugene Leviant 5784e96f5c [ELF] Fix LMA offset calculation
Differential revision: https://reviews.llvm.org/D30832

llvm-svn: 297713
2017-03-14 08:57:09 +00:00
Eugene Leviant 30c1b436ad [ELF] Fix crash when .eh_frame(_hdr) is discarded
lld crashes when .eh_frame or .eh_frame_hdr section is discarded
in linker script and there is no PHDRS directive.

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

llvm-svn: 297712
2017-03-14 08:49:09 +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
Rui Ueyama 034a33a942 Remove a useless temporary variable.
llvm-svn: 297687
2017-03-13 23:26:37 +00:00
Rui Ueyama f327999a45 Simplify and add comments. NFC.
llvm-svn: 297686
2017-03-13 23:23:40 +00:00
Rui Ueyama fed8b570b7 Make FileOutputBuffer fail early if you pass a directory.
Previously, it created a temporary directory and then failed when
FileOutputBuffer tried to rename that file to the destination file
(which is actually a directory name).

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

llvm-svn: 297679
2017-03-13 22:19:05 +00:00
Rui Ueyama 8ebf6588a5 Add a comment to say that -build-id=sha1 is a synonym for tree.
llvm-svn: 297677
2017-03-13 21:48:38 +00:00
Rui Ueyama eaeca5ed79 [ELF] Fail the link early if an output path is invalid
Patch from James Henderson.

If a user has a long link, e.g. due to a large LTO link, they do not
wish to run it and find that it failed because there was a mistake in
their command-line, after they waited for some significant amount of
time. This change adds some basic checking of the linker output file
path, which is run shortly after parsing the command-line and linker
script. An error is emitted if LLD cannot write to the specified path.

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

llvm-svn: 297645
2017-03-13 17:24:52 +00:00
Peter Collingbourne f8435a9bda ELF: Resolve _end symbols correctly.
Fix a bug introduced in r297313 which caused them to resolve to the end
of the ELF header in PIEs and DSOs.

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

llvm-svn: 297638
2017-03-13 16:40:20 +00:00
George Rimar 78aa270041 [ELF] - Remove unnecessary template. NFC.
llvm-svn: 297622
2017-03-13 14:40:58 +00:00