Commit Graph

4436 Commits

Author SHA1 Message Date
Rui Ueyama 3ce825ed26 ELF2: Make SymbolTable a template class.
SymbolTable was not a template class. Instead we had switch-case-based
type dispatch to call desired functions. We had to do that because
SymbolTable was created before we know what ELF type objects had been
passed.

Every time I tried to add a new function to the symbol table, I had to
define a dispatcher which consist of a single switch statement.

It also brought an restriction what the driver can do. For example,
we cannot add undefined symbols before any files are added to the symbol
table. That's because no symbols can be added until the symbol table
knows the ELF type, but when it knows about that, it's too late.

In this patch, the driver makes a decision on what ELF type objects
are being handled. Then the driver creates a SymbolTable object for
an appropriate ELF type.

http://reviews.llvm.org/D13544

llvm-svn: 249902
2015-10-09 21:07:25 +00:00
Rui Ueyama 6ccc8ca6d9 Simplify. NFC.
llvm-svn: 249895
2015-10-09 20:32:54 +00:00
Rui Ueyama d888d10cf4 ELF2: Reduce code repetition.
llvm-svn: 249882
2015-10-09 19:34:55 +00:00
Rafael Espindola 444576d4c4 Add support for comdats.
The implementation is a direct translation to c++ of the rules in the ELF spec.

llvm-svn: 249881
2015-10-09 19:25:07 +00:00
Rafael Espindola 26fd69de90 Don't silently ignore an error.
Found by inspection.

llvm-svn: 249843
2015-10-09 16:15:57 +00:00
Rui Ueyama af311c1d01 ELF2: Call OutputSection::finalize() from createSections.
Previously, we did this in assignAddresses(), but finalization was
not part of assigning addresses, so this is a better place.

llvm-svn: 249842
2015-10-09 16:03:53 +00:00
Rui Ueyama bf3fd7c9a0 ELF2: Emit a PT_PHDR header as the first entry of the program header.
PT_PHDR entry points to the program header itself.

llvm-svn: 249839
2015-10-09 15:31:49 +00:00
Rafael Espindola d540919ff1 Revert "[ELF2] - Implemented rel[a].plt sections"
This reverts commit r249816.

It broke building llvm with lld:

$ ./bin/FileCheck
./bin/FileCheck: error while loading shared libraries: unexpected PLT reloc type 0x06

I think the only thing that is wrong with this patch is that it is too soon.

The plt we create (and its relocs) don't support lazy loading, so they have
to be relocated as ordinary dynamic relocations.

llvm-svn: 249835
2015-10-09 14:25:49 +00:00
Igor Kudrin 65bddeaacf [ELF2] Check for TLS mismatch in symbol resolution.
The linker should generate an error if a TLS symbol is resolved
for a non-TLS reference and vice versa.

The patch addresses PR24244 (https://llvm.org/bugs/show_bug.cgi?id=24244)

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

llvm-svn: 249817
2015-10-09 09:58:39 +00:00
George Rimar b352b9ce69 [ELF2] - Implemented rel[a].plt sections
.rela.plt contains list of elements in the PLT, which are liable to the relocation during the dynamic linking.

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

llvm-svn: 249816
2015-10-09 09:58:08 +00:00
Rui Ueyama fe7eeed585 ELF2: Sort. NFC.
llvm-svn: 249803
2015-10-09 02:46:28 +00:00
Rui Ueyama 36f69229e6 Simplify expressions. NFC.
llvm-svn: 249793
2015-10-09 00:50:05 +00:00
Rui Ueyama 49c68a7cf7 Remove getters/setters that don't provide much abstraction.
llvm-svn: 249791
2015-10-09 00:42:06 +00:00
Rui Ueyama 964ffb3e11 Define --output= as an alias to -o.
llvm-svn: 249789
2015-10-09 00:33:44 +00:00
Rui Ueyama 5a9640be32 ELF2: Split Writer::createSections into small functions.
Also added a few comments.

llvm-svn: 249781
2015-10-08 23:49:30 +00:00
Rui Ueyama 00851fdf4c Use uintX_t instead of unsigned int to fix potential cross-linking issue.
llvm-svn: 249765
2015-10-08 22:43:55 +00:00
Hal Finkel e3c2626aa4 [ELF2] Make the system page size a target-dependent property
The required page alignment is different on different targets. On PowerPC, for
example, we need 64K pages (the loader won't set different permissions on a
finer granularity than that). I've set the existing targets to what I believe
to be the correct values, and have updated the regression tests accordingly.

llvm-svn: 249760
2015-10-08 22:23:54 +00:00
Hal Finkel 6c2a3b8368 [ELF2] Make the .plt entry size target dependent
The size of a .plt entry is different on different targets (it is,
specifically, much larger than 8 on all PPC ABIs). There is no functional
change here (later patches to create .plt entries for PPC64 will depend on this
change).

llvm-svn: 249756
2015-10-08 21:51:31 +00:00
Hal Finkel 4729064a1c Revert: r249728 - Roll back r249726 and r249723 because they broke buildbots.
Reapply r249726 (and r249723), hopefully with the correct test fixups this time.

Original commit message:

Address a FIXME in ELF/Writer.cpp: Make VAStart a target-dependent property.
I've set the values for the existing targets to what I believe to be the
correct values, and updated the regression tests accordingly.

llvm-svn: 249752
2015-10-08 21:25:04 +00:00
Rui Ueyama 1890799f0c Re-apply r249630: ELF2: Use `-flavor gnu2` after `not` to fix Windows buildbot.
Thanks to George Rimar's r249696, `not` is now able to find ld.lld2
executable correctly.

llvm-svn: 249746
2015-10-08 20:57:29 +00:00
Rafael Espindola 6390d16fd1 Don't silently ignore an error.
Found by inspection.

llvm-svn: 249744
2015-10-08 20:43:19 +00:00
Rafael Espindola 98af66f9c5 Make this test a bit stricter.
The only way for SecIndex to be zero in here is for an extended section
number to be zero, which would be an error.

llvm-svn: 249736
2015-10-08 20:29:22 +00:00
Rui Ueyama af21d92320 ELF2: Do not pass GotVA because it's accessible as Out<ELFT>::Got->getVA().
llvm-svn: 249729
2015-10-08 20:06:07 +00:00
Rui Ueyama 7114f0597b Roll back r249726 and r249723 because they broke buildbots.
llvm-svn: 249728
2015-10-08 20:00:02 +00:00
Hal Finkel 1cbf51a41b [ELF2] Add missing test fixup after r249723
llvm-svn: 249726
2015-10-08 19:53:12 +00:00
Hal Finkel eb84ce8bd1 [ELF2] Make VAStart a target-dependent property
Address a FIXME in ELF/Writer.cpp: Make VAStart a target-dependent property.
I've set the values for the existing targets to what I believe to be the
correct values, and updated the regression tests accordingly.

llvm-svn: 249723
2015-10-08 19:36:39 +00:00
Hal Finkel cbd21a6ad2 [ELF2] Use EntrySize, not 8, to advance the .plt buffer when writing
In preparation for making the size of a .plt entry target dependent, use the
existing EntrySize variable when writing (instead of a hard-coded value). NFC.

llvm-svn: 249720
2015-10-08 19:16:05 +00:00
George Rimar 48570f1f4b [ELF2] Test for i686 relocations updated with comments.
Reviewed by Rafael. 

llvm-svn: 249719
2015-10-08 18:58:10 +00:00
Rafael Espindola 79e4452535 Test that we handle empty archives.
This was failing before 249709.

llvm-svn: 249710
2015-10-08 18:10:53 +00:00
Davide Italiano 68a39a6565 [ELF2] Implement linker script SEARCH_DIR() directive.
llvm-svn: 249707
2015-10-08 17:51:41 +00:00
Simon Atanasyan 456bd05d97 [ELF2][mips] Support elf32ltsmip/elf32btsmip target emulation as the -m arguments
llvm-svn: 249683
2015-10-08 12:13:38 +00:00
Rafael Espindola d42f4e5389 Add a convenience variable. NFC.
llvm-svn: 249682
2015-10-08 12:02:38 +00:00
Denis Protivensky 90c5099e8a [ELF2] Add ENTRY command to the linker script
Set ENTRY as an entry point if -e is not specified.

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

llvm-svn: 249661
2015-10-08 06:48:38 +00:00
Rui Ueyama 10c415fd63 Remove a default which immediately breaks.
getID()'s return type is unsigned int, so I don't think we need this
default for -Wswitch-enum.

llvm-svn: 249650
2015-10-08 03:21:29 +00:00
Rui Ueyama aca48ffb41 ELF2: Inititalize other symbols only once as well.
llvm-svn: 249645
2015-10-08 00:44:28 +00:00
Rui Ueyama 833ce281db ELF2: Make member variable names shorter.
I'm going to use them in other patches, and the names feel too long
despite their narrow scope.

llvm-svn: 249642
2015-10-08 00:29:00 +00:00
Rui Ueyama 9ea49c7948 ELF2: Initialize SyntheticOptional only once.
llvm-svn: 249636
2015-10-07 23:46:11 +00:00
Rui Ueyama e66e001c90 ELF2: Use the same name as COFF.
llvm-svn: 249635
2015-10-07 23:20:23 +00:00
Davide Italiano 8d9ace60ca [ELF/AArch64] Add tests to verify we handle overflow correctly for relocs.
llvm-svn: 249634
2015-10-07 23:15:22 +00:00
Rui Ueyama f82a0eef13 ELF2: Use `-flavor gnu2` after `not` to fix Windows buildbot.
`not` command on Windows is not able to find an executable from PATH
if a given command already has an extension even if the extension is
not ".exe".

llvm-svn: 249630
2015-10-07 22:20:43 +00:00
Davide Italiano c3858ab82e [ELF2] Garbage collect or{16,64}le. They're now unused.
llvm-svn: 249628
2015-10-07 22:11:20 +00:00
Davide Italiano 06d843226b [ELF2/AArch64] _ABS* relocations don't read contents. Fix it.
Spotted by: Rafael Espindola.

llvm-svn: 249627
2015-10-07 22:10:02 +00:00
Rui Ueyama e1f91529c8 ELF2: Rename dupError() -> reportConflict().
llvm-svn: 249622
2015-10-07 21:37:24 +00:00
Rui Ueyama 0d0bcf7433 ELF2: Stop using SymbolTableSection as a container for SymbolTable.
`Symtab` is better than `Out<ELFT>::SymTab->getSymTable()`.

llvm-svn: 249619
2015-10-07 21:25:39 +00:00
Rui Ueyama 2cac5843a0 ELF2: Define a utility function to handle simple command line options.
llvm-svn: 249592
2015-10-07 19:34:51 +00:00
Rui Ueyama 15ef5e174b ELF2: Make singleton output sections globally accessible.
Previously, output sections that are handled specially by the linker
(e.g. PLT or GOT) were created by Writer and passed to other classes
that need them. The problem was that because these special sections
are required by so many classes, the plumbing work became too much
burden.

This patch is to simply make them accessible from anywhere in the
linker to eliminate the plumbing work once and for all.

http://reviews.llvm.org/D13486

llvm-svn: 249590
2015-10-07 19:18:16 +00:00
George Rimar 730c27894a [ELF2] - fix to use PLT/GOT for DSO function calls (X86TargetInfo)
Differential Revision: http://reviews.llvm.org/D13522

llvm-svn: 249588
2015-10-07 18:46:13 +00:00
Rui Ueyama 75230398c2 ELF2: De-templatize writeResult for simplicity.
llvm-svn: 249586
2015-10-07 18:29:51 +00:00
Rui Ueyama 58d7d704d8 Style fix.
llvm-svn: 249584
2015-10-07 18:22:46 +00:00
Rafael Espindola 87c647aee1 Remove remaining uses of "-flavor gnu2".
llvm-svn: 249582
2015-10-07 18:20:07 +00:00
Rui Ueyama 60fe7fcc6b ELF2: Use ld.lld2 instead of lld -flavor gnu2.
llvm-svn: 249573
2015-10-07 17:31:39 +00:00
Rui Ueyama b4908761f8 ELF2: Rename local variable name `Out` in preparation to define `Out` global var.
llvm-svn: 249568
2015-10-07 17:04:18 +00:00
Rui Ueyama 0db335fd5e ELF2: Move functions out of line.
llvm-svn: 249566
2015-10-07 16:58:54 +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
Denis Protivensky 92aa1c02df [ELF2] Fix gcc build error
llvm-svn: 249524
2015-10-07 08:21:34 +00:00
Rafael Espindola cea0b3b45d Don't create dynamic relocations for weak undefined symbols.
llvm-svn: 249520
2015-10-07 04:22:55 +00:00
Rafael Espindola e782f673a8 Skip entries handled by the dynamic linker.
We were writing got entries in the first positions, not in the positions
corresponding to locally defined symbols.

llvm-svn: 249518
2015-10-07 03:56:05 +00:00
Rafael Espindola c05ad3dedb Create linker generated symbols earlier.
We were incorrectly deciding that a dynamic relocation was needed for them.

llvm-svn: 249512
2015-10-07 02:51:44 +00:00
Rafael Espindola cbffa8cc97 Add missing % to t2.so.
llvm-svn: 249505
2015-10-07 02:01:47 +00:00
Rafael Espindola 52dca345db Create simpler dynamic relocations for local symbols in got.
If the symbol is not preemptable, we can use a R_X86_64_RELATIVE.

llvm-svn: 249496
2015-10-07 00:58:20 +00:00
Rui Ueyama ee59282bfd ELF2: Implement OUTPUT() linker script directive.
llvm-svn: 249491
2015-10-07 00:25:09 +00:00
Rafael Espindola 3378526f34 Fix typo.
llvm-svn: 249488
2015-10-07 00:15:43 +00:00
Rafael Espindola a662738e02 Don't create dynamic relocations when its known what the got points to.
llvm-svn: 249485
2015-10-06 23:56:53 +00:00
Rafael Espindola 4b81795c2a Update tests for upcoming change.
I am about to change lld to avoid creating unnecessary got entries for locally
defined symbols when creating executables.

Update tests that were depending on the current behavior.

llvm-svn: 249474
2015-10-06 21:52:48 +00:00
Michael J. Spencer f32446fb65 [elf2] Correctly determine if we should ignore missing __tls_get_addr.
llvm-svn: 249462
2015-10-06 20:39:09 +00:00
Davide Italiano aad4402097 [ELF2] Address r249428 post comit review. Style + test trim.
llvm-svn: 249451
2015-10-06 20:02:15 +00:00
Michael J. Spencer fcacad263a [elf2] Fix style.
llvm-svn: 249450
2015-10-06 19:57:05 +00:00
Rui Ueyama ee8c53bbe2 ELF2: Inline small functions.
llvm-svn: 249449
2015-10-06 19:57:01 +00:00
Rui Ueyama b5fb88584a ELF2: Update README.
llvm-svn: 249447
2015-10-06 19:21:13 +00:00
Davide Italiano ef4be6b4fe [ELF2/AArch64] Function names should start with a verb (lower case).
Pointed out by: Rafael Espindola.

llvm-svn: 249443
2015-10-06 19:01:32 +00:00
Rui Ueyama 87bc41bcee ELF2: Use shorter names before this file grows larger.
llvm-svn: 249441
2015-10-06 18:54:43 +00:00
Rui Ueyama 33bb1a23b3 ELF2: or{16,32,64}le should really do bitwise-OR.
llvm-svn: 249436
2015-10-06 18:11:18 +00:00
Rui Ueyama 190beb3144 ELF2: Define or{16,32,64}le that are analogous to add32le.
llvm-svn: 249435
2015-10-06 18:08:03 +00:00
Davide Italiano c39c75dee4 [ELF2] Implement --{enable, disable}-new-dtags options.
llvm-svn: 249428
2015-10-06 16:20:00 +00:00
Rafael Espindola 85a6e0f870 Never fetch members for weak undefined symbols.
We were still fetching them when the archive was seen first.

We should experiment with just letting lazy symbols get to compare, it
might be cleaner for ELF.

llvm-svn: 249417
2015-10-06 15:18:50 +00:00
Rafael Espindola b90582dbbd Avoid recursive calls to init (we would crash).
llvm-svn: 249412
2015-10-06 15:03:52 +00:00
Rafael Espindola 8614c566e2 Handle strong undefined symbols fetching members after a weak undefined.
This is a case that requires --start-group --end-group with regular ELF
linkers. Fortunately it is still possible to handle it with lazy symbols without
taking a second look at archives.

Thanks to Michael Spencer for the bug report.

llvm-svn: 249406
2015-10-06 14:33:58 +00:00
Rafael Espindola 6f4bd532d3 Rearrange a bit for clarity. NFC.
llvm-svn: 249404
2015-10-06 14:17:53 +00:00
Rafael Espindola 03ab3368a0 External symbols need a full dynamic reloc, not R_X86_64_RELATIVE.
We were already doing the right thing if the symbol was seen in a shared
library, but not if it was completely missing.

llvm-svn: 249397
2015-10-06 12:39:58 +00:00
George Rimar d01ffbdb1b Fixed typo
llvm-svn: 249393
2015-10-06 12:08:08 +00:00
Michael J. Spencer 6e78d16b3b [elf2] Address style comments.
llvm-svn: 249368
2015-10-06 02:13:54 +00:00
Michael J. Spencer 95538ca99a [elf2] Add __preinit_array, and __fini_array start and end symbols.
llvm-svn: 249367
2015-10-06 01:16:17 +00:00
Michael J. Spencer 4c46f57a49 [elf2] Ignore __tls_get_addr when static linking.
llvm-svn: 249365
2015-10-06 00:45:42 +00:00
Rafael Espindola 41127ad7af Fix R_X86_64_RELATIVE for local symbols that refer to other sections.
We were mixing up the relocated and target sections.

llvm-svn: 249360
2015-10-05 22:49:16 +00:00
Davide Italiano b4606e183e [ELF2/AArch64] Read the right amount of bytes.
This was clearly wrong (thanks Rui for spotting), and I honestly would 
like to get this tested so such mistakes won't repeat. Unfortunately, I
wasn't (easily) able to craft a test that exposes the bad behavior.
Ideally, we would like to get tests of this kind for all relocations, but
at the time of writing, this is not true. So, for now just fix this bug
and try to re-evaluate a way to test this in the future.

llvm-svn: 249359
2015-10-05 22:43:42 +00:00
Rafael Espindola 9c3e4d2af5 Handle a common symbol needing a R_X86_64_RELATIVE.
llvm-svn: 249357
2015-10-05 21:23:08 +00:00
Rafael Espindola 3c83e2bbfb Include existing addend when computing R_X86_64_RELATIVE.
llvm-svn: 249353
2015-10-05 21:09:37 +00:00
Rafael Espindola d75fbd221d Make this test a bit more strict.
Before the ADDR variables could match the empty string.

llvm-svn: 249350
2015-10-05 20:54:39 +00:00
Rafael Espindola ae24400424 Create R_X86_64_RELATIVE when needed.
The dynamic relocation code needs refactoring, but it is probably better
to do it with this test passing.

llvm-svn: 249340
2015-10-05 19:30:12 +00:00
Rafael Espindola d1cf421bd5 Don't copy STT_SECTION from the inputs.
This matches the behavior of gold and bfd ld.

llvm-svn: 249326
2015-10-05 16:25:43 +00:00
Igor Kudrin 024c84c77c Remove an extra blank line.
llvm-svn: 249324
2015-10-05 16:05:18 +00:00
Rafael Espindola 4f674ed138 Include hidden and internal symbols in the regular symbol table.
This matches the behavior of bfd ld and gold. It is also convenient for
testing other changes.

llvm-svn: 249323
2015-10-05 15:24:04 +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
Davide Italiano b00e523d00 [ELF2/AArch64] R_AARCH64_ABS{16,32} can fail.
Add tests to ensure we handle this case this case gracefully.

llvm-svn: 249255
2015-10-04 01:08:58 +00:00
Davide Italiano df88f968e3 [ELF2/AArch64] Add support for AARCH64_ABS{16,32,64} relocations.
I saw these in the wild while trying to link shared libraries.

llvm-svn: 249254
2015-10-04 00:59:16 +00:00
Davide Italiano 0b6974bfe0 [ELF/AArch64] Support R_AARCH64_ADR_PREL_PG_H121 relocation.
llvm-svn: 249246
2015-10-03 19:56:07 +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
Michael J. Spencer 7744d9a201 [elf2] Remove unused flag in test.
llvm-svn: 249204
2015-10-02 22:39:35 +00:00
Davide Italiano d9b5be4c83 [ELF/AArch64] Fix a couple of typos. My bad, sorry.
llvm-svn: 249201
2015-10-02 22:17:09 +00:00
Rui Ueyama 5713b8d0db ELF2: Use less templates so that we can use struct assignment. NFC.
llvm-svn: 249200
2015-10-02 22:17:07 +00:00
Davide Italiano 318ca22914 [ELF2/AArch64] Add comment and change name to match the one of the ABI.
Fix style while I'm here.

llvm-svn: 249198
2015-10-02 22:13:51 +00:00
Davide Italiano 1f31a2c11c [ELF2/AArch64] Add support for R_AARCH64_ADR_PREL_PG_H121
llvm-svn: 249195
2015-10-02 22:00:42 +00:00
Michael J. Spencer ed3476b79f [elf2] Add STB_GNU_UNIQUE support.
llvm-svn: 249193
2015-10-02 21:57:52 +00:00
Rui Ueyama 04dae558f4 ELF2: Make Writer::assignAddress() a bit shorter. NFC.
llvm-svn: 249190
2015-10-02 21:23:17 +00:00
Rui Ueyama 0fb1ee0c77 Fix variable names.
llvm-svn: 249188
2015-10-02 21:13:19 +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 7757224466 Add static initialization/finalization array support.
This adds entries in the dynamic table for .init_array, .fini_array and
.preinit_array.

llvm-svn: 249175
2015-10-02 19:37:55 +00:00
Hal Finkel 58d7ee397d [ELF2] Simplify test from r249150
As Rafael pointed out, we don't need quite so many flags on the llvm-readobj
RUN line here.

llvm-svn: 249162
2015-10-02 17:57:29 +00:00
Rafael Espindola b2a5cafb37 Weak undefined symbols should not fetch archive members.
llvm-svn: 249160
2015-10-02 17:41:22 +00:00
Hal Finkel d26da9258f [ELF2] Fix mixed-Endian handling in DynamicSection<ELFT>::writeTo
Using the "raw" Elf64_Dyn or Elf32_Dyn structures in
DynamicSection<ELFT>::writeTo does not correctly handle mixed-Endian
situations. Instead, use the corresponding llvm::object::* structures which
have Endian-converting members (like the rest of the code).

This fixes all currently-failing elf2 tests when running on big-Endian
PPC64/Linux (I've added a big-Endian test case which should fail on
little-Endian machines in the same way that test/elf2/shared.s failed on
big-Endian machines prior to this change).

llvm-svn: 249150
2015-10-02 16:21:30 +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
Rafael Espindola 7d76847da3 Simplify. NFC.
llvm-svn: 249128
2015-10-02 13:23:29 +00:00
Rafael Espindola 98efd89e7e Use ld.lld2 as a argv[0] alias.
The reason for the name is so that we can run

./build/bin/clang -fuse-ld=lld2 test.o -o t

llvm-svn: 249122
2015-10-02 12:57:34 +00:00
Rui Ueyama 8c205d5394 ELF2: Merge duplicates using lambdas. NFC.
llvm-svn: 249118
2015-10-02 01:33:31 +00:00
Rui Ueyama 43155d0d48 [LLD] Fix Clang-tidy modernize-use-nullptr warnings; other minor cleanups.
Patch from Eugene Zelenko!

llvm-svn: 249111
2015-10-02 00:36:00 +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
Rafael Espindola dc7f5f2b77 Remove dead file.
llvm-svn: 249080
2015-10-01 21:51:07 +00:00
Rafael Espindola 5d41326751 Still define __init_array_(start|end) if there is no .init_array.
This matches the behavior of other linkers and seems necessary to link
in some older systems.

llvm-svn: 249077
2015-10-01 21:22:26 +00:00
Rafael Espindola d31088b37a Simplify instantiation. NFC.
llvm-svn: 249074
2015-10-01 21:18:37 +00:00
Michael J. Spencer 52bf0ebfdf [lld][elf2] Sort output sections.
Sort by:
ALLOC
ALLOC && NOBITS
ALLOC & EXEC
ALLOC & EXEC && NOBITS
ALLOC & WRITE
ALLOC & WRITE && NOBITS
<nothing> (ignoring NOBITS)

The dynamic section is finalized early because it adds strings to the dynamic string table, which comes before the dynamic table.

llvm-svn: 249071
2015-10-01 21:15:02 +00:00
Rafael Espindola 3e60379fd9 Don't crash on files with no symbol table.
Thanks to Roman Divacky for the test.

llvm-svn: 249066
2015-10-01 20:26:37 +00:00
George Rimar 57e40deb8d [ELF2] Implement --no-undefined flag.
llvm-svn: 249064
2015-10-01 20:14:45 +00:00
Rafael Espindola ff1dcc59d9 Make the test a bit stronger.
This shows that it is really DT_SONAME that is used to detect dups.

llvm-svn: 249062
2015-10-01 20:04:31 +00:00
Rafael Espindola 6a3b5ded8a Don't include shared libraries multiple times.
llvm-svn: 249061
2015-10-01 19:52:48 +00:00
Rui Ueyama b9287b1fba ELF2: Use -soname to create a test .so file. Remove the .so binary from repository.
llvm-svn: 249059
2015-10-01 19:39:02 +00:00
Rui Ueyama 7de3f3719a ELF2: Add -soname option.
llvm-svn: 249058
2015-10-01 19:36:04 +00:00
Chris Bieneman 03c48b01bf [CMake] Don't include the lld test directory if LLVM_INCLUDE_TESTS is Off
This matches the behavior of LLVM and Clang.

llvm-svn: 249050
2015-10-01 18:17:47 +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
Rui Ueyama 47d4f9496c Remove trailing whitespaces.
llvm-svn: 249037
2015-10-01 17:33:36 +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
Rafael Espindola c8b158155c Copy DT_SONAME to DT_NEEDED.
If a shared library has a DT_SONAME entry, that is what should be included
in the DT_NEEDED of a program using it.

We don't implement -soname yet, so check in a .so for now.

llvm-svn: 249025
2015-10-01 15:47:50 +00:00
Rui Ueyama bd35d75e42 ELF2: Linker scripts can refer other linker scripts. Test that.
This did not work before r249023.

llvm-svn: 249024
2015-10-01 15:45:41 +00:00
Rui Ueyama 983ed2b749 ELF2: Define Driver::addFile() as a one-stop place to open a file.
Opening a file and dispatching to readLinkerScript() or createFile()
is a common operation. We want to use that at least from Driver and
from LinkerScript. In COFF, we had the same problem. This patch
resolves the problem in the same way as we did for COFF.

Now, if you have a path that you want to open, just call
Driver->addFile(StringRef). That function opens the file and handles
that as if that were given by command line. This function is the
only place we call identify_magic().

llvm-svn: 249023
2015-10-01 15:23:09 +00:00
Rui Ueyama 44f5d91af9 ELF2: Rename undefError -> reportUndefined.
The new name starts with a verb, and it does not imply that it errors
out and exit (it acutally can just emit a warning depending on settings.)

llvm-svn: 249016
2015-10-01 14:46:54 +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 819f7127c0 ELF2: Move tests for linker script from basic.s to linkerscript.s.
llvm-svn: 248961
2015-09-30 23:15:35 +00:00
Rui Ueyama 2dfd74f758 ELF2: Add DT_REL{,A}ENT and DT_SYMENT.
According to the ELF specification, these dynamic array entries are mandatory.

http://reviews.llvm.org/D13303

llvm-svn: 248952
2015-09-30 21:57:53 +00:00
Davide Italiano c02fcafef6 [ELF2] Expand test comment a little bit, use reloc name as section name.
llvm-svn: 248930
2015-09-30 19:44:30 +00:00
Rui Ueyama 7971152589 ELF2: Do not set default values that will always be overwritten.
These member variables are overwritten unconditionally by Driver,
so setting default values would be confusing.

llvm-svn: 248922
2015-09-30 17:26:13 +00:00
Rui Ueyama f7c5fbb1ca ELF2: Create LinkerScript.cpp and move code from DriverUtils to there.
llvm-svn: 248920
2015-09-30 17:23:26 +00:00
Rui Ueyama bf506b7d48 ELF2: LinkerScript: Handle quoted tokens.
llvm-svn: 248919
2015-09-30 17:15:29 +00:00
Rui Ueyama f5c4aca98f ELF2: Add basic linker script support.
This linker script parser and evaluator is powerful enough to read
Linux's libc.so, which is (despite its name) a linker script that
contains OUTPUT_FORMAT, GROUP and AS_NEEDED directives.

The parser implemented in this patch is a recursive-descendent one.
It does *not* construct an AST but consumes directives in place and
sets the results to Symtab object, like what Driver is doing.
This should be very fast since less objects are allocated, and
this is also more readable.

http://reviews.llvm.org/D13232

llvm-svn: 248918
2015-09-30 17:06:09 +00:00
Rafael Espindola 3c412e14cc Expand a comment a bit.
llvm-svn: 248894
2015-09-30 12:30:58 +00:00
George Rimar 431f94c8e0 test commit
llvm-svn: 248890
2015-09-30 11:42:29 +00:00
Igor Kudrin f03d2b4d1c [ELF2] Simplify buildSysrootedPath()
Reviewed by: rafael

llvm-svn: 248885
2015-09-30 10:39:37 +00:00
Rui Ueyama 82d705e6d9 Remove unused declaration and forward declaration.
llvm-svn: 248877
2015-09-30 03:31:05 +00:00
Rui Ueyama d0e5aebf3a Expand `auto` whose real type is not obvious from context.
llvm-svn: 248876
2015-09-30 02:42:27 +00:00
Rui Ueyama 90b3daaa5c Remove `else` after `return`.
llvm-svn: 248875
2015-09-30 02:37:51 +00:00
Rui Ueyama 294b136db4 Remove `explicit` from constructors that take more than one parameter.
llvm-svn: 248873
2015-09-30 02:06:17 +00:00
Rui Ueyama 5ba3ac4f10 Simplify switch statements. NFC.
llvm-svn: 248871
2015-09-30 01:40:08 +00:00
Rui Ueyama c55733e79c ELF2: Advance the buffer pointers right after we use them.
So that it is clear that we are incrementing the pointers for sure. NFC.

llvm-svn: 248868
2015-09-30 00:54:29 +00:00
Rui Ueyama b189b5c535 Make template instantiation code a bit shorter. NFC.
llvm-svn: 248866
2015-09-30 00:43:22 +00:00
Rui Ueyama 8ddfa812af ELF2: Split SymbolTableSection<ELFT>::writeTo into two smaller functions.
Also added brief comments.

llvm-svn: 248864
2015-09-30 00:32:10 +00:00
Rui Ueyama e3fbc89c44 ELF2: Do not use host pointer size to calculate x86_64 relocation addresses.
Previous code had a potential portability issue because intptr_t is
not guaranteed to be 64 bit.

llvm-svn: 248856
2015-09-29 23:25:21 +00:00
Rafael Espindola 9a0db7cbef Fix typo.
llvm-svn: 248855
2015-09-29 23:23:53 +00:00
Rafael Espindola 3ef3a4c9ff Start adding support for static programs using dynamic libraries.
This is just enough for a hello world using a dynamic glibc.

llvm-svn: 248854
2015-09-29 23:22:16 +00:00
Rafael Espindola 6a78fd5f41 This reverts commit r248845 and r248848.
They broke elf2/basic-mips.s.

Revert "[elf2] Sort output sections."
Revert "[elf2] Fix build."

llvm-svn: 248851
2015-09-29 23:19:25 +00:00
Rui Ueyama 85bbe0c46b Remove the dependency to 'test' command.
llvm-svn: 248849
2015-09-29 23:13:40 +00:00
Michael J. Spencer a0abcfd8e7 [elf2] Fix build.
llvm-svn: 248848
2015-09-29 23:12:50 +00:00
Michael J. Spencer fe07bd67fd [elf2] Sort output sections.
Sort by:
ALLOC
ALLOC && NOBITS
ALLOC & EXEC
ALLOC & EXEC && NOBITS
ALLOC & WRITE
ALLOC & WRITE && NOBITS
<nothing> (ignoring NOBITS)

The dynamic section is finalized early because it adds strings to the dynamic string table, which comes before the dynamic table.

llvm-svn: 248845
2015-09-29 23:05:40 +00:00
Rui Ueyama 1500a90093 ELF2: Do not create ArrayRefs and use const arrays instead. NFC.
llvm-svn: 248844
2015-09-29 23:00:47 +00:00
Rui Ueyama 511631975d ELF2: Make default-output.s test idempotent.
This test failed if being run more than once because of the
remaining file of the last run.

llvm-svn: 248843
2015-09-29 22:57:22 +00:00
Rui Ueyama a7e628ff10 ELF2: Unbreak buildbot.
Subshell didn't work on Windows.

llvm-svn: 248840
2015-09-29 22:46:52 +00:00
Rui Ueyama 4993d0eb51 ELF2: Sort Config member variables. NFC.
llvm-svn: 248838
2015-09-29 22:33:21 +00:00
Rui Ueyama d7c417c03e ELF2: Assign bool values directly. NFC.
llvm-svn: 248837
2015-09-29 22:33:18 +00:00
Rui Ueyama 4eed0114c5 ELF2: Use 'a.out' as default output file name.
llvm-svn: 248831
2015-09-29 21:49:40 +00:00
Rafael Espindola 2d73648667 Update test to use invalid elf file in archives.
The code in driver is about to change so that the invalid files would no
longer be seen as ELF.

This makes sure that the error path will remain tested.

llvm-svn: 248820
2015-09-29 18:44:18 +00:00
Rui Ueyama 9d4c6d771b [ELF2] Implemented --entry flag.
Patch from George Rimar!

llvm-svn: 248806
2015-09-29 16:40:13 +00:00
Rafael Espindola 8acb95c7ab Add support for R_386_GOT32.
llvm-svn: 248799
2015-09-29 14:42:37 +00:00
Rafael Espindola be901e2dbc Don't apply a relocation if we create a dynamic reloc.
With RELA that is just wasteful, with REL the relocation gets applied
twice.

llvm-svn: 248795
2015-09-29 13:51:43 +00:00
Rafael Espindola 6d7fcdb518 Add R_386_GOTPC support.
llvm-svn: 248793
2015-09-29 13:36:32 +00:00
Simon Atanasyan 49829a1bfe [ELF2] Add initial MIPS support
Besides a trivial MIPS support the patch introduces new TargetInfo class
member getDefaultEntry() to override default name of the entry symbol.
MIPS uses __start for that.

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

llvm-svn: 248779
2015-09-29 05:34:03 +00:00
Cameron Esfahani e211e204da NFC: Fix spelling error in comment.
llvm-svn: 248768
2015-09-29 00:21:38 +00:00
Rafael Espindola 2732235508 Try to fix gcc warning
llvm-svn: 248749
2015-09-28 22:12:54 +00:00
Rafael Espindola 5f19f1224c Delete dead code.
llvm-svn: 248747
2015-09-28 22:07:52 +00:00
Lang Hames 9a4c94ec5a [lld][MachO] Fix a think-o to get the twolevel/dynamic_lookup test passing.
llvm-svn: 248736
2015-09-28 20:52:21 +00:00
Rafael Espindola 4b2ca85c1a Implement --allow-multiple-definition.
Patch by George Rimar!

llvm-svn: 248733
2015-09-28 20:30:11 +00:00
Lang Hames 5c692009bc [lld][MachO] Initial implementation of -flat_namespace and -undefined.
This is a basic initial implementation of the -flat_namespace and
-undefined options for LLD-darwin. It ignores several subtlties,
but the result is close enough that we can now link LLVM (but not
clang) on Darwin and pass all regression tests.

llvm-svn: 248732
2015-09-28 20:25:14 +00:00
Rafael Espindola 085a8f5ea7 Don't include fully resolved relocations in the dynamic relocation table.
llvm-svn: 248731
2015-09-28 20:18:40 +00:00
Rafael Espindola 46e01554b1 Add support for got/ptl referring to symbols defined in .o files.
llvm-svn: 248730
2015-09-28 19:48:34 +00:00
Rafael Espindola dfc7200b18 Add support for local absolute symbols.
llvm-svn: 248726
2015-09-28 18:29:47 +00:00
Rui Ueyama c5e22d906b ELF2: Include file names in error messages.
llvm-svn: 248724
2015-09-28 18:20:41 +00:00
Igor Kudrin 1309fc0378 [ELF2] Add --sysroot command line switch
Reviewers: rafael, ruiu

Subscribers: llvm-commits

Projects: #lld

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

llvm-svn: 248715
2015-09-28 15:01:59 +00:00
Rafael Espindola eb990af31e Trying to fix the windows build.
llvm-svn: 248709
2015-09-28 13:11:36 +00:00
Rafael Espindola abb7b28686 Add support for -L and -l command line switches.
Patch by Igor Kudrin!

llvm-svn: 248708
2015-09-28 12:52:21 +00:00
Rafael Espindola 83af95d927 Enable the aarch64 tests.
llvm-svn: 248707
2015-09-28 12:22:25 +00:00
Davide Italiano aabc45b5ad [ELF] Sort a list of cases alphabetically for consistency/clarity. NFC.
llvm-svn: 248680
2015-09-27 09:01:28 +00:00
Davide Italiano 1d750a6fc3 [ELF2/AArch64] Support for R_AARCH64_ADR_PREL_LO21 relocation.
llvm-svn: 248679
2015-09-27 08:45:38 +00:00
NAKAMURA Takumi 00eecb88a4 lld/test/elf2/basic-aarch64.s should not REQUIRE x86.
FIXME: The feature "arm64" is not activated in lit.cfg.
llvm-svn: 248664
2015-09-26 09:21:58 +00:00
Davide Italiano 6993ba4d3e [ELF2] Don't inline function and define it in OutputSection.cpp. NFC.
Reported/Requested by: Rafael Espindola

llvm-svn: 248643
2015-09-26 00:47:56 +00:00
Davide Italiano f096e10a47 [ELF2] Spell llvm-readobj correctly.
llvm-svn: 248642
2015-09-26 00:43:49 +00:00
Davide Italiano cde9336717 [ELF2] Add initial AArch64 support.
Differential Revision:	http://reviews.llvm.org/D13167

llvm-svn: 248641
2015-09-26 00:32:04 +00:00
Tom Stellard d0626804fc ELF/AMDGPU: Text section should be called .hsatext
Reviewers: atanasyan, ruiu

Subscribers: llvm-commits

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

llvm-svn: 248621
2015-09-25 21:42:30 +00:00
Rafael Espindola 84aff152d9 Simplify enumeration definition.
Thanks to Rui for the suggestion.

llvm-svn: 248615
2015-09-25 21:20:23 +00:00
Rafael Espindola 551dfd8818 Implement --noinhibit-exec.
Patch by George Rimar!

llvm-svn: 248605
2015-09-25 19:24:57 +00:00
Rafael Espindola 0e604f913a Add support for creating the symbols __init_array_start and __init_array_end.
llvm-svn: 248604
2015-09-25 18:56:53 +00:00
Rafael Espindola 5b197f0620 Fix the typedef.
Thanks to David Blaikie for noticing.

llvm-svn: 248602
2015-09-25 18:32:09 +00:00
Rafael Espindola cd076f0113 Move more logic to getSymVA to avoid code duplication.
llvm-svn: 248599
2015-09-25 18:19:03 +00:00
Rafael Espindola 25b0acb57e Move variables closer to use. NFC.
llvm-svn: 248590
2015-09-25 17:32:37 +00:00
Rafael Espindola 35c6af3c9c Move a few methods out of line. NFC.
llvm-svn: 248586
2015-09-25 17:19:10 +00:00
Rui Ueyama 548d22c073 COFF: ICF should not merge sectinos if their alignments are not the same.
There's actually a room to improve this patch. Instead of not merging
sections that have different alignements, we can choose the section that
has the largest alignment requirement among all sections that are otherwise
considered the same. Then all section alignments are satisfied, so we can
merge them.

I don't know if that improvement could make any difference for real-world
input, so I'll leave it alone. Would be interesting to revisit later.

llvm-svn: 248581
2015-09-25 16:50:12 +00:00
Rui Ueyama c9e746b9e6 COFF: Fix local varaible type.
This is intended to be 64-bit integer, but size_t is not guranteed
to be the same or larger type than uint64_t.

llvm-svn: 248580
2015-09-25 16:38:13 +00:00
Rui Ueyama de88072a00 COFF: Rename Ptr -> Repl.
This pointer points to a replacement for this chunk. Ptr was not a good name.

llvm-svn: 248579
2015-09-25 16:20:24 +00:00
Rui Ueyama eeb22f8251 ELF2: Support reponse files.
http://reviews.llvm.org/D13148

llvm-svn: 248575
2015-09-25 15:37:33 +00:00
Rafael Espindola 38af127c6a Fix the parent class of SharedSymbol.
It is a defined symbol according to classof. Found by inspection.

llvm-svn: 248573
2015-09-25 15:34:03 +00:00
Rafael Espindola d13d9606fb Inline function into only use.
llvm-svn: 248572
2015-09-25 15:08:44 +00:00
Davide Italiano b558b79c88 [ELF2] Make buildbot happy again.
llvm-svn: 248560
2015-09-25 04:22:13 +00:00
Davide Italiano 85121bbf24 [ELF2] Use static non-member function when it suffices.
Pointed out by Rui Ueyama.

llvm-svn: 248559
2015-09-25 03:56:11 +00:00
Rui Ueyama 3f4ec66624 ELF2: Use lambdas instead of named functions.
They are short and used only once, so writing them where they are used
is better.

llvm-svn: 248558
2015-09-25 03:48:25 +00:00
Rui Ueyama 4c4993bba6 Remove dead code.
llvm-svn: 248557
2015-09-25 03:38:56 +00:00
Davide Italiano aa7c533ec3 [ELF2] Fix binaries so they actually run on FreeBSD.
Since FreeBSD 4.1, the kernel expects binaries to be marked with
ELFOSABI_FREEBSD in the ELF header to exec() them. LLD unconditionally 
sets OSABI to ELF_OSABINONE, and everything linked with it won't run 
on FreeBSD (unless explicitly rebranded).

Example:
% ./aarch64-hello
ELF binary type "0" not known.
zsh: exec format error: ./aarch64-hello

FreeBSD could be modified to accept ELF_OSABINONE, but that would break all
existing binaries, so the kernel needs to support both ABINONE and ABIFREEBSD.
I plan to push this change in FreeBSD one day, which, unfortunately, is 
not today. This code patches lld so it sets the header field correctly.

For completeness, the rationale of this change is explained in the FreeBSD 
commit message, and it's apparently to pleasee binutils maintainers at the time.
https://svnweb.freebsd.org/base?view=revision&revision=59342

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

llvm-svn: 248554
2015-09-25 01:59:13 +00:00
Chris Bieneman 77456efcb1 [CMake] Move LLD to the new style for symlink generation, and make the links list overridable.
Reviewers: lhames, rafael

Subscribers: llvm-commits

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

llvm-svn: 248544
2015-09-24 21:53:18 +00:00
Rui Ueyama c28a08b8d2 COFF: Remove duplicate parameter from hash value calculation.
llvm-svn: 248526
2015-09-24 19:00:42 +00:00
Rui Ueyama 1392d8b5fe Fix memory leak in FileArchive::find().
Patch from George Rimar!

llvm-svn: 248525
2015-09-24 18:59:26 +00:00
Rui Ueyama d5b5ab7638 [ELF2] Output of all unknown arguments instead of only one.
Patch from George Rimar!

llvm-svn: 248524
2015-09-24 18:55:33 +00:00
Davide Italiano bf37cdec28 [ELF2] Remove ignored options handling.
This was prematurely committed (and I take the blame for that).
Ideally, we want to support only ignored options that are really used
by somebody. Some of the options listed are not even supported by gold
(but only by ld.bfd), which says a lot about their "real-world" usefulness.

llvm-svn: 248503
2015-09-24 15:12:34 +00:00
Rafael Espindola e1901cc33d Simplify memory management by having ELFData contain a ELFObj.
llvm-svn: 248502
2015-09-24 15:11:50 +00:00
Davide Italiano d75d3b94fd [ELF2] Add support for -discard-none.
Differential Revision:	http://reviews.llvm.org/D13083

llvm-svn: 248499
2015-09-24 15:08:23 +00:00
Rafael Espindola e0f09fac78 Add a test covering ELFFile's constructor failing.
llvm-svn: 248498
2015-09-24 14:55:25 +00:00
Rafael Espindola 0872ea3954 Simplify with some ideas from COFF:
* add using namespace llvm::support::endian.
* create a add32le static helper.

Thanks to Rui for the suggestion.

llvm-svn: 248491
2015-09-24 14:16:02 +00:00
Rafael Espindola d27adc42e6 Add support for the _GLOBAL_OFFSET_TABLE_ symbol.
llvm-svn: 248490
2015-09-24 13:34:01 +00:00
Rafael Espindola 5a5fdf7f73 Fix typo.
Thanks to Sean Silva for noticing.

llvm-svn: 248488
2015-09-24 12:58:44 +00:00
Rafael Espindola cdfecffd80 Add support for relocating R_X86_64_GOTPCREL.
llvm-svn: 248425
2015-09-23 20:08:25 +00:00
Rafael Espindola c2d211994d Create the .bss section early so that we don't have to set it after the fact.
llvm-svn: 248412
2015-09-23 18:25:05 +00:00
Michael J. Spencer 2812aa82d0 [elf2] Pass BSSSec to the relocation handling code differently. Don't store it in the symbol.
llvm-svn: 248393
2015-09-23 16:57:31 +00:00
Davide Italiano aab93b59d4 [ELF2] - added ignored command line options for compatibility.
Patch by George Grimar.

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

llvm-svn: 248389
2015-09-23 15:46:44 +00:00
Rafael Espindola 6173f848b9 Print more information about undefined symbols.
llvm-svn: 248382
2015-09-23 14:37:01 +00:00
Rafael Espindola 8e5560d894 Don't complain about symbols showing up in multible shared libraries.
llvm-svn: 248381
2015-09-23 14:23:59 +00:00
Rafael Espindola 1a49e58181 Print more information about duplicated symbols.
llvm-svn: 248380
2015-09-23 14:10:24 +00:00
Davide Italiano a89d178a4f [ELF2] Add ASCII representation of the string table to test.
Requested by: rafael

llvm-svn: 248361
2015-09-23 01:56:26 +00:00
Davide Italiano e44456b1b9 [ELF2] Constify getStrTabSec().
llvm-svn: 248360
2015-09-23 01:50:53 +00:00
Rafael Espindola 1ab429bf49 Fix a last minuted edit that should not have been committed.
Sorry about that.

llvm-svn: 248349
2015-09-22 23:42:55 +00:00
Rafael Espindola 05a3dd2cba Implement --export-dynamic.
llvm-svn: 248347
2015-09-22 23:38:23 +00:00
Rafael Espindola 7f07442bb6 Move the last remaining hard coded relocations to Target.
Unfortunately the i386 and x86_64 relocation have the same numerical value
and it is a probably a bit much to add got support for another architecture
just to test this.

llvm-svn: 248326
2015-09-22 21:35:51 +00:00
Rafael Espindola 1d6063e804 Stub out ARM and PPC targets so that we can use a switch to create them.
llvm-svn: 248324
2015-09-22 21:24:52 +00:00
Rafael Espindola 3efa4e982e Add a token ppc64 reloc just to have a test showing that we handle BE.
llvm-svn: 248321
2015-09-22 21:12:55 +00:00
Rafael Espindola c40108858d Move relocation processing to Target.
I will add a couple of ppc64 relocs in the next patches.

llvm-svn: 248319
2015-09-22 20:54:08 +00:00
Rafael Espindola 8c21fad1e8 Fix a merge problem.
r248289 got lots when I moved code to Target.cpp. Sorry about that.

llvm-svn: 248317
2015-09-22 20:06:19 +00:00
Rafael Espindola 01205f79a4 Start adding target abstractions.
This is just enough to get PLT working on 32 bit x86.

The idea behind using a virtual interface is that it should be easy to
convert any of the functions to template parameters if any turns out to be
performance critical.

llvm-svn: 248308
2015-09-22 18:19:46 +00:00