Commit Graph

240 Commits

Author SHA1 Message Date
Rafael Espindola eed9725451 Hide the --full-shutdown option.
llvm-svn: 324365
2018-02-06 18:12:41 +00:00
Rui Ueyama bb8d15e4d7 Add -no-allow-multiple-definition, -no-pic-executable and -no-warn-common.
GNU gold has these options.

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

llvm-svn: 324300
2018-02-06 00:45:15 +00:00
Rui Ueyama e80ce52cee Allow both -no-omagic and --no-omagic.
Any multi-character option that doesn't start with "o" should be
allowed to start both with "-" and "--".

llvm-svn: 324262
2018-02-05 19:14:03 +00:00
Peter Smith 64f65b02d2 [ELF] Implement --[no-]apply-dynamic-relocs option.
When resolving dynamic RELA relocations the addend is taken from the
relocation and not the place being relocated. Accordingly lld does not
write the addend field to the place like it would for a REL relocation.
Unfortunately there is some system software, in particlar dynamic loaders
such as Bionic's linker64 that use the value of the place prior to
relocation to find the offset that they have been loaded at. Both gold
and bfd control this behavior with the --[no-]apply-dynamic-relocs option.
This change implements the option and defaults it to true for compatibility
with gold and bfd.

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

llvm-svn: 324221
2018-02-05 10:15:08 +00:00
Rui Ueyama 7a64a3d59c Simplify.
llvm-svn: 324155
2018-02-02 22:48:09 +00:00
Rui Ueyama edd4ec54d6 Update Eq so that it uses NAME just like B does. NFC.
llvm-svn: 324154
2018-02-02 22:45:47 +00:00
Rui Ueyama 6a8e79b8e5 Add -{no,}-check-sections flags to enable/disable section overlchecking
GNU linkers have this option.

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

llvm-svn: 324150
2018-02-02 22:24:06 +00:00
Rui Ueyama aad2e328b9 Add --no-gnu-unique and --no-undefined-version for completeness.
Differential Revision: https://reviews.llvm.org/D42865

llvm-svn: 324145
2018-02-02 21:44:06 +00:00
Rui Ueyama 14f07a0ea5 Consolidate --foo and --no-foo options. NFC.
Differential Revision: https://reviews.llvm.org/D42859

llvm-svn: 324141
2018-02-02 21:25:51 +00:00
Rui Ueyama 5d87b6911f Fix typo: --nopie -> --no-pie.
--nopie was a typo. GNU gold doesn't recognize it. It is also
inconsistent with other options that have --foo and --no-foo.

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

llvm-svn: 324043
2018-02-02 00:31:05 +00:00
James Henderson 9c6e2fd5a4 [ELF] Add --print-icf-sections flag
Currently ICF information is output through stderr if the "--verbose"
flag is used. This differs to Gold for example, which uses an explicit
flag to output this to stdout. This commit adds the
"--print-icf-sections" and "--no-print-icf-sections" flags and changes
the output message format for clarity and consistency with
"--print-gc-sections". These messages are still output to stderr if
using the verbose flag. However to avoid intermingled message output to
console, this will not occur when the "--print-icf-sections" flag is
used.

Existing tests have been modified to expect the new message format from
stderr.

Patch by Owen Reynolds.

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

Reviewers: ruiu, rafael

Reviewed by: 

llvm-svn: 323976
2018-02-01 16:00:46 +00:00
Ed Maste 6ed7f00e49 Correct typo in help text
Information is a mass noun and doesn't take a plural "s".

llvm-svn: 322180
2018-01-10 12:55:14 +00:00
Rafael Espindola b5506e6baf Rename --icf-data and add a corresponding flag for functions.
When we have --icf=safe we should be able to define --icf=all as a
shorthand for --icf=safe --ignore-function-address-equality.

For now --ignore-function-address-equality is used only to control
access to non preemptable symbols in shared libraries.

llvm-svn: 322152
2018-01-10 01:37:36 +00:00
Peter Smith 96ca4f5e91 [ELF] Remove Duplicate .ARM.exidx sections
The ARM.exidx section contains a table of 8-byte entries with the first
word of each entry an offset to the function it describes and the second
word instructions for unwinding if an exception is thrown from that
function. The SHF_LINK_ORDER processing will order the table in ascending
order of the functions described by the exception table entries. As the
address range of an exception table entry is terminated by the next table
entry, it is possible to merge consecutive table entries that have
identical unwind instructions.

For this implementation we define a table entry to be identical if:
- Both entries are the special EXIDX_CANTUNWIND.
- Both entries have the same inline unwind instructions.
We do not attempt to establish if table entries that are references to
.ARM.extab sections are identical.

This implementation works at a granularity of a single .ARM.exidx
InputSection. If all entries in the InputSection are identical to the
previous table entry we can remove the InputSection. A more sophisticated
but more complex implementation would rewrite InputSection contents so that
duplicates within a .ARM.exidx InputSection can be merged.

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

llvm-svn: 320803
2017-12-15 11:09:41 +00:00
Rui Ueyama 1ce416c635 Remove trailing whitespace.
llvm-svn: 320520
2017-12-12 20:00:30 +00:00
Rafael Espindola 814ece6854 Add an option for ICFing data.
An internal linker has support for merging identical data and in some
cases it can be a significant win.

This is behind an off by default flag so it has to be requested
explicitly.

llvm-svn: 320448
2017-12-12 01:36:24 +00:00
Peter Collingbourne d1eefa993b ELF: Ignore --long-plt flag.
This flag can be ignored because we always emit long PLTs.

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

llvm-svn: 320178
2017-12-08 19:36:19 +00:00
Peter Smith 732cd8cbef [ELF] Implement scanner for Cortex-A53 Erratum 843419
Add a new file AArch64ErrataFix.cpp that implements the logic to scan for
the Cortex-A53 Erratum 843419. This involves finding all the executable
code, disassembling the instructions that might trigger the erratum and
reporting a message if the sequence is detected.

At this stage we do not attempt to fix the erratum, this functionality
will be added in a later patch. See D36749 for proposal.

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

llvm-svn: 319780
2017-12-05 15:59:05 +00:00
Rui Ueyama 11adb536e1 Ignore -no-ctors-in-init-array.
Patch by dxf@google.com.

llvm-svn: 318513
2017-11-17 08:17:36 +00:00
Rui Ueyama 700b1f8a56 Add --no-omagic and --no-print-gc-sections.
llvm-svn: 317068
2017-11-01 02:04:43 +00:00
Peter Collingbourne 5c54f15c55 ELF: Add support for emitting dynamic relocations in the Android relocation packing format.
The Android relocation packing format is a more compact
format for dynamic relocations in executables and DSOs
that is based on delta encoding and SLEBs. An overview
of the format can be found in the Android source code:
https://android.googlesource.com/platform/bionic/+/refs/heads/master/tools/relocation_packer/src/delta_encoder.h

This patch implements relocation packing using that format.

This implementation uses a more intelligent algorithm for compressing
relative relocations than Android's own relocation packer. As a
result it can generally create smaller relocation sections than
that packer. If I link Chromium for Android targeting ARM32 I get a
.rel.dyn of size 174693 bytes, as compared to 371832 bytes with gold
and the Android packer.

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

llvm-svn: 316775
2017-10-27 17:49:40 +00:00
George Rimar 9814d15136 [ELF] - Implement --orphan-handling option.
It is PR34946.

Spec (http://man7.org/linux/man-pages/man1/ld.1.html) tells about
--orphan-handling=MODE, option where MODE can be one of four:
"place", "discard", "warn", "error".
Currently we already report orphans when -verbose given,
what becomes excessive with option implemented.

Patch stops reporting orphans when -versbose is given,
and support "place", "warn" and "error" modes.
It is not yet clear that "discard" mode is useful so it is not supported.

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

llvm-svn: 316583
2017-10-25 15:20:30 +00:00
George Rimar 228340315d [ELF] - Removed unused class from Options.td. NFC.
llvm-svn: 315993
2017-10-17 12:23:51 +00:00
Rui Ueyama e2f52eb22f Add -no-gdb-index which negates -gdb-index option.
llvm-svn: 312753
2017-09-07 22:40:54 +00:00
Rui Ueyama 38eab87671 Add -no-eh-frame-hdr which negates -eh-frame-hdr.
Note that ld.bfd and ld.gold have the option.

llvm-svn: 312010
2017-08-29 16:53:24 +00:00
Rui Ueyama 5c19028cec Allow not only -O<number> but also -O <number>.
Fixes https://bugs.llvm.org/show_bug.cgi?id=34311

llvm-svn: 311682
2017-08-24 18:34:44 +00:00
George Rimar cb38bf526b [ELF] - LTO: Try to be option compatible with the gold plugin.
This is relative to PR30720.

Previously we ignored all --plugin-opt arguments.
Patch adds support for them.

Patch does not add any new LTO options,
and just implements mapping from --plugin-opt to existent ones.

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

llvm-svn: 310826
2017-08-14 10:17:30 +00:00
Rui Ueyama ae704a5472 Add --icf=none option.
--icf=none negates --icf=all.

llvm-svn: 310526
2017-08-09 21:32:38 +00:00
George Rimar d5948f3a9a [ELF] - Ignore --warn-once option.
Was discussed in D35797 thread.

llvm-svn: 309096
2017-07-26 10:25:49 +00:00
Rui Ueyama 8109789a33 Simplify ignored options.
Since the flag is ignored anyway, it doesn't matter whether
it is an alias or not.

llvm-svn: 309055
2017-07-25 23:32:05 +00:00
George Rimar 4f37d57547 [ELF] - Introduce multiclass Eq helper for Options.td
Eq helper allows to define `XXX` and `XXX=` options forms easily.
Patch adds testcases for few aliases.

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

llvm-svn: 308752
2017-07-21 16:27:26 +00:00
Rui Ueyama 875ae82b0b Add the --chroot option for --reproduce.
Summary:
If the linker is invoked with `--chroot /foo` and `/bar/baz.o`, it
tries to read the file from `/foo/bar/baz.o`. This feature is useful
when you are dealing with files created by the --reproduce option.

Reviewers: grimar

Subscribers: llvm-commits, emaste

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

llvm-svn: 308646
2017-07-20 18:17:55 +00:00
George Rimar dae8495faf [ELF] - Stop listing version-script= form as ignored option.
Funny but we list it as ignored for about 1.5 years atm,
though LLD started to support version script really long time ago.

llvm-svn: 308170
2017-07-17 10:15:15 +00:00
George Rimar f525c928cf [ELF] - Implement filter library support (-F / --filter)
This is PR33766.

-F name
--filter=name
When creating an ELF shared object, set the internal DT_FILTER field to the specified name. This tells the dynamic linker that the symbol table of the shared object which is being created should be used as a filter on the symbol table of the shared object name.

If you later link a program against this filter object, then, when you run the program, the dynamic linker will see the DT_FILTER field. The dynamic linker will resolve symbols according to the symbol table of the filter object as usual, but it will actually link to the definitions found in the shared object name. Thus the filter object can be used to select a subset of the symbols provided by the object name.
(https://linux.die.net/man/1/ld).

Shared Objects as Filters:
https://docs.oracle.com/cd/E19683-01/817-3677/chapter4-31738/index.html

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

llvm-svn: 308167
2017-07-17 09:43:18 +00:00
Rui Ueyama d1f8b8162b Implement the --exclude-libs option.
The --exclude-libs option is not a popular option, but at least some
programs in Android depend on it, so it's worth to support it.

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

llvm-svn: 305920
2017-06-21 15:36:24 +00:00
Rui Ueyama 5012858e26 Accept not only --reproduce <foo> but also --reproduce=<foo>.
llvm-svn: 303905
2017-05-25 19:49:54 +00:00
George Rimar bb451903f5 [ELF] - Accept --defsym foo=value form.
Previously we accepted --defsym=foo=value only.

Reported by Sean Silva.

llvm-svn: 302227
2017-05-05 11:59:15 +00:00
Rui Ueyama 789723fddf Ignore -no-keep-memory.
When the -no-keep-memory option is given, BFD linker tries to save
memory in their own way. Since our internal architecture is completely
different from that linker, that option doesn't make sense to us.

llvm-svn: 301772
2017-04-30 13:45:06 +00:00
Rui Ueyama b402a866c1 Move LTO options above "all options beyond this are ignored" comment
llvm-svn: 301771
2017-04-30 13:44:52 +00:00
George Rimar 9703ad2221 [ELF] - Implemented --defsym option.
gnu ld description of option is:

--defsym=symbol=expression
Create a global symbol in the output file, containing the absolute address given 
by expression. You may use this option as many times as necessary to define multiple
symbols in the command line. A limited form of arithmetic is supported for the 
expression in this context: you may give a hexadecimal constant or the name of an
existing symbol, or use "+" and "-" to add or subtract hexadecimal constants or 
symbols. If you need more elaborate expressions, consider using the linker command
language from a script. Note: there should be no white space between symbol, 
the equals sign ("="), and expression.

In compare with D32082, this patch does not support math expressions and absolute
symbols. It implemented via code similar to --wrap. That covers 1 of 3 possible
--defsym cases.

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

llvm-svn: 301391
2017-04-26 10:40:02 +00:00
George Rimar dbf9339715 [ELF] - Implemented --compress-debug-sections option.
Patch implements --compress-debug-sections=zlib.

In compare with D20211 (a year old patch, abandoned), it implementation
uses streaming and fully reimplemented, does not support zlib-gnu for
simplification.

This is PR32308.

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

llvm-svn: 300444
2017-04-17 08:58:12 +00:00
Rui Ueyama 0cbf1fd2f6 Fix varaible names that correspond to command line options.
llvm-svn: 298632
2017-03-23 18:16:42 +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
Rui Ueyama 62d547441d Options such as -omagic or -opt-remarks-* should be interpreted as -o.
Options can start with `-` or `--` unless they start with "o".
Any option that starts with `-o` should be interpreted as an output
file name. This is a quote from the GNU ld man page.

  Note -- there is one exception to this rule.  Multiple letter
  options that start with a lower case 'o' can only be preceded by
  two dashes.  This is to reduce confusion with the -o option.
  So for example -omagic sets the output file name to magic whereas
  --omagic sets the NMAGIC flag on the output.

We didn't handle that properly before.

llvm-svn: 297508
2017-03-10 21:22:28 +00:00
Peter Collingbourne e02775f068 ELF: Add ThinLTO caching support.
This patch adds an option named --thinlto-cache-dir, which specifies the
path to a directory in which to cache native object files for ThinLTO
incremental builds.

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

llvm-svn: 296702
2017-03-01 23:00:10 +00:00
George Rimar 87b0d68633 [ELF] - Implemented --no-dynamic-linker option
Feature is used for producing static-linked PIE executables
(https://gcc.gnu.org/ml/gcc/2015-06/msg00008.html)
And was implemented in GNU ld https://gcc.gnu.org/ml/gcc/2015-08/msg00099.html

I also found it in linux kernel build system,
though I think that x86/x64 bootloader does not really rely on it.
Seems it used for PPC though.

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

llvm-svn: 296097
2017-02-24 08:26:18 +00:00
Davide Italiano db4b0a7194 [LTO] Add support for optimization remarks.
Differential Revision:  https://reviews.llvm.org/D29878

llvm-svn: 294971
2017-02-13 17:49:18 +00:00
George Rimar 82bd8be6d8 Recommit r294464 "[ELF] - Added partial support for --emit-relocs (no --gc-section case, no /DISCARD/ support) #3"
with temporarily file name fix in testcase.

Original commit message:

-q, --emit-relocs - Generate relocations in output

Simplest implementation: 
* no GC case, 
* no "/DISCARD/" linkerscript command support.

This patch is extracted from D28612 / D29636,

Relative to PR31579.

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

llvm-svn: 294469
2017-02-08 16:18:10 +00:00
George Rimar 0b2cc8190d Reverted r294464 "[ELF] - Added partial support for --emit-relocs (no --gc-section case, no /DISCARD/ support) #3"
Broked build bot:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/5835/steps/test/logs/stdio

llvm-svn: 294466
2017-02-08 16:10:14 +00:00
George Rimar d6ae624552 [ELF] - Added partial support for --emit-relocs (no --gc-section case, no /DISCARD/ support) #3
-q, --emit-relocs - Generate relocations in output

Simplest implementation: 
* no GC case, 
* no "/DISCARD/" linkerscript command support.

This patch is extracted from D28612 / D29636,

Relative to PR31579.

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

llvm-svn: 294464
2017-02-08 15:53:33 +00:00