Commit Graph

8993 Commits

Author SHA1 Message Date
Rui Ueyama 8bee41e423 Simplify. NFC.
llvm-svn: 311700
2017-08-24 20:32:58 +00:00
Rui Ueyama 9f7032aaf0 Minor refactoring. NFC.
llvm-svn: 311696
2017-08-24 20:26:54 +00:00
Rui Ueyama 5c19028cec Allow not only -O<number> but also -O <number>.
Fixes https://bugs.llvm.org/show_bug.cgi?id=34311

llvm-svn: 311682
2017-08-24 18:34:44 +00:00
Rui Ueyama 00cf731ecd Make empty arguments visible in error messages.
Before this patch, lld printed out something like

  error: -O: number expected, but got

After this patch, it prints out the same error message like this:

  error: -O: number expected, but got ''

Fixes https://bugs.llvm.org/show_bug.cgi?id=34311

llvm-svn: 311681
2017-08-24 18:34:32 +00:00
Sam Clegg 7dbd1fd73b Update comments: parallel_for_each -> parallelForEach
Also remove unused include of raw_ostream.h

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

llvm-svn: 311587
2017-08-23 19:03:20 +00:00
Petr Hosek b93c5b9f7e [ELF] Don't output headers into a segment if there's no space for them
Currently, LLD checks whether there's enough space for headers by
checking if headers fit below the address of the first allocated
section. However, that's always thue if the binary doesn't start
at zero which means that LLD always emits a segment for headers,
even if no other sections belong to that segment.

This is a problem in cases when linker script is being used with a
non-zero start address when we don't want to make the headers visible
by not leaving enough space for them. This pattern is common in
embedded programming but doesn't work in LLD.

This patch changes the behavior of LLD in case when linker script
is being to match the behavior of BFD ld and gold, which is to only
place headers into a segment when they're covered by some output
section.

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

llvm-svn: 311586
2017-08-23 18:44:34 +00:00
George Rimar de2d1066ae [ELF] - Do not report multiple errors for single one in ScriptLexer::setError.
Previously up to 3 errors were reported at once,
with patch we always will report only one,
just like in other linker code.

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

llvm-svn: 311537
2017-08-23 08:48:39 +00:00
George Rimar 55f207fb1f [ELF] - Repair dynsym-pie.s testcase.
It was broken from begining, because visibility
attributes were not applied properly to
symbols before this patch.

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

llvm-svn: 311536
2017-08-23 08:42:35 +00:00
George Rimar 51d193f8b3 [ELF] - Fix for "Bug 34238 - LTO is optimizing away symbols referenced from linker scripts"
Code suggested by Rui Ueyama in PR34238 comments.

Previously LTO optimized away symbols referenced from linker script
because did not see that them are used from regular objects.

Patch adds such symbols as undefined earlier, before running LTO,
what sets IsUsedInRegularObj for them and fixes the issue.

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

llvm-svn: 311534
2017-08-23 08:37:22 +00:00
Martell Malone 8cd2f13938 NFC: LLD fix OptTable Variable Name Style
llvm-svn: 311518
2017-08-23 02:33:42 +00:00
Rui Ueyama e158f7c329 Revert r311468: If --dynamic-list is given, only those symbols are preemptible
This reverts commit r311468 because it broke some CFI bots.

llvm-svn: 311497
2017-08-22 21:54:58 +00:00
Rui Ueyama 9cbbacb910 If --dynamic-list is given, only those symbols are preemptible
Patch by Rafael Espíndola.

This is PR34053.

The implementation is a bit of a hack, given the precise location where
IsPreemtible is set, it cannot be used from
SymbolTable::handleAnonymousVersion.

I could add another method to SymbolTable if you think that would be
better.

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

llvm-svn: 311468
2017-08-22 16:31:47 +00:00
George Rimar 5bd647dfd0 [ELF] - Remove outdated comment. NFC.
llvm-svn: 311449
2017-08-22 11:11:11 +00:00
George Rimar 3a1af22099 [ELF] - Make IR symbols be visible when doing relocatable link.
This is PR33097.
Previously when doing relocatable link, all IR symbols were absent
in result object file. Patch makes external symbols to be exported.

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

llvm-svn: 311431
2017-08-22 08:36:54 +00:00
Chandler Carruth ffe62e3ae9 Fix a -Wpessimizing-move warning from Clang on this code --
a std::move() isn't needed here as the object is a temporary.

llvm-svn: 311430
2017-08-22 08:02:12 +00:00
Eric Beckmann 87c6acf38a Integrate manifest merging library into LLD.
Summary: Now that the llvm-mt manifest merging libraries are complete, we may use them to merge manifests instead of needing to shell out to mt.exe.

Subscribers: mgorny, llvm-commits

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

llvm-svn: 311424
2017-08-22 03:15:28 +00:00
Sam Elliott 29404b3a62 [lld] Update Tests for Emitting Single Inline Remark
Summary: This change depends on https://reviews.llvm.org/D36054 and should be landed at the same time.

Reviewers: anemet

Reviewed By: anemet

Subscribers: llvm-commits, emaste

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

llvm-svn: 311348
2017-08-21 16:41:59 +00:00
Zachary Turner d1de2f4f5e [llvm-pdbutil] Add support for dumping detailed module stats.
This adds support for dumping a summary of module symbols
and CodeView debug chunks.  This option prints a table for
each module of all of the symbols that occurred in the module
and the number of times it occurred and total byte size.  Then
at the end it prints the totals for the entire file.

Additionally, this patch adds the -jmc (just my code) option,
which suppresses modules which are from external libraries or
linker imports, so that you can focus only on the object files
and libraries that originate from your own source code.

llvm-svn: 311338
2017-08-21 14:53:25 +00:00
James Henderson d447a7a128 [ELF] Remove dependency on hexdump from lit test
hexdump is not part of the GNU coreutils, and so is not required to be able to
build and test LLVM, according to the documentation. This change removes the
dependency on hexdump from a lit test.

Reviewers: grimar

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

llvm-svn: 311335
2017-08-21 14:11:08 +00:00
George Rimar f7ef2a13f6 [ELF] - Recommit "[ELF] - Do not forget to fill last bytes of PT_LOADs with trap instructions."
With fix: explicitly specify ouput format for hexdump tool call.

Original commit message:

[ELF] - Do not forget to fill last bytes of PT_LOADs with trap instructions.

Previously last 4 bytes of executable loads
were not filled with trap instructions,
patch fixes this bug.

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

llvm-svn: 311315
2017-08-21 08:31:14 +00:00
George Rimar 09a6945b48 [ELF] - Revert r311310 "[ELF] - Do not forget to fill last bytes of PT_LOADs with trap instructions."
It broke BB:
http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/11792/steps/test_lld/logs/stdio

llvm-svn: 311314
2017-08-21 08:13:45 +00:00
George Rimar 8902bb8e62 [ELF] - Enable threading in many-sections.s testcase. NFC.
This is PR32942, previously threading was disabled
because slowed down this testcase a lot.
It was fixed in r311312.

llvm-svn: 311313
2017-08-21 08:10:35 +00:00
George Rimar 5d0ea70ad5 [ELF] - Do not segfault when doing logical and/or operations on symbols that have no output sections.
Previously we would crash on samples from testcase,
because were trying to access zero pointer to output section.

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

llvm-svn: 311311
2017-08-21 07:57:12 +00:00
George Rimar c7392cbe9a [ELF] - Do not forget to fill last bytes of PT_LOADs with trap instructions.
Previously last 4 bytes of executable loads
were not filled with trap instructions,
patch fixes this bug.

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

llvm-svn: 311310
2017-08-21 07:51:21 +00:00
Rui Ueyama 42479e02ca Rename {Lazy,}ObjectKind -> {Lazy,}ObjKind.
I renamed corresponding classes in r309199 but forgot to rename enums
at the moment. Rename them now to make them consistent.

llvm-svn: 311214
2017-08-19 00:13:54 +00:00
Ben Dunbobbin 95637558fa Test commit.
Removed extraneous comment markers

llvm-svn: 311169
2017-08-18 16:15:36 +00:00
George Rimar 7e5b0a5978 [ELF] - Don't segfault when accessing location counter inside MEMORY command.
We would previously crash on next script:
MEMORY { name : ORIGIN = .; }

Patch fixes that.

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

llvm-svn: 311073
2017-08-17 08:47:21 +00:00
Rui Ueyama 314a005002 Remove a lock and use a std::unique_ptr instead.
We had a lock to guard BAlloc from being used concurrently, but that
is not very easy to understand. This patch replaces it with a
std::unique_ptr.

llvm-svn: 311056
2017-08-17 00:27:55 +00:00
Davide Italiano aa33e74f4b [ELF/LTO] -function-sections/-data-sections are exact options.
Also add a test. This fixes r310995 and PR34200.

llvm-svn: 310998
2017-08-16 08:21:04 +00:00
George Rimar d6d24ac437 [ELF] - Ignore -plugin-opt=-function-sections/-plugin-opt=-data-sections. NFC.
Clang passes this options to linker. We should ignore them,
anyways they are always enabled by default atm.

Fixes https://bugs.llvm.org/show_bug.cgi?id=34200.

llvm-svn: 310995
2017-08-16 07:25:09 +00:00
Martin Storsjo 92f32d0c53 [COFF] Don't produce weak aliases in import libraries
When creating an import library from lld, the cases with
Name != ExtName shouldn't end up as a weak alias, but as a real
export of the new name, which is what actually is exported from
the DLL.

This restores the behaviour of renamed exports to what it was in
4.0.

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

llvm-svn: 310992
2017-08-16 05:23:00 +00:00
Martin Storsjo a50275cfe5 [COFF] Fix the name type for stdcall functions in import libraries
Since SVN r303491 and r304573, LLD used the COFFImportLibrary
functions from LLVM. These only had two names, Name and ExtName,
which wasn't enough to convey all the details of stdcall functions.

Stdcall functions got the wrong symbol name in the import library
itself in r303491, which is why it was reverted in r304561. When
re-landed and fixed in r304573 (after adding a test in r304572),
the symbol name itself in the import library ended up right, but the
name type of the import library entry was wrong.

This had the effect that linking to the import library succeeded
(contrary to in r303491, where linking to such an import library
failed), but at runtime, the symbol wouldn't be found in the DLL
(since the caller linked to the stdcall decorated name).

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

llvm-svn: 310989
2017-08-16 05:13:25 +00:00
Zachary Turner 1bc6cb64b1 Fix warning about unused variable.
I'm explicitly ignoring the warning by casting to void instead of
deleting the local assignment, because it's confusing to see a
function that fails when its return value evaluates to true.
But when you see that it's a std::error_code, it makes more sense.

llvm-svn: 310965
2017-08-15 21:46:51 +00:00
Zachary Turner 024323cb12 [LLD COFF/PDB] Incrementally update the build id.
Previously, our algorithm to compute a build id involved hashing the
executable and storing that as the GUID in the CV Debug Record chunk,
and setting the age to 1.

This breaks down in one very obvious case: a user adds some newlines to
a file, rebuilds, but changes nothing else. This causes new line
information and new file checksums to get written to the PDB, meaning
that the debug info is different, but the generated code would be the
same, so we would write the same build over again with an age of 1.

Anyone using a symbol cache would have a problem now, because the
debugger would open the executable, look at the age and guid, find a
matching PDB in the symbol cache and then load it. It would never copy
the new PDB to the symbol cache.

This patch implements the canonical Windows algorithm for updating
a build id, which is to check the existing executable first, and
re-use an existing GUID while bumping the age if it already
exists.

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

llvm-svn: 310961
2017-08-15 21:31:41 +00:00
Rui Ueyama 2b6631bb36 Remove GdbIndexSection::finalizeContents.
GdbIndexSection doesn't need lazy finalization because when an instance
of the class is created, we already know all debug info sections.
We can initialize the instnace in the ctor.

llvm-svn: 310931
2017-08-15 17:01:39 +00:00
Rui Ueyama e5d642cf5b Use ArrayRef instead of std::vector&.
llvm-svn: 310930
2017-08-15 17:01:28 +00:00
Rui Ueyama 2114cab93d Update a comment and rename a function.
llvm-svn: 310929
2017-08-15 17:01:17 +00:00
Rui Ueyama 43099e4409 Remove SymbolTable::findInCurrentDSO.
This function doesn't seem to add value to the symbol table as
it is easy to write code without it.

llvm-svn: 310925
2017-08-15 16:03:11 +00:00
Rui Ueyama 6238ed2457 Update comments as the function does not write to the first page anymore.
Also refactored the code a bit.

llvm-svn: 310886
2017-08-14 21:18:12 +00:00
Martin Storsjo d2752aa9ec [COFF] Add support for aligncomm directives
These are emitted for comm symbols in object files, when targeting
a GNU environment.

Alternatively, just ignore them since we already align CommonChunk
to the natural size of the content (up to 32 bytes). That would only
trade away the possibility to overalign small symbols, which doesn't
sound like something that might not need to be handled?

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

llvm-svn: 310871
2017-08-14 19:07:27 +00:00
Zachary Turner 302dc8bccf [PDB] Ignore all S_UDT symbols when writing PDBs.
We don't have the right algorithm for copying S_UDT symbols
from object files to the globals stream, and having it wrong
is worse than not having it at all, since it breaks display
of local variables of UDT types (for example, "dv Foo" fails
in our current implementation, but succeeds if the S_UDT records
are omitted).  Omit them until we fix the algorithm.

llvm-svn: 310867
2017-08-14 18:44:58 +00:00
Rui Ueyama a13897245c Add a comment and remove a TODO.
A TODO is not a todo unless we really have to do it, but
they are not required at the moment.

llvm-svn: 310864
2017-08-14 17:48:30 +00:00
George Rimar 8bb437c98f [ELF] - Ignore --plugin-opt=mcpu= and --plugin-opt=thinlto.
Attemp to fix BB.

Previously we ignored all --plugin-opt options, 
but now (after r310826) error out on non implemented ones.
This caused BB to fail:

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/3405/steps/check-cfi-and-supported%20in%20gcc%20build/logs/stdio

llvm-svn: 310835
2017-08-14 12:36:14 +00:00
George Rimar cb38bf526b [ELF] - LTO: Try to be option compatible with the gold plugin.
This is relative to PR30720.

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

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

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

llvm-svn: 310826
2017-08-14 10:17:30 +00:00
Zachary Turner b57884e818 Fix some broken tests.
These were pending in a separate patch but I forgot to squash them
before comitting, and this one didn't go through.

llvm-svn: 310764
2017-08-11 21:14:01 +00:00
Rui Ueyama be7e001369 Add `-z muldefs` option.
llvm-svn: 310757
2017-08-11 20:49:48 +00:00
Zachary Turner f6822c869c [pdb] Fix linker module symbols to work with dbgeng.
The linker module contains a symbol of type S_COMPILE3 which
contains various information about the compiler and linker used
to create the PDB, such as the name of the linker, the target
machine, and the linker version.  Interestingly, if we set the
version string to 0.0.0.0, then when trying to view local
variables WinDbg emits an error that private symbols are not
present.  By setting this to a valid MSVC linker version string,
local variables can display.

As such, even though it is not representative of LLVM's version
information, we need this for compatibility.

llvm-svn: 310755
2017-08-11 20:46:47 +00:00
Zachary Turner 28e31ee45e Output S_SECTION symbols to the Linker module.
PDBs need to contain 1 module for each object file/compiland,
and a special one synthesized by the linker.  This one contains
a symbol record for each output section in the executable with
its address information.  This patch adds such symbols to the
linker module.  Note that we also are supposed to add an
S_COFFGROUP symbol for what appears to be each input section that
contributes to each output section, but it's not entirely clear
how to generate these yet, so I'm leaving that for a separate
patch.

llvm-svn: 310754
2017-08-11 20:46:28 +00:00
Zachary Turner 964e096345 Remove unused lambda capture.
llvm-svn: 310752
2017-08-11 20:37:49 +00:00
Zachary Turner ee9906d884 [LLD/PDB] Write actual records to the globals stream.
Previously we were writing an empty globals stream.  Windows
tools interpret this as "private symbols are not present in
this PDB", even when they are, so we need to fix this.  Regardless,
without it we don't have information about global variables, so
we need to fix it anyway.  This patch does that.

With this patch, the "lm" command in WinDbg correctly reports
that we have private symbols available, but the "dv" command
still refuses to display local variables.

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

llvm-svn: 310743
2017-08-11 19:00:03 +00:00