Commit Graph

9156 Commits

Author SHA1 Message Date
Rui Ueyama
cfc2f80df6 Remove {get,set}Align accessor functions and use Alignment member variable instead.
llvm-svn: 313204
2017-09-13 21:54:55 +00:00
Rafael Espindola
c57f8cd7ea Simplify. NFC.
The isShared case was handled by the isInCurrentDSO check.

llvm-svn: 313190
2017-09-13 20:47:53 +00:00
Rafael Espindola
3d9f1c032a Add a helper for checking for weak undef. NFC.
llvm-svn: 313188
2017-09-13 20:43:04 +00:00
Rui Ueyama
a835babef9 Do not use hasArgNoClaim().
Arg instances can be claimed. After claimed, its `isClaimed` function
returns true. We do not use that notion in lld, so using NoClaim
versions of functions is just confusing. This patch is to just use
hasArg instead of hasArgNoClaim.

llvm-svn: 313187
2017-09-13 20:30:59 +00:00
Rafael Espindola
3e635f2309 Use existing helper. NFC.
llvm-svn: 313184
2017-09-13 20:07:13 +00:00
Rui Ueyama
9c37d8c18b Use getUnaliasedOption so that this switch works for option aliases.
There are no alises handled by this switch, but getUnaliasesdOption is
preferred way of doing this. This is also consistent with ELF and COFF.

llvm-svn: 313180
2017-09-13 19:44:36 +00:00
Rui Ueyama
7d306a598e Move a piece of code above some local variable definitions to make their scope narrower.
llvm-svn: 313178
2017-09-13 19:40:07 +00:00
Martin Storsjo
2ba37d4b3e [MinGW] Only apply -Bstatic to following libraries
This is how the flag is documented in GNU binutils ld; -Bstatic
only applies to -l options after it, until the next -Bdynamic.

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

llvm-svn: 313175
2017-09-13 19:29:44 +00:00
Martin Storsjo
31fe4cd25d [MinGW] Support dllexport on i386
In MinGW configurations (GCC, or clang with a *-windows-gnu target),
the -export directives in the object file contains the undecorated
symbol name, while it is decorated in MSVC configurations. (On the
command line, link.exe takes an undecorated symbol name for the
-export argument though.)

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

llvm-svn: 313174
2017-09-13 19:29:39 +00:00
Rafael Espindola
f6c74c472d Remove CopyRelSecOff from SharedSymbol.
This reduces the size of SharedSymbol which in turn reduces the size
of Symbol from 88 to 80 bytes.

llvm-svn: 313154
2017-09-13 16:59:12 +00:00
NAKAMURA Takumi
34fc973b08 lldMinGW itself doesn't require libpthread.
llvm-svn: 313129
2017-09-13 07:59:07 +00:00
George Rimar
cb888a620d [ELF] - Refactor of Writer<ELFT>::forEachRelSec.
There is no need to scan over all input sections for relocatable output.
As we do not process or scan relocations anyways.
Patch moves check for Config->Relocatable out to avoid that and also removes
excessive check for isa<EhInputSection> from first for loop. 
It is excessive because we handle all of them in a second for loop below.
That all allowed to simplify code.

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

llvm-svn: 313127
2017-09-13 07:54:47 +00:00
Martin Storsjo
064b0fac93 [MinGW] Support creating DLLs with a def file
Differential Revision: https://reviews.llvm.org/D37761

llvm-svn: 313125
2017-09-13 07:28:13 +00:00
Martin Storsjo
32e1626a2e [MinGW] Add support for the options --[no-]whole-archive
Differential Revision: https://reviews.llvm.org/D37769

llvm-svn: 313124
2017-09-13 07:28:09 +00:00
Martin Storsjo
8278ba51d3 [COFF] Add support for the -wholearchive option
This fixes PR31824.

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

llvm-svn: 313123
2017-09-13 07:28:03 +00:00
Rafael Espindola
7415819186 Handle lazy symbols is Symbol::includeInDynsym.
This should fix the lto bootstrap.

It is somewhat hard to remember about lazy symbols deep down in the
link. It might be worth it replacing them with undefined symbols once
we are done adding files.

llvm-svn: 313103
2017-09-13 00:47:06 +00:00
Rui Ueyama
56614e41a4 Add a comment about a workaround for ld.gold -r.
llvm-svn: 313095
2017-09-12 23:43:45 +00:00
Rui Ueyama
28ebaf39cb Add test cases for the -l option.
llvm-svn: 313094
2017-09-12 23:42:26 +00:00
Ben Dunbobbin
0b95d3784a [ELF] Handle references to garbage collected common symbols
https://reviews.llvm.org/rL312796 meant that references to garbage collected common symbols would cause a segfault.

This change fixes the behaviour for references to stripped common symbols.

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

llvm-svn: 313086
2017-09-12 22:41:45 +00:00
Rafael Espindola
67df57a242 Remove Offset from Common.
It is not needed since it is always 0.

llvm-svn: 313076
2017-09-12 21:19:09 +00:00
Martin Storsjo
6d8dace438 [MinGW] Pass the undecorated entry point name to the COFF linker
On i386, the --entry parameter to GNU ld is supposed to be a decorated
symbol name, while it is an undecorated name in link.exe.

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

llvm-svn: 313066
2017-09-12 19:23:54 +00:00
Rafael Espindola
30ea5cf543 Update comment. NFC.
llvm-svn: 313051
2017-09-12 17:18:03 +00:00
Rafael Espindola
4d5601608d Simplify handling of predefined symbols.
Given our representation of symbols as section + offset, we can
finalize symbols like _end as soon as the section is known.

llvm-svn: 313048
2017-09-12 16:38:01 +00:00
Rui Ueyama
a54ed0a407 Simplify MinGW test.
Differential Revision: https://reviews.llvm.org/D37708

llvm-svn: 313045
2017-09-12 16:29:07 +00:00
Simon Atanasyan
b04eee5236 [MIPS] Check raw binary file content instead of disassembled code. NFC
For now LLD does not setup the least-significant bit for microMIPS
symbols. llvm-objdump does not like that. In attempt to fix
sanitizer-x86_64-linux-fast build-bot let's temporarily check the raw
binary file content.

llvm-svn: 313040
2017-09-12 16:09:42 +00:00
Simon Atanasyan
4f70b30d6f [MIPS] Initial support of microMIPS code linking
The patch implements initial support of microMIPS code linking:
  - Handle microMIPS specific relocations.
  - Emit both R1-R5 and R6 microMIPS PLT records.

For now linking mixed set of regular and microMIPS object files is not
supported. Also the patch does not handle (setup and clear) the
least-significant bit of an address which is utilized as the ISA mode
bit and allows to make jump between regular and microMIPS code without
any thunks.

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

llvm-svn: 313028
2017-09-12 13:08:24 +00:00
Peter Smith
38029d3c89 [ELF] Rename variables and add comments to getISThunkSec [NFC]
Replace OutputSection *Cmd to OutputSection *OS. The Commands vector was
moved to OutputSection but the names of the variables were not. This patch
changes the names to match.

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

llvm-svn: 313015
2017-09-12 09:17:39 +00:00
Rafael Espindola
a6acd23c53 Align addresses, not offsets.
This fixes two more cases where we were aligning the offset in a
section, instead of the final address.

llvm-svn: 312983
2017-09-12 00:06:00 +00:00
NAKAMURA Takumi
8a55c471ba lldMinGW: Add LLVMSupport in libdeps.
llvm-svn: 312981
2017-09-12 00:01:07 +00:00
Rafael Espindola
b7147ad3dd Correct ALIGN expression when inside a section.
When given

foobar = ALIGN(., 0x100);

my expectation from what the manual says is that the final address of
foobar will be aligned. It seems that bfd aligns the offset in the
section, which causes some odd results if the section is not 0x100
aligned. Gold aligns the address.

This changes lld to align the final address.

llvm-svn: 312979
2017-09-11 23:44:53 +00:00
Adrian Prantl
dcf890598c Update testcases for llvm-dwarfdump command line interface change
llvm-svn: 312976
2017-09-11 23:34:12 +00:00
Adrian Prantl
65b79a544f Update testcases for llvm-dwarfdump command line interface change
llvm-svn: 312974
2017-09-11 23:28:21 +00:00
Rui Ueyama
9d9bdabee3 Ignore /natvis option for now.
/natvis is a new command line option introduced by MSVC 2017.
We eventually have to support it, but for now, let's ignore it so that
we can at least link stuff instead of printing out an error.

Patch by Michael Rickert.

llvm-svn: 312966
2017-09-11 22:24:13 +00:00
Rui Ueyama
d2da71f971 Reorder functions so that related functions come closer.
llvm-svn: 312964
2017-09-11 22:04:37 +00:00
Rui Ueyama
447479677f Rename COFFLdOptTable MinGWOptTable for consistency.
llvm-svn: 312963
2017-09-11 22:04:25 +00:00
Rui Ueyama
c16fd25c29 Make the scope of an anonymous namespace as narrow as possible.
llvm-svn: 312962
2017-09-11 22:04:13 +00:00
Rui Ueyama
95114b497f Remove unused includes and do not enclose the entire file with a namespace.
llvm-svn: 312961
2017-09-11 22:04:01 +00:00
Rui Ueyama
febfec2b3c Fix MinGW/CMakeLists.txt.
We do not use "Shim" as a name of MinGW driver, so rename it MinGW.
I don't think the former dependency list was correct. MinGW driver
depends on COFF.

llvm-svn: 312960
2017-09-11 22:03:49 +00:00
Martell Malone
0d17638b89 LLD: Add -mllvm flag to the MinGW driver.
This adds support for passing LTO flags to the MINGW driver
in GNU LD style i.e. -mllvm flag -> /mllvm:flag

Reviewers: ruiu, mstorsjo

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

llvm-svn: 312956
2017-09-11 21:36:37 +00:00
Rui Ueyama
c3e4602645 Sort options.
This patch also rename OPT_outlib OPT_out_implib for consistency.

llvm-svn: 312949
2017-09-11 20:54:51 +00:00
Martin Storsjo
5d5aa214d8 [MinGW] Ignore the sysroot parameter
If the sysroot parameter is passed to the clang frontend, clang
already uses it to find libraries and adds -L options for it, but
also passes it on to the linker. Therefore we can get pretty far
by just ignoring it altogether.

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

llvm-svn: 312945
2017-09-11 20:43:43 +00:00
Martin Storsjo
a79762a32d [MinGW] Map the -verbose option, implement -### for showing the produced parameters
Pass the -verbose option through to the COFF linker, and show the
arguments passed to it. If the -### option is specified, just show
the produced argument list and exit, just like in clang.

Replace the first argument with "lld-link" in order to produce a
correct command line.

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

llvm-svn: 312944
2017-09-11 20:43:39 +00:00
Rui Ueyama
5941b0bb63 Improve readability of MinGW driver. NFC.
Summary:
In addition to removing a few global variables and functions, I believe
this patch improves code readability a bit in general.

Reviewers: mstorsjo, martell

Subscribers: llvm-commits

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

llvm-svn: 312940
2017-09-11 20:14:47 +00:00
Rui Ueyama
e298e5e9c5 Remove cross-target test dependency.
Tests for MinGW shouldn't depend on files under test/COFF/Inputs.

llvm-svn: 312931
2017-09-11 18:00:03 +00:00
Martell Malone
894dbbe8eb LLD: Introduce a GNU LD style driver for COFF
When building COFF programs many targets such as mingw prefer
to have a gnu ld frontend. Rather then having a fully fledged
standalone driver we wrap a shim around the LINK driver.

Extra tests were provided by mstorsjo

Reviewers: mstorsjo, ruiu

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

llvm-svn: 312926
2017-09-11 17:02:59 +00:00
James Henderson
4c2a3ec33b [ELF] Fix issue with test when build path contains '@'
'@' is a valid character in file paths, but the linker script tokenizer treats it
as a separate token. This was leading to an unexpected test failure, on our local
builds. This patch changes the test to quote the path to prevent this happening.

An alternative would have been to add '@' to the list of "unquoted tokens" in
ScriptLexer.cpp, but ld.bfd has the same behaviour as the current LLD.

Reviewers: ruiu

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

llvm-svn: 312922
2017-09-11 15:55:54 +00:00
Rui Ueyama
9011320921 Remove a redundant local variable.
llvm-svn: 312823
2017-09-08 19:41:35 +00:00
Rafael Espindola
8016bdfd93 Handle empty dynamic lists.
llvm-svn: 312820
2017-09-08 18:53:43 +00:00
Rafael Espindola
ee6a352a8d Handle lazy symbols is computeIsPreemptible.
llvm-svn: 312812
2017-09-08 18:41:49 +00:00
Rafael Espindola
716c57bfb5 Simplify. NFC.
We handled all undefined symbols before this.

llvm-svn: 312808
2017-09-08 18:23:25 +00:00
Rafael Espindola
bb468da200 Simplify as this runs before copy relocations are created.
llvm-svn: 312807
2017-09-08 18:21:14 +00:00
Rafael Espindola
d72d97b3be If --dynamic-list is given, only those symbols are preemptible.
This allows combining --dynamic-list and version scripts too. The
version script controls which symbols are visible, and
--dynamic-list controls which of those are preemptible.

Unlike previous versions, undefined symbols are still considered
preemptible, which was the issue breaking the cfi tests.

This fixes pr34053.

llvm-svn: 312806
2017-09-08 18:16:59 +00:00
Dmitry Mikulin
1e30f07ce7 Currently lld creates a single section to collect all commons. There is no way
to separate commons based on file name patterns. The following linker script
construct does not work because commons are allocated before section placement
is done and the only synthesized BssSection that holds all commons has no file
associated with it:
SECTIONS { .common_0 : { *file0.o(COMMON) }}

This patch changes the allocation of commons to create a section per common
symbol and let the section logic do the layout.

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

llvm-svn: 312796
2017-09-08 16:22:43 +00:00
George Rimar
9a2da39837 [ELF] - Simplify #2. NFC.
llvm-svn: 312789
2017-09-08 13:40:07 +00:00
George Rimar
7ac3825afb [ELF] - Simplify. NFC.
llvm-svn: 312787
2017-09-08 13:26:45 +00:00
George Rimar
113a5ca029 [ELF] - Simplify and improve symbols.s testcase.
There is no need to check anything excepr that
symbol is not in output.
Previously additional iformation like symbol values
or flags were checked, that was not correct.
For example if we would provide symbol with different
value/visibility/type for case when should not provide 
symbol at all, testcase would not fail.

llvm-svn: 312779
2017-09-08 09:31:01 +00:00
George Rimar
5f37541c73 [ELF] - Linkerscript: implement REGION_ALIAS.
REGION_ALIAS(alias, region)

Alias names can be added to existing memory regions created with
the MEMORY command. Each name corresponds to at most one
memory region.

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

llvm-svn: 312777
2017-09-08 08:23:15 +00:00
Rafael Espindola
0ff545c018 Revert "Revert "Revert r311468: If --dynamic-list is given, only those symbols are preemptible""
This reverts commit r312757.

Evgenii Stepanov reports that it broke some tests.

llvm-svn: 312771
2017-09-08 01:09:52 +00:00
Peter Collingbourne
052e855e2b COFF: Implement ThinLTO cache and cache pruning support.
Differential Revision: https://reviews.llvm.org/D37607

llvm-svn: 312770
2017-09-08 00:50:50 +00:00
Rui Ueyama
721b71d532 Replace CRLF.
llvm-svn: 312765
2017-09-07 23:54:32 +00:00
Rui Ueyama
d63ac33948 Remove a stale comment.
llvm-svn: 312763
2017-09-07 23:54:20 +00:00
Peter Collingbourne
cef809938d COFF: Remove unnecessary casts. NFCI.
llvm-svn: 312762
2017-09-07 23:49:09 +00:00
Rafael Espindola
b7d0be5896 Revert "Revert r311468: If --dynamic-list is given, only those symbols are preemptible"
If --dynamic-list is given, only those symbols are preemptible.

This allows combining --dynamic-list and version scripts too. The
version script controls which symbols are visible, and --dynamic-list
controls which of those are preemptible.

This fixes pr34053.

llvm-svn: 312757
2017-09-07 23:19:09 +00:00
Rui Ueyama
e2f52eb22f Add -no-gdb-index which negates -gdb-index option.
llvm-svn: 312753
2017-09-07 22:40:54 +00:00
Peter Collingbourne
9e26e97955 COFF: PDB: Allow multiple modules with the same name.
It is possible for two modules to have the same name if they are
archive members with the same name, or if we are doing LTO (in which
case all modules will have the name "lto.tmp").

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

llvm-svn: 312744
2017-09-07 20:39:46 +00:00
Rafael Espindola
c20759038b Drop --no-threads from tests.
The performance problem with --threads is fixed.

llvm-svn: 312738
2017-09-07 19:07:49 +00:00
Peter Smith
20489ec563 [ELF] Always write non-immediate bits for AArch64 branch instruction.
To support errata patching on AArch64 we need to be able to overwrite
an arbitrary instruction with a branch. For AArch64 it is sufficient to
always write all the bits of the branch instruction and not just the
immediate field. This is safe as the non-immediate bits of the branch
instruction are always the same.

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

llvm-svn: 312727
2017-09-07 16:29:52 +00:00
George Rimar
6823c5f0c0 [ELF] - Rename PhdrEntry::First/Last to FirstSec/LastSec. NFC.
As was suggested in D34956 thread.

llvm-svn: 312712
2017-09-07 11:01:10 +00:00
George Rimar
582ede8922 [ELF] - Store pointer to PT_LOAD instead of pointer to first section in OutputSection
It is a bit more convinent and helps to simplify logic 
of program headers allocation a little.

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

llvm-svn: 312711
2017-09-07 10:53:07 +00:00
Andrew Ng
6dee736c91 [LLD] Fix padding of .eh_frame when in executable segment
The default padding for an executable segment is the target trap
instruction which for x86_64 is 0xCC. However, the .eh_frame section
requires the padding to be zero. The code that writes the .eh_frame
section assumes that its segment is zero initialized and does not
explicitly write the zero padding. This does not work when the .eh_frame
section is in the executable segment (for example when using
-no-rosegment).

This patch changes the .eh_frame writing code to explicitly write the
zero padding.

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

llvm-svn: 312706
2017-09-07 08:43:56 +00:00
James Henderson
7594c61d2d [ELF] Prevent crash with binary inputs with non-ascii file names
If using --format=binary with an input file name that has one or more non-ascii
characters in, LLD has undefined behaviour (it crashes on my Windows Debug build)
when calling isalnum with these non-ascii characters. Instead, of calling
std::isalnum, this patch uses an internal version that ignores the locale and
checks a specific subset of characters.

Reviewers: ruiu

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

llvm-svn: 312705
2017-09-07 08:30:09 +00:00
Rafael Espindola
17e93d28f2 Simplify type. NFC.
llvm-svn: 312675
2017-09-06 22:16:32 +00:00
Davide Italiano
a0186dd986 [ELF/Writer] Fix english in a comment. NFCI.
llvm-svn: 312669
2017-09-06 21:16:51 +00:00
Rui Ueyama
0440be4a42 Detect linker script INCLUDE cycles.
Differential Revision: https://reviews.llvm.org/D37524

llvm-svn: 312656
2017-09-06 18:14:08 +00:00
Rui Ueyama
fd06b02558 Add a comment.
llvm-svn: 312655
2017-09-06 18:09:06 +00:00
Rui Ueyama
a353d9cb18 Remove a trailing empty line that didn't end with '\n'.
llvm-svn: 312652
2017-09-06 17:41:29 +00:00
Peter Smith
1d5a070386 [ELF][AArch64] Add alignment checks for the LDST<N>_ABS_LO12_NC relocations
The R_AARCH64_LDST<N>_ABS LO12_NC relocations where N is 8, 16, 32, 64 or
128 have a scaled immediate. For example R_AARCH64_LDST32_ABS_LO12_NC
shifts the calculated value right by 4. If the target symbol + relocation
addend is not aligned properly then bits of the answer will be lost.

This change adds an alignment check to the relocations to make sure the
target of the relocation is aligned properly. This matches the behavior of
GNU ld. The motivation is to catch ODR violations such as a declaration of
extern int foo, but a definition of bool foo as the compiler may use
R_AARCH64_LDST32_ABS_LO12_NC for the former, but not align the destination.

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

llvm-svn: 312637
2017-09-06 14:23:06 +00:00
Peter Smith
3ef89b0fc7 [ELF] Move fixSectionAlignments() before first call to assignAddresses()
The fixSectionAlignments() function may alter the alignment of some
OutputSections, this is likely to alter the addresses calculated earlier
in assignAddresses(). By moving the call to fixSectionAlignments() we
make sure that assignAddresses() is consistent with the early calculation
used for RangeThunks and the final call just before writing the image.

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

llvm-svn: 312636
2017-09-06 14:02:14 +00:00
James Henderson
1304e8dd6e [ELF] Rewrite --symbol-ordering-file path in reproducer
The --symbol-ordering-file path was not being rewritten in the response file when
using --reproduce. This patch adds this to the list of switches that are rewritten,
so that the path is somewhere within the reproducer directory tree.

Reviewers: ruiu

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

llvm-svn: 312626
2017-09-06 10:10:49 +00:00
George Rimar
c2dffe3aa0 [ELF] - Linkerscript: set load address correctly if MEMORY command used.
Previously LLD did not calculate LMAOffset correctly when
AT and MEMORY were used together.

Patch fixes PR34407.

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

llvm-svn: 312625
2017-09-06 09:35:09 +00:00
Eric Beckmann
0aa4b7d4c5 Fix crbug 759265 by suppressing llvm mt warnings.
Summary:
Previous would throw warning whenever libxml2 is not installed.  Now
only give this warning if merging manifest fails.

Subscribers: llvm-commits

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

llvm-svn: 312604
2017-09-06 01:50:36 +00:00
Nico Weber
a05cbb8b95 lld-link: Add --rsp-quoting= flag.
This ports https://reviews.llvm.org/D19425 from clang /
https://reviews.llvm.org/D22015 from the ELF port to COFF lld. This can be
useful when linking COFF files on a posix host.

https://reviews.llvm.org/D37452

llvm-svn: 312594
2017-09-05 23:46:45 +00:00
Rui Ueyama
2ea27186b4 Use raw_string_ostream::str to get a result string.
Looks like raw_string_ostream is buffered. If we do not call `flush`
nor `str`, it is not guaranteed that a result string has all characters
that were written to it.

It wasn't failing on buildbots, but I could reproduce the issue on my
Windows workstation.

llvm-svn: 312577
2017-09-05 21:17:32 +00:00
Rui Ueyama
888da8c232 Do not use invalid iterators to fix Windows build.
std::vector::insert invalidates all iterators, so it was not safe to do

  Script->Opt.Commands.insert(++I, Make(ElfSym::End1));
  Script->Opt.Commands.insert(++I, Make(ElfSym::End2));

because after the first line, `I` is no longer valid.

This patch rewrites fixes the issue. I belive the new code without
higher-order functions is a bit more readable than before.

llvm-svn: 312570
2017-09-05 20:17:37 +00:00
Peter Collingbourne
d0e9c167d8 LTO: Try to open cache files before renaming them.
It appears that a potential race between the cache client and the cache
pruner that I thought was unlikely actually happened in practice [1].
Try to avoid the race condition by opening the temporary file before
renaming it. Do this only on non-Windows platforms because we cannot
rename open files on Windows using the sys::fs::rename function.

[1] https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Fchromium.memory%2FLinux_CFI%2F1610%2F%2B%2Frecipes%2Fsteps%2Fcompile%2F0%2Fstdout

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

llvm-svn: 312567
2017-09-05 19:51:38 +00:00
Simon Atanasyan
7644191fb1 [MIPS] Convert template parameters to function arguments. NFC
Pass BSIZE and SHIFT as a function arguments to the `writeRelocation`
routine. It does not make a sense to have so many `writeRelocation's`
instances.

llvm-svn: 312495
2017-09-04 16:16:46 +00:00
Simon Atanasyan
351cf49579 [MIPS] Add curly brackets to improve code readability. NFC.
llvm-svn: 312494
2017-09-04 16:16:41 +00:00
George Rimar
6fb163162e [ELF] - Add testcase testing .gdb_index generation when base address of CU is used.
Recently (before r312477) lib/DebugInfo incorrectly handled the case
when debug ranges uses base address of CU. Section index was not
calulcated properly and LLD crashed on provided testcase.

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

llvm-svn: 312478
2017-09-04 10:46:15 +00:00
Saleem Abdulrasool
353c57a3f6 COFF: simplify thunk handling (NFC)
Apply the simplification suggestions that Peter Collingbourne made
during the review at D37368.  The returned thunk is cast to the
appropriate type in the SymbolTable, and the constant symbol's body is
not needed directly, so avoid the assignment.  NFC

llvm-svn: 312391
2017-09-01 23:35:43 +00:00
Saleem Abdulrasool
3170ad7431 COFF: handle multiply defined symbols with different storage
If a symbol is locally defined and is DLL imported in another
translation unit, and the object with the locally defined version is
loaded prior to the imported version, then the linker will fail to
resolve the definition of the thunk and return the locally defined
symbol.  This will then be attempted to be cast to an import thunk,
which will clearly fail.

Only return the thunk if the symbol is inserted or a thunk is created.
Otherwise, report a duplication error.

llvm-svn: 312386
2017-09-01 22:12:10 +00:00
Petr Hosek
7ab9f7be0c [ELF] Set p_memsz to p_filesz when aligning the last segment to page boundary
Having p_filesz different from p_memsz is confusing some tools.

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

llvm-svn: 312384
2017-09-01 21:48:20 +00:00
Zachary Turner
abb17cc084 [llvm-pdbutil] Support dumping CodeView from object files.
We have llvm-readobj for dumping CodeView from object files, and
llvm-pdbutil has always been more focused on PDB.  However,
llvm-pdbutil has a lot of useful options for summarizing debug
information in aggregate and presenting high level statistical
views.  Furthermore, it's arguably better as a testing tool since
we don't have to write tests to conform to a state-machine like
structure where you match multiple lines in succession, each
depending on a previous match.  llvm-pdbutil dumps much more
concisely, so it's possible to use single-line matches in many
cases where as with readobj tests you have to use multi-line
matches with an implicit state machine.

Because of this, I'm adding object file support to llvm-pdbutil.
In fact, this mirrors the cvdump tool from Microsoft, which also
supports both object files and pdb files.  In the future we could
perhaps rename this tool llvm-cvutil.

In the meantime, this allows us to deep dive into object files
the same way we already can with PDB files.

llvm-svn: 312358
2017-09-01 20:06:56 +00:00
George Rimar
e89c5bfbc2 [ELF] - Never call splitIntoPieces() twice. NFC.
Previously it was called twice for .comment synthetic section.
That created 2 pieces of data, which was deduplicated anyways,
but was not clean.

llvm-svn: 312327
2017-09-01 12:04:52 +00:00
Petr Hosek
18821b60b0 [ELF] Generate symbol assignments for predefined symbols
The problem with symbol assignments in implicit linker scripts is that
they can refer synthetic symbols such as _end, _etext or _edata. The
value of these symbols is currently fixed only after all linker script
commands are processed, so these assignments will be using non-final and
hence invalid value.

Rather than fixing the symbol values after all command processing have
finished, we instead change the logic to generate symbol assignment
commands that set the value of these symbols while processing the
commands, this ensures that the value is going to be correct by the time
any reference to these symbol is processed and is equivalent to defining
these symbols explicitly in linker script as BFD ld does.

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

llvm-svn: 312305
2017-09-01 02:23:31 +00:00
George Rimar
b08c249a4b [ELF] - Removed unused dummy methods. NFC.
llvm-svn: 312233
2017-08-31 11:05:38 +00:00
George Rimar
b2051f176c [ELF] - Fix comment. NFC.
llvm-svn: 312231
2017-08-31 10:14:10 +00:00
Rui Ueyama
01d0265106 Simplify writeArchive return type.
writeArchive returned a pair, but the first element of the pair is always
its first argument on failure, so it doesn't make sense to return it from
the function. This patch change the return type so that it does't return it.

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

llvm-svn: 312177
2017-08-30 22:11:03 +00:00
Rui Ueyama
c1e101f356 Revert r312171: Support nested static libraries.
This reverts commit r312171 because it is pointed out that that's not a
correct fix (see https://bugs.llvm.org/show_bug.cgi?id=32674#c14) and
also because it broke buildbots.

llvm-svn: 312174
2017-08-30 21:22:59 +00:00
Rui Ueyama
a68748659a Support nested static libraries.
MSVC link.exe supports nested static libraries. That is, an .a file can
contain other .a file as its member. It is reported that MySQL actually
depends on this feature.

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

llvm-svn: 312171
2017-08-30 20:55:41 +00:00
Rui Ueyama
f59b709ae4 Move a function from Driver.cpp to InputFile.cpp.
This patch doesn't improve code per se, but it should make the following
patch's diff easier to read.

llvm-svn: 312170
2017-08-30 20:55:18 +00:00