Commit Graph

141 Commits

Author SHA1 Message Date
Davide Italiano 8c83382a95 [ELF] Support --output. Also output= can take two dashes.
llvm-svn: 276826
2016-07-27 01:57:15 +00:00
Petr Hosek d7bd2389ce [ELF] Support for setting the base address
The -image-base option allows for overriding the base address.

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

llvm-svn: 275206
2016-07-12 19:37:53 +00:00
Davide Italiano 3f36781dec [ELF] Ignore --demangle. We already demangle symbols by default.
llvm-svn: 274806
2016-07-07 23:32:36 +00:00
Davide Italiano f296a7eeae [ELF] Introduce a flag to parse response files according to windows rules.
Differential Revision:  http://reviews.llvm/org/D22015

llvm-svn: 274684
2016-07-06 21:24:34 +00:00
Davide Italiano c03d610cff [ELF] Support --entry= option variant. Update tests while I'm there.
llvm-svn: 274524
2016-07-04 21:50:50 +00:00
George Rimar 857644cef8 [ELF] - Implemented --fatal-warnings option.
--fatal-warnings: Treat warnings as errors

DIfferential revision: http://reviews.llvm.org/D21969

llvm-svn: 274504
2016-07-04 13:43:12 +00:00
Rui Ueyama 1df56894f8 Do not allow "--" with single-letter options.
In general, we accept both -foo and --foo as command line options,
but if an option is a single letter option, we don't want to allow
double dashes because GNU linkers don't accept such combination.

llvm-svn: 274219
2016-06-30 08:43:23 +00:00
George Rimar e86dcd0cbd [ELF] - Added support for --unresolved-symbols option.
Option has next description (http://linux.die.net/man/1/ld):
"--unresolved-symbols=method
Determine how to handle unresolved symbols. There are four possible values for method
according to documentation:

ignore-all: Do not report any unresolved symbols.
report-all: Report all unresolved symbols. This is the default.
ignore-in-object-files: Report unresolved symbols that are contained in shared libraries, but ignore them if they come from regular object files.
ignore-in-shared-libs: Report unresolved symbols that come from regular object files, but ignore them if they come from shared libraries."

Since report-all is default and we traditionally do not report about undefined symbols in lld,
report-all does not report about undefines from DSO. 
ignore-in-object-files also does not do that. Handling of that option differs from what gnu linkers do.

Option works in next way in lld:
ignore-all: Do not report any unresolved symbols.
report-all: Report all unresolved symbols except symbols from DSOs. This is the default.
ignore-in-object-files: The same as ignore-all.
gnore-in-shared-libs: The same as report-all.

This is PR24524.

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

llvm-svn: 274123
2016-06-29 12:35:04 +00:00
George Rimar 36b2c0a683 [ELF] - Implemented --no-undefined-version flag
Option checks for cases where a version script explicitly lists
a symbol, but the symbol is not defined and errors out such
cases if any.

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

llvm-svn: 273998
2016-06-28 08:07:26 +00:00
Rui Ueyama 6a9940260c Define -v and -V as aliases to --version.
This is for GNU compatibility.

llvm-svn: 273847
2016-06-27 07:35:00 +00:00
Rui Ueyama 596eba86bc Ignore --sort-common.
Because we always sort common symbols, we can ignore the option.

llvm-svn: 273842
2016-06-27 02:43:27 +00:00
Rui Ueyama d60dae8a6a Implement --trace-symbol=symbol option.
Patch by Shridhar Joshi.

This option provides names of all the link time modules which define and
reference symbols requested by user. This helps to speed up application
development by detecting references causing undefined symbols.
It also helps in detecting symbols being resolved to wrong (unintended)
definitions in case of applications containing multiple definitions for
same symbols with different types, bindings.

Implements PR28226.

llvm-svn: 273536
2016-06-23 07:00:17 +00:00
Rui Ueyama d1188f757c Accept both single and double dashes for all options.
This is a follow-up patch to r273218. GNU ld accepts both "--" and "-"
for all multi-letter options except "-o". This patch makes lld compatible
with that behavior.

llvm-svn: 273256
2016-06-21 08:45:50 +00:00
Rui Ueyama 36a31171ff Allow both one and two dashes for all multi-letter options.
GNU ld's manual page says that all options whose names are
multiple letters, except those who start with "o", can start
either with one or two dashes.

llvm-svn: 273218
2016-06-20 23:10:40 +00:00
Davide Italiano a074fe41bf [ELF] Accept --soname= (two dashes).
Update an existing test to exercise the new functionality, while
I'm here.

llvm-svn: 273175
2016-06-20 17:58:09 +00:00
Davide Italiano df24d5b8c8 [LTO] Add --lto-aa-pipeline.
Differential Revision:  http://reviews.llvm.org/D20888

llvm-svn: 271605
2016-06-02 22:58:11 +00:00
Sean Silva 8ef190c7b0 Make -L description a bit more precise.
llvm-svn: 270966
2016-05-27 04:48:26 +00:00
Sean Silva 3b536d0916 Explain a bit better what --start-lib and --end-lib do.
llvm-svn: 270965
2016-05-27 04:48:24 +00:00
Sean Silva 688fade4dd Add a help description for --threads to avoid confusion.
llvm-svn: 270964
2016-05-27 04:48:21 +00:00
Sean Silva 2c1a9da83f --threads is a flag, not a number
We would previously accept `--threads=4`, but this option just turns on
threading and does not specify a number of threads.

I ran into this by accident because I was passing `--threads=<n>` but
the number didn't seem to affect anything.

llvm-svn: 270963
2016-05-27 04:30:27 +00:00
Rui Ueyama 1795f782e9 Do not ignore --no_ctors_in_init_array flag.
That flag is probably too dangerous to ignore silently.

llvm-svn: 270711
2016-05-25 15:30:11 +00:00
Rui Ueyama c789b631f3 Really define --export-dynamic-symbol= as an alias to --export-dynamic-symbol.
Thanks to Sean for pointing it out.

llvm-svn: 270660
2016-05-25 04:29:55 +00:00
Rui Ueyama dadda2fe08 Add a few options for compatibility with GNU.
llvm-svn: 270651
2016-05-25 03:38:16 +00:00
Saleem Abdulrasool 5e9944ee0a ELF: accept and ignore --no-undefined-version for compatibility
This is currently unsupported.  Accept and ignore the flag for invocation
compatibility.

llvm-svn: 269788
2016-05-17 17:34:50 +00:00
Davide Italiano d26c4a14ca [LTO] Add the ability to specify a subset of passes to run.
Differential Revision:  http://reviews.llvm.org/D20267

llvm-svn: 269605
2016-05-15 19:29:38 +00:00
Davide Italiano bf5ef7b63b [ELF] Ignore -d option (and aliases).
The linker already allocates common symbols by default.
Discussed with Rafael.

llvm-svn: 268117
2016-04-29 21:44:02 +00:00
Davide Italiano 575ad8c2e1 [ELF] -R is an alias for -rpath.
perl-5 uses the former, so provide an alias. Found while linking
the whole set of FreeBSD ports with lld.

llvm-svn: 267801
2016-04-27 21:56:53 +00:00
Davide Italiano 034f58a9bd [ELF] Introduce --reproduce flag.
--reproduce dumps the object files in a directory chosen
(preserving the file system layout) and the linker invocation
so that people can create an archive and upload for debugging.

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

llvm-svn: 267497
2016-04-26 00:22:24 +00:00
Rui Ueyama 1e9e615f92 LTO: Merge -lto-no-discard-value-names with -save-temps.
This patch is to remove -lto-no-discard-value-names flag and
instead to use -save-temps as we discussed in the post-commit
review thread for r267020.

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

llvm-svn: 267230
2016-04-22 21:43:10 +00:00
Peter Collingbourne 66ac1d6152 ELF: Implement basic support for --version-script.
This patch only implements support for version scripts of the form:
  { [ global: symbol1; symbol2; [...]; symbolN; ] local: *; };
No wildcards are supported, other than for the local entry. Symbol versioning
is also not supported.

It works by introducing a new Symbol flag which tracks whether a symbol
appears in the global section of a version script.

This patch also simplifies the logic in SymbolBody::isPreemptible(), and
teaches it to handle the case where symbols with default visibility in DSOs
do not appear in the dynamic symbol table because of a version script.

Fixes PR27482.

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

llvm-svn: 267208
2016-04-22 20:21:26 +00:00
Peter Collingbourne 760e583e22 ELF: Implement --export-dynamic-symbol.
llvm-svn: 267184
2016-04-22 18:44:06 +00:00
Saleem Abdulrasool 1b5bf445a0 ELF: support -- version of discard-{all,locals}
GNU ld and gold only support the discard-all and discard-locals with two dashes.
Retain the compatibility with the one dash spelling, but also accept the two
dashed form.

llvm-svn: 267032
2016-04-21 18:29:13 +00:00
Saleem Abdulrasool 1761dddc4f ELF: alias `--no-copy-dt-needed-entries` to `--no-add-needed`
`--add-needed` and `--no-add-needed` have been deprecated due to the similarity
of their spelling to `--as-needed` and `--no-as-needed`.  They have been renamed
to `--copy-dt-needed-entries` and `--no-copy-dt-needed-entries`.

llvm-svn: 267031
2016-04-21 18:29:09 +00:00
Davide Italiano 5abcb3cc5b [LTO] Discard names for values that are not global by default.
Rafael reported on the mailing list that this reduces peak memory
usage while linking llvm-as by 15%. It makes sense to make it
the default, and introduce an inverse knob -lto-no-discard-value-names
for those who want to restore the old behavior.

llvm-svn: 267020
2016-04-21 17:46:38 +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
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
Adhemerval Zanella 9df0720766 ELF: Implement --dynamic-list
This patch implements the --dynamic-list option, which adds a list of
global symbol that either should not be bounded by default definition
when creating shared libraries, or add in dynamic symbol table in the
case of creating executables.

The patch modifies the ScriptParserBase class to use a list of Token
instead of StringRef, which contains information if the token is a
quoted or unquoted strings. It is used to use a faster search for
exact match symbol name.

The input file follow a similar format of linker script with some
simplifications (it does not have scope or node names). It leads
to a simplified parser define in DynamicList.{cpp,h}.

Different from ld/gold neither glob pattern nor mangled names
(extern 'C++') are currently supported.

llvm-svn: 266227
2016-04-13 18:51:11 +00:00
Peter Collingbourne e217660591 ELF: Ignore --detect-odr-violations flag.
Differential Revision: http://reviews.llvm.org/D18877

llvm-svn: 265744
2016-04-07 23:15:50 +00:00
Rui Ueyama 3a41be277a ELF: Implement --build-id=md5.
Previously, we supported only one hash function, FNV-1, so
BuildIdSection directly handled hash computation. In this patch,
I made BuildIdSection an abstract class and defined two subclasses,
BuildIdFnv1 and BuildIdMd5.

llvm-svn: 265737
2016-04-07 22:49:21 +00:00
Rui Ueyama 5d92af65d3 Sort options.
llvm-svn: 265724
2016-04-07 21:10:42 +00:00
Rui Ueyama c4354a3c18 ELF: Define -S as an alias for --strip-debug.
llvm-svn: 265723
2016-04-07 21:10:09 +00:00
Rui Ueyama fc6a4b045f ELF: Add --strip-debug option.
If --strip-debug option is given, then all sections whose names start
with ".debug" are removed from output.

llvm-svn: 265722
2016-04-07 21:04:51 +00:00
Rui Ueyama 8c76487ee5 ELF: Add --no-gnu-unique option.
When the option is specified, then all STB_GNU_UNIQUE symbols are
converted to STB_GLOBAL symbols.

llvm-svn: 265717
2016-04-07 20:41:41 +00:00
Rui Ueyama f8baa66056 ELF: Implement --start-lib and --end-lib
start-lib and end-lib are options to link object files in the same
semantics as archive files. If an object is in start-lib and end-lib,
the object is linked only when the file is needed to resolve
undefined symbols. That means, if an object is in start-lib and end-lib,
it behaves as if it were in an archive file.

In this patch, I introduced a new notion, LazyObjectFile. That is
analogous to Archive file type, but that works for a single object
file instead of for an archive file.

http://reviews.llvm.org/D18814

llvm-svn: 265710
2016-04-07 19:24:51 +00:00
Rui Ueyama e0f1ab87c8 Ignore --warn-execstack.
Stack is not executable by default in LLD-built executables unless
you pass -z execstack option. So --warn-execstack option does not make
sense to us.

llvm-svn: 265619
2016-04-06 23:55:43 +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
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
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
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
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