Commit Graph

68 Commits

Author SHA1 Message Date
Ed Maste 3261be4b8d Add --version-script= alias for --version-script
llvm-svn: 255249
2015-12-10 14:08:45 +00:00
George Rimar a5fbebc206 [ELF] - Implemented --print-gc-sections command line argument.
List all sections removed by garbage collection. This option is only effective if garbage collection has been enabled via the `--gc-sections' option.

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

llvm-svn: 255235
2015-12-10 09:12:18 +00:00
Rui Ueyama 6220fd8bfd Define -E as an alias for --export-dynamic.
llvm-svn: 253713
2015-11-20 21:22:53 +00:00
Ed Maste c98805b493 Accept -whole-archive and -no-whole-archive (with a single dash)
Clang uses the single-dash version in addSanitizerRuntime().

llvm-svn: 253477
2015-11-18 17:22:02 +00:00
Rui Ueyama 1d37e60dc5 ELF2: Make comment less opinionated.
llvm-svn: 253058
2015-11-13 18:56:07 +00:00
Rui Ueyama a6f103f705 ELF2: Add comments and reorganize option list a bit.
llvm-svn: 252978
2015-11-13 00:26:12 +00:00
Rui Ueyama f5bcf2a72f ELF2: Print an error message for --relocatable.
llvm-svn: 252923
2015-11-12 18:54:15 +00:00
Simon Atanasyan 069b2dd66c [Driver] Ignore -G option in both new and old ELF linker
This is optimization option that make sense for MIPS targets. We can
safely ignore it now.

llvm-svn: 251519
2015-10-28 14:50:58 +00:00
Simon Atanasyan 07fe7a943f [Driver] Accept both -m <emulation> and -m<emulation>
GNU linkers accept both variants and at least for MIPS target gcc passes
joined variant of the '-m' option.

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

llvm-svn: 251497
2015-10-28 05:13:12 +00:00
Davide Italiano ce0d48adbb [ELF2/Driver] Accept both -L <arg> and -L<arg>.
This matches ld.bfd and ld.gold behavior. The change is simple enough
and avoid trouble to consumers (they don't have to change their Makefiles).
Side note: found while trying to build FreeBSD base system with lld.

llvm-svn: 251408
2015-10-27 15:10:53 +00:00
Rui Ueyama 0b2b964797 ELF2: Ignore -( and -).
They are aliases to --start-group and --end-group, respectively.

llvm-svn: 251332
2015-10-26 19:05:44 +00:00
George Rimar 5dad7c1d4c Reapply r251144: fixed test.
llvm-svn: 251184
2015-10-24 08:52:46 +00:00
Rui Ueyama b621d1ae58 Revert "[ELF2] --strip-all/-s command line implemented"
This reverts commit r251144 because the new test is failing.

llvm-svn: 251148
2015-10-23 21:08:41 +00:00
George Rimar 236bf3bfe4 [ELF2] --strip-all/-s command line implemented
-s, --strip-all - Strip all symbols
Implementation removes .strtab and .symtab sections from output.

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

llvm-svn: 251144
2015-10-23 20:24:44 +00:00
Rafael Espindola 2c1217d82a Parse and store the value of the -O option.
llvm-svn: 251136
2015-10-23 19:02:19 +00:00
Rui Ueyama c4aaed9255 ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.

In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.

This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.

It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.

http://reviews.llvm.org/D13950

llvm-svn: 251043
2015-10-22 18:49:53 +00:00
Igor Kudrin 1b0d7066ff [ELF2] Add support for GNU Hash section
This patch implements --hash-style command line switch.

* By default, or with "sysv" or "both" parameters, the linker generates
  a standard ELF hash section.
* With "gnu" or "both", it produces a GNU-style hash section.

That section requires the symbols in the dynamic symbol table section, which
are referenced in the GNU hash section, to be placed after not hashed ones and
to be sorted to correspond the order of hash buckets in the GNU Hash section.

The division function, as well as estimations for the section's parameters,
are just the first rough attempt and the subjects for further adjustments.

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

llvm-svn: 251000
2015-10-22 08:21:35 +00:00
George Rimar 85f1d6678f [ELF2] -l behavior is JoinedOrSeparate. Keeping consistency with ld here.
llvm-svn: 250812
2015-10-20 10:03:14 +00:00
Davide Italiano 5d1ec86910 [Driver] Ignore some options used to link FreeBSD userland.
We're gonna implement them at some point, but they're mostly warning,
not of vital importance at this stage of development.

llvm-svn: 250738
2015-10-19 21:01:32 +00:00
Ed Maste cbd42b17c7 Recognize -Bshareable alias for -shared
llvm-svn: 250397
2015-10-15 13:03:16 +00:00
Davide Italiano cebb449e11 [ELF2] Add support for -Bsymbolic.
llvm-svn: 250225
2015-10-13 21:02:34 +00:00
Rui Ueyama 35da9b6e1c ELF2: Implement --as-needed.
This patch adds AsNeeded and IsUsed bool fields to SharedFile. AsNeeded bit
is set if the DSO is enclosed with --as-needed and --no-as-needed. IsUsed
bit is off by default. When we adds a symbol to the symbol table for dynamic
linking, we set its SharedFile's IsUsed bit.

If AsNeeded is set but IsUsed is not set, we don't want to write that
file's SO name to DT_NEEDED field.

http://reviews.llvm.org/D13579

llvm-svn: 249998
2015-10-11 20:59:12 +00:00
Davide Italiano 4e47d589e6 [ELF2] Implement -T/--script.
This one tests more carefully SEARCH_DIR() as an added bonus.

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

llvm-svn: 249969
2015-10-11 03:53:36 +00:00
Rui Ueyama a467240309 ELF2: Add --verbose.
It is currently not actually verbose but rather terse,
but that's intentional.

llvm-svn: 249964
2015-10-11 02:03:03 +00:00
Rui Ueyama 964ffb3e11 Define --output= as an alias to -o.
llvm-svn: 249789
2015-10-09 00:33:44 +00:00
George Rimar 97aad172b8 [ELF2] -z now option implemented
When generating an executable or shared library, mark it to tell the dynamic linker to resolve all symbols when the program is started, or when the shared library is linked to using dlopen, instead of deferring function call resolution to the point when the function is first called.

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

llvm-svn: 249551
2015-10-07 15:00:21 +00:00
Denis Protivensky 1ef7b3ff55 [ELF2] Handle -m option
Parse and apply emulation given with -m option.
Check input files to match ELF type and machine architecture provided with -m.

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

llvm-svn: 249529
2015-10-07 09:13:03 +00:00
Davide Italiano c39c75dee4 [ELF2] Implement --{enable, disable}-new-dtags options.
llvm-svn: 249428
2015-10-06 16:20:00 +00:00
George Rimar d01ffbdb1b Fixed typo
llvm-svn: 249393
2015-10-06 12:08:08 +00:00
Igor Kudrin b1f2b51a89 [ELF2] Add DT_INIT and DT_FINI dynamic table entries
The entries are added if there are "_init" or "_fini" entries in
the symbol table respectively. According to the behavior of ld,
entries are inserted even for undefined symbols.

Symbol names can be overridden by using -init and -fini command
line switches. If used, these switches neither add new symbol table
entries nor require those symbols to be resolved.

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

llvm-svn: 249297
2015-10-05 10:29:46 +00:00
Denis Protivensky 22220d5d5f [ELF2] Add --undefined option
Add symbol specified with -u as undefined which may cause additional
object files from archives to be linked into the resulting binary.

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

llvm-svn: 249295
2015-10-05 09:43:57 +00:00
Ed Maste 2c86fb4bde Accept --dynamic-linker in addition to -dynamic-linker.
This matches what bfd ld accepts.

llvm-svn: 249234
2015-10-03 09:32:48 +00:00
Ed Maste 21e4e148c6 Add -rpath= alias for -rpath
llvm-svn: 249230
2015-10-03 06:54:24 +00:00
Ed Maste 75c2feb753 Rename alias definitions by both aliased and alias name
Differential Revision: http://reviews.llvm.org/D13397

llvm-svn: 249186
2015-10-02 21:01:59 +00:00
Rafael Espindola 4876c886fc Ignore --version-script.
llvm-svn: 249149
2015-10-02 16:20:39 +00:00
Ed Maste 2dab6c9bcc Allow -soname arg in addition to -soname=arg
Differential Revision: http://reviews.llvm.org/D13387

llvm-svn: 249146
2015-10-02 15:45:26 +00:00
Ed Maste 9c95ac2946 Ignore --enable-new-dtags and --no-fatal-warnings
Found while testing a FreeBSD base system build with lld.  Ignored for
now while we continue to identify missing options and functionality.

llvm-svn: 249144
2015-10-02 15:29:31 +00:00
Rafael Espindola fc96a263a1 Ignore options used during a clang build.
llvm-svn: 249135
2015-10-02 14:25:26 +00:00
Rafael Espindola 327b178dd6 Accept some options with both -- and -.
This matches what both gold and bfd ld accept.

llvm-svn: 249134
2015-10-02 14:21:24 +00:00
Michael J. Spencer b660b61954 [elf2] Ignore --{start,end}-group.
llvm-svn: 249093
2015-10-01 22:54:37 +00:00
Rafael Espindola 8f13bef575 Ignore --no-add-needed.
llvm-svn: 249089
2015-10-01 22:31:38 +00:00
George Rimar 57e40deb8d [ELF2] Implement --no-undefined flag.
llvm-svn: 249064
2015-10-01 20:14:45 +00:00
Rui Ueyama 7de3f3719a ELF2: Add -soname option.
llvm-svn: 249058
2015-10-01 19:36:04 +00:00
Igor Kudrin 2696bbeb93 [ELF2] Add --[no-]whole-archive command line switches
Summary:
If --whole-archive is used, all symbols from the following archives are added to the output. --no-whole-archive restores default behavior. These switches can be used multiple times.

NB. We have to keep an ArchiveFile instance within SymbolTable even if --whole-archive mode is active since it can be a thin archive which contains just names of external files. In that case actual memory buffers for the archive members will be stored within the File member of ArchiveFile class.

Reviewers: rafael, ruiu

Subscribers: grimar, llvm-commits

Projects: #lld

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

llvm-svn: 249045
2015-10-01 18:02:21 +00:00
Rui Ueyama fd124db996 ELF2: Tidy up Options.td again.
llvm-svn: 249038
2015-10-01 17:33:38 +00:00
George Rimar ee05828261 [ELF2] Implement --allow-shlib-undefined as default behavior.
We ignore --{no,}allow-shlib-undefined options and always allow undefined
symbols if we are building a DSO.

llvm-svn: 249036
2015-10-01 17:24:24 +00:00
Igor Kudrin d912ee9595 [ELF2] Add -Bstatic and -Bdynamic command line switches
Summary:
These switches affect library searching for '-l' which follow them. Synonym forms are also supported:
* -dy and -call_shared for -Bdynamic switch
* -dn, -non_shared and -static for -Bstatic switch 

Reviewers: rafael, ruiu

Subscribers: emaste, llvm-commits

Projects: #lld

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

llvm-svn: 249029
2015-10-01 16:42:03 +00:00
Rui Ueyama 1c8092c915 ELF2: Tidy up Options.td.
Fix indentation and sort options alphabetically.

llvm-svn: 248969
2015-10-01 00:33:02 +00:00
Rui Ueyama 5d8ef2cbd8 ELF2: Ignore some command line argument that clang passes to the linker.
llvm-svn: 248967
2015-10-01 00:24:54 +00:00
Rui Ueyama 9d4c6d771b [ELF2] Implemented --entry flag.
Patch from George Rimar!

llvm-svn: 248806
2015-09-29 16:40:13 +00:00