Commit Graph

1106 Commits

Author SHA1 Message Date
Martin Storsjo 49037d2b3c [COFF] Fix a longstanding typo in a variable name. NFC.
llvm-svn: 346846
2018-11-14 10:26:47 +00:00
Reid Kleckner 944843c880 [PDB] Simplify symbol handling code, NFC
- Make mergeSymbolRecords a method of PDBLinker to reduce the number of
parameters it needs.

- Remove a stale FIXME comment about error handling. We already drop
unknown symbol records, log them, and continue.

- Update a comment about why we're copying the symbol record. We do it
to realign the record. We can already mutate the symbol record memory,
it's memory allocated by relocateDebugChunk.

- Avoid the extra `CVSymbol NewSym` variable. We can mutate Sym in
place, which is best, since we're mutating the underlying record anyway.

llvm-svn: 346817
2018-11-13 23:44:39 +00:00
Reid Kleckner 551acf03dc [COFF] Simplify relocation to discarded section diagnostic code, NFC
Move it out of the loop that applies relocations for readability.

llvm-svn: 346777
2018-11-13 18:30:31 +00:00
Reid Kleckner 9ba2c72deb [PDB] Simplify some ghash code, NFC
Instead of calling the same function twice with different parameters,
make the parameters depend on the condition.

llvm-svn: 346578
2018-11-10 01:36:02 +00:00
Reid Kleckner f3dc9649ce Fix -Wextra-qualification warning
llvm-svn: 346431
2018-11-08 18:53:56 +00:00
Reid Kleckner 7a44fe956a [COFF] Improve relocation against discarded section error
Summary:
Reuse the "referenced by" note diagnostic code that we already use for
undefined symbols. In my case, it turned this:
  lld-link: error: relocation against symbol in discarded section: .text
  lld-link: error: relocation against symbol in discarded section: .text
  ...

Into this:
  lld-link: error: relocation against symbol in discarded section: .text
  >>> referenced by libANGLE.lib(CompilerGL.obj):(.SCOVP$M)
  >>> referenced by libANGLE.lib(CompilerGL.obj):(.SCOVP$M)
  ...

  lld-link: error: relocation against symbol in discarded section: .text
  >>> referenced by obj/third_party/angle/libGLESv2/entry_points_egl_ext.obj:(.SCOVP$M)
  >>> referenced by obj/third_party/angle/libGLESv2/entry_points_egl_ext.obj:(.SCOVP$M)
  ...

I think the new output is more useful.

Reviewers: ruiu, pcc

Subscribers: llvm-commits

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

llvm-svn: 346427
2018-11-08 18:38:17 +00:00
Alexandre Ganea 4b2957243b [LLD] Fix Microsoft precompiled headers cross-compile on Linux
Differential revision: https://reviews.llvm.org/D54122

llvm-svn: 346403
2018-11-08 14:42:37 +00:00
Alexandre Ganea 8a0eb44398 Fix build breakerage on GCC 5.4:
/home/buildslave/slave_as-bldslv8/lld-perf-testsuite/llvm/tools/lld/COFF/PDB.cpp:365:51: error: 'auto' not allowed in lambda parameter
  auto DbgIt = find_if(File->getDebugChunks(), [](auto &C) {
                                                  ^~~~

http://lab.llvm.org:8011/builders/lld-perf-testsuite/builds/8717/steps/build-bin%2Flld/logs/stdio

llvm-svn: 346160
2018-11-05 19:43:34 +00:00
Alexandre Ganea 71c43ceaf8 [COFF][LLD] Add link support for Microsoft precompiled headers OBJs
This change allows for link-time merging of debugging information from
Microsoft precompiled types OBJs compiled with cl.exe /Z7 /Yc and /Yu.

This fixes llvm.org/PR34278

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

llvm-svn: 346154
2018-11-05 19:20:47 +00:00
Fangrui Song ccfc8415c2 Set MAttrs in LTO mode
Summary: Without this patch, MAttrs are not set.

Patch by Yin Ma

Reviewers: espindola, MaskRay, ruiu, pcc

Reviewed By: MaskRay, pcc

Subscribers: pcc, emaste, sbc100, inglorion, arichardson, aheejin, steven_wu, llvm-commits

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

llvm-svn: 345884
2018-11-01 20:02:49 +00:00
Martin Storsjo 865cb5604c [MinGW] Support for multiarch runtimes layout
Patch by Peiyuan Song!

llvm-svn: 345117
2018-10-24 07:42:10 +00:00
Martin Storsjo 28212dfce6 [COFF] Fix error handling on duplicates for import library symbols
Normally one wouldn't run into that case, but it is possible with
a little creative ordering of special libraries.

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

llvm-svn: 344776
2018-10-19 06:39:36 +00:00
Zachary Turner 5bba1cafbe Better support for POSIX paths in PDBs.
This a resubmission of a patch which was previously reverted
due to breaking several lld tests.  The issues causing those
failures have been fixed, so the patch is now resubmitted.

---Original Commit Message---

While it doesn't make a *ton* of sense for POSIX paths to be
in PDBs, it's possible to occur in real scenarios involving
cross compilation.

The tools need to be able to handle this, because certain types
of debugging scenarios are possible without a running process
and so don't necessarily require you to be on a Windows system.
These include post-mortem debugging and binary forensics (e.g.
using a debugger to disassemble functions and examine symbols
without running the process).

There's changes in clang, LLD, and lldb in this patch.  After
this the cross-platform disassembly and source-list tests pass
on Linux.

Furthermore, the behavior of LLD can now be summarized by a much
simpler rule than before: Unless you specify /pdbsourcepath and
/pdbaltpath, the PDB ends up with paths that are valid within
the context of the machine that the link is performed on.

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

llvm-svn: 344377
2018-10-12 17:26:19 +00:00
Zachary Turner e8a6c3eb96 Revert SymbolFileNativePDB plugin.
This was originally causing some test failures on non-Windows
platforms, which required fixes in the compiler and linker.  After
those fixes, however, other tests started failing.  Reverting
temporarily until I can address everything.

llvm-svn: 344279
2018-10-11 18:45:44 +00:00
Zachary Turner e502f8b315 Better support for POSIX paths in PDBs.
While it doesn't make a *ton* of sense for POSIX paths to be
in PDBs, it's possible to occur in real scenarios involving
cross compilation.

The tools need to be able to handle this, because certain types
of debugging scenarios are possible without a running process
and so don't necessarily require you to be on a Windows system.
These include post-mortem debugging and binary forensics (e.g.
using a debugger to disassemble functions and examine symbols
without running the process).

There's changes in clang, LLD, and lldb in this patch.  After
this the cross-platform disassembly and source-list tests pass
on Linux.

Furthermore, the behavior of LLD can now be summarized by a much
simpler rule than before: Unless you specify /pdbsourcepath and
/pdbaltpath, the PDB ends up with paths that are valid within
the context of the machine that the link is performed on.

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

llvm-svn: 344269
2018-10-11 18:01:55 +00:00
Martin Storsjo 8cc0f71261 [COFF] Add and use a Wordsize field in Config. NFCI.
Differential Revision: https://reviews.llvm.org/D53143

llvm-svn: 344265
2018-10-11 17:45:58 +00:00
Martin Storsjo 21eb363302 [COFF] Set proper pointer size alignment for LocalImportChunk
When these are accessed with load/store instructions on ARM64,
it becomes strictly necessary to have them properly aligned.

This fixes PR39228.

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

llvm-svn: 344264
2018-10-11 17:45:51 +00:00
Fangrui Song a535e0543f Eliminate dependency to formatv(). NFC.
llvm-svn: 344212
2018-10-11 00:58:00 +00:00
Martin Storsjo 33d43ff851 [COFF] Look for libfoo.a if foo.lib is specified, for MinGW
This allows using #pragma comment(lib, "foo") in MinGW built code,
if built with -fms-extensions. (This works for system libraries and
static libraries only, as it doesn't try to look for .dll.a. As
ld.bfd doesn't support embedded defaultlib directives, this isn't
in widespread use among mingw users.)

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

llvm-svn: 344124
2018-10-10 09:00:10 +00:00
Fangrui Song 2043a58abe Adapt OptTable::PrintHelp change in D51009
Summary: Before, OptTable::PrintHelp append "[options] <inputs>" to its parameter `Help`. It is more flexible to change its semantic to `Usage` and let user customize the usage line.

Reviewers: rupprecht, ruiu, espindola

Reviewed By: rupprecht

Subscribers: emaste, sbc100, arichardson, aheejin, llvm-commits

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

llvm-svn: 344099
2018-10-10 00:15:36 +00:00
Nico Weber 4764bb2cb1 lld-link: Use /pdbsourcepath: for more places when present.
/pdbsourcepath: was added in https://reviews.llvm.org/D48882 to make it
possible to have relative paths in the debug info that clang-cl writes.
lld-link then makes the paths absolute at link time, which debuggers require.
This way, clang-cl's output is independent of the absolute path of the build
directory, which is useful for cacheability in distcc-like systems.

This patch extends /pdbsourcepath: (if passed) to also be used for:

1. The "cwd" stored in the env block in the pdb is /pdbsourcepath: if present
2. The "exe" stored in the env block in the pdb is made absolute relative
   to /pdbsourcepath: instead of the cwd
3. The "pdb" stored in the env block in the pdb is made absolute relative
   to /pdbsourcepath: instead of the cwd
4. For making absolute paths to .obj files referenced from the pdb

/pdbsourcepath: is now useful in three scenarios (the first one already working
before this change):

1. When building with full debug info, passing the real build dir to
   /pdbsourcepath: allows having clang-cl's output to be independent
   of the build directory path. This patch effectively doesn't change
   behavior for this use case (assuming the cwd is the build dir).

2. When building without compile-time debug info but linking with /debug,
   a fake fixed /pdbsourcepath: can be passed to get symbolized stacks
   while making the pdb and exe independent of the current build dir.
   For this two work, lld-link needs to be invoked with relative paths for
   the lld-link invocation itself (for "exe"), for the pdb output name, the exe
   output name (for "pdb"), and the obj input files, and no absolute path
   must appear on the link command (for "cmd" in the pdb's env block).
   Since no full debug info is present, it doesn't matter that the absolute
   path doesn't exist on disk -- we only get symbols in stacks.

3. When building production builds with full debug info that don't have
   local changes, and that get source indexed and their pdbs get uploaded
   to a symbol server. /pdbsourcepath: again makes the build output independent
   of the current directory, and the fixed path passed to /pdbsourcepath: can
   be given the source indexing transform so that it gets mapped to a
   repository path. This has the same requirements as 2.

This patch also makes it possible to create PDB files containing Windows-style
absolute paths when cross-compiling on a POSIX system.

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

llvm-svn: 344061
2018-10-09 17:52:25 +00:00
Nico Weber 9d7524160a lld-link: Implement support for %_PDB% and %_EXT% for /pdbaltpath:.
Warn that references to regular env vars are ignored.

Fixes PR38940.

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

llvm-svn: 344003
2018-10-08 23:06:05 +00:00
Martin Storsjo 08ab568aaa [COFF] Do MinGW specific entry/subsystem inference
ld.bfd doesn't do any inference of subsystem; unless the windows
subsystem is specified, the console subsystem is used.

For the console subsystem, the entry point is called mainCRTStartup,
regardless of whether the the user code entry point is main or wmain.
The same goes for the windows subsystem, where the entry point always
is WinMainCRTStartup, for both WinMain and wWinMain in user code.

One detail that we don't emulate, is that if the inferred entry point
is undefined, ld.bfd silently just sets the entry point to the start
of the image. And if an explicit entry point is set, but it is
undefined, the link still succeeds but the linker warns about the
entry point not being found.

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

llvm-svn: 343879
2018-10-05 19:43:24 +00:00
Martin Storsjo cab6dafc04 [COFF] Cope with GCC produced weak aliases referring to comdat functions
For certain cases of inline functions written to comdat sections,
GCC 5.x produces a weak symbol in addition, which would end up
undefined in some cases.

This no longer seems to happen with GCC 6.x or newer though.

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

llvm-svn: 343877
2018-10-05 19:43:16 +00:00
Alexandre Ganea 149de8de19 [LLD][COFF] Fix ordering of CRT global initializers in COMDAT sections
(patch by Benoit Rousseau)

This patch fixes a bug where the global variable initializers were sometimes not invoked in the correct order when it involved a C++ template instantiation.

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

llvm-svn: 343847
2018-10-05 12:56:46 +00:00
Martin Storsjo 2657200274 [COFF] Cope with weak aliases produced by GNU tools
When GNU tools create a weak alias, they produce a strong symbol
named .weak.<weaksymbol>.<relatedstrongsymbol>.

GNU ld allows many such weak alternatives for the same weak symbol, and
the linker picks the first one encountered.

This can't be reproduced by assembling from .s files, since llvm-mc
produces symbols named .weak.<weaksymbol>.default in these cases.

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

llvm-svn: 343704
2018-10-03 18:31:53 +00:00
Nico Weber d377826277 lld-link: Several tweaks to default entry point selection.
Three related changes:

1. link.exe uses the presence of main and wmain to decide if it should call
   mainCRTStartup or wmainCRTStartup, even if /nodefaultlib is passed. For
   compatibility, remove FindMain logic.

2. Default to the non-wide entrypoint if main is not found. This has two effects:

2a. In normal links, lld-link now prints

        lld-link: error: undefined symbol: _main
        >>> referenced by f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:78
        >>>               libcmt.lib(exe_main.obj):("int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ))
        >>> referenced by f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283
        >>>               libcmt.lib(exe_main.obj):("int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ))

    instead of

        lld-link: error: entry point must be defined

    This is arguably a better error message, since it now mentions that _main is
    missing. (This matches link.exe's diagnostic in this case.)

2b. With /nodefautlib, we now default to mainCRTStartup if no main() is
    present, again matching link.exe. This makes r337407 obsolete.

This means if you have a cc file containing both mainCRTStartup and
wmainCRTStartup and you pass /nodefaultlib /subsystem:console, lld-link will
now call mainCRTStartup, matching link.exe

3. Print a warning if both main and wmain are present, similar to link.exe's
   LNK4067.

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

llvm-svn: 343698
2018-10-03 17:01:39 +00:00
Martin Storsjo 0f8f0d6d1d [COFF] In MinGW mode, ignore relocations against a discarded section
When GCC produces a jump table as part of a comdat function, the
jump table itself is produced as plain non-comdat rdata section. When
linked with ld.bfd, all of those rdata sections are kept, with
relocations unchanged in the sections that refer to discarded comdat
sections.

This has been observed with at least GCC 5.x and 7.x.

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

llvm-svn: 343422
2018-09-30 18:31:03 +00:00
Alexandre Ganea 91def5cc6a [LLD][COFF] Fix pdb loading when the path points to a removable device
Differential Revision: https://reviews.llvm.org/D52666

llvm-svn: 343366
2018-09-28 21:53:40 +00:00
Martin Storsjo 32e651e169 [COFF] Don't do autoexport of symbols from GNU import libraries
This involves adding more generic list of symbol suffixes/prefixes
to ignore for autoexport; adding a few other entries to these lists
as well from the corresponding lists in binutils.

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

llvm-svn: 343070
2018-09-26 06:13:47 +00:00
Martin Storsjo 2bfa125fd6 [COFF] Allow automatic dllimport from gnu import libraries
Don't assume that the IAT chunk will be a DefinedImportData, it can
just as well be a DefinedRegular for gnu import libraries.

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

llvm-svn: 343069
2018-09-26 06:13:39 +00:00
Martin Storsjo 57ddec0dd1 [COFF] Add support for creating range extension thunks for ARM
This is a feature that MS link.exe lacks; it currently errors out on
such relocations, just like lld did before.

This allows linking clang.exe for ARM - practically, any image over
16 MB will likely run into the issue.

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

llvm-svn: 342962
2018-09-25 10:59:29 +00:00
Will Wilson 3cb18346d7 [lld-link] Generalize handling of /debug and /debug:{none,full,fastlink,ghash,symtab}
Implement final argument precedence if multiple /debug arguments are passed on the command-line to match expected link.exe behavior.
Support /debug:none and emit warning for /debug:fastlink with automatic fallback to /debug:full.
Emit error if last /debug:option is unknown.
Emit warning if last /debugtype:option is unknown.

https://reviews.llvm.org/D50404

llvm-svn: 342894
2018-09-24 15:28:03 +00:00
Martin Storsjo 5f6d527f09 [COFF] Support linking to import libraries from GNU binutils
GNU binutils import libraries aren't the same kind of short import
libraries as link.exe and LLD produce, but are a plain static library
containing .idata section chunks. MSVC link.exe can successfully link
to them.

In order for imports from GNU import libraries to mix properly with the
normal import chunks, the chunks from the existing mechanism needs to
be added into named sections like .idata$2.

These GNU import libraries consist of one header object, a number of
object files, one for each imported function/variable, and one trailer.
Within the import libraries, the object files are ordered alphabetically
in this order. The chunks stemming from these libraries have to be
grouped by what library they originate from and sorted, to make sure
the section chunks for headers and trailers for the lists are ordered
as intended. This is done on all sections named .idata$*, before adding
the synthesized chunks to them.

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

llvm-svn: 342777
2018-09-21 22:01:06 +00:00
Martin Storsjo 5fefad793c [COFF] Fix the name mangling of a function in the autoexport exclusion list
The __NULL_IMPORT_DESCRIPTOR symbol has two leading underscores on
architectures other than i386 as well; it is not a mangled symbol name.

llvm-svn: 342448
2018-09-18 07:22:05 +00:00
Martin Storsjo 32d21d6a2d [COFF] Add support for delay loading DLLs for ARM64
Differential Revision: https://reviews.llvm.org/D52190

llvm-svn: 342447
2018-09-18 07:22:01 +00:00
Martin Storsjo cb9570eb22 [COFF] Fix a block with incorrect indentation. NFC.
llvm-svn: 342446
2018-09-18 07:21:55 +00:00
Nico Weber 0bd2d304e6 lld-link: Set PDB GUID to hash of PDB contents instead of to a random byte sequence.
Previously, lld-link would use a random byte sequence as the PDB GUID. Instead,
use a hash of the PDB file contents.

To not disturb llvm-pdbutil pdb2yaml, the hash generation is an opt-in feature
on InfoStreamBuilder and ldb/COFF/PDB.cpp always sets it.

Since writing the PDB computes this ID which also goes in the exe, the PDB
writing code now must be called before writeBuildId(). writeBuildId() for that
reason is no longer included in the "Code Layout" timer.

Since the PDB GUID is now a function of the PDB contents, the PDB Age is always
set to 1. There was a long comment above loadExistingBuildId (now gone) about
how not changing the GUID and only incrementing the age was important, but
according to the discussion in PR35914 that comment was incorrect.

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

llvm-svn: 342334
2018-09-15 18:37:22 +00:00
Nico Weber da15acbd68 lld-link: print demangled symbol names for "undefined symbol" diagnostics
For this, add a few toString() calls when printing the "undefined symbol"
diagnostics; toString() already does demangling on Windows hosts.

Also make lld::demangleMSVC() (called by toString(Symbol*)) call LLVM's
microsoftDemangle() instead of UnDecorateSymbolName() so that it works on
non-Windows hosts – this makes both updating tests easier and provides a better
user experience for people doing cross-links.

This doesn't yet do the right thing for symbols starting with __imp_, but that
can be improved in a follow-up.

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

llvm-svn: 342332
2018-09-15 18:27:09 +00:00
Martin Storsjo 7a41693898 [COFF] Provide __CTOR_LIST__ and __DTOR_LIST__ symbols for MinGW
MinGW uses these kind of list terminator symbols for traversing
the constructor/destructor lists. These list terminators are
actual pointers entries in the lists, with the values 0 and
(uintptr_t)-1 (instead of just symbols pointing to the start/end
of the list).

(This mechanism exists in both the mingw-w64 crt startup code and
in libgcc; normally the mingw-w64 one is used, but a DLL build of
libgcc uses the libgcc one. Therefore it's not trivial to change
the mechanism without lots of cross-project synchronization and
potentially invalidating some combinations of old/new versions
of them.)

When mingw-w64 has been used with lld so far, the CRT startup object
files have so far provided these symbols, ending up with different,
incompatible builds of the CRT startup object files depending on
whether binutils or lld are going to be used.

In order to avoid the need of different configuration of the CRT startup
object files depending on what linker to be used, provide these symbols
in lld instead. (Mingw-w64 checks at build time whether the linker
provides these symbols or not.) This unifies this particular detail
between the two linkers.

This does disallow the use of the very latest lld with older versions
of mingw-w64 (the configure check for the list was added recently;
earlier it simply checked whether the CRT was built with gcc or clang),
and requires rebuilding the mingw-w64 CRT. But the number of users of
lld+mingw still is low enough that such a change should be tolerable,
and unifies this aspect of the toolchains, easing interoperability
between the toolchains for the future.

The actual test for this feature is added in ctors_dtors_priority.s,
but a number of other tests that checked absolute output addresses
are updated.

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

llvm-svn: 342294
2018-09-14 22:26:59 +00:00
Martin Storsjo 4c201a8ba5 [COFF] Avoid copying of chunk vectors. NFC.
When declaring the pair variable as "auto Pair : Map", it is
effectively declared as
std::pair<std::pair<StringRef, uint32_t>, std::vector<Chunk *>>.
This effectively does a full, shallow copy of the Chunk vector,
just to be thrown away after each iteration.

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

llvm-svn: 342205
2018-09-14 06:08:51 +00:00
Rui Ueyama 11ca38f421 COFF: Add support for /force:multiple option
Patch by Thomas Roughton.

This patch adds support for linking with multiple definitions to LLD's
COFF driver, in line with link.exe's /force:multiple option.

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

llvm-svn: 342191
2018-09-13 22:05:10 +00:00
Nico Weber f1828e3240 lld-link: For nonexisting inputs, omit follow-on diagnostics
For lld-link missing.obj, lld-link currently prints:

  lld-link: error: could not open foo.obj: No such file or directory
  lld-link: warning: /machine is not specified. x64 is assumed
  lld-link: error: subsystem must be defined

The 2nd and 3rd diagnostics are consequences of the input not existing and are
not interesting. If input files are missing, the best thing we can do is point
that out and then return.

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

llvm-svn: 342158
2018-09-13 18:13:21 +00:00
Zachary Turner a1f85f8bdd [PDB] Emit old fpo data to the PDB file.
r342003 added support for emitting FPO data from the
DEBUG_S_FRAMEDATA subsection of the .debug$S section to the PDB
file.  However, that is not the end of the story.  FPO can end
up in two different destinations in a PDB, each corresponding to
a different FPO data source.

The case handled by r342003 involves copying data from the
DEBUG_S_FRAMEDATA subsection of the .debug$S section to the
"New FPO" stream in the PDB, which is then referred to by the
DBI stream.  The case handled by this patch involves copying
records from the .debug$F section of an object file to the "FPO"
stream (or perhaps more aptly, the "Old FPO" stream) in the PDB
file, which is also referred to by the DBI stream.

The formats are largely similar, and the difference is mostly
only visible in masm generated object files, such as some of the
low-level CRT object files like memcpy.  MASM doesn't appear to
support writing the DEBUG_S_FRAMEDATA subsection, and instead
just writes these records to the .debug$F section.

Although clang-cl does not emit a .debug$F section ever, lld still
needs to support it so we have good debugging for CRT functions.

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

llvm-svn: 342080
2018-09-12 21:02:01 +00:00
Zachary Turner 42e7cc1b0f [PDB] Write FPO Data to the PDB.
llvm-svn: 342003
2018-09-11 22:35:01 +00:00
Alexandre Ganea 472e9b0ab2 Buildfix for r341825
llvm-svn: 341827
2018-09-10 14:07:11 +00:00
Alexandre Ganea d93b07f0b0 [LLD][COFF] Cleanup error messages / add more coverage tests
- Log the reason for a PDB or precompiled-OBJ load failure
- Properly handle out-of-date PDB or precompiled-OBJ signature by displaying a corresponding error
- Slightly change behavior on PDB failure: any subsequent load attempt from another OBJ would result in the same error message being logged
- Slightly change behavior on PDB failure: retry with filename only if previous error was ENOENT ("no such file or directory")
- Tests: a. for native PDB errors; b. cover all the cases above

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

llvm-svn: 341825
2018-09-10 13:51:21 +00:00
Nico Weber cc08366035 Remove an effectively unused local variable.
llvm-svn: 341823
2018-09-10 13:20:16 +00:00
Bob Haarman 2ba4d231d1 [COFF] don't mark lazy symbols as used in regular objects
Summary:
r338767 updated the COFF and wasm linker SymbolTable code to be
strutured more like the ELF linker's. That inadvertedly changed the
behavior of the COFF linker so that lazy symbols would be marked as
used in regular objects. This change adds an overload of the insert()
function, similar to the ELF linker, which does not perform that
marking.

Reviewers: ruiu, rnk, hans

Subscribers: aheejin, sunfish, llvm-commits

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

llvm-svn: 341585
2018-09-06 20:23:56 +00:00
Nico Weber 13b55bbc2f lld-link: Write an empty "repro" debug directory entry if /Brepro is passed
If the coff timestamp is set to a hash, like lld-link does if /Brepro is
passed, the coff spec suggests that a IMAGE_DEBUG_TYPE_REPRO entry is in the
debug directory. This lets lld-link write such a section.
Fixes PR38429, see bug for details.

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

llvm-svn: 341486
2018-09-05 18:02:43 +00:00