Commit Graph

4624 Commits

Author SHA1 Message Date
George Rimar c2c7d15486 [ELF] - Fix mistypes in test cases.
llvm-svn: 337528
2018-07-20 08:07:33 +00:00
Martin Storsjo a55fc71614 [COFF] Write the debug directory and build id to a separate section for MinGW
For dwarf debug info, an executable normally either contains the debug
info, or it is stripped out. To reduce the storage needed (slightly)
for the debug info kept separately from the released, stripped binaries,
one can choose to only copy the debug data from the original executable
(essentially the reverse of the strip operation), producing a file with
only debug info.

When copying the debug data from an executable with GNU objcopy,
the build id and debug directory need to reside in a separate section,
as this will be kept while the rest of the .rdata section is removed.

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

llvm-svn: 337526
2018-07-20 05:44:34 +00:00
Sid Manning 690b544f41 [ELF][HEXAGON] Add support for R_HEX_B15_PCREL
Add support and update the testcase.

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

llvm-svn: 337494
2018-07-19 20:27:43 +00:00
Sid Manning bdd71f358d Add support for R_HEX_B32_PCREL_X, R_HEX_B22_PCREL_X relocations
A couple more basic relocations plus testcase.

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

llvm-svn: 337484
2018-07-19 19:10:56 +00:00
George Rimar ad760e3ec6 [ELF] - One more test case for .eh_frame_hdr.
This is to test the following error message:
https://github.com/llvm-mirror/lld/blob/master/ELF/SyntheticSections.cpp#L544

Which occurs when LLD meets unsupported address encoding when scans
.eh_frame to build .eh_frame_hdr section.

llvm-svn: 337458
2018-07-19 14:27:19 +00:00
Takuto Ikuta d855928ec3 [PDB] Add PDBSourcePath flag to support absolutize source file path
This patch changes relative path for source files in obj files to
absolute path in PDB when linking with added flag.

I will make obj file generated by clang-cl independent from build
directory for chromium build. But I don't want to confuse visual studio
debugger or require additional configuration. To attain this goal, I
added flag to convert relative source file path in obj to absolute path
when emitting PDB.

By removing absolute path from obj files, we can share build cache
between chromium developers even when they are doing debug build.
That will make build time faster.

More context:
https://bugs.chromium.org/p/chromium/issues/detail?id=712796
https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/5HXSVX-7fPc

llvm-svn: 337439
2018-07-19 04:56:22 +00:00
Martin Storsjo c35e4bf7eb [COFF] Don't produce base relocs for discardable sections
Dwarf debug info contains some data that contains absolute addresses.
Since these sections are discardable and aren't loaded at runtime,
there's no point in adding base relocations for them.

This makes sure that after stripping out dwarf debug info, there are no
base relocations that point to nonexistent sections.

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

llvm-svn: 337438
2018-07-19 04:25:22 +00:00
Peter Collingbourne a327a4c34e ELF: Implement --icf=safe using address-significance tables.
Differential Revision: https://reviews.llvm.org/D48146

llvm-svn: 337429
2018-07-18 22:49:31 +00:00
Fangrui Song 4a2948253f [ELF] Error if -r --gdb-index are used together
Reviewers: ruiu, espindola

Subscribers: emaste, arichardson, llvm-commits

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

llvm-svn: 337427
2018-07-18 22:02:48 +00:00
Sam Clegg 2df314d17f [WebAssembly] Fix archive member display in error messages
Add a test for this by causing a symbol collision
between archive members.

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

llvm-svn: 337426
2018-07-18 21:46:09 +00:00
Rui Ueyama f43fba739c Revert r336609: Fix direct calls to __wrap_sym when it is relocated.
This reverts commit r336609 as it doesn't seem to work with AArch64
thunk creation when used with ASan.

llvm-svn: 337413
2018-07-18 18:24:46 +00:00
Rui Ueyama c93530d873 Look for an entry point function if /nodefaultlib is given.
Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=38018

Reviewers: thakis

Subscribers: llvm-commits

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

llvm-svn: 337407
2018-07-18 17:48:14 +00:00
George Rimar 7d8e632e98 [ELF] - Stop silently producing a broken .eh_frame_hdr.
Currently, getFdePC() returns uint64_t. Its because the following
encodings might use 8 bytes: DW_EH_PE_absptr and DW_EH_PE_udata8.

But caller assigns returned value to uint32_t field:
https://github.com/llvm-mirror/lld/blob/master/ELF/SyntheticSections.cpp#L508

Value is used for building .eh_frame_hdr section.
We use DW_EH_PE_sdata4 encoding for building it at this moment:
https://github.com/llvm-mirror/lld/blob/master/ELF/SyntheticSections.cpp#L2545

And that means that an overflow issue might happen if
DW_EH_PE_absptr/DW_EH_PE_udata8 address encodings are present
in .eh_frame. In that case, before this patch, we silently would
truncate the address and produced broken .eh_frame_hdr section.

It would be not hard to support real 64-bit values for
DW_EH_PE_absptr/DW_EH_PE_udata8 encodings, but it is
unclear if it is usefull and if we should do it.

Since nobody faced/reported it, int this patch I only implement
a check to stop producing broken output silently for now.

llvm-svn: 337382
2018-07-18 11:56:53 +00:00
George Rimar a1bb8f7a0c [ELF] - Add a test case to check DW_EH_PE_absptr address encoding.
This covers the following line of the code:
https://github.com/llvm-mirror/lld/blob/master/ELF/SyntheticSections.cpp#L525

llvm-svn: 337377
2018-07-18 11:02:37 +00:00
George Rimar c51b81de9c [ELF] - Improve eh-frame-value-format7.s test case.
This adds .eh_frame_hdr content checking to test
that DW_EH_PE_udata2 address was decoded correctly.

llvm-svn: 337374
2018-07-18 10:42:10 +00:00
George Rimar 2566c0a2f2 [ELF] - Improve relocatable-many-sections.s test case. NFC.
This adds a check for .shstrtab section index.

llvm-svn: 337365
2018-07-18 08:52:09 +00:00
George Rimar b9f3ea3e1c [ELF] - Do not produce broken output when amount of sections is > ~65k
This is a part of ttps://bugs.llvm.org//show_bug.cgi?id=38119

We produce broken ELF header now when the number of output sections is >= SHN_LORESERVE (0xff00).

ELF spec says (http://www.sco.com/developers/gabi/2003-12-17/ch4.eheader.html):

e_shnum:
If the number of sections is greater than or equal to SHN_LORESERVE (0xff00), this member has the value zero
and the actual number of section header table entries is contained in the sh_size field of the section header at index 0.
(Otherwise, the sh_size member of the initial entry contains 0.)

e_shstrndx
If the section name string table section index is greater than or equal to SHN_LORESERVE (0xff00), this member has the
value SHN_XINDEX (0xffff) and the actual index of the section name string table section is contained in the sh_link field of
the section header at index 0. (Otherwise, the sh_link member of the initial entry contains 0.)

We did not set these fields correctly earlier. The patch fixes the issue.

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

llvm-svn: 337363
2018-07-18 08:44:38 +00:00
George Rimar 9958f620f9 [ELF] — Add a test case for DW_EH_PE_udata2 encoding.
This adds a test to check LLD can handle such address format correctly.
Test case covers the following line:
https://github.com/llvm-mirror/lld/blob/master/ELF/SyntheticSections.cpp#L519

llvm-svn: 337362
2018-07-18 08:39:31 +00:00
Sterling Augustine 4fd84c18df Implement framework for linking split-stack object files, and x86_64 support.
llvm-svn: 337332
2018-07-17 23:16:02 +00:00
Sam Clegg f989a92dea [WebAssemlby] Set IsUsedInRegularObj correctly for undefined data symbols
Differential Revision: https://reviews.llvm.org/D49113

llvm-svn: 337314
2018-07-17 19:15:02 +00:00
George Rimar 1f1dc636d3 [ELF] - Add test for checking unknown -color-diagnostics arguments.
This covers a following line with the test:
https://github.com/llvm-mirror/lld/blob/master/ELF/DriverUtils.cpp#L73

llvm-svn: 337268
2018-07-17 12:14:48 +00:00
George Rimar da4302ce0d [ELF] - Add a test for --no-warn-symbol-ordering.
Mentioned flag was never tested together with
--call-graph-ordering-file. And the following line
was uncovered:

https://github.com/llvm-mirror/lld/blob/master/ELF/Symbols.cpp#L248

llvm-svn: 337266
2018-07-17 12:04:23 +00:00
George Rimar 448ef7793d [ELF] - Check we able to report function symbols that encloses a location in error messages.
InputSectionBase::getLocation() have the following block of the code which
is uncovered by our test cases:
https://github.com/llvm-mirror/lld/blob/master/ELF/InputSection.cpp#L238

Patch adds a test to trigger this branch.

llvm-svn: 337256
2018-07-17 09:37:53 +00:00
George Rimar ea5d3f23e0 [ELF] - Fix BB. 'Filecheck' -> 'FileCheck'.
llvm-svn: 337254
2018-07-17 09:10:16 +00:00
George Rimar ff71afe809 [ELF] - Check we are able to report zlib decompressor errors.
This test case adds a check for the following line of the code:
https://github.com/llvm-mirror/lld/blob/master/ELF/InputSection.cpp#L194

llvm-svn: 337252
2018-07-17 08:42:42 +00:00
George Rimar e25b1c35bb [ELF] - Check we are able to report errors when DW_AT_decl_file is invalid.
We did not try to support this intentionally but have
an error handling and reporting logic that can take care
of that and hence needs a test. 

llvm-svn: 337250
2018-07-17 08:04:27 +00:00
Yunlian Jiang 588afe422e remove temporal file directory before testing in thinlto-debug-fission.ll
Summary:
This removes the %T/dwo directory before calling ld.lld in ELF/lto/thinlto-debug-fission.ll so that
files aren't left over from previous runs.

Reviewers: espindola, pcc

Reviewed By: pcc

Subscribers: inglorion, emaste, arichardson, eraman, steven_wu, dexonsmith, llvm-commits

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

llvm-svn: 337210
2018-07-16 20:28:48 +00:00
Yunlian Jiang 496fb3e7a0 Support option -plugin-opt=dwo_dir=
Summary:
This adds support to option -plugin-opt=dwo_dir=${DIR}. This option is used to specify the directory to store the .dwo files when LTO and debug fission is used
at the same time.

Reviewers: ruiu, espindola, pcc

Reviewed By: pcc

Subscribers: eraman, dexonsmith, mehdi_amini, emaste, arichardson, steven_wu, llvm-commits

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

llvm-svn: 337195
2018-07-16 17:55:48 +00:00
George Rimar e420cd8d05 [ELF] - Cover ObjFile<ELFT>::getLineInfo() with a test.
There was no test for the first `return`.

llvm-svn: 337182
2018-07-16 15:27:53 +00:00
Nico Weber 6c414a31ae attempt to get test/COFF/driver.test passing on sanitizer-x86_64-linux-fast; cf r337092
llvm-svn: 337093
2018-07-14 11:47:23 +00:00
Nico Weber c421fe5ef4 lld-link: Add /lib to Options.td so that it appears in lld-link's help output.
https://reviews.llvm.org/D49319

llvm-svn: 337086
2018-07-14 04:07:51 +00:00
Zachary Turner bf9abccacd [coff] Remove dots in path pointing to PDB file.
Some Microsoft tools (e.g. new versions of WPA) fail when the
COFF Debug Directory contains a path to the PDB that contains
dots, such as D:\foo\./bar.pdb.  Remove dots before writing this
path.

This fixes pr38126.

llvm-svn: 336873
2018-07-12 00:44:15 +00:00
Yi Kong a2125b12ec Also search BitcodeFiles for exclude-lib symbols
Archives created with ThinLTO are bitcodes, they also need to be searched for excluded symbols.

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

llvm-svn: 336826
2018-07-11 17:45:28 +00:00
Igor Kudrin 4f48b3ef90 [ELF] Update addends in non-allocatable sections for REL targets when creating a relocatable output.
This fixes PR37735.

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

llvm-svn: 336799
2018-07-11 12:52:04 +00:00
George Rimar fd6af6dc98 [ELF] - Report proper error message about mixing bitcode files.
If we have 2 bitcode inputs for different targets, LLD would
print "<internal>" instead of the name of one of the files.

The patch adds a test and fixes this issue.

llvm-svn: 336794
2018-07-11 12:32:00 +00:00
Rui Ueyama d29c039119 Parallelize GdbIndexSection's symbol table creation.
Since .gdb_index sections contain all known symbols, they can be very large.
One of my executables has a .gdb_index section of 1350 GiB. Uniquifying
symbols by name takes 3.77 seconds on my machine. This patch parallelize it.

  Time to call createSymbols() with 8.4 million unique symbols:

  Without this patch: 3773 ms
  Parallelism = 1:    4374 ms
  Parallelism = 2:    2628 ms
  Parallelism = 16:    837 ms

As you can see above, this algorithm is a bit more inefficient
than the non-parallelized version, but even with dual-core, it is
faster than that, so I think it is overall a win.

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

llvm-svn: 336790
2018-07-11 11:37:10 +00:00
Rui Ueyama f51c853cf1 Remove a workaround for an old GCC bug.
This workaround is for GCC 5.4.1. Without this workaround, lld will
produce larger .gdb_index sections for object files compiled with the
buggy version of the compiler.

Since it is not for correctness, and it affects only debug builds (since
you are generating .gdb_index sections), perhaps the hack shouldn't have been
added in the first place. At least, I think it is time to remove this hack.

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

llvm-svn: 336788
2018-07-11 10:52:00 +00:00
Simon Atanasyan 64fb2901e5 [ELF][MIPS] Add mote tests on MipsArchTree routines, fix typos in error messages
This fix add more test cases for routines check MIPS ELF header flags and
flags from .MIPS.abiflags sections. The tests use yaml2obj for object
files generation because not all combinations of flags can be produced
by LLVM tools.

llvm-svn: 336704
2018-07-10 16:51:17 +00:00
George Rimar 92108de572 [ELF] - Add a test for readCallGraph() code.
This is to test the following untested line:
https://github.com/llvm-mirror/lld/blob/master/ELF/Driver.cpp#L643

llvm-svn: 336670
2018-07-10 13:42:21 +00:00
Martin Storsjo 474be005db [COFF] Store import symbol pointers as pointers to the base class
Future symbol insertions can potentially change the type of these
symbols - keep pointers to the base class to reflect this, and
use dynamic casts to inspect them before using as the subclass
type.

This fixes crashes that were possible before, by touching these
symbols that now are populated as e.g. a DefinedRegular, via
the old pointers with DefinedImportThunk type.

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

llvm-svn: 336652
2018-07-10 10:40:11 +00:00
George Rimar bc6702a424 [ELF] - Improve call graph pasing error reporting.
This adds a file name to the error message,
adds a missing test case and refactors code a bit. 

llvm-svn: 336651
2018-07-10 10:28:55 +00:00
George Rimar 20b92c4d0d [ELF] - Report call graph profile file names in error messages.
We did not report file names for some reason.

llvm-svn: 336650
2018-07-10 10:16:48 +00:00
Rui Ueyama a9e169edff Fix a bug for packed relocations.
Previously, we didn't create multiple consecutive bitmaps.
Added a test to catch this bug too.

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

llvm-svn: 336620
2018-07-09 23:54:24 +00:00
Rui Ueyama 3e730b8ae6 Fix direct calls to __wrap_sym when it is relocated.
Patch by Matthew Koontz!

Before, direct calls to __wrap_sym would not map to valid PLT entries,
so they would crash at runtime. This change maps such calls to the same
PLT entry as calls to sym that are then wrapped.

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

llvm-svn: 336609
2018-07-09 22:03:05 +00:00
Rui Ueyama 11479daf2f lld: add experimental support for SHT_RELR sections.
Patch by Rahul Chaudhry!

This change adds experimental support for SHT_RELR sections, proposed
here: https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg

Pass '--pack-dyn-relocs=relr' to enable generation of SHT_RELR section
and DT_RELR, DT_RELRSZ, and DT_RELRENT dynamic tags.

Definitions for the new ELF section type and dynamic array tags, as well
as the encoding used in the new section are all under discussion and are
subject to change. Use with caution!

Pass '--use-android-relr-tags' with '--pack-dyn-relocs=relr' to use
SHT_ANDROID_RELR section type instead of SHT_RELR, as well as
DT_ANDROID_RELR* dynamic tags instead of DT_RELR*. The generated
section contents are identical.

'--pack-dyn-relocs=android+relr --use-android-relr-tags' enables both
'--pack-dyn-relocs=android' and '--pack-dyn-relocs=relr': lld will
encode the relative relocations in a SHT_ANDROID_RELR section, and pack
the rest of the dynamic relocations in a SHT_ANDROID_REL(A) section.

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

llvm-svn: 336594
2018-07-09 20:08:55 +00:00
Zaara Syeda 75c348a097 [PPC64] Add TLS local dynamic to local exec relaxation
This patch adds the target call back relaxTlsLdToLe to support TLS relaxation
from local dynamic to local exec model.

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

llvm-svn: 336559
2018-07-09 16:35:51 +00:00
Zachary Turner 648bebdc67 [PDB] One more fix for hasing GSI records.
The reference implementation uses a case-insensitive string
comparison for strings of equal length.  This will cause the
string "tEo" to compare less than "VUo".  However we were using
a case sensitive comparison, which would generate the opposite
outcome.  Switch to a case insensitive comparison.  Also, when
one of the strings contains non-ascii characters, fallback to
a straight memcmp.

The only way to really test this is with a DIA test.  Before this
patch, the test will fail (but succeed if link.exe is used instead
of lld-link).  After the patch, it succeeds even with lld-link.

llvm-svn: 336464
2018-07-06 21:01:42 +00:00
George Rimar 475dc96901 [ELF] - Add test for empty version in a symbol name.
This covers the following line which was untested:
https://github.com/llvm-mirror/lld/blob/master/ELF/Symbols.cpp#L170

llvm-svn: 336443
2018-07-06 15:03:53 +00:00
Hans Wennborg b09e004cde Relax filechecks in r336405 tests
They were failing in Chromium's packaging builds with:

  C:\b\rr\tmphqfaff\w\src\third_party\llvm\tools\lld\test\COFF\pdb-globals-dia-vfunc-collision2.test:24:8:
  error: expected string not found in input
  CHECK: func [0x00001060+ 0 - 0x0000106c-12 | sizeof= 12] (FPO) virtual int __cdecl A132()
         ^
  <stdin>:8:11: note: scanning from here
   struct S [sizeof = 8] {
            ^
  <stdin>:9:2: note: possible intended match here
   func [0x00001060+ 0 - 0x0000106c-12 | sizeof= 12] (FPO) virtual int __cdecl S::A132()
   ^

Maybe due to different DIA versions.

llvm-svn: 336424
2018-07-06 08:44:08 +00:00
Hans Wennborg bf7caf4232 dos2unix
llvm-svn: 336423
2018-07-06 08:44:04 +00:00