Commit Graph

7558 Commits

Author SHA1 Message Date
George Rimar 14460e0216 [ELF] - Do not crash when move location counter backward.
PR31335 shows that we do that in next case:
SECTIONS { .text 0x2000 : {. = 0x100 ; *(.text) } }

though documentations says that "If . is used inside a section 
description however, it refers to the byte offset from the start
of that section, not an absolute address. " looks does not work 
as documented in bfd (as mentioned in comments for PR31335).

Until we find out the expected behavior was suggested at least not
to 'crash', what we do after trying to generate huge file.

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

llvm-svn: 289782
2016-12-15 07:27:28 +00:00
Peter Collingbourne 6ee0b4e9f5 COFF: Open and map input files asynchronously on Windows.
Profiling revealed that the majority of lld's execution time on Windows was
spent opening and mapping input files. We can reduce this cost significantly
by performing these operations asynchronously.

This change introduces a queue for all operations on input file data. When
we discover that we need to load a file (for example, when we find a lazy
archive for an undefined symbol, or when we read a linker directive to
load a file from disk), the file operation is launched using a future and
the symbol resolution operation is enqueued.  This implies another change
to symbol resolution semantics, but it seems to be harmless ("ninja All"
in Chromium still succeeds).

To measure the perf impact of this change I linked Chromium's chrome_child.dll
with both thin and fat archives.

Thin archives:

Before (median of 5 runs): 19.50s
After: 10.93s

Fat archives:

Before: 12.00s
After: 9.90s

On Linux I found that doing this asynchronously had a negative effect on
performance, probably because the cost of mapping a file is small enough that
it becomes outweighed by the cost of managing the futures. So on non-Windows
platforms I use the deferred execution strategy.

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

llvm-svn: 289760
2016-12-15 04:02:23 +00:00
Rui Ueyama fd7ed23ee7 Rename functions as per post commit review for r289072.
llvm-svn: 289758
2016-12-15 03:31:53 +00:00
Sean Silva 902ae3cb3f Rename this variable.
`SC` didn't make much sense. We don't seem to have a clear convention,
but `IS` sounds good here because it emphasizes that it is an input
section (this is one place in the code where we are dealing with both
input sections and output sections at the same time so that extra
emphasis makes it a bit clearer).

llvm-svn: 289748
2016-12-15 00:57:53 +00:00
Peter Collingbourne c4e9482164 COFF: We no longer require lib.exe to test DLL exports.
llvm-svn: 289745
2016-12-15 00:11:17 +00:00
Sean Silva 7608626631 Rename InputSection.cpp:getSymVA to getRelocTargetVA.
This name was really confusing because there is also another static
helper Symbols.cpp:getSymVA which has the same name.

llvm-svn: 289733
2016-12-14 22:45:52 +00:00
Davide Italiano 19d647b667 [LTO] Catch up with llvm. Modules without DL are now considered invalid.
llvm-svn: 289722
2016-12-14 21:58:26 +00:00
Michal Gorny 906534fe4e Remove unnecessary llvm/Config/config.h includes
Remove the includes of <llvm/Config/config.h> private LLVM header.
The relevant files seem not to use any definitions from that file,
and it is not available when building against installed LLVM.

The use in lib/ReaderWriter/MachO/MachOLinkingContext.cpp originates
from rL218718, and the use in ELF/Strings.cpp from rL274804 (where it
was moved from Symbols.cpp). In both cases, they were added as a part of
demangling support, and they provided HAVE_CXXABI_H.

Since we are now using the LLVM demangler library instead, the code was
removed and the includes and no longer necessary.

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

llvm-svn: 289707
2016-12-14 20:53:57 +00:00
Peter Smith 532bc984f5 [ELF] Accept first SHT_ARM_ATTRIBUTES section
The eglibc library, as used by Ubuntu 14.04 requires the presence of an
SHT_ARM_ATTRIBUTES section in for the purposes of checking hard/soft float
compatibility when dlopen() is used. Unfortunately when the section is not
present dlopen() fails with a generic could not find file message.
    
This change makes lld keep the first .ARM.attributes section that it
encounters and propagates it to the output. This is not a complete
SHT_ARM_ATTRIBUTES implementation, that would involve reading the contents
of the section and joining each individual attribute. It should suffice
for a homogenous build all libraries and executables on the same system
with a compatible set of command line options.

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

llvm-svn: 289642
2016-12-14 10:36:12 +00:00
Rafael Espindola 09d5daab49 Refactor duplicated expression. NFC.
llvm-svn: 289550
2016-12-13 16:59:19 +00:00
Peter Smith d92099991b [ELF] Add R_ARM_RELATIVE to relocations that can be applied to GotSection
When compiling -fpie and linking with the --pie option the R_ARM_GOTBREL
relocation to D is resolved by writing the value of D into the .got slot
and emitting an R_ARM_RELATIVE relocation for it.
    
This changes adds the R_ARM_RELATIVE relocation to the switch in
relocateOne() so we can process the GotSection relocation to write the
value of the variable as well as emitting the dynamic relocation.

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

llvm-svn: 289527
2016-12-13 10:42:05 +00:00
Rafael Espindola 5f51ed1ca7 Simplify the test. NFC.
llvm-svn: 289499
2016-12-12 23:52:21 +00:00
Simon Atanasyan 2903a8a11f [ELF][MIPS] Calculate default _gp value relative to the GPREL section with the lowest address
llvm-svn: 289471
2016-12-12 21:34:11 +00:00
Peter Collingbourne e50f4854c2 COFF: Fix memory leaks reported by lsan.
llvm-svn: 289451
2016-12-12 18:42:09 +00:00
Simon Atanasyan b9666655c2 [ELF][MIPS] Fix .MIPS.options ri_gp_value on MIPS64
The VA of _gp was being truncated to 32 bits when calling getVa(), but
for 64bit MIPS we need to write a 64 bit value to .MIPS.options.

Patch by Alexander Richardson.

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

llvm-svn: 289432
2016-12-12 14:30:18 +00:00
Saleem Abdulrasool f1af26ddf2 build: add support for standalone lld build
Enable building lld as a standalone project. This is motivated by the desire to
package lld for inclusion in a linux distribution. This allows building lld
against an existing paired llvm installation. Now that lld is usable on x86_64,
it makes sense to revive this configuration to allow distributions to package
it.

llvm-svn: 289421
2016-12-12 05:47:40 +00:00
Peter Collingbourne 4b5a7ac831 COFF: Remove an unused mutex declaration.
llvm-svn: 289415
2016-12-12 03:16:18 +00:00
Peter Collingbourne 8155dfa8f3 COFF: Use a DenseSet instead of a map to atomic_flag to track which archive members have been read.
Differential Revision: https://reviews.llvm.org/D27667

llvm-svn: 289414
2016-12-12 03:16:14 +00:00
Peter Collingbourne 3f530938f6 COFF: Use CachedHashStringRef in the symbol table.
This resulted in about a 1% perf improvement linking chrome_child.dll.

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

llvm-svn: 289410
2016-12-11 22:15:30 +00:00
Peter Collingbourne 8b65e51b73 COFF: Load inputs immediately instead of adding them to a queue.
This patch replaces the symbol table's object and archive queues, as well as
the convergent loop in the linker driver, with a design more similar to the
ELF linker where symbol resolution directly causes input files to be added to
the link, including input files arising from linker directives. Effectively
this removes the last vestiges of the old parallel input file loader.

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

llvm-svn: 289409
2016-12-11 22:15:25 +00:00
Peter Collingbourne 99111287fc COFF: Use a bit in SymbolBody to track which symbols are written to the symbol table.
Using a set here caused us to take about 1 second longer to write the symbol
table when linking chrome_child.dll. With this I consistently get better
performance on Windows with the new symbol table.

Before r289280 and with r289183 reverted (median of 5 runs): 17.65s
After this change: 17.33s

On Linux things look even better:

Before: 10.700480444s
After: 5.735681610s

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

llvm-svn: 289408
2016-12-11 22:15:20 +00:00
Sanjoy Das fd4016b7c7 Fix TBAA metadata
The existing tbaa metadata in the test is ill-formed, and fails the
verifier after r289402.

llvm-svn: 289405
2016-12-11 21:10:11 +00:00
Rui Ueyama 327705d17d Create a TPI stream only when /debugpdb is given.
Adding type records to TPI stream is too time consuming.
It is reported that linking chrome_child.dll took 5 minutes.

llvm-svn: 289330
2016-12-10 17:23:23 +00:00
Ismail Donmez 85588fa2b0 Fix shared library build
llvm-svn: 289320
2016-12-10 09:29:47 +00:00
Rui Ueyama 86581e496b Rename find(SymbolVersion) to avoid overloading with find(StringRef).
llvm-svn: 289293
2016-12-10 00:34:06 +00:00
Peter Collingbourne 6baa5d276d COFF: Fix test failure on Windows.
llvm-svn: 289289
2016-12-09 23:34:49 +00:00
Rafael Espindola dd9dd488fc Fix a bogus warning.
We first decide that the symbol is global, than that it should have
version foo. Since it was already not the default version, we were
producing a bogus warning.

llvm-svn: 289284
2016-12-09 22:40:49 +00:00
Peter Collingbourne 79a5e6b1b7 COFF: New symbol table design.
This ports the ELF linker's symbol table design, introduced in r268178,
to the COFF linker.

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

llvm-svn: 289280
2016-12-09 21:55:24 +00:00
Meador Inge b06147db0c [ELF] Fix test case thinko from r289152
It was pointed out in a post-commit review that the tests
were structured oddly.  Fixed thusly.

llvm-svn: 289278
2016-12-09 21:51:37 +00:00
Rafael Espindola 157c51dce1 Add support for R_X86_64_GOT64.
llvm-svn: 289277
2016-12-09 21:46:39 +00:00
Hans Wennborg 1818e65aad COFF: Support both /lldmap and /lldmap:<file>
The former option bases the filename on the output name, e.g. if the
link output is a.exe, the map will be written to a.map. This matches the
behaviour of link.exe's /MAP option and is useful for creating a map
file of each executable when building a large project.

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

llvm-svn: 289271
2016-12-09 20:54:44 +00:00
Peter Collingbourne fa7f393714 COFF: Move a call to toString() out of the hot path.
Profiling revealed that we were spending 5% of our time linking
chrome_child.dll just in this call to toString().

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

llvm-svn: 289270
2016-12-09 20:51:33 +00:00
Rui Ueyama df41b13b09 Remove `REQUIRES: shell` hack to workaround an echo issue.
These tests are disabled on Windows, but they seem to work just fine now,
so I'll enable them.

llvm-svn: 289251
2016-12-09 18:49:37 +00:00
Rafael Espindola 1ef90d2f25 Fix parsing when one extern follows another.
llvm-svn: 289224
2016-12-09 16:44:05 +00:00
Rafael Espindola 49cd09337c Don't crash on an extra symbol in a version script.
llvm-svn: 289217
2016-12-09 15:08:40 +00:00
Rafael Espindola 6239ce6889 Give preempting symbols precedence over linker script.
llvm-svn: 289212
2016-12-09 14:12:02 +00:00
Peter Smith 4b360292ed [ELF][I386] .got.plt entries for i386 should use VA of ifunc resolver
The i386 glibc ld.so expects the .got.slot entry that is relocated by a 
R_386_IRELATIVE relocation to point directly at the ifunc resolver and
not the address of the PLT entry + 6 (thus entering the lazy resolver).
This is also the case for ARM and I suspect it is because these use REL
relocations and can't use the addend field to store the address of the
ifunc resolver. If the lazy resolver is used we get an error message
stating that only R_386_JUMP_SLOT is supported.

As ARM and i386 share the same code, I've removed the ARM specific test
and added a writeIgotPlt() function that by default calls writeGotPlt().
ARM and i386 override this to write the address of the ifunc resolver.

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

llvm-svn: 289198
2016-12-09 09:59:54 +00:00
Rui Ueyama 26186c7e0f Add type records to TPI stream.
I don't think the data I add to a TPI stream in this patch is correct,
but at least it can be displayed using llvm-pdbdump. Until I add more
streams to a PDB file, I'm not able to know whether the data will be
accepted by MSVC tools or not.

llvm-svn: 289183
2016-12-09 04:46:54 +00:00
Rui Ueyama 7a0a076e40 COFF: Use make() in SymbolTable and Writer.
llvm-svn: 289170
2016-12-09 02:13:12 +00:00
Meador Inge 95c7d8d2a7 [ELF] Allow output section data commands to take expressions
The current implementation of the output section data store commands
can only handle integer literals, but it should really handle arbitrary
expressions [1].  This commit fixes that.

[1] https://sourceware.org/binutils/docs-2.27/ld/Output-Section-Data.html#Output-Section-Data

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

llvm-svn: 289152
2016-12-08 23:21:30 +00:00
Rui Ueyama 89ccd0f31c Split linkerscript.s into small test files.
linkerscript.s is the first test file for linker script, and at the moment
it contains all tests for linker scripts. Now that test file doesn't make
sense.

linkerscript2.s was just badly named. Renamed searchdir.s.

llvm-svn: 289148
2016-12-08 22:36:12 +00:00
Rui Ueyama 3c04f8d790 Print a warning message if ENTRY() symbol is not found.
llvm-svn: 289146
2016-12-08 22:26:31 +00:00
Rui Ueyama 968468033c Fix -Wunused-private-field.
llvm-svn: 289112
2016-12-08 21:49:18 +00:00
Rui Ueyama 8d433d71f5 COFF: Use a string saver in Memory.h in Driver.
llvm-svn: 289104
2016-12-08 21:27:09 +00:00
Rui Ueyama 8fe1767cdd Remove unnecessary `llvm::`.
llvm-svn: 289102
2016-12-08 20:50:47 +00:00
Rui Ueyama bf4ad1d63d COFF: Use make() to create a new file object in createFile.
llvm-svn: 289097
2016-12-08 20:20:22 +00:00
Rui Ueyama 7fed58cd9f Start using make() in COFF (with a smaller change.)
llvm-svn: 289089
2016-12-08 19:10:28 +00:00
Rui Ueyama aa4f4450af Revert r289084: Start using make() in COFF.
This reverts commit r289084 to appease buildbots.

llvm-svn: 289086
2016-12-08 18:49:04 +00:00
Rui Ueyama 843233b920 Start using make() in COFF.
We don't want ELF and COFF to diverge too much.

llvm-svn: 289085
2016-12-08 18:31:18 +00:00
Rui Ueyama 520d9169e6 Move Memory.{h,cpp} to lld/Support so that we can use them from COFF.
llvm-svn: 289084
2016-12-08 18:31:13 +00:00
Rafael Espindola d0ebd84c42 Change the implementation of --dynamic-list to use linker script parsing.
The feature is documented as
-----------------------------
The format of the dynamic list is the same as the version node
without scope and node name.  See *note VERSION:: for more
information.
--------------------------------

And indeed qt uses a dynamic list with an 'extern "C++"' in it. With
this patch we support that

The change to gc-sections-shared makes us match bfd. Just because we
kept bar doesn't mean it has to be in the dynamic symbol table.

The changes to invalid-dynamic-list.test and reproduce.s are because
of the new parser.

The changes to version-script.s are the only case where we change
behavior with regards to bfd, but I would like to see a mix of
--version-script and --dynamic-list used in the wild before
complicating the code.

llvm-svn: 289082
2016-12-08 17:54:26 +00:00
Rui Ueyama 6f6d46d497 Use `make` to simplify. NFC.
llvm-svn: 289081
2016-12-08 17:48:52 +00:00
Rui Ueyama 6dbf7ff747 Use make to instantiate Target and LinkerScript. NFC.
llvm-svn: 289079
2016-12-08 17:44:39 +00:00
Rui Ueyama e4eadb6a24 Split LinkerDriver::link. NFC.
llvm-svn: 289078
2016-12-08 17:44:37 +00:00
Rui Ueyama 34bf8677a4 Remove a special handling of AMDGPU entry points.
This is the last peculiar semantics left in the linker. If you want to
always set an entry point to 0, you can pass `-e 0` to the linker.

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

llvm-svn: 289077
2016-12-08 17:32:58 +00:00
Rafael Espindola 7e71415cb3 Add support for 'extern "C"'.
It is used by Qt.

llvm-svn: 289074
2016-12-08 17:26:53 +00:00
Rui Ueyama 8cb6283e74 Make function names shorter. NFC.
llvm-svn: 289072
2016-12-08 17:18:09 +00:00
Rui Ueyama 248e4a344c Do not use template where template is not needed.
Compilers can inline and optimize this code in the same way as template.

llvm-svn: 289071
2016-12-08 17:04:18 +00:00
Rafael Espindola 4737f94132 Make this test more strict. NFC.
llvm-svn: 289069
2016-12-08 16:51:56 +00:00
Rafael Espindola 191390a851 Inline function called only once.
llvm-svn: 289067
2016-12-08 16:26:20 +00:00
Rafael Espindola 361da4cef7 Handle C++ names in anon scripts.
llvm-svn: 289066
2016-12-08 16:20:29 +00:00
Rafael Espindola defdfa86c1 Inline two functions called only once. NFC.
llvm-svn: 289065
2016-12-08 16:02:48 +00:00
Rafael Espindola c65aee64ec Add two helper functions. NFC.
llvm-svn: 289064
2016-12-08 15:56:33 +00:00
Rafael Espindola 39c16dfbce Simplify. NFC.
llvm-svn: 289062
2016-12-08 15:36:58 +00:00
Simon Atanasyan 872764f6fe [ELF] Correct addAbsolute function argument name
Follow-up to r289025.

llvm-svn: 289061
2016-12-08 15:29:17 +00:00
George Rimar c49fd8c477 [ELF] - Read 16 bits for R_386_16/R_386_PC16 relocations instead of 32.
Looks it was theoretically incorrect if the section is at the very end of the file as
reading 32 bits would pass the end of file

llvm-svn: 289046
2016-12-08 13:50:28 +00:00
Peter Smith baffdb8bc2 [ELF] ifunc implementation using synthetic sections
This change introduces new synthetic sections IpltSection, IgotPltSection
that represent the ifunc entries that would previously have been put in
the PltSection and the GotPltSection. The separation makes sure that
the R_*_IRELATIVE relocations are placed after the non R_*_IRELATIVE
relocations, which permits ifunc resolvers to know that the .got.plt
slots will be initialized prior to the resolver being called.

A secondary benefit is that for ARM we can move the IgotPltSection and its
dynamic relocations to the .got and .rel.dyn as the ARM glibc expects all
the R_*_IRELATIVE relocations to be in the .rel.dyn

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

llvm-svn: 289045
2016-12-08 12:58:55 +00:00
Simon Atanasyan 6a4eb75c46 [ELF][MIPS] Make _gp, _gp_disp, __gnu_local_gp global symbols
These MIPS specific symbols should be global because in general they can
have an arbitrary value. By default this value is a fixed offset from .got
section.

This patch adds more checks to the mips-gp-local.s test case but marks
it as XFAIL because LLD does not allow redefinition of absolute symbols
value by a linker script. This should be fixed by D27276.

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

llvm-svn: 289025
2016-12-08 06:19:47 +00:00
Rafael Espindola 41217616a8 Delete dead code.
Thanks to George Rimar for pointing it out.

llvm-svn: 289020
2016-12-08 03:17:05 +00:00
Rui Ueyama 9a97acc097 Remove redundant call of std::unique_ptr::get.
Obj is an instance of std::unique_ptr, so *Obj.get() is the same as *Obj.

llvm-svn: 288996
2016-12-07 23:26:39 +00:00
Rui Ueyama 332e02a164 Fix Windows buildbots.
clang-format-diff sorted these #include's in the asciibetical order,
but they need to be in this order.

llvm-svn: 288995
2016-12-07 23:24:32 +00:00
Rui Ueyama 4c5b8cea02 Make demangle() return None instead of "" if a given string is not a mangled symbol.
llvm-svn: 288993
2016-12-07 23:17:05 +00:00
Rui Ueyama a45d45e231 COFF: Define overloaded toString functions.
Previously, we had different way to stringize SymbolBody and InputFile
to construct error messages. This patch defines overloaded function
toString() so that we don't need to memorize all these different
function names.

With that change, it is now easy to include demangled names in error
messages. Now, if there is a symbol name conflict, we'll print out
both mangled and demangled names.

llvm-svn: 288992
2016-12-07 23:17:02 +00:00
Rafael Espindola d4db0b3748 Rename MaxPageSize to DefaultMaxPageSize to avoid confusion.
Thanks to Rui for the suggestion.

llvm-svn: 288982
2016-12-07 21:13:27 +00:00
Rui Ueyama 007f9f3e3d Fix Windows buildbots.
llvm-svn: 288975
2016-12-07 20:31:46 +00:00
Rafael Espindola 476d20764a Use the correct MaxPageSize.
Now Target->MaxPageSize is only used as the default value of
Config->MaxPageSize.

llvm-svn: 288974
2016-12-07 20:29:46 +00:00
Rui Ueyama f966fe6c38 Do not pass line number to convertToUnixPathSeparator.
Line number can never contain '/' or '\', so the previous code
was pointless at that point.

llvm-svn: 288973
2016-12-07 20:25:45 +00:00
Rui Ueyama 63d064e9d1 Make convertToUnixPathSeparator return a new string instead of mutating argument.
llvm-svn: 288972
2016-12-07 20:22:27 +00:00
Rafael Espindola 8b8f74f6b7 Simplify. NFC.
llvm-svn: 288971
2016-12-07 20:20:39 +00:00
Rafael Espindola a86a9c6fad Use the correct MaxPageSize.
Found by inspection.

llvm-svn: 288970
2016-12-07 20:10:43 +00:00
George Rimar 49326e4d84 Format. NFC.
llvm-svn: 288967
2016-12-07 19:44:27 +00:00
George Rimar 92c88a4f76 [ELF] - Print absolute file name in errors when possible.
Currently LLD prints basename of source file name in error messages,
for example:
$ mkdir foo
$ echo 'void _start(void) { foobar(); }' > foo/bar.c
$ gcc -g -c foo/bar.c
$ bin/ld.lld -o out bar.o 
bin/ld.lld: error: bar.c:1: undefined symbol 'foobar'
$
This should say:
bin/ld.lld: error: foo/bar.c:1: undefined symbol 'foobar'

This is PR31299

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

llvm-svn: 288966
2016-12-07 19:42:25 +00:00
Adhemerval Zanella d719d37156 ELF/AArch64: Refactor R_AARCH64_LDST{8,15,32,64,128}_ABS_LO12_NC Relocations
This patch refactor how to apply the R_AARCH64_LDST{8,16,32,64,128}_ABS_NC
relocations by adding a new function to correct extract the bits expected
by each relocation.  This make is explicit which are the bits range expected
and simplify the code to mask and shift the deriable values.

It also fixes the R_AARCH64_LDST128_ABS_LO12_NC mask, although in pratice
the mask/shift always returns a 16 bytes aligned value.

Checked on AArch64 and with test-suite.

llvm-svn: 288921
2016-12-07 17:31:48 +00:00
Rui Ueyama 4de746f326 Add comments and reorder code a bit to clarify the intention. NFC.
llvm-svn: 288885
2016-12-07 04:45:34 +00:00
Rui Ueyama 9e5f5effe5 Make a decision about whether we should warn on missing entry or not early.
Config->WarnMissingEntry is a single-purpose boolean variable, and
I think it's easier to understand than Config->HasEntry.

llvm-svn: 288883
2016-12-07 04:06:21 +00:00
Rui Ueyama a1407c4fdf Simplify -e <number> option handling.
This patch is to parse the entry symbol name lazily.

llvm-svn: 288882
2016-12-07 03:23:06 +00:00
Petr Hosek 7173340e1f [ELF] Fix the broken PPC test
This is related to the change in handling of entry point symbols.

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

llvm-svn: 288880
2016-12-07 03:04:02 +00:00
Petr Hosek 2f50fef095 [ELF] Shared libraries should have entry point
Shared libraries should have entry set following the same rules as for
regular binaries. The only difference is that in case the default entry
point (_start or __start) isn't found (unless it was set explicitly), we
shouldn't give a warning as in case of regular binaries.

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

llvm-svn: 288878
2016-12-07 02:26:16 +00:00
Petr Hosek 668bebed6d [ELF] Only binaries should have DT_DEBUG entry
The presence of DT_DEBUG entry is unrelated to the existence of entry point.

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

llvm-svn: 288877
2016-12-07 02:05:42 +00:00
George Rimar a2a32c2cc8 [ELF] - Teach LLD to recognize PT_OPENBSD_BOOTDATA
Minor patch to fix PR31288

OpenBSD commit:
d39116912b

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

llvm-svn: 288832
2016-12-06 17:57:42 +00:00
Rafael Espindola 074ba93ceb Don't print empty PT_LOAD.
If we do, the freebsd dynamic linker tries to call mmap with a size 0,
which fails.

It is hard to avoid creating them when linker scripts are used, so we
just delete empty PT_LOADs at the end.

llvm-svn: 288808
2016-12-06 13:43:34 +00:00
Rafael Espindola e004d4bfc2 Don't crash trying to write an 0 addend.
For preemptable symbols the dynamic linker does all the work. Trying
to compute the addend is at best wasteful and can also lead to crashes
in cases of programs that uses tls but doesn't define any tls
variables.

llvm-svn: 288803
2016-12-06 12:19:24 +00:00
Rafael Espindola 43c3cb7786 Make the test a bit more strict. NFC.
llvm-svn: 288802
2016-12-06 12:15:12 +00:00
Rui Ueyama c8e6884871 Inline MergeInputSection::getData().
This change seems to make LLD 0.6% faster when linking Clang with
debug info. I don't want us to have lots of local optimizations,
but this function is very hot, and the improvement is small but
not negligible, so I think it's worth doing.

llvm-svn: 288757
2016-12-06 02:19:30 +00:00
Rafael Espindola d207c37806 Test only the relevant bits.
This test only needs to test the Type (SharedObject), the address of
the first PT_LOAD and the presence of PT_DYNAMIC.

llvm-svn: 288719
2016-12-05 22:27:21 +00:00
Rafael Espindola d6b42ee404 Don't check the symbol values is this test.
It only needs to find how many are local.

llvm-svn: 288716
2016-12-05 22:16:32 +00:00
Rui Ueyama c38860b0d2 Revert r288707: Split removeUnusedSyntheticSections into two functions.
That patch broke build.

llvm-svn: 288708
2016-12-05 21:39:35 +00:00
Rui Ueyama 29e7a19e17 Split removeUnusedSyntheticSections into two functions.
llvm-svn: 288707
2016-12-05 21:37:16 +00:00
Rafael Espindola 7b4dd875df Don't check symbol value in this test.
llvm-svn: 288704
2016-12-05 21:02:45 +00:00
Rafael Espindola 35ac8bab7b Don't check the symbol value in this test.
llvm-svn: 288702
2016-12-05 20:56:40 +00:00