Commit Graph

5553 Commits

Author SHA1 Message Date
Rafael Espindola 28ed95f45e Revert unintentional change.
resolve can remain private.

Thanks to Rui for noticing it.

llvm-svn: 265336
2016-04-04 19:22:51 +00:00
Sean Silva e33321f767 Put these options in sorted order.
Feedback from Davide on r265206.

llvm-svn: 265335
2016-04-04 19:21:52 +00:00
Rui Ueyama b5792b231b Rename Other -> StOther.
"Other" as a name is too generic, so name it StOther.

llvm-svn: 265332
2016-04-04 19:09:08 +00:00
Rui Ueyama dd41807392 Add comments.
llvm-svn: 265320
2016-04-04 18:15:38 +00:00
Rui Ueyama d575edb780 Fix -disable-verify test.
This test didn't actually test the functionality. The new test
verifies that "-verify" is passed if and only if -disable-verify
is not given.

llvm-svn: 265316
2016-04-04 17:42:01 +00:00
Pete Cooper 4b35a64cb1 Fix test which failed Error migration on Windows bots.
Note, this is https://llvm.org/bugs/show_bug.cgi?id=27187.

The problem here was that just converting an error to a bool doesn't
always set the checked bit.  We only set that bit if the Error didn't
actually contain an error.  Otherwise we'd end potentially up silently
dropping it.

Instead just use the consumeError method which is designed to allow us
to drop an error.

llvm-svn: 265311
2016-04-04 16:56:09 +00:00
Simon Atanasyan 38da8c3bac [ELF][MIPS] Extend test case to check LA25 stubs creation for STO_MIPS_PIC symbols. NFC.
The only way to get an object file with symbols marked by the STO_MIPS_PIC
flag is to link PIC and non-PIC object files and generate a relocatable
output using '-r' command line option. Now LLD is able to generate a relocatable
output but does not mark PIC symbols by the STO_MIPS_PIC flag. So I have
to use binary input mips-sto-pic.o generated by GNU BFD linker.

llvm-svn: 265310
2016-04-04 16:47:31 +00:00
Rafael Espindola c64119a9bf Regenerate test file.
It had been created with a lld version that was producing an invalid
sh_info.

llvm-svn: 265305
2016-04-04 16:02:39 +00:00
Rafael Espindola 193b99c53c Try to fix the windows build.
MSVC doesn't want StringRef in an union.

llvm-svn: 265297
2016-04-04 14:31:20 +00:00
Rafael Espindola ccfe3cb3d6 Don't store an Elf_Sym for most symbols.
Our symbol representation was redundant, and some times would get out of
sync. It had an Elf_Sym, but some fields were copied to SymbolBody.

Different parts of the code were checking the bits in SymbolBody and
others were checking Elf_Sym.

There are two general approaches to fix this:
* Copy the required information and don't store and Elf_Sym.
* Don't copy the information and always use the Elf_Smy.

The second way sounds tempting, but has a big problem: we would have to
template SymbolBody. I started doing it, but it requires templeting
*everything* and creates a bit chicken and egg problem at the driver
where we have to find ELFT before we can create an ArchiveFile for
example.

As much as possible I compared the test differences with what gold and
bfd produce to make sure they are still valid. In most cases we are just
adding hidden visibility to a local symbol, which is harmless.

In most tests this is a small speedup. The only slowdown was scylla
(1.006X). The largest speedup was clang with no --build-id, -O3 or
--gc-sections (i.e.: focus on the relocations): 1.019X.

llvm-svn: 265293
2016-04-04 14:04:16 +00:00
Davide Italiano 842fa53026 [LTO] Implement -disable-verify, which disables bitcode verification.
So, there are some cases when the IR Linker produces a broken
module (which doesn't pass the verifier) and we end up asserting
inside the verifier. I think it's always a bug producing a module
which does not pass the verifier but there are some cases in which
people can live with the broken module (e.g. if only DebugInfo
metadata are broken). The gold plugin has something similar.

This commit is motivated by a situation I found in the
wild. It seems that somebody else discovered it independently
and reported in PR24923.

llvm-svn: 265258
2016-04-03 03:39:09 +00:00
Davide Italiano 88dbd3b1cf [LTO] Add a test to ensure we reject negative opt level.
We already got this right, but it never hurts adding another
test, in case we'll change the handling in the future, to ensure
we don't break it.

llvm-svn: 265256
2016-04-03 03:12:00 +00:00
Davide Italiano 8848d44e46 [LTO] Reject invalid optimization levels.
llvm-svn: 265255
2016-04-03 02:41:15 +00:00
Davide Italiano 887d76c392 [LTO] Fix -save-temps in case -o is not specified.
Currently we create a file called .lto.bc. In UNIX,
ls(1) by default doesn't show up files starting with
a dot, as they're (only by convention) hidden.
This makes the output of -save-temps a little bit
hard to find. Use "a.out.lto.bc" instead if the
output file is not specified.

While here, change an existing -save-temps test to
exercise this more interesting behaviour.

llvm-svn: 265254
2016-04-03 02:16:56 +00:00
Davide Italiano c4965009bd [ELF] Prefer 'auto' over explicit type for consistency.
llvm-svn: 265250
2016-04-02 23:47:54 +00:00
Ed Schouten 988b827992 Provide support for Binutils' --no-dynamic-linker option.
GNU ld seems to write a PT_INTERP header into executables containing a
default (read: bogus) value if --dynamic-linker flag is not provided.
LLD is different in the sense that it omits it unless --dynamic-linker
is provided, which seems fair.

Binutils 2.26 added a new flag, --no-dynamic-linker, that can be used to
generate binaries without PT_INTERP. Let's go ahead and also add this
flag to LLD, so that we can invoke the linker in a portable way.

Reviewed by:	ruiu
Differential Revision:	http://reviews.llvm.org/D18723

llvm-svn: 265246
2016-04-02 20:58:02 +00:00
Rui Ueyama 12dff23951 Simplify. NFC.
llvm-svn: 265242
2016-04-02 19:36:36 +00:00
Rui Ueyama 24d0d2f917 Merge two `if`s.
llvm-svn: 265241
2016-04-02 19:31:01 +00:00
Rui Ueyama 8fe7ce5903 Variable names should start with uppercase letters.
llvm-svn: 265239
2016-04-02 19:15:26 +00:00
Rui Ueyama 7e71c61a7a Rename a variable. NFC.
We had variables MB and Mb in this function. Rename of one them.

llvm-svn: 265237
2016-04-02 19:09:07 +00:00
Rui Ueyama d1aa97b5c2 Do not return early.
Early return in this context is a bit confusing, so avoid doing it.

llvm-svn: 265236
2016-04-02 18:52:23 +00:00
Rui Ueyama 1fc5d48877 Move code to initialize LLVM to one place.
llvm-svn: 265235
2016-04-02 18:18:44 +00:00
Rui Ueyama bfc1d9d976 Remove DefinedElf class.
DefinedElf was a superclass of DefinedRegular and SharedSymbol classes
and represented the notion of defined symbols created for ELF symbols.

It turned out that we didn't use that class often. We had only two
occurrences of dyn_cast'ing to DefinedElf, and both were easily
rewritten without it.

The class was also a bit confusing. The concept of "created for ELF
symbol" is orthogonal to defined/undefined types. However, we had
two distinct classes, DefinedElf and UndefinedElf.

This patch simply removes the class. Now the class hierarchy is one
level shallower.

llvm-svn: 265234
2016-04-02 18:06:18 +00:00
Sean Silva abd25c9b3e Call cl::ParseCommandLineOptions from the driver.
Thanks to Rui for the suggestion; this simplifies things.

llvm-svn: 265213
2016-04-02 04:08:02 +00:00
Davide Italiano 4fda708624 [LTO] Fix symbols which were internalized incorrectly.
If a symbol is defined in an archive, when we replace its body
the isUsedInRegularObj wasn't set correctly. Internalize makes
its decision based on that bit so we ended up internalizing
symbols that we shouldn't (because they're referenced).
This should fix. Thanks to Peter and Rafael for discussion
and help diagnosing the issue!

Found during LTO of unittests.

llvm-svn: 265208
2016-04-02 02:10:40 +00:00
Sean Silva 242bbdb7bf Fix MSVC build after r265206
c:\b\slave\sanitizer-windows\llvm\tools\lld\elf\Config.h(94) : error C2797: 'lld:🧝:Configuration::MLlvm': list initialization inside member initializer list or non-static data member initializer is not implemented

llvm-svn: 265207
2016-04-02 01:51:51 +00:00
Sean Silva 8e4ad5dbf8 PR27104: Add -mllvm option
The argv[0] is based on the analogous thing in clang.

llvm-svn: 265206
2016-04-02 01:39:56 +00:00
Rafael Espindola 059f3fb8fb Don't create a plt when LD access is optimized.
llvm-svn: 265203
2016-04-02 00:19:22 +00:00
Rafael Espindola cf3b04dab9 Don't create a PLT when we optimize out the plt use.
llvm-svn: 265202
2016-04-01 23:36:56 +00:00
Rui Ueyama e8a45e48f9 Rename a few variables. NFC.
We had Phdr, PHdr and Phdrs in one line. That was a bit confusing.

llvm-svn: 265194
2016-04-01 22:42:04 +00:00
Rafael Espindola 36404d0030 Simplify if. NFC.
llvm-svn: 265166
2016-04-01 18:04:21 +00:00
George Rimar 687788c90e [ELF] - Split Writer::assignAddresses(): extract code for initializing dummies sections
Extracts code for initializing dummies sections
to avoid possible duplication in following patches.

Differential review: http://reviews.llvm.org/D18691

llvm-svn: 265159
2016-04-01 17:30:52 +00:00
Rui Ueyama f7f52ef65d Make error handling consistent.
Some functions in Writer reports error using HasError, and some reports
their return values. This patch makes them to consistently use HasError.

llvm-svn: 265156
2016-04-01 17:24:19 +00:00
Rui Ueyama 8ecc2ec0e3 Remove dead code.
Thanks to George Rimor for pointing it out.

llvm-svn: 265155
2016-04-01 17:17:14 +00:00
Rui Ueyama a63baf176f Don't do extra work if -r is given.
fixAbsoluteSymbols fixes linker-created symbol addresses. Since we don't
create such symbols for relocatable output, we don't need to call this
function.

llvm-svn: 265154
2016-04-01 17:11:42 +00:00
Rui Ueyama e044e9cf80 Tidy up address and file offset assignments in the Writer.
assignAddressesRelocatable function did not set addresses to sections
despite its name. What it actually did is to set file offsets to sections.
assignAddresses function assigned addresses and file offsets to sections.
So there was a confusion what they were doing, and they had duplicate code.

This patch separates file offset assignments from address assignments.
A new function, assignFileOffsets assign file offsets. assignAddresses
do not care about file offsets anymore.

llvm-svn: 265151
2016-04-01 17:07:17 +00:00
Rafael Espindola 790db9c458 Bring r264761 back with an extra fix.
The extra fix is to note that it still requires copy relocations.

Original message:

Change how we handle R_MIPS_LO16.

Mips aligns PT_LOAD to 16 bits (0x10000). That means that the lower 16
bits are always the same, so we can, effectively, say that the
relocation is relative.

P.S.: Suggestions for a better name for the predicate are welcome :-)

llvm-svn: 265150
2016-04-01 17:00:36 +00:00
Rafael Espindola 2ee0092053 Don't apply a recolation that the dynamic linker will rewrite.
This matches the behavior of both bfd and gold. Looks like we just got
here for mips because of a bad ordering of an if else chain.

llvm-svn: 265147
2016-04-01 16:21:09 +00:00
Rafael Espindola 666625b78c Pass a const pointer to getImplicitAddend. NFC.
llvm-svn: 265143
2016-04-01 14:36:09 +00:00
Rafael Espindola 31d2ada6d5 Refactor duplicated code.
We had almost identical code to handle creating a plt entry in two
places.

llvm-svn: 265142
2016-04-01 14:14:48 +00:00
Rafael Espindola b97f4beec4 Avoid creating duplicated relocations.
llvm-svn: 265139
2016-04-01 12:54:27 +00:00
George Rimar 5a5c39ca2a Fix linux buildbot after r265136
http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/20138

Fix: Move method above class that uses it.
Works fine with MSVS.

llvm-svn: 265137
2016-04-01 12:24:28 +00:00
George Rimar e2da42a762 Make dummySectionsNum() to be not a member of writer. NFC.
llvm-svn: 265136
2016-04-01 11:59:32 +00:00
George Rimar b345e0d15c Split Writer::assignAddresses(): extract common code to fixFileOff(). NFC.
llvm-svn: 265131
2016-04-01 11:04:47 +00:00
George Rimar 900a260357 Split Writer::assignAddresses(): extract assignPhdrs(). NFC.
llvm-svn: 265130
2016-04-01 10:49:14 +00:00
George Rimar efded31a61 [ELF] - Move calculation of _end to fixAbsoluteSymbols()
That is consistent with other symbols: _edata, _etext
and can help to avoid duplicate code.

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

llvm-svn: 265129
2016-04-01 10:23:32 +00:00
Davide Italiano 8eca282dc9 [LTO] Inherit options from Codegen before initializing TargetMachine.
This fixes bootstrap of llvm-tblgen (with LTO) and PR27150.
Slightly longer explanation follows.

Emission of .init_array instead of .ctors is supported only on a
subset of the Target LLVM supports. Codegen needs to be conservative
and always emit .ctors unless instructed otherwise (based on target).
If the dynamic linker sees .init_array it completely ignores
what's inside .ctors and therefore some constructors are not called
(and this causes llvm-tblgen to crash on startup).

Teach LLD/LTO about the Codegen options so we end up always emitting
.init_array and avoid this issue.
In future, we might end up supporting mix of .ctors and .init_array
in different input files if this shows up as a real-world use case.
The way gold handles this case is mapping .ctors from input into
.init_array in output. There's also another caveat because
as far as I understand .ctors run in reverse order so when we do
the copy/mapping we need to reverse copy in the output if there's
more than one ctor. That's why I'd rather avoid this complicate logic
unless there's a real need.

An analogous reasoning holds for .dtors/.fini_array.

llvm-svn: 265085
2016-04-01 00:35:29 +00:00
Peter Collingbourne d418b1da38 ELF: Correctly handle --whole-archive for thin archives.
Differential Revision: http://reviews.llvm.org/D18669

llvm-svn: 265073
2016-03-31 23:12:18 +00:00
Simon Atanasyan 13f6da1d2c [ELF] Implement infrastructure for thunk code creation
Some targets might require creation of thunks. For example, MIPS targets
require stubs to call PIC code from non-PIC one. The patch implements
infrastructure for thunk code creation and provides support for MIPS
LA25 stubs. Any MIPS PIC code function is invoked with its address
in register $t9. So if we have a branch instruction from non-PIC code
to the PIC one we cannot make the jump directly and need to create a small
stub to save the target function address.
See page 3-38 ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf

- In relocation scanning phase we ask target about thunk creation necessity
by calling `TagetInfo::needsThunk` method. The `InputSection` class
maintains list of Symbols requires thunk creation.

- Reassigning offsets performed for each input sections after relocation
scanning complete because position of each section might change due
thunk creation.

- The patch introduces new dedicated value for DefinedSynthetic symbols
DefinedSynthetic::SectionEnd. Synthetic symbol with that value always
points to the end of the corresponding output section. That allows to
escape updating synthetic symbols if output sections sizes changes after
relocation scanning due thunk creation.

- In the `InputSection::writeTo` method we write thunks after corresponding
input section. Each thunk is written by calling `TargetInfo::writeThunk` method.

- The patch supports the only type of thunk code for each target. For now,
it is enough.

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

llvm-svn: 265059
2016-03-31 21:26:23 +00:00
Peter Collingbourne 098c3fcb03 ELF: Add more variants of ignored flags.
Differential Revision: http://reviews.llvm.org/D18668

llvm-svn: 265058
2016-03-31 21:18:34 +00:00
Rui Ueyama b339b6de0d Define a utility function to read -O and lto-O options.
llvm-svn: 265056
2016-03-31 21:15:31 +00:00
Peter Collingbourne ed22f9b6f1 ELF: Add flag for controlling LTO optimization level.
Differential Revision: http://reviews.llvm.org/D18667

llvm-svn: 265053
2016-03-31 21:00:27 +00:00
Ed Maste e2b7677c9e lld: accept and ignore _fbsd suffix in emulation name
Differential Revision:	http://reviews.llvm.org/D18661

llvm-svn: 265044
2016-03-31 20:26:30 +00:00
Rafael Espindola 4e5ab42e21 Pass a const SymbolBody to needsGot. NFC.
llvm-svn: 265012
2016-03-31 13:38:28 +00:00
Rafael Espindola 66ea7bb2c1 Fix the alignment check.
We have to check the final value that is written.

I don't think this has any real word implications (unless something
supports unaligned instructions), but unblocks simplifying the handling
of PC relative relocations.

llvm-svn: 265009
2016-03-31 12:09:36 +00:00
Pete Cooper f4d7688e4b Revert "Remove useless unreachable. Switch coverage already gives us this. NFC"
This reverts commit r264945.

The commit only removed an unreachable in a method with a covered switch, but
GCC is likely to warn on this, and the coding standards recommend just leaving
in the unreachable.

llvm-svn: 264983
2016-03-31 01:23:23 +00:00
Pete Cooper eadf9e4ec9 Remove unused variants of make_dynamic_error_code. NFC.
make_dynamic_error_code was used to create a std::error_code with
a std::string message.  Now that we are migrating to llvm::Error,
there are no calls to these make_dynamic_error_code methods.

There is one single call to make_dynamic_error_code remaining, the one
inside GenericError::convertToErrorCode().  That method is only called
from File::doParse() which should be a temporary situation.  We need
to work out how to deal with File::parse() caching the error result from
doParse().  Caching errors isn't supported in the new scheme, and probably
isn't needed here, but we need to work that out.

Once thats done, dynamic error and all utilities around it can be deleted.

llvm-svn: 264982
2016-03-31 01:21:50 +00:00
Pete Cooper 2f6216c181 Use Expected<T> instead of ErrorOr<T>in yaml reader. NFC
llvm-svn: 264981
2016-03-31 01:13:04 +00:00
Pete Cooper d0a643e7dc Change library search methods to return Optional instead of ErrorOr.
These methods weren't really throwing errors.  The only error used
was that a file could not be found, which isn't really an error at all
as we are searching paths and libraries for a file.  All of the callers
also ignored errors and just used the returned path if one was available.

Changing to return Optional<StringRef> as that actually reflects what
we are trying to do here: optionally find a given path.

llvm-svn: 264979
2016-03-31 01:09:35 +00:00
Pete Cooper dc59c794d0 Fix a bunch more of -Wpessimizing-move issues.
Thanks to Rui for pointing out this warning was firing.

llvm-svn: 264978
2016-03-31 00:38:02 +00:00
Pete Cooper e487da165c Fix a bunch of -Wpessimizing-move issues.
Thanks to Rui for pointing out this warning was firing.

llvm-svn: 264977
2016-03-31 00:35:50 +00:00
Pete Cooper 514594bdd3 Convert a few macho reader/writer helpers to new error handling. NFC.
These methods were responsible for some of the few remaining calls
to llvm::errorCodeToError.  Converting them makes us have more Error's
in the api and fewer error_code's.

llvm-svn: 264974
2016-03-31 00:08:16 +00:00
Pete Cooper c6e7b8146a Convert readBinary to llvm::Error. NFC
llvm-svn: 264973
2016-03-30 23:58:24 +00:00
Pete Cooper ec4e166a5a Convert normalized file to atoms methods to new error handling. NFC.
This converts almost all of the error handling in atom creation
to llvm::Error instead of std::error_code.

llvm-svn: 264968
2016-03-30 23:43:27 +00:00
Pete Cooper 8eaf62ca5d Fix MachO test which is failing on a Windows bot.
This is breaking http://lab.llvm.org:8011/builders/lld-x86_64-win7/builds/31647/steps/test%20lld/logs/stdio.

The issue seems to be that it can't write to a file in /tmp, probably because that path doesn't
exist on Windows.  This was failing after I added EXPECT_FALSE(ec) in r264961 for the error
handling migration.

llvm-svn: 264962
2016-03-30 23:28:49 +00:00
Pete Cooper fefbd22814 Convert lld file writing to llvm::Error. NFC.
This converts the writeFile method, as well as some of the ones it calls
in the normalized binary file writer and yaml writer.

llvm-svn: 264961
2016-03-30 23:10:39 +00:00
Simon Atanasyan cf8c42f546 [ELF][MIPS] Revert r264761 and add test case to demonstrate the problem
If we make R_MIPS_LO16 a relative relocation, linker:
- never creates R_MIPS_COPY relocation for it
- attempts to create R_MIPS_REL32 dynamic relocation if R_MIPS_LO16's
  target is a preemptible symbol

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

llvm-svn: 264956
2016-03-30 22:43:14 +00:00
Paul Robinson 56a97912cb Update copyright year to 2016.
llvm-svn: 264953
2016-03-30 22:40:59 +00:00
Rui Ueyama 1e0f022f05 Fix -Wpessimizing-move warnings.
llvm-svn: 264951
2016-03-30 22:40:16 +00:00
Pete Cooper 63d1aba2ce Remove useless unreachable. Switch coverage already gives us this. NFC
llvm-svn: 264945
2016-03-30 22:34:37 +00:00
Paul Robinson a8305830db Docs: keep copyright years up-to-date.
llvm-svn: 264942
2016-03-30 22:25:04 +00:00
Davide Italiano bbaf5e0acf [LTO] Add a test to ensure we treat externally available symbols correctly.
We already get it right, but there was no coverage for it.

llvm-svn: 264925
2016-03-30 21:01:14 +00:00
Pete Cooper 3c40b5b750 Convert file handle* methods to llvm::Error instead of std::error_code. NFC.
This updates most of the file handling methods in the linking context and
resolver to use the new API.

llvm-svn: 264924
2016-03-30 20:56:54 +00:00
Pete Cooper 96be123198 Change loadFileList to llvm::Error. NFC
llvm-svn: 264921
2016-03-30 20:44:14 +00:00
Pete Cooper c73c9d273d Convert lld Pass::runOnFile to llvm::Error from std::error_code. NFC.
Pretty mechanical change here.  Just replacing all the std::error_code() with
llvm::Error() and make_dynamic_error_code with make_error<GenericError>

llvm-svn: 264917
2016-03-30 20:36:31 +00:00
Rui Ueyama 8dbbb2555b Attempt to fix test failure on Windows.
Windows seems to complain that the file cannot be removed because
it is still in use. We don't have to remove the file but instead
just overwrite it, so do that.

llvm-svn: 264915
2016-03-30 20:25:26 +00:00
Reid Kleckner 750e76d245 Fix the detection of the shell feature and disable some tests when its not present
llvm-svn: 264912
2016-03-30 20:15:50 +00:00
Reid Kleckner 4f88914c5b Remove unused fwd decl for LLVM IR stuff that lives in LTO now
llvm-svn: 264911
2016-03-30 20:15:41 +00:00
Pete Cooper 1e00911ee0 Change getReferenceInfo/getPairReferenceInfo to use new Error handling. NFC.
Adds a GenericError class to lld/Core which can carry a string.  This is
analygous to the dynamic_error we currently use in lld/Core.

Use this GenericError instead of make_dynamic_error_code.  Also, provide
an implemention of GenericError::convertToErrorCode which for now converts
it in to the dynamic_error_code we used to have.  This will go away once
all the APIs are converted.

llvm-svn: 264910
2016-03-30 20:15:06 +00:00
Rui Ueyama 4709190376 Split Writer::assignAddresses. NFC.
llvm-svn: 264905
2016-03-30 19:41:51 +00:00
Adhemerval Zanella 69b29b2b7c [lld] [ELF/AArch64] Add aarch64 TLS IE to LE relax for local symbol test
This patch add a TLS relax optimization test when transforming
Initial-Exec to Local-Exec for local symbols (which can not be preempted).

llvm-svn: 264903
2016-03-30 19:12:18 +00:00
Rui Ueyama 38dc83417b Include line number in error message for linker scripts.
This patch is based on http://reviews.llvm.org/D18545 written
by George Rimar.

llvm-svn: 264878
2016-03-30 16:51:57 +00:00
Rafael Espindola 287e100db2 No relocation needs bot SA and ZA.
Pass only one of them to relocateOne.

llvm-svn: 264866
2016-03-30 13:27:50 +00:00
Rafael Espindola 8cc68c313b Implement getImplicitAddend for mips.
llvm-svn: 264865
2016-03-30 13:18:08 +00:00
Rafael Espindola abc9a12929 Simplify mips addend processing.
It is now added to the addend in the same way as a regular Elf_Rel
addend.

llvm-svn: 264864
2016-03-30 12:45:58 +00:00
Rafael Espindola da99df366d Fix handling of addends on i386.
Because of merge sections it is not sufficient to just add them while
applying a relocation.

llvm-svn: 264863
2016-03-30 12:40:38 +00:00
Ismail Donmez 22921c9cf5 Fix shared build after r264790
llvm-svn: 264844
2016-03-30 08:31:46 +00:00
George Rimar f1c0bf5b40 [ELF] - Do not keep undefined locals in .symtab
gold and bfd do not include the undefined locals in symtab.
We have no reasons to support that either.

That fixes PR27016

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

llvm-svn: 264843
2016-03-30 08:16:11 +00:00
Rui Ueyama f43d15009c Fix comments.
The original comments were separated by new code that is irrelevant to
the comment. This patch moves the comment to the right place and update it.

llvm-svn: 264816
2016-03-30 00:43:49 +00:00
Davide Italiano 49fe4eda4c [LTO] Add a comment to explain how we handle @llvm.used.
Requested by: Rui Ueyama.

llvm-svn: 264809
2016-03-29 23:57:22 +00:00
Rafael Espindola 163974dd33 Simplify AHL handling.
This simplifies a few things

* Read the value as early as possible, instead of passing a pointer to
  the location.
* Print the warning for missing pair close to where we find out it is
  missing.
* Don't pass the value to relocateOne.

llvm-svn: 264802
2016-03-29 23:05:59 +00:00
Davide Italiano 47c33f0387 [ELF] Drive-by cleanup, make LTO.cpp clang-format clean.
llvm-svn: 264791
2016-03-29 21:48:25 +00:00
Davide Italiano 86f2bd5ca1 [LTO] Teach LTO about @llvm.used global.
If a symbol appears in @llvm.used, the linker is forced to treat
the symbol as there's a reference to it.

llvm-svn: 264790
2016-03-29 21:46:35 +00:00
Rui Ueyama 319d7304c3 Simplify. NFC.
llvm-svn: 264785
2016-03-29 20:53:21 +00:00
Rui Ueyama 4e62db4167 Replace a FIXME with a regular comment.
Because it doesn't have to be fixed even though it is probably
better to do.

llvm-svn: 264772
2016-03-29 19:19:03 +00:00
Rui Ueyama 01ddc06484 Make BitcodeCompiler::compile a non-template function. NFC.
llvm-svn: 264770
2016-03-29 19:08:46 +00:00
Rafael Espindola cba3e8b4b5 Change how we handle R_MIPS_LO16.
Mips aligns PT_LOAD to 16 bits (0x10000). That means that the lower 16
bits are always the same, so we can, effectively, say that the
relocation is relative.

llvm-svn: 264761
2016-03-29 18:18:19 +00:00
Simon Atanasyan 121e5bc95f [ELF][MIPS] Remove redundant comments from the test. NFC.
Now llvm-objdump prints target function name for `jal` instruction by itself.

llvm-svn: 264732
2016-03-29 14:26:24 +00:00
Simon Atanasyan d2980d3e20 [ELF][MIPS] Reduce number of redundant entries in the local part of MIPS GOT
Local symbol which requires GOT entry initialized by "page" address.
This address is high 16 bits of sum of the symbol value and the relocation
addend. In the relocation scanning phase final values of symbols are unknown
so to reduce number of allocated GOT entries do the following trick. Save
all output sections referenced by GOT relocations during the relocation
scanning phase. Then later in the `GotSection::finalize` method calculate
number of "pages" required to cover all saved output sections and allocate
appropriate number of GOT entries. We assume the worst case - each 64kb
page of the output section has at least one GOT relocation against it.

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

llvm-svn: 264730
2016-03-29 14:07:22 +00:00
George Rimar 9e18c7f81a Forgot to address last minor review comment in r264708. Doing that now.
llvm-svn: 264711
2016-03-29 09:37:17 +00:00