Commit Graph

1535 Commits

Author SHA1 Message Date
Rafael Espindola 29af472cf6 Use llvm::CachedHash.
llvm-svn: 266982
2016-04-21 12:21:06 +00:00
George Rimar 72ab8481fa [ELF] - Make LinkerScript::getSectionOrder private. NFC.
llvm-svn: 266979
2016-04-21 11:28:11 +00:00
George Rimar dbbd8b15bf [ELF] - Use ArrayRef instead of std::vector& for LinkerScript module. NFC.
llvm-svn: 266978
2016-04-21 11:21:48 +00:00
George Rimar 71b26e94fd [ELF] - Get rid of SectionOrder array.
SectionOrder vector was a part of LinkerScript class.

It can be removed because Commands vector contains the 
same information and SectiorOrder is just a subset.

Differential revision: http://reviews.llvm.org/D19171

llvm-svn: 266974
2016-04-21 10:22:02 +00:00
Davide Italiano 3c0410d09d [LTO] Discard names for Values that are not global.
This is not on by default (but it might be in the future).
The knob to enable the optimization is -lto-discard-value-names.

llvm-svn: 266953
2016-04-21 04:46:22 +00:00
Simon Atanasyan 98a4ba54df [ELF][MIPS] Treat R_MIPS_TLS_{D}TPREL_HI16/LO16 as relative relocations
These relocations are calculated as S + A - DTPREL or S + A - TPREL,
where DTPREL = TlsVA - 0x8000, TPREL = TlsVA - 0x7000. So the result
is relative to the TLS output section and is not an absolut value
The fix allows to escape creation of unnecessary dynamic relocations
in case of DSO linking.

llvm-svn: 266923
2016-04-20 21:57:51 +00:00
Simon Atanasyan ca58a8ff5b [ELF][MIPS] Create GOT entries for R_MIPS_REL32 dynamic relocations
MIPS ABI turns using of GOT and dynamic relocations inside out. While
regular ABI uses dynamic relocations to fill up GOT entries MIPS ABI
requires dynamic linker to fills up GOT entries using specially sorted
dynamic symbol table. This affects even dynamic relocations against
symbols which do not require GOT entries creation explicitly, i.e. do
not have any GOT-relocations. So if a preemptible symbol has a dynamic
relocation we anyway have to create a GOT entry for it.

If a non-preemptible symbol has a dynamic relocation against it, dynamic
linker takes it st_value, adds offset and writes down result of the
dynamic relocation. In case of preemptible symbol dynamic linker
performs symbol resolution, writes the symbol value to the GOT entry and
reads the GOT entry when it needs to perform a dynamic relocation.

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

llvm-svn: 266921
2016-04-20 21:40:33 +00:00
Kevin Enderby dd98c91e08 Needed change to lld for the change to libObject’s getName() for symbols now returning Expected<...>
With the llvm change in r266919 this is the matching needed change to the lld code
now that libObject’s getName() for symbols now returning Expected<...> .

llvm-svn: 266920
2016-04-20 21:24:51 +00:00
Rui Ueyama 6011811beb Define and use a utility function. NFC.
llvm-svn: 266914
2016-04-20 20:54:13 +00:00
Rui Ueyama 99e519cdeb ELF: Redefine parseExpr to parse an expression. NFC.
Previously the function reads an operator and the rest of
the expressions. This patch makes it to actually parse an expression
which starts with a primary pexression followed by other expressions
concatenated with operators.

llvm-svn: 266912
2016-04-20 20:48:25 +00:00
Rui Ueyama 07320e4030 ELF: Template LinkerScript class.
Originally, linker scripts were basically an alternative way to specify
options to the command line options. But as we add more features to hanlde
symbols and sections, many member functions needed to be templated.
Now most the members are templated. It is probably time to template the
entire class.

Previously, LinkerScript is an executor of the linker script as well as
a storage of linker script configurations. This is not suitable to template
the class because when we are reading linker script files, we don't know
the ELF type yet, so we can't instantiate ELF-templated classes.

In this patch, I defined a new class, ScriptConfiguration, to store
linker script configurations. ScriptParser writes parse results to it,
and LinkerScript uses them.

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

llvm-svn: 266908
2016-04-20 20:13:41 +00:00
Rafael Espindola c6b17bdc29 Delete refersToGotEntry.
It can be computed from the expression.

llvm-svn: 266890
2016-04-20 17:30:22 +00:00
Rafael Espindola 475dbf42e4 Simplify mips gp0 handling.
In all currently supported cases this is a nop.

llvm-svn: 266888
2016-04-20 17:20:49 +00:00
Rafael Espindola 2081dbcc7a Inline canRelaxTls.
It was always called in a position where the relocation type was already
known.

llvm-svn: 266880
2016-04-20 15:01:42 +00:00
Rafael Espindola f54413c18e Simplify canRelaxTls.
Check isTls in the called and pass a SymbolBody&.

llvm-svn: 266879
2016-04-20 14:52:18 +00:00
Rafael Espindola cc36a63f0b Move canRelaxTls to Writer.cpp. NFC.
llvm-svn: 266878
2016-04-20 14:41:55 +00:00
Rafael Espindola 6eda85ac1f Delete needsDynRelative.
It is now redundant. Writer.cpp can reason that 2 dynamic relocations
are needed: one to find the final got entry address and one to fill the
got entry.

llvm-svn: 266876
2016-04-20 14:36:24 +00:00
Sean Silva 580c1b6952 Revert "[ELF] - Avoid using memset for zero-initialization of struct member. NFC."
This reverts commit r266618. It breaks basically everything.

I think VS2013 doesn't interpret this code in the same way.
The size field (at least) is left uninitialized, causing all sorts of havok
(e.g. creating a 34GB file for a trivial hello world program).

The offending compiler reports itself as follows:

    c:\release-vs2013>cl /?
    Microsoft (R) C/C++ Optimizing Compiler Version 18.00.40629 for x64
    Copyright (C) Microsoft Corporation.  All rights reserved.

llvm-svn: 266857
2016-04-20 04:26:16 +00:00
Rafael Espindola 58cd5db4ef Simplify mips got handling.
This avoids computing the address of a position in the got just to then
subtract got->getva().

llvm-svn: 266831
2016-04-19 22:46:03 +00:00
Rui Ueyama 0536ec0242 Make a function file-scoped.
llvm-svn: 266816
2016-04-19 20:50:25 +00:00
Rafael Espindola f350d25942 Fix pr27420.
Return the right expression for R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX.

llvm-svn: 266810
2016-04-19 20:18:52 +00:00
Rui Ueyama 7a81d674f6 Attempt to fix buildbot.
llvm-svn: 266799
2016-04-19 19:04:03 +00:00
Rui Ueyama 960504b91d ELF: Add +, -, *, / and & to SECTIONS linker script command.
This patch is based heavily on George Rimor's patch
http://reviews.llvm.org/D19221.

In the linker script, you can write expressions to compute addresses.
Currently we only support "+" operator. This adds a few more operators.

Since this patch adds * and /, we need to handle operator precedences
properly. I implemented that using the operator-precedence grammar.

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

llvm-svn: 266798
2016-04-19 18:58:11 +00:00
George Rimar a3ab1091d1 Updated comment. NFC.
llvm-svn: 266727
2016-04-19 12:09:25 +00:00
Duncan P. N. Exon Smith 28d8d04657 LTO: Adapt to LLVM API changes in r266713
llvm-svn: 266714
2016-04-19 04:57:40 +00:00
Rui Ueyama 9e957a0ac6 Rename LocationNode -> SectionsCommand.
They are called sections-command in the doc, so it is nice to keep
it consistent with it.
https://sourceware.org/binutils/docs/ld/SECTIONS.html#SECTIONS

llvm-svn: 266668
2016-04-18 21:00:45 +00:00
Rui Ueyama 54115af45e Remove redundant curly braces.
llvm-svn: 266667
2016-04-18 21:00:43 +00:00
Rui Ueyama 7c18c28c97 Refactor LinkerScript::assignAddresses. NFC.
llvm-svn: 266666
2016-04-18 21:00:40 +00:00
Rafael Espindola de088e69a1 Add missing dependency.
llvm-svn: 266655
2016-04-18 19:03:36 +00:00
George Rimar 4f2aa57569 [ELF] - Avoid using memset for zero-initialization of struct member. NFC.
llvm-svn: 266618
2016-04-18 15:16:17 +00:00
Rafael Espindola f4c1cd4006 Fix handling of R_X86_64_GOT32.
It computes the offset to the end of .got.

llvm-svn: 266610
2016-04-18 12:58:59 +00:00
Rafael Espindola ece62b962e Simplify handling of R_X86_64_TPOFF32. NFC.
llvm-svn: 266609
2016-04-18 12:44:33 +00:00
Rafael Espindola 5bf59728e2 Remove isGotRelative.
It is now redundant with the expression. While at it, handle both "X -
Got" and "Got - PC".

llvm-svn: 266607
2016-04-18 12:31:37 +00:00
Rafael Espindola 3f5d634c73 Have getRelExpr handle all cases on x86.
This requires adding a few more expression types, but is already a small
simplification. Having Writer.cpp know the exact expression will also
allow further simplifications.

llvm-svn: 266604
2016-04-18 12:07:13 +00:00
Rafael Espindola 3c20fb4e5d Merge duplicated cases. NFC.
llvm-svn: 266601
2016-04-18 11:53:42 +00:00
Rafael Espindola 99c224787b Delete the now redundant pointsToLocalDynamicGotEntry.
llvm-svn: 266584
2016-04-18 01:34:20 +00:00
Rafael Espindola df17277d72 Have getRelExpr return the final values for tls gd.
llvm-svn: 266583
2016-04-18 01:29:15 +00:00
Rafael Espindola c4d56970dc Change getRelExpr to return the final value for TLSLD. NFC.
llvm-svn: 266580
2016-04-18 00:28:57 +00:00
Rafael Espindola abf6c650ac Make CreateTargetMachine as small as possible.
It is a pity that we have to create a TargetMachine once per thread,
so at least make that code as small as possible.

llvm-svn: 266578
2016-04-17 23:20:08 +00:00
Ismail Donmez 23e5a38407 Fix shared build after r266484
llvm-svn: 266558
2016-04-17 09:01:51 +00:00
Duncan P. N. Exon Smith 2c66b23d79 LTO: Merge debug info types when linking bitcode
Make sure lld enables ODR type uniquing for debug info when invoking
LTO, as a follow-up to LLVM r266549.

llvm-svn: 266555
2016-04-17 07:35:38 +00:00
Simon Atanasyan 737a92c893 [ELF] Include Twine.h header to restore LLD build after r266524. NFC
llvm-svn: 266527
2016-04-16 10:58:45 +00:00
George Rimar 652852c5c0 Recommitted 266457 with fix:
* Do script driven layout only if SECTIONS section exist.

Initial commit message:

[ELF] - Implemented basic location counter support.

This patch implements location counter support. 
It also separates assign addresses for sections to assignAddressesScript() if it scipt exists.

Main testcase is test/ELF/linkerscript-locationcounter.s, It contains some work with location counter. It is basic now.
Implemented location counter assignment and '+' operations.

Patch by myself with LOTS of comments and design suggestions from Rui Ueyama.

Differential revision: http://reviews.llvm.org/D18499

llvm-svn: 266526
2016-04-16 10:10:32 +00:00
Davide Italiano 493b683f79 [LTO] Don't crash on a BitcodeFile without DataLayout.
Emit an error instead.

llvm-svn: 266504
2016-04-16 01:33:33 +00:00
Rui Ueyama faac567e68 Revert r266457: "[ELF] - Implemented basic location counter support."
This reverts commit r266457 as it breaks "hello world" both on
Linux and FreeBSD.

llvm-svn: 266485
2016-04-15 22:39:27 +00:00
Davide Italiano bc176631cd [LTO] Implement parallel Codegen for LTO using splitCodeGen.
Parallelism level can be chosen using the new --lto-jobs=K option
where K is the number of threads used for CodeGen. It currently
defaults to 1.

llvm-svn: 266484
2016-04-15 22:38:10 +00:00
Rafael Espindola 5628ee7631 Simplify got handling.
Each getRelExpr is now expected to return the correct got expression
instead of having Writer patch it up with needsGot.

llvm-svn: 266466
2016-04-15 19:14:18 +00:00
Rafael Espindola 7dd20563a2 Merge duplicated cases. NFC.
llvm-svn: 266459
2016-04-15 17:57:27 +00:00
George Rimar ea25877d4a [ELF] - Implemented basic location counter support.
This patch implements location counter support. 
It also separates assign addresses for sections to assignAddressesScript() if it scipt exists.

Main testcase is test/ELF/linkerscript-locationcounter.s, It contains some work with location counter. It is basic now.
Implemented location counter assignment and '+' operations.

Patch by myself with LOTS of comments and design suggestions from Rui Ueyama.

Differential revision: http://reviews.llvm.org/D18499

llvm-svn: 266457
2016-04-15 17:44:19 +00:00
Rafael Espindola 38c67a27fe Store a Symbol for EntrySym.
This makes it impossible to forget to call repl on the SymbolBody.

llvm-svn: 266432
2016-04-15 14:41:56 +00:00