Commit Graph

5906 Commits

Author SHA1 Message Date
Dima Stepanov fb8978fc6a Fix the function to set the section VMA/LMA fields in case of using
the linker script. The cycle in the ELF/LinkerScript.cpp:assignAddresses()
routine will be used to go through all the sections and set all the
addresses correctly.

Add new test to check this case.

llvm-svn: 270090
2016-05-19 18:15:54 +00:00
Rafael Espindola 6989ebf661 Simplify, NFC.
llvm-svn: 269983
2016-05-18 21:05:18 +00:00
Rafael Espindola e4c86d83fe Drop vestigial support for UseLazyBinding=false.
Lazy binding is quite important for use case like a shared build of
llvm. Also, if someone wants to disable it, it is better done in the
compiler (disable plt generation).

The only reason to keep it is to make it easier to add a new
architecture. But it doesn't really help much as it is possible to start
with non lazy relocation and plt code but still let the generic part
create a dedicated .got.plt and .rela.plt.

llvm-svn: 269982
2016-05-18 21:03:36 +00:00
Rafael Espindola e2f43770a4 UseLazyBinding is always true in here, simplify.
llvm-svn: 269979
2016-05-18 20:44:24 +00:00
Peter Smith 4df2e14dce Fix typo in comment aligment should be alignment. NFC.
llvm-svn: 269905
2016-05-18 11:40: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
Rui Ueyama 147036605e Add `explicit`.
llvm-svn: 269703
2016-05-16 21:06:31 +00:00
Davide Italiano 5020d2ade5 Sort includes, and don't look into system headers.
llvm-svn: 269607
2016-05-15 19:43:02 +00:00
Davide Italiano c26f981da2 Remove unused include. NFC.
llvm-svn: 269606
2016-05-15 19:36:23 +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
Simon Atanasyan 4e3a15c9f3 [ELF][MIPS] Rename R_MIPS_GOT_xxx relocation expression kinds
New names reflect purpose of corresponding GOT entries better.
Both expression types related to entries allocated in the 'local'
part of MIPS GOT. R_MIPS_GOT_LOCAL_PAGE is for entries contain 'page'
addresses. R_MIPS_GOT_LOCAL is for entries contain 'full' address.

llvm-svn: 269597
2016-05-15 18:13:50 +00:00
Rui Ueyama fe65877c76 Reorganize the cpio archiver as CpioFile class. NFC.
This code separates the code to create cpio archive from the driver.

llvm-svn: 269593
2016-05-15 17:10:23 +00:00
Rui Ueyama 109ff37430 Update for a recent format change.
llvm-svn: 269496
2016-05-13 21:58:46 +00:00
Rui Ueyama 9194db78fb Support --build-id=0x<hexstring>.
If you specify the option in the form of --build-id=0x<hexstring>,
that hexstring is set as a build ID. We observed that the feature
is actually in use in some builds, so we want this feature.

llvm-svn: 269495
2016-05-13 21:55:56 +00:00
Rafael Espindola 7229496787 When using Rela, don't write the addend to the output section.
The Elf_Rela has an explicit addend. It doesn't need the addend to be
written to the section being relocated.

Since relative relocations are very common in the output, this is a
noticeable speedup. The results I got were

chromium
  master 4.778149487
  patch  4.761120792 0.996436131802
chromium fast
  master 1.896253636
  patch  1.840990582 0.970856718241
the gold plugin
  master 0.399337811
  patch  0.392279276 0.982324401032
clang
  master 0.666873675
  patch  0.665895708 0.998533504865
llvm-as
  master 0.037101095
  patch  0.037123149 1.00059442989
the gold plugin fsds
  master 0.422473396
  patch  0.414192879 0.980399909016
clang fsds
  master 0.747302008
  patch  0.744843964 0.996710775599
llvm-as fsds
  master 0.033146245
  patch  0.033064531 0.997534743377
scylla
  master 4.08857525
  patch  4.082245184 0.998451767275

llvm-svn: 269417
2016-05-13 14:15:37 +00:00
Rafael Espindola 686ffc6f4c Slit the relocation scan in two parts.
The first part handles whatever has to be written to the r_offset
position.

The second part handles creating got and plt entries.

llvm-svn: 269375
2016-05-12 22:51:22 +00:00
Rafael Espindola 203b0773a3 Move addend computation to a helper function.
llvm-svn: 269369
2016-05-12 22:19:35 +00:00
Rafael Espindola 01f1636408 Handle thunks in adjustExpr.
This is similar to the other changes this function does. With this all
Relocations.push_back calls look similar.

llvm-svn: 269362
2016-05-12 21:53:34 +00:00
Rafael Espindola 62cb02eef1 This reverts commit r269359 and r269360.
I will commit again with a fixed commit message.

llvm-svn: 269361
2016-05-12 21:51:16 +00:00
Rafael Espindola cc42a90b76 Handle thunks in adjustExpr.
This is similar to the other changes this function does. With this all
Relocations.push_back calls look similar.

llvm-svn: 269360
2016-05-12 21:47:26 +00:00
Rafael Espindola 01a94f8336 bra
llvm-svn: 269359
2016-05-12 21:47:24 +00:00
Peter Collingbourne 0ef3874de3 Move undefine to a separate function.
llvm-svn: 269331
2016-05-12 19:46:14 +00:00
George Rimar fa91000290 [ELF] implemented -z defs option
Just do not allow to link shared library if there are
undefined symbols.

This fixes PR27447

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

llvm-svn: 269183
2016-05-11 13:48:41 +00:00
George Rimar 71e64b2df9 [ELF] - Fixed failture of mips-64-got.s on x32 configuration.
win32 was my case.
Before that change test failed with next error for me:
23>  ******************** TEST 'lld :: ELF/mips-64-got.s' FAILED ********************
....
23>  Command 3 Stderr:
23>  relocation R_MIPS_GOT_PAGE out of range

llvm-svn: 269166
2016-05-11 09:41:15 +00:00
Davide Italiano 334fce92d9 [LTO] Don't crash on old DebugInfo.
Drop them and produce a graceful warning instead.

llvm-svn: 269149
2016-05-11 01:07:22 +00:00
Rafael Espindola f72914f42a Add a link to the format description.
llvm-svn: 269102
2016-05-10 19:26:55 +00:00
Rafael Espindola e502751c42 Fix typo.
llvm-svn: 269072
2016-05-10 16:23:46 +00:00
George Rimar c191acf097 [ELF] - Implemented -z combrelocs/nocombreloc.
This is the option which sorts relocs to optimize dynamic linker performance.
-z combelocs is the default in gold, also it ignores -z nocombreloc,
this patch do the same.

Patch sorts relocations by symbols only and do not create any
DT_REL[A]COUNT entries. That is different with what gold/bfd do.

More information about option is here:
http://www.airs.com/blog/archives/186
http://people.redhat.com/jakub/prelink.pdf, p.2

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

llvm-svn: 269066
2016-05-10 15:47:57 +00:00
Rafael Espindola 78db5a9dca Print member name in undefined symbol error.
llvm-svn: 268976
2016-05-09 21:40:06 +00:00
Rafael Espindola 4ee6cb3a70 Document and test the first few .got.plt entries.
llvm-svn: 268945
2016-05-09 18:12:15 +00:00
Rafael Espindola 45a33fb799 Allow user defined __init_aray_start.
Fixes pr27683.

llvm-svn: 268926
2016-05-09 15:25:54 +00:00
Daniel Sanders dcb98e61c7 [mips] Fix mips-got16.s following r268900.
$LC0 and $LC1 are no longer present in the symbol table because they are
rewritten to .text+offset and .data+offset.

llvm-svn: 268911
2016-05-09 13:01:01 +00:00
Simon Atanasyan 8c8a5b5f81 [ELF][MIPS] Handling 'packed' N64 ABI relocations
MIPS N64 ABI packs multiple relocations into the single relocation
record. In general, all up to three relocations can have arbitrary types.
In fact, Clang and GCC uses only a few combinations. For now, we support
two of them. That is allow to pass at least all LLVM test suite cases.

<any relocation> / R_MIPS_SUB / R_MIPS_HI16 | R_MIPS_LO16
<any relocation> / R_MIPS_64 / R_MIPS_NONE

The first relocation is a 'real' relocation which is calculated using
the corresponding symbol's value. The second and the third relocations
used to modify result of the first one: extend it to 64-bit, extract
high or low part etc. For details, see part 2.9 'Relocation' at
https://dmz-portal.mips.com/mw/images/8/82/007-4658-001.pdf

llvm-svn: 268876
2016-05-08 14:08:40 +00:00
Simon Atanasyan 10296c2344 [ELF][MIPS] Remove redundant local variable. NFC
llvm-svn: 268852
2016-05-07 07:36:47 +00:00
Simon Atanasyan 5b9ac41c13 [ELF][MIPS] Reduce code duplication. NFC
llvm-svn: 268743
2016-05-06 15:02:54 +00:00
Simon Atanasyan 9ac819860f [ELF][MIPS] Reduce all MIPS R_GOTREL addends by MipsGPOffset in the single place. NFC
llvm-svn: 268742
2016-05-06 15:02:50 +00:00
Simon Atanasyan 1a728fdf5c [ELF][MIPS] Simplify `if` condition. NFC
In case of MIPS ABI relocation has R_GOTREL expression's type iif the
relocation type is either R_MIPS_GPREL16 or R_MIPS_GPREL32. So it is
enough to check expression's type only.

llvm-svn: 268741
2016-05-06 15:02:45 +00:00
Rui Ueyama 31f9f6100e Use the new type for StringTableBuilder::getMap.
llvm-svn: 268699
2016-05-06 00:52:08 +00:00
Rafael Espindola d39dadeb64 Don't produce a relocation to read only memory.
This is hopefully last case where we would produce a relocation to a
read only section.

llvm-svn: 268688
2016-05-05 21:19:38 +00:00
Rafael Espindola 66434562e7 Fix copy relocations in pie.
We were creating the copy relocations just fine, but then thinking that
the .bss position could be preempted and creating a dynamic relocation
to it, which would crash at runtime since that memory is read only.

llvm-svn: 268668
2016-05-05 19:41:49 +00:00
Peter Collingbourne 3ad1c1e242 ELF: Undefine all symbols, not just those that we expect to be defined.
This allows the combined LTO object to provide a definition with the same
name as a symbol that was internalized without causing a duplicate symbol
error. This normally happens during parallel codegen which externalizes
originally-internal symbols, for example.

In order to make this work, I needed to relax the undefined symbol error to
only report an error for symbols that are used in regular objects.

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

llvm-svn: 268649
2016-05-05 17:13:49 +00:00
Rafael Espindola 474eb019b4 Move static function to avoid forward declaration. NFC.
llvm-svn: 268646
2016-05-05 16:40:28 +00:00
Rafael Espindola 462220de47 Reuse logic for deciding whether to keep a local symbol or not.
llvm-svn: 268644
2016-05-05 16:38:46 +00:00
Rafael Espindola 3e0b7837bf Cache result when tail merging too.
This speeds up a link of chromium with -O2 (but no icf,gc) from
1.940664632 to 1.925578119.

llvm-svn: 268639
2016-05-05 16:12:25 +00:00
Rafael Espindola d89fbca21d Fix --gc-sections when .eh_frame has a lsda.
We have to add sections to the work list, not just mark them live.

llvm-svn: 268628
2016-05-05 13:51:14 +00:00
Peter Collingbourne e29e142a10 ELF: Do not use -1 to mark pieces of merge sections as being tail merged.
We were previously using an output offset of -1 for both GC'd and tail
merged pieces. We need to distinguish these two cases in order to filter
GC'd symbols from the symbol table -- we were previously asserting when we
asked for the VA of a symbol pointing into a dead piece, which would end
up asking the tail merging string table for an offset even though we hadn't
initialized it properly.

This patch fixes the bug by using an offset of -1 to exclusively mean GC'd
pieces, using 0 for tail merges, and distinguishing the tail merge case from
an offset of 0 by asking the output section whether it is tail merge.

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

llvm-svn: 268604
2016-05-05 04:10:12 +00:00
Rui Ueyama ca16c104c6 Merge two tests for the same purpose.
I accidentally added another test file as I didn't notice
that the test file existed.

llvm-svn: 268598
2016-05-05 02:32:09 +00:00
Rui Ueyama ac75a27809 Add a test for --reproduce on Windows.
It is insanely hard to write a test that works both on Windows and Unix.
I tried to workaround it with cpio's minor options, but the behaviors of
the options were myterious. It just doesn't worth to spend time on it.
And probably minor options could break buildbots that doesn't have the
GNU version of cpio command.

In this patch, I simply added a separate test file that runs only on
Windows.

llvm-svn: 268596
2016-05-05 02:18:04 +00:00
Rui Ueyama af2312feb7 Make --reproduce to not produce undesired whitespace.
Fixes bug 27648.

llvm-svn: 268569
2016-05-04 23:12:55 +00:00
Simon Atanasyan da83bbc1a1 [ELF][MIPS] Create combined dynamic relocation type R_MIPS_REL32/R_MIPS_64/R_MIPS_NONE
MIPS N64 ABI packs multiple relocations into the single relocation
record. Particularly it requires to represent dynamic relative
relocation as a combination of R_MIPS_REL32 and R_MIPS_64 relocations.

llvm-svn: 268565
2016-05-04 22:39:40 +00:00