Commit Graph

408 Commits

Author SHA1 Message Date
Jack Andersen 2fa85b9bd4 Merge branch 'master' into small-data 2017-01-27 08:22:12 -10:00
Rafael Espindola 5007232701 Fix and simplify the reporting of undefined symbols.
Now reportUndefined only has to look at Config->UnresolvedSymbols and
the symbol. getUnresolvedSymbolOption does all the hard work of
mapping options like -shared and -z defs to one of the
UnresolvedPolicy enum entries.

The critical fix is that now "-z defs --warn-unresolved-symbols" only
warns.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@293290 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-27 15:52:08 +00:00
Davide Italiano a5dc0ab0d0 [ELF] Add warn-unresolved-symbols/error-unresolved-symbols options
Patch by Dmitry Mikulin.
PR: 31735

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

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@293139 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-26 02:19:20 +00:00
Rui Ueyama dc05e91183 Add file comments to Driver.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@293130 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-26 01:52:05 +00:00
Rui Ueyama 09e97e6cb4 Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@293100 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-25 21:49:23 +00:00
Rafael Espindola 366d3b63de Change the --retain-symbols-file implementation.
It now uses the same infrastructure as symbol versions. This fixes us
creating a dynamic relocation without a corresponding dynamic symbol.

This also means that unlike gold and bfd we keep a STB_LOCAL in the
static symbol table. It seems an odd feature to offer precise control
over what is in a symbol table that is not used by the dynamic
linker. We can bring this back if needed, but it would probably be
better to just have --discard option that tells the linker to keep in
the static symbol table only what is in the dynamic one.

Should fix the eog build.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@293093 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-25 21:23:06 +00:00
Rui Ueyama bf786ac1e2 Do not allocate space for common symbols with -r
Currently ld.lld -r allocates space for common symbols, whereas ld.bfd
-r doesn't.  As a result the OpenBSD makefile bits for creating libraries
fail as they use ld -X -r to strip local symbols, which results in
duplicate symbol errors because space for the common symbols has been
allocated.

The diff also implements the --define-commons option such that allocation
of commons can be forced even if -r is used.

Patch by Mark Kettenis.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@292878 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-24 03:41:20 +00:00
Rui Ueyama 90ded2b61c Add -no-{export-dynamic,fatal-warnings}.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@292048 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-15 03:38:55 +00:00
Rui Ueyama 720140dd10 Add -print-map and -M options.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@292046 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-15 02:52:34 +00:00
Rafael Espindola eea64b3d65 Implement -Map.
The format is not exactly the same as the one in bfd since bfd always
follows a linker script and prints it along.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291958 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-13 21:05:46 +00:00
George Rimar 3358d46117 [ELF] - Reuse Decompressor class.
Intention of change is to get rid of code duplication.
Decompressor was introduced in D28105.

Change allows to get rid of few methods relative to decompression.

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

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291758 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12 10:53:31 +00:00
Rui Ueyama 68320f36fa Add linker-script-included files to reproduce tar files.
Previously, files added using INCLUDE directive weren't added
to reproduce archives. In this patch, I defined a function to
open a file and use that from Driver and LinkerScript.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291413 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-09 01:42:02 +00:00
Rui Ueyama cfca03737d Rename lld::stringize -> lld::toString.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291223 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-06 10:04:35 +00:00
Rui Ueyama 03c1d58f2f Use TarWriter to create tar archives instead of cpio.
This is how we use TarWriter in LLD. Now LLD does not append
a file extension, so you need to pass `--reproduce foo.tar`
instead of `--reproduce foo`.

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

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291210 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-06 02:33:53 +00:00
Rui Ueyama edec367af1 Remove Driver::OwningMB and instead use make().
We managed new MemoryBuffers in different ways in LinkerScript.cpp and
Driver.cpp. With this patch, they are managed in the same way.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290411 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-23 03:19:09 +00:00
Simon Atanasyan 46c287cc73 [ELF] Do not warn about missed entry symbol in case of relocatable output
Relocatable file does not need to have an entry symbol so the warning is
useless in that case.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290206 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-20 22:24:45 +00:00
Rui Ueyama 20a95df793 Remove Compressed member from InputSectionData.
This value is used only once, and we can compute a value.
So we don't need to save it.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290164 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-20 05:47:55 +00:00
Rui Ueyama 4cc2141f48 Set Config->ColorDiagnostics early so that all error messages are colored.
Previously, some errors that were checked before we set to
Config->ColorDiagnostics weren't colored. This patch moves the code
to set the variable so that such error messages are colored just like
other error messages.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290157 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-20 02:17:24 +00:00
Rui Ueyama 7f64678432 Simplify type of Config->SymbolOrderingFile.
That variable was of type DenseMap<StringRef, unsigned>, but the
unsigned numbers needed to be monotonicly increasing numbers because
the implementation that used the variable depended on that fact.
That was an implementation detail and shouldn't have leaked into Config.

This patch simplifies its type to std::vector<StringRef>.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290151 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-20 01:51:08 +00:00
Rui Ueyama 61ecef49ac Inline a small function.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290150 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-20 01:34:31 +00:00
George Rimar b2ed533c46 [ELF] - Implemented --retain-symbols-file option
--retain-symbols-file=filename
Retain only the symbols listed in the file filename, discarding all others. 
filename is simply a flat file, with one symbol name per line. This option 
is especially useful in environments (such as VxWorks) where a large global 
symbol table is accumulated gradually, to conserve run-time memory.

Note: though documentation says "--retain-symbols-file does not discard 
undefined symbols, or symbols needed for relocations.", both bfd and gold 
do that, and this patch too, like testcase show.

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

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290122 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-19 18:00:52 +00:00
Rui Ueyama 973d1e7833 Remove inappropriate use of CachedHashStringRef.
Use of CachedHashStringRef makes sense only when we reuse hash values.
Sprinkling it to all DenseMap has no benefits and just complicates data types.
Basically we shouldn't use CachedHashStringRef unless there is a strong
reason to to do so.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290076 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-19 03:14:16 +00:00
Rui Ueyama 54b01a52e8 Remove lld/Support/Memory.h.
I thought for a while about how to remove it, but it looks like we
can just copy the file for now. Of course I'm not happy about that,
but it's just less than 50 lines of code, and we already have
duplicate code in Error.h and some other places. I want to solve
them all at once later.

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

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290062 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-18 14:06:06 +00:00
Rui Ueyama 5c041201b6 Print a warning message if ENTRY() symbol is not found.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289146 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 22:26:31 +00:00
Rui Ueyama ca7af8d122 Move Memory.{h,cpp} to lld/Support so that we can use them from COFF.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289084 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 18:31:13 +00:00