Commit Graph

8908 Commits

Author SHA1 Message Date
Martin Storsjo 405b5bcc36 [COFF] Correctly set the thumb bit in DLL export addresses
The same adjustment is already done for the entry point in
Writer.cpp and for relocations that point to executable code
in Chunks.cpp.

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

llvm-svn: 308953
2017-07-25 06:10:44 +00:00
Martin Storsjo 25712667cb [COFF] Add a test for producing DLLs and import libraries for ARM64
This is a test for LLVM SVN r308951.

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

llvm-svn: 308952
2017-07-25 06:08:25 +00:00
Rafael Espindola dc49af9d32 Make a function static. NFC.
llvm-svn: 308939
2017-07-24 23:55:33 +00:00
Tom Stellard 1d70d75f46 Fix ObjCPass on big-endian host
Summary:
This fixes test/mach-o/objc-image-info-pass-output.yaml on
big-endian hosts.

Reviewers: lhames, kledzik, ruiu

Reviewed By: ruiu

Subscribers: llvm-commits

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

llvm-svn: 308935
2017-07-24 23:13:31 +00:00
Dmitry Mikulin 97d6a80895 If user requested section alignment is greater than MaxPageSize, propagate it to segment headers correctly.
Differential Revision: https://reviews.llvm.org/D35813

llvm-svn: 308930
2017-07-24 21:27:02 +00:00
Davide Italiano 0a26c5738d [ELF] Fix a typo introduced in r308915.
Thanks to Rafael for finding it in a post-commit review.

llvm-svn: 308921
2017-07-24 20:18:16 +00:00
Davide Italiano 957f1206e9 [LTO] Make sure symbol ordering is honoured also for data.
Follow-up to r308915 suggested by Rafael and Peter.

llvm-svn: 308920
2017-07-24 20:15:07 +00:00
Davide Italiano 4deb97c377 [ELF] Fix a couple of typos in a test.
llvm-svn: 308916
2017-07-24 19:42:13 +00:00
Davide Italiano 1f4e29c71d [LTO] Make sure symbol ordering is honoured.
We do this emitting a section for every function when LTO is used.
Fixes PR33888.

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

llvm-svn: 308915
2017-07-24 19:38:13 +00:00
Rafael Espindola fae04ae44c Handle a section being more aligned than a page size.
llvm-svn: 308812
2017-07-22 00:17:57 +00:00
Rafael Espindola ca5740d95a Don't crash on an empty section with an ALIGN.
llvm-svn: 308809
2017-07-22 00:00:51 +00:00
Rui Ueyama 8940102671 Fix a test breakage caused by r308752.
llvm-svn: 308775
2017-07-21 20:15:46 +00:00
George Rimar 4f37d57547 [ELF] - Introduce multiclass Eq helper for Options.td
Eq helper allows to define `XXX` and `XXX=` options forms easily.
Patch adds testcases for few aliases.

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

llvm-svn: 308752
2017-07-21 16:27:26 +00:00
Igor Kudrin 7d2b15a7ab [ELF] Avoid data race in ObjectFile<ELFT>::getDILineInfo().
Differential Revision: https://reviews.llvm.org/D35537

llvm-svn: 308728
2017-07-21 11:26:08 +00:00
Petr Hosek 8b591f592b [ELF] Remove processNonSectionCommands
This method is no longer being used anywhere.

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

llvm-svn: 308706
2017-07-21 01:02:30 +00:00
Petr Hosek 039fb8c296 [ELF] Align the value if needed when computing the expression
Also add the test cases for the addition and subtraction both for
the relative and absolute case.

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

llvm-svn: 308692
2017-07-20 23:11:47 +00:00
Kevin Enderby b4c351dfd1 lld matching change for llvm change r308690 to add error handling to
the dyld compact export entries in libObject.

llvm-svn: 308691
2017-07-20 23:09:19 +00:00
Rui Ueyama 800cd3ec40 Add a missing tool dependency.
This dependency was introduced in r308681.

llvm-svn: 308686
2017-07-20 22:39:31 +00:00
Rafael Espindola 2bd185bcde Fix symbol type with icf.
We were not looking at Repl and so thinking there was no output
section associated with the merged symbol. Because of that it was
produced as absolute.

This was found by an internal round of testing.

llvm-svn: 308681
2017-07-20 21:55:40 +00:00
Rui Ueyama bc2c9e0278 Do not strip SHF_GROUP in elf::decompressAndMergeSections().
SHF_GROUP flag should have been removed when the control reaches here
because InputSectionBase turns the flag off. So this code should be
redundant.

llvm-svn: 308680
2017-07-20 21:42:30 +00:00
Rui Ueyama 875ae82b0b Add the --chroot option for --reproduce.
Summary:
If the linker is invoked with `--chroot /foo` and `/bar/baz.o`, it
tries to read the file from `/foo/bar/baz.o`. This feature is useful
when you are dealing with files created by the --reproduce option.

Reviewers: grimar

Subscribers: llvm-commits, emaste

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

llvm-svn: 308646
2017-07-20 18:17:55 +00:00
Rafael Espindola 4b1008af73 Add test from pr33173.
It was fixed by r308544.

llvm-svn: 308634
2017-07-20 17:14:52 +00:00
Martin Storsjo 5ae7649a4e [COFF] Support 128 bit SIMD/FP ldr/str in IMAGE_REL_ARM64_PAGEOFFSET_12L
Also extend the tests for IMAGE_REL_ARM64_PAGEOFFSET_12L to test
all 8/16/32/64 bit GPR and 8/16/32/64/128 SIMD/FP bit ldr/str variants,
and a ldr with an existing offset.

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

llvm-svn: 308631
2017-07-20 16:48:33 +00:00
Martin Storsjo dd62dffbcb [COFF] Minor tweaks to ARM64 relocation code. NFC.
Fix issues found in existing code, while reviewing other changes.

Change the data type of a variable to uint32_t, to avoid potential issues
with signedness in shifts.

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

llvm-svn: 308586
2017-07-20 05:49:58 +00:00
Martin Storsjo b3c97b9623 [COFF] Align import address chunks to the pointer size
This fixes cases on ARM64 when importing from more than one DLL,
in case the imports from the first DLL ended up unaligned.

When fixing up a IMAGE_REL_ARM64_PAGEOFFSET_12L, which shifts the
offset by the load/store size, check that the shift doesn't discard
any bits. (This would also detect if the import address chunks were
unaligned.)

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

llvm-svn: 308585
2017-07-20 05:49:54 +00:00
Rafael Espindola 8b1afd59c3 Speed up gdb index creation.
With that in place we can use lld's own infrastructure for the low
level detail of dwarf parsing.

With this we don't decompress sections twice, we don't scan all
realocations and even with this simplistic implementation linking
clang with gdb index goes from 34.09 seconds to 20.80 seconds.

llvm-svn: 308544
2017-07-19 22:27:35 +00:00
Rui Ueyama 0deaacb95a Call StringRef::contains only once for each StringRef.
llvm-svn: 308529
2017-07-19 21:49:01 +00:00
Rui Ueyama 12234f8093 Use StringRef::contains().
llvm-svn: 308526
2017-07-19 21:40:26 +00:00
Rui Ueyama 7eaf3d4b31 Fix one more occurrence of getOption().getID().
llvm-svn: 308523
2017-07-19 21:06:46 +00:00
Rui Ueyama 38b0f4a1f2 Handle option aliases in a better way.
In this way, we don't need to know which options have aliases.

llvm-svn: 308519
2017-07-19 20:30:04 +00:00
Rafael Espindola aca2afcc55 Don't depend on these symbols being implicitly global.
This might change in llvm-mc and it is nice to be explicit in a test.

llvm-svn: 308506
2017-07-19 18:24:38 +00:00
Reid Kleckner d91ca7666f [PDB] Emit TPI and IPI hashes
llvm-svn: 308497
2017-07-19 17:26:07 +00:00
Rafael Espindola 3ddf2110d5 Bring back r307364.
In addition this includes a change to prefer symbols with a default
version @@ over unversioned symbols.

Original commit message:

[ELF] - Handle symbols with default version early.

This fixes last testcase provided in PR28414.
In short issue is next: when we had X@@Version symbol in object A,
we did not resolve it to X early. Then when in another object B
we had reference to undefined X, symbol X from archive was fetched.
Since both archive and object A contains another symbol Z, duplicate
symbol definition was triggered as a result.

Correct behavior is to use X@@Version from object A instead and do not fetch
any symbols from archive.

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

llvm-svn: 308492
2017-07-19 16:45:05 +00:00
Hans Wennborg 884e84533d Clear release notes for 6.0.0
llvm-svn: 308475
2017-07-19 14:09:52 +00:00
Hans Wennborg 7e9b4784a6 Bump docs version to 6.0
llvm-svn: 308463
2017-07-19 13:47:08 +00:00
Saleem Abdulrasool 2334adeb02 test: remove duplicated test
This test is folded into implib-name.  Don't bother with the racy test.
The use of %T results in left-overs from previous tests which write out
the same import library as this test.

llvm-svn: 308409
2017-07-19 02:39:00 +00:00
Saleem Abdulrasool ace2fa7da4 COFF: improve link conformance for import names
Improve the link conformance for the import name embedded into the
import library.  This requires the associated change to the LLVM portion
for the DEF file parser.  The import file generation embeds a different
name based on whether the driver is invoked as "link" or "lib".
Furthermore, the LIBRARY keyword in the DEF file influences the import
name.  The behaviour can be summarised according to the following table:

      | LIBRARY w/ ext |   LIBRARY w/o ext   | no LIBRARY
 -----+----------------+---------------------+------------------
 LINK | {value}        | {value}.{.dll/.exe} | {output name}
  LIB | {value}        | {value}.dll         | {output name}.dll

llvm-svn: 308407
2017-07-19 02:01:27 +00:00
Rafael Espindola 2b84fa418b Make the test more precise.
The real issue was the missing explicit versions.

llvm-svn: 308391
2017-07-18 23:26:16 +00:00
Rafael Espindola 483506562c Add a test for PR33820.
This would have found the issue.

llvm-svn: 308389
2017-07-18 22:52:44 +00:00
Saleem Abdulrasool 08c83ea0f3 test: add COFF test for library extension handling
Ensure that an extension other than .dll, .exe is preserved as per the
behaviour of link.

llvm-svn: 308386
2017-07-18 22:25:07 +00:00
Rafael Espindola a4148c6eed Fix REQUIRES line.
llvm-svn: 308385
2017-07-18 22:14:26 +00:00
Rafael Espindola afbb7be6d5 Fix a crash.
This is PR33821.

What we really want to check in here is if the output section was
created, not if the command was empty.

llvm-svn: 308382
2017-07-18 21:46:27 +00:00
Rui Ueyama ede4c7ecbc Fix errors in r308335 and add "REQUIRES: x86" to one more file.
llvm-svn: 308339
2017-07-18 18:51:43 +00:00
Jon Chesterfield e0ca2ff070 [LLD] Mark a number of x86 only tests to require x86
Noticed while testing for an out of tree target. There are probably more tests that should be so marked.
I'm not sure who owns these tests so I've added a few names I recognise from the recent history.

With advice from probinson, ruiu, rafael and dramatically improved by davidb. Thank you all!

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

llvm-svn: 308335
2017-07-18 18:40:50 +00:00
Shoaib Meenai 9a61a791ac [COFF] Accept discarded relocations in DWARF debug sections
DWARF debug sections can also contain relocations against symbols in
discared segments. LLD should accept such relocations.

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

llvm-svn: 308315
2017-07-18 15:11:05 +00:00
George Rimar b939d32f53 [ELF] - Fix member name: alignment -> Alignment. NFC.
llvm-svn: 308300
2017-07-18 11:59:19 +00:00
George Rimar 67c60727ce [ELF] - Apply clang-format. NFC.
llvm-svn: 308297
2017-07-18 11:55:35 +00:00
Reid Kleckner f8522d81c3 Fix pdb-type-server-simple test on non-Windows
Assume that the LF_TYPESERVER2 record contains Windows-style paths.  In
any case, 'sys::path::filename(Path, Style::windows)' will work on
Unix-style paths.

llvm-svn: 308241
2017-07-18 00:33:53 +00:00
Rui Ueyama 0e0369e535 Revert r307364: [ELF] - Handle symbols with default version early.
This reverts commit r307364 because that change is likely to have
caused https://bugs.llvm.org/show_bug.cgi?id=33820.

llvm-svn: 308239
2017-07-18 00:33:14 +00:00
Reid Kleckner 651db91c2d [PDB] Merge in types and items from type servers (/Zi)
Summary:
Object files compiled with /Zi emit type information into a type server
PDB. The .debug$S section will contain a single TypeServer2Record with
the absolute path and GUID of the type server. LLD needs to load the
type server PDB and merge all types and items it finds in it into the
destination PDB.

Depends on D35495

Reviewers: ruiu, inglorion

Subscribers: zturner, llvm-commits

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

llvm-svn: 308235
2017-07-18 00:21:25 +00:00
Reid Kleckner 67653ee086 [codeview] Fix YAML for LF_TYPESERVER2 by hoisting PDB_UniqueId
Summary:
We were treating the GUIDs in TypeServer2Record as strings, and the
non-ASCII bytes in the GUID would not round-trip through YAML.

We already had the PDB_UniqueId type portably represent a Windows GUID,
but we need to hoist that up to the DebugInfo/CodeView library so that
we can use it in the TypeServer2Record as well as in PDB parsing code.

Reviewers: inglorion, amccarth

Subscribers: llvm-commits, hiraditya

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

llvm-svn: 308234
2017-07-17 23:59:44 +00:00
Rui Ueyama 8d8916d1dd Fix tests for .ctors/.dtors.
They are supposed to contain pointers, so .byte wasn't quite right.

llvm-svn: 308214
2017-07-17 20:42:52 +00:00
Reid Kleckner a842cd75e2 [codeview] Remove TypeServerHandler and PDBTypeServerHandler
Summary:
Instead of wiring these through the CVTypeVisitor interface, clients
should inspect the CVTypeArray before visiting it and potentially load
up the type server's TPI stream if they need it.

No tests relied on this functionality because LLD was the only client.

Reviewers: ruiu

Subscribers: mgorny, hiraditya, zturner, llvm-commits

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

llvm-svn: 308212
2017-07-17 20:28:06 +00:00
Shoaib Meenai e1d7776c53 [ELF] Use stable_sort for compareByFilePosition
The comment at the top of compareByFilePosition indicates that it relies
on stable_sort to preserve the order of synthetic sections. We were
using sort instead of stable_sort, however, leading to incorrect
synthetic section ordering.

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

llvm-svn: 308207
2017-07-17 19:42:19 +00:00
Peter Smith a49442f323 [ELF] Introduce target specific inBranchRange() function
In preparation for range extension thunks introduce a function that will
check whether a branch identified by a relocation type at a source address
can reach a destination.

For targets where range extension thunks are not supported the function will
return true as it is not expected that branches are out of range. An
implementation has been provided for ARM.

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

llvm-svn: 308188
2017-07-17 16:54:29 +00:00
George Rimar dae8495faf [ELF] - Stop listing version-script= form as ignored option.
Funny but we list it as ignored for about 1.5 years atm,
though LLD started to support version script really long time ago.

llvm-svn: 308170
2017-07-17 10:15:15 +00:00
George Rimar f525c928cf [ELF] - Implement filter library support (-F / --filter)
This is PR33766.

-F name
--filter=name
When creating an ELF shared object, set the internal DT_FILTER field to the specified name. This tells the dynamic linker that the symbol table of the shared object which is being created should be used as a filter on the symbol table of the shared object name.

If you later link a program against this filter object, then, when you run the program, the dynamic linker will see the DT_FILTER field. The dynamic linker will resolve symbols according to the symbol table of the filter object as usual, but it will actually link to the definitions found in the shared object name. Thus the filter object can be used to select a subset of the symbols provided by the object name.
(https://linux.die.net/man/1/ld).

Shared Objects as Filters:
https://docs.oracle.com/cd/E19683-01/817-3677/chapter4-31738/index.html

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

llvm-svn: 308167
2017-07-17 09:43:18 +00:00
Reid Kleckner af88a910fd [CodeView] Dump BuildInfoSym and ProcSym type indices
I need to print the type index in hex so that I can match it in
FileCheck for a test I'm writing.

llvm-svn: 308107
2017-07-15 18:10:39 +00:00
Rafael Espindola 3eb2bb1a28 Avoid using OutputSections::Sections.
This code runs after clearOutputSections.

llvm-svn: 308066
2017-07-14 22:26:16 +00:00
Rafael Espindola 72385ba53a Pass OutputSectionCommand to getOSThunkSec. NFC.
llvm-svn: 308057
2017-07-14 21:37:10 +00:00
Rafael Espindola e8b087c7e4 Pass OutputSectionCommand to forEachExecInputSection's callback.
NFC, just makes the OutputSectionCommand available.

llvm-svn: 308056
2017-07-14 21:33:14 +00:00
George Rimar b444efb939 [ELF] - Update testcases after LLVM update. (D35351)
llvm-svn: 308034
2017-07-14 16:00:34 +00:00
George Rimar 638e8a405d [ELF] - Remove dependency on precompiled inputs from -gdb-index testcases.
Previously we used precompiled objects in gdb-index.s and
debug-gnu-pubnames.s testcases. We can avoid that.

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

llvm-svn: 308005
2017-07-14 08:26:44 +00:00
Igor Kudrin 202a9f6817 [ELF] Fix writing the content of the .got section in a wrong place.
In filling the .got sections, InputSection::OutSecOff was added twice
when finding the position to apply a relocation: first time in
InputSection::writeTo() and then in SectionBase::getOffset().

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

llvm-svn: 308003
2017-07-14 08:10:45 +00:00
Shoaib Meenai e7ecbbcd62 [lld] Update Windows support docs
The /appcontainer flag was added in r299728, and the lib.exe dependency
for creating import libraries was removed in r275242. Update the docs
accordingly.

The PDB support also needs updating, but I'll leave that for someone
who's more familiar with the current status (probably rnk).

llvm-svn: 307998
2017-07-14 04:05:39 +00:00
Peter Collingbourne b069a36f27 ELF: Exclude dead symbols from -Map output.
This was previously erroring out if one of the dead symbols was a
TLS symbol and we were able to discard all TLS sections.

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

llvm-svn: 307984
2017-07-14 00:31:56 +00:00
Peter Collingbourne 3e2abdef02 ELF: Reword a somewhat misleading error message.
PT_TLS is a type of program header, so we wouldn't expect to see
one in an object file. This error should probably be referring to
the fact that we didn't see a section with the flag SHF_TLS, which
would normally cause us to create a PT_TLS program header.

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

llvm-svn: 307983
2017-07-14 00:22:46 +00:00
Reid Kleckner 0faf6d7beb [PDB] Put LLD's PDB writing code in a class NFC
Summary:
We've accumulated about five or so data structures that are widely
referenced:
- PDBBuilder
- Type table
- Id table
- PDB string table
- Type server handler

I'm about to rewrite type server handling, and I need a new class in LLD
where I can put its state. By creating a new PDBLinker class, I hope to
put it there next.

Reviewers: ruiu

Subscribers: llvm-commits

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

llvm-svn: 307979
2017-07-14 00:14:58 +00:00
Rui Ueyama 1e77ad1456 Move feature-specific functions out of Strings.cpp.
Functions declared in Strings.h should provide generic string operations
for the linker, but some of them are too specific to some features. This
patch moves them to the location where they are used.

llvm-svn: 307949
2017-07-13 20:30:35 +00:00
Reid Kleckner 3b8acb2c5a [COFF] Bounds check relocations
Summary:
This would have caught the invalid object file I used in my test case in
r307726. The OOB was only caught by ASan later, which is slow and
doesn't work on some platforms. LLD should do some basic input
validation itself. This check isn't perfect, so relocations can reach
OOB by up to seven bytes, but it's better than what we had and probably
cheap.

Reviewers: ruiu

Subscribers: llvm-commits

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

llvm-svn: 307948
2017-07-13 20:29:59 +00:00
Reid Kleckner 6597c28d76 [PDB] Fix type server handling for archives
Summary:
This fixes type indices for SDK or CRT static archives. Previously we'd
try to look next to the archive object file path, which would not exist
on the local machine.

Also error out if we can't resolve a type server record. Hypothetically
we can recover from this error by discarding debug info for this object,
but that is not yet implemented.

Reviewers: ruiu, amccarth

Subscribers: aprantl, hiraditya, llvm-commits

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

llvm-svn: 307946
2017-07-13 20:12:23 +00:00
Rafael Espindola 300b38678c Refactor gdb index creation.
I have a patch to let DwarfContext defer to lld for getting section
contents and relocations.

That is a pretty big performance improvement.

This is just a refactoring to make that easier to do.

This change makes the *creation* of gdb index a dedicated step and
makes that templated. That is so that we can uses Elf_Rel in the code.

llvm-svn: 307867
2017-07-12 23:56:53 +00:00
Reid Kleckner 03b5baf480 Re-land "[PDB] Use a more appropriate message for a fatal error"
This re-commits r307726 with valid line table relocations.

llvm-svn: 307829
2017-07-12 18:49:43 +00:00
Adrian McCarthy a6c21919d0 Temporary fix to green up the build bots on behalf of zturner who's on vacation.
llvm-svn: 307823
2017-07-12 18:10:02 +00:00
Rafael Espindola d3fc0c91e3 Bring back InVersionScript.
We were producing bogus warnings without it.

llvm-svn: 307820
2017-07-12 17:49:17 +00:00
George Rimar 8c804d9746 [ELF] - Allow moving location counter backward in some cases.
Patch removes restriction about moving location counter
backwards outside of output sections declarations.

That may be useful for some apps relying on such scripts, 
known example is linux kernel.

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

llvm-svn: 307794
2017-07-12 14:50:25 +00:00
George Rimar 3e8a461bdf [ELF] - Give a symbol version extracted from name a priority over version set by script.
This fixes PR33712.

Imagine following script and code:

VER1 { global: foo; local: *; };
VER2 { global: foo; };

.global bar
bar:
.symver bar, foo@VER1

.global zed
zed:
.symver zed, foo@@VER2

We add foo@@VER2 as foo to symbol table, because have to resolve references to
foo for default symbols.
Later we are trying to assign symbol versions from script. For that we are searching for 'foo'
again. Here it is placed under VER1 and VER2 at the same time, we find it twice and trying to
set version again both times, hence LLD shows a warning.
Though sample code is correct: we have 2 different versions of foo.

Patch gives a symbol version extracted from name a priority over version set by script.

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

llvm-svn: 307792
2017-07-12 13:54:42 +00:00
George Rimar d92e1286ed [ELF] - Fix handling of weak symbols from static library when using version script.
When version script was used, binding opf undefined weak symbols sometimes
was calculated as STB_LOCAL, making them non-preemtible what
broke correct relocations handling logic for them.

Fixes PR33738.

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

llvm-svn: 307767
2017-07-12 11:09:46 +00:00
Vitaly Buka e970c2b706 Revert "[PDB] Use a more appropriate message for a fatal error"
Revert "[PDB] Tweak bad type index error handling"

check-lld with asan detects use-after-poison.

This reverts commits r307733 and r307726.

llvm-svn: 307752
2017-07-12 04:34:17 +00:00
Rui Ueyama 106179a257 Remove redundant newline.
llvm-svn: 307750
2017-07-12 01:43:01 +00:00
Reid Kleckner 992263c14e [PDB] Use a more appropriate message for a fatal error
llvm-svn: 307733
2017-07-11 23:44:51 +00:00
Rafael Espindola a69df6f843 Update now that the llvm-mc bug is fixed.
llvm-svn: 307728
2017-07-11 22:56:51 +00:00
Reid Kleckner 2bf9ab2d62 [PDB] Tweak bad type index error handling
Translate invalid type indices to a sentinel value instead of skipping
the record. Skipping records isn't a good recovery method, because we
can skip a scope open or close record, which will confuse the scope
management code.

We currently have lots of invalid type indices on Microsoft-provided
standard libraries, because the LF_TYPESERVER2 records contain absolute
paths that are only valid on their build servers. Our type server
handlers need to look at other things (GUIDs) to find these type server
PDBs.

llvm-svn: 307726
2017-07-11 22:37:50 +00:00
Rui Ueyama 9a1898768f Remove unnecessary local variable.
llvm-svn: 307703
2017-07-11 20:33:04 +00:00
Rafael Espindola da8a47ab01 Delete redundant InVersionScript field.
Thanks to Rui for the suggestion.

llvm-svn: 307690
2017-07-11 18:59:45 +00:00
George Rimar 4a9cfc8267 [ELF] - Fix functionality treating IFunc definitions in DSOs as functions.
It was intially implemented in D19517 but then broken.
Patch fixes PR33707, testcase is based on PR's case.

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

llvm-svn: 307652
2017-07-11 11:40:59 +00:00
Peter Smith c1ace40bf9 [ELF] Add comment to explain LinkerScript::CurAddressState [NFC]
r307367 via D34345 split out the temporary address state used within
processCommands() and assignAddresses(). Due to the way that getSymbolValue
is used by the ScriptParser there is no way of giving the current
OutputSection to getSymbolValue() without somehow accessing the created
addressState. The suggestion was that by making a pointer that would go out
of scope we would find out by ASAN/MSAN or a crash if someone had misused
currentAddressState.

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

llvm-svn: 307637
2017-07-11 09:28:27 +00:00
Martin Storsjo 2779165d8c [COFF] Add initial support for some ARM64 relocations and import thunks
This is enough to link a working hello world executable, with
a call to an imported function, a string constant passed to
the imported function, and loads from a global variable.

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

llvm-svn: 307629
2017-07-11 07:22:44 +00:00
Zachary Turner 7eaf1d96ad [lld/pdb] Create an empty public symbol record stream.
This is part of the continuing effort to increase parity between
LLD and MSVC PDBs.  link still doesn't like our PDBs, so the most
obvious thing to check was whether adding an empty publics stream
would get it to do something else.  It still fails in the same way
but at least this removes one more variable from the equation.
The next logical step would be to try creating an empty globals
stream.

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

llvm-svn: 307598
2017-07-10 22:40:20 +00:00
Zachary Turner 77f23b9c21 Fix pdb-linker-module test on linux.
lld-link is apparently a symlink to lld.  Our pdb writing code
uses llvm::sys::fs::getMainExecutable() and writes that value
into the PDB, which will resolve symlinks etc.  But what we
really want is the exact value of argv[0], which matches what
the MS linker does.  Fix this by just writing argv[0] instead
of calling getMainExecutable.

llvm-svn: 307592
2017-07-10 21:09:11 +00:00
Zachary Turner 6708e0b45e [lld/pdb] Add some basic linker module symbols.
Differential Revision: https://reviews.llvm.org/D35152

llvm-svn: 307590
2017-07-10 21:01:37 +00:00
Zachary Turner a9d944fd6f Resubmit "Add pdb-diff test."
This was originally reverted because of two issues.
  1) Printing ANSI color escape codes even when outputting to
     a file
  2) Module name comparisons were failing when comparing a PDB
     generated on one machine to a PDB generated on another
     machine.

I attempted to fix #2 by adding command line options which let
you specify prefixes to strip from the beginning of embedded
paths, which effectively lets us specify a path to "base" each
PDB from and only compare the parts under the base.  But this is
tricky because PDB paths always use Windows path syntax, even
when they are created on non-Windows hosts.  A problem still
existed when constructing the prefix to strip, where we were
accidentally using a host-specific path separator instead of
a Windows path separator.

This resubmission fixes the issue on Linux (and I have verified
that the test now passes on Linux).

llvm-svn: 307571
2017-07-10 19:16:49 +00:00
Zachary Turner ba3836bc78 Revert "Build fixes for pdb-diff test."
This reverts commit 180af3fdbdb17ec35b45ec1f925fd743b28d37e1.

This is still breaking due to linux-specific path differences.

llvm-svn: 307559
2017-07-10 17:32:47 +00:00
Zachary Turner 6da7a3058e Fix pdb-diff test.
A test was checked in on Friday that worked by checking in an
object file and PDB generated locally by MSVC, and then having
the test run lld-link on the object file and diffing LLD's PDB
against the checked in PDB.

This failed because part of the diffing algorithm involves
determining if two modules are the same, and if so drilling into
the module and diffing individual fields of the module.  The
only thing we can use to make this determination though is the
"name" of the module, which is a path to where the module (obj
file) was read from on the machine where it was linked.  This
fails for obvious reasons when comparing a PDB generated on one
machine to a PDB on another machine.

The fix employed here is to add two command line options to the
diff subcommand, which allow the user to specify a "binary root
path".  The bin root path, if specified, is stripped from the
beginning of any embedded PDB paths.  The test is updated to
specify the user's local test output directory for the left
PDB, and is hardcoded to the location where the original PDB
was created for the right PDB.  This way all the equivalence
comparisons should succeed.

llvm-svn: 307555
2017-07-10 16:52:15 +00:00
Eric Beckmann c8dba240b1 Revert "Revert "Revert "Revert "Switch external cvtres.exe for llvm's own resource library.""""
This reverts commit 147f45ff24456aea59575fa4ac16c8fa554df46a.

Revert "Revert "Revert "Revert "Replace trivial use of external rc.exe by writing our own .res file.""""

This reverts commit 61a90a67ed54a1f0dfeab457b65abffa129569e4.

The patches were intially reverted because they were causing a failure
on CrWinClangLLD.  Unfortunately, this was done haphazardly and didn't
compile, so the revert was reverted again quickly to fix this.  One that
was done, the revert of the revert was itself reverted.  This allowed me
to finally fix the actual bug in r307452.  This patch re-enables the
code path that had originally been causing the bug, now that it (should)
be fixed.

llvm-svn: 307460
2017-07-08 03:06:10 +00:00
Zachary Turner 41f6a453e4 Delete the pdb diff test.
This is failing on Linux for unknown reasons, so I need to
get the bots green while I investigate.

llvm-svn: 307459
2017-07-08 02:54:19 +00:00
Eric Beckmann 7c865f004b Add name offset flags, for parity with cvtres.exe.
Summary:
The original cvtres.exe sets the high bit when an identifier offset
points to a string.  Even though this is not mentioned in the spec, and
in fact does not seem to cause errors with most cases, for some reason
this causes a failure in Chromium where the new resource file is not
verified as a new version.  This patch sets this high bit flag, and also
adds a test case to check that the output of our library is always
identical to original cvtres.

Reviewers: zturner, ruiu

Subscribers: llvm-commits, hiraditya

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

llvm-svn: 307452
2017-07-07 23:23:53 +00:00
Zachary Turner 3a11fdf8ce [PDB] More changes to bring lld PDBs to parity with MSVC.
1) Don't write a /src/headerblock stream.  This appears to be
   written conditionally by MSVC, but it's not clear what the
   condition is.  For now, just remove it since we dont' know
   what it is anyway and the particular pdb we've checked in
   for the test doesn't have one.
2) Write a valid timestamp for the PDB file signature.  This
   leads to non-reproducible builds, but it matches the default
   behavior of link, so it should be out default as well.  If
   we need reproducibility, we should add a separate command
   line option for it that is off by default.
3) Write an empty FPO stream.  MSVC seems to always write an
   FPO stream.  This change makes the stream directory match
   up, although we still need to make the contents of the FPO
   stream match.

llvm-svn: 307436
2017-07-07 20:25:39 +00:00
Zachary Turner fe71c546e7 [llvm-pdbutil] Fix build.
Some platforms require an explicit specialization of std::hash
for PdbRaw_FeaturesSig.  Also a test involving case sensitivity
needed to be fixed.  For now that particular check just accepts
any path even if they're completely different.  Long term we
should output paths in the correct case to match MSVC.

llvm-svn: 307426
2017-07-07 19:00:06 +00:00
Zachary Turner 448dea419c Use windows path syntax when writing PDB module name.
Without this we would just append whatever the user
wrote on the command line, so if we're in C:\foo
and we run lld-link bar/baz.obj, we would write
C:\foo\bar/baz.obj in various places in the PDB.
MSVC linker does not do this, so we shouldn't either.
This fixes some differences in the diff test, so we
update the test as well.

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

llvm-svn: 307423
2017-07-07 18:46:14 +00:00