Commit Graph

10392 Commits

Author SHA1 Message Date
Alexander Shaposhnikov f59ab35b1b [lld] Fix comdat tests
This diff adjusts the comdat tests after changing the format
of llvm-readobj output for .group sections.

llvm-svn: 327353
2018-03-13 00:07:53 +00:00
Sam Clegg e3f3ccf886 [WebAssembly] Refactor to avoid conflating global and fucntion index space. NFC
Differential Revision: https://reviews.llvm.org/D44358

llvm-svn: 327326
2018-03-12 19:56:23 +00:00
Sam Clegg dbd33b80b7 [WebAssembly] Verify contents of relocation target before writing it
Verify that the location where a relocation is about the be
applied contains the expected existing value.

This is essentially a sanity check to catch bugs in the compiler
and the linker.

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

llvm-svn: 327325
2018-03-12 19:54:26 +00:00
Nicholas Wilson 0185281ad1 [WebAssembly] Add test for imported ctor and fix indexing bug found
This bug was found by accident while trying to expand out testcases
for imported symbols, and is covered by the additional test case.

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

llvm-svn: 327290
2018-03-12 16:04:04 +00:00
Nicholas Wilson 5639da89a9 [WebAssembly] Reorder synthetic functions to come first
This matches the existing ordering that's been there for globals
for a while (__stack_pointer coming first).

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

llvm-svn: 327286
2018-03-12 15:44:07 +00:00
George Rimar 59ebd4adf0 [ELF] - Formatted comment, fixed mistype. NFC.
llvm-svn: 327280
2018-03-12 15:18:35 +00:00
George Rimar 0984cfa9ab [ELF] - Removed excessive lookup. NFC.
llvm-svn: 327272
2018-03-12 14:15:38 +00:00
Nico Weber f06ae4f3b4 Make lld-link shout at me less.
This makes the output of some flag names in warning messages consistent with
the output of /? and the output of flags in most other diagnostics.

https://reviews.llvm.org/D44307

llvm-svn: 327261
2018-03-12 12:45:40 +00:00
George Rimar e3f198d58a [ELF] - Change consume()->expect() in INSERT AFTER parsing.
AFTER keyword is mandatory and consume() was 
used by mistake here. We accepted broken script before
this patch, testcase shows the issue.

llvm-svn: 327260
2018-03-12 12:34:43 +00:00
Nico Weber 11a6db3027 [lld-link] For suppressible warnings, print the warning number.
The warning can be suppressed by passing the number to /ignore:.
https://reviews.llvm.org/D44297

llvm-svn: 327257
2018-03-12 12:04:17 +00:00
Peter Smith 18aa0be36e For most Targets the _GLOBAL_OFFSET_TABLE_ symbol is expected to be at
the start of the .got.plt section so that _GLOBAL_OFFSET_TABLE_[0] =
reserved value that is by convention the address of the dynamic section.
Previously we had defined _GLOBAL_OFFSET_TABLE_ as either the start or end
of the .got section with the intention that the .got.plt section would
follow the .got. However this does not always hold with the current
default section ordering so _GLOBAL_OFFSET_TABLE_[0] may not be consistent
with the reserved first entry of the .got.plt.

X86, X86_64, Arm and AArch64 will use the .got.plt. Mips and Power use .got

Fixes PR36555

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

llvm-svn: 327248
2018-03-11 20:58:18 +00:00
Sam Clegg c1be8230ef [WebAssembly] Improve logging and comments around relocations. NFC.
Differential Revision: https://reviews.llvm.org/D44350

llvm-svn: 327232
2018-03-11 01:35:02 +00:00
Rui Ueyama 72a9a2321f [WebAssembly] Remove a second parameter from toString().
toString(T) is a stringize function for an object of type T. Each type
that has that function defined should know how to stringize itself, and
there should be one string representation of an object. Passing a
"supplemental" argument to toString() breaks that princple. We shouldn't
add a second parameter to that function.

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

llvm-svn: 327182
2018-03-09 22:59:34 +00:00
Fangrui Song 17208f1ef9 [ELF] Add elf64lppc emulation.
Subscribers: emaste, arichardson, llvm-commits

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

llvm-svn: 327177
2018-03-09 22:11:46 +00:00
Fangrui Song 0c483024e4 [ELF] Convert {read,write}*be to endianness-aware read/write.
Subscribers: emaste, nemanjai, arichardson, kbarton, llvm-commits

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

llvm-svn: 327156
2018-03-09 18:03:22 +00:00
Peter Collingbourne 04ff122632 ELF: Do not create multiple thunks for the same virtual address.
This avoids creating multiple thunks for symbols with aliases or which
belong to ICF'd sections. This patch reduces the size of Chromium for
Android by 260KB (0.8% of .text).

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

llvm-svn: 327154
2018-03-09 17:54:43 +00:00
Nicholas Wilson 2e55ee77e2 [WebAssembly] Handle weak undefined functions with a synthetic stub
This error case is described in Linking.md. The operand for call requires
generation of a synthetic stub.

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

llvm-svn: 327151
2018-03-09 17:06:38 +00:00
Nicholas Wilson ebda41f812 [WebAssembly] Refactor order of creation for SyntheticFunction
Previously we created __wasm_call_ctors with null InputFunction, and
added the InputFunction later. Now we create the SyntheticFunction with
null body, and set the body later.

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

llvm-svn: 327149
2018-03-09 16:43:05 +00:00
David Zarzycki 3e77b20dba [CMake] Properly conditionalize installation of lld libraries
In what appears to be a copy-and-paste error, lld currently only
installs libraries if the lld tools are configured to build.

Instead, lld should allow the libraries to be installed even if the lld
tools are not being built. Additionally, if users want to only install
the tools and not the libraries, the LLVM way of doing that is by
checking for LLVM_INSTALL_TOOLCHAIN_ONLY.

This fixes PR35960.

llvm-svn: 327126
2018-03-09 13:09:36 +00:00
Nico Weber 0771c604c9 [lld-link] Add support for /ignore:4037.
Fixes PR36657.
https://reviews.llvm.org/D44286

llvm-svn: 327124
2018-03-09 12:41:04 +00:00
Zachary Turner b575f46b6d Resubmit "Write a hash of the executable into the PE timestamp fields."
This fixes the broken tests that were causing failures.  The tests
before were verifying that the time stamp was 0, but now that we
are actually writing a timestamp, I just removed the match against
the timestamp value.

llvm-svn: 327049
2018-03-08 19:33:47 +00:00
George Rimar 1136ec64e8 [ELF] - Fix crash relative to SHF_LINK_ORDER sections.
Our code assumes all input sections in an output SHF_LINK_ORDER
section has SHF_LINK_ORDER flag. We do not check that and that can cause a crash.

That happens because we call 
std::stable_sort(Sections.begin(), Sections.end(), compareByFilePosition);, 
where compareByFilePosition predicate does not expect to see
null when calls getLinkOrderDep. 

The same might happen when sections refer to non-regular sections. 
Test cases demonstrate the issues, patch fixes them.

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

llvm-svn: 327006
2018-03-08 15:06:58 +00:00
George Rimar 9e2c8a9db1 [ELF] - Support "INSERT AFTER" statement.
This implements INSERT AFTER in a following way:

During reading scripts it collects all insert statements.
After we done and read all files it inserts statements into script commands list.

With that:
* Rest of code does know nothing about INSERT.
* Approach is straightforward and have no visible limitations.
* It is also easy to support INSERT BEFORE (was seen in clang code once).
* Should work for PR35877 and similar cases.

Cons:
* It assumes we have "main" scripts that describes sections.

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

llvm-svn: 327003
2018-03-08 14:54:38 +00:00
Hans Wennborg aee5881a85 [COFF] Make the DOS stub a real DOS program
It only adds a few bytes and is nice for backward compatibility.

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

llvm-svn: 327001
2018-03-08 14:27:28 +00:00
Heejin Ahn 2dce27d852 [WebAssembly] Add except_ref as a first-class type
Summary:
Add except_ref as a first-class type, according to the [[https://github.com/WebAssembly/exception-handling/blob/master/proposals/Level-1.md | Level 1 exception handling proposal ]].
Companion to D43706.

Reviewers: sbc100

Subscribers: jfb, dschuff, jgravelle-google, sunfish, llvm-commits

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

llvm-svn: 326986
2018-03-08 04:06:57 +00:00
Rui Ueyama e66d7a798f Return early. NFC.
We don't need to handle an object file having more than one symbol table,
so as soon as we find the first one, we can process it and then return
from the function.

llvm-svn: 326977
2018-03-08 01:22:30 +00:00
Sam Clegg 7f81418183 [WebAssembly] Honor --allow-undefined even for explicit exports
When a symbol is exported via --export=foo but --allow-undefined
is also specified, the symbol is now allowed to be undefined.
Previously we were special casing such symbols.

This combinations of behavior is exactly what emescripten
requires. Although we are trying hard not to allow emscripten
specific features in lld, this one makes sense.

Enforce this behavior by added this case to test/wasm/undefined.ll.

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

llvm-svn: 326976
2018-03-08 01:16:05 +00:00
Rui Ueyama c13d858b6d Simplify LazyobjFile and readElfSymbols.
addElfSymbols and readJustSymbolsFile still has duplicate code, but
I didn't come up with a good idea to eliminate them. Since this patch
is an improvement, I'm sending this for review.

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

llvm-svn: 326972
2018-03-08 01:05:58 +00:00
Fangrui Song d8139348fb [ELF] Update test/ELF/eh-frame-hdr-augmentation.s
llvm-svn: 326944
2018-03-07 21:25:58 +00:00
Zachary Turner 0b4af0434b Revert "Write a hash of the executable into the PE timestamp fields."
This is breaking a couple of tests, so I'm reverting temporarily
until I can get everything resolved properly.

llvm-svn: 326943
2018-03-07 21:22:10 +00:00
Rui Ueyama 301305fd3d Use exact uint32_t for uint32_t ELF field. NFC.
llvm-svn: 326934
2018-03-07 19:25:36 +00:00
Rui Ueyama 5aa2db1e12 Initialize a member in C++11 style. NFC.
llvm-svn: 326933
2018-03-07 19:25:27 +00:00
Matt Morehouse 915b4dbf8a [lld] Attempt to appease buildbot.
r326903 broke the conflict-debug-variable.s test.

llvm-svn: 326931
2018-03-07 19:18:14 +00:00
Zachary Turner 69f3347b56 Write a hash of the executable into the PE timestamp fields.
Windows tools treats the timestamp fields as sort of a build id,
using it to archive executables on a symbol server, as well as
for matching executables to PDBs.  We were writing 0 for these
fields, which would cause symbol servers to break as they are
indexed in the symbol server based on this value.

Although the field is called timestamp, it can really be any
value that is unique per build, so to support reproducible builds
we use a hash of the executable here.

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

llvm-svn: 326920
2018-03-07 18:13:41 +00:00
George Rimar bf3c384673 [ELF] - Adjust rangeToString to report ranges in a different format.
It was raised during the review of D43819.

LLD usually use [X, Y] for reporting ranges, like below:
"relocation R_386_16 out of range: 65536 is not in [0, 65535]"

Patch changes rangeToString() to do the same.

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

llvm-svn: 326918
2018-03-07 17:54:25 +00:00
Rui Ueyama b0084a0eee Revert r326911: Improve --warn-symbol-ordering.
This reverts commit r326911 because it was committed by accident.

llvm-svn: 326914
2018-03-07 17:24:46 +00:00
Rui Ueyama e1847da924 Rename Indent{1,2} -> Indent{8,16}.
llvm-svn: 326912
2018-03-07 17:15:15 +00:00
Rui Ueyama ebfab927d9 Improve --warn-symbol-ordering.
Summary:
I originally tried to simplify code and then noticed that lld doesn't
do what it tells to the user by warn(). It says "unable to order
discarded symbol" but it actually can for sections eliminated by ICF.
With this patch, lld doesn't sort such sections.

Reviewers: jhenderson, rafael

Subscribers: emaste, arichardson, llvm-commits

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

llvm-svn: 326911
2018-03-07 17:15:06 +00:00
James Henderson cb4c19f315 [ELF] Prevent crash when reporting errors if debug line cannot be parsed
LLD uses the debug info and debug line sections to determine the location of
e.g. references to undefined symbols, when producing error messages. In the
event that debug info was present, but debug line parsing failed for some
reason, then a nullptr would end up being dereferenced by the location-lookup
code.

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

Reviewers: grimar
llvm-svn: 326899
2018-03-07 15:22:58 +00:00
Nicholas Wilson dbd90bf8d1 [WebAssembly] Run clang-format. NFC
llvm-svn: 326896
2018-03-07 13:28:16 +00:00
George Rimar 527bfd7a48 [ELF] - Recommit r326892,r326893 "[ELF] - Report LMA region overflows."
With fix: add missing "RUN:" prefix to test case.

Original commit message:
We do not report LMA region overflows currently.
Both GNU linkers do that. The patch implements it.

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

llvm-svn: 326895
2018-03-07 12:44:18 +00:00
George Rimar 06846c2251 [ELF] - Revert r326892, r326893.
Bots are still unhappy:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/26259

llvm-svn: 326894
2018-03-07 12:33:00 +00:00
George Rimar 64b2ba1f81 [ELF] - Fix build bot after r326892 "[ELF] - Report LMA region overflows."
Removed excessive line from testcase.

llvm-svn: 326893
2018-03-07 12:16:26 +00:00
George Rimar 97e054e00d [ELF] - Report LMA region overflows.
We do not report LMA region overflows currently.
Both GNU linkers do that. The patch implements it.

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

llvm-svn: 326892
2018-03-07 11:54:30 +00:00
George Rimar 54baa5f45f [ELF] - Allow discarding .hash and .gnu.hash from linker script.
Currently, LLD segfaults when linker script attempts to discard
one of the hash sections. This patch fixes that.

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

llvm-svn: 326891
2018-03-07 11:47:15 +00:00
Nicholas Wilson 06e0d17cf5 [WebAssembly] Remove duplicated line of code and unreachable check. NFC
Differential Revision: https://reviews.llvm.org/D44146

llvm-svn: 326888
2018-03-07 11:15:47 +00:00
Nicholas Wilson 8269f37ce6 [WebAssembly] Use StringSaver to retain ownership of ctor function body. NFC
Differential Revision: https://reviews.llvm.org/D44149

llvm-svn: 326885
2018-03-07 10:37:50 +00:00
Rui Ueyama 9f0c36e7a9 Split long lines in a test file.
llvm-svn: 326850
2018-03-07 00:07:26 +00:00
Rui Ueyama 9e0171fbb6 Do not create temporary strings just to print out spaces. NFC.
llvm-svn: 326841
2018-03-06 22:48:46 +00:00
Rui Ueyama 09fcd4c34c Implement --just-symbols.
Differential Revision: https://reviews.llvm.org/D39348

llvm-svn: 326835
2018-03-06 21:25:37 +00:00
Rafael Espindola ddb33c0961 Improve duplicated version handling.
It looks like the problem that caused us to originally warn instead of
error was that of a symbol being assigned to the same version twice.

Now we don't warn if a symbol is assigned to the same version twice,
but error if it is assigned to multiple.

This fixes pr28342.

llvm-svn: 326813
2018-03-06 17:05:12 +00:00
Rui Ueyama 067617f9ba Remove redundant casts.
llvm-svn: 326753
2018-03-05 23:50:45 +00:00
Nicholas Wilson 94d3b16101 [WebAssembly] Reorder reloc sections to come after symtab
This matches LLVM change D43940.

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

llvm-svn: 326693
2018-03-05 12:33:58 +00:00
George Rimar 162d436c8e [ELF] - Support moving location counter when MEMORY is used.
We do not expand memory region correctly for following scripts:

.foo.1 : 
 {
   *(.foo.1)
   . += 0x1000;
 } > ram
Patch generalizes expanding of output sections and memory
regions in one place and fixes the issue.

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

llvm-svn: 326688
2018-03-05 10:54:03 +00:00
George Rimar 7b91e2133e [ELF] - Report location for div/mod by zero.
"division by zero" or "modulo by zero" are not
very informative errors and even probably confusing
as does not let to know that error is coming from linker script.
Patch adds location reporting.

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

llvm-svn: 326686
2018-03-05 10:02:44 +00:00
Rafael Espindola e3a6062844 Simplify. NFC.
Since r321982 we don't set VersionId in scanShlibUndefined, which
makes InVersionScript redundant.

llvm-svn: 326641
2018-03-03 02:13:50 +00:00
Rui Ueyama e89b0ef0a0 [WebAssembly] Simplify createDefined. NFC.
Differential Revision: https://reviews.llvm.org/D43849

llvm-svn: 326615
2018-03-02 21:19:55 +00:00
Nicholas Wilson 36f14f41e6 [WebAssembly] Rename global types to match the notation in the spec
llvm-svn: 326583
2018-03-02 14:54:34 +00:00
Nicholas Wilson f2f6d5e03b [WebAssembly] Export non-hidden defined data symbols via wasm globals
This fixes a TODO introduced in rLLD325861.

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

llvm-svn: 326581
2018-03-02 14:51:36 +00:00
Nicholas Wilson f6dbc2edee [WebAssembly] Pass ownership of body to SyntheticFunction. NFC
This avoids the Writer unnecessarily having a member to retain ownership
of the function body.

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

llvm-svn: 326580
2018-03-02 14:48:50 +00:00
Nicholas Wilson cb81a0c9d9 [WebAssembly] Add validation for init function signature
Differential Revision: https://reviews.llvm.org/D43947

llvm-svn: 326579
2018-03-02 14:46:54 +00:00
George Rimar 97785af464 [ELF] - Report error when memory region is overflowed by data commands.
LLD can not catch a memory area overflow when using a data command.
If we have the script below:

.foo : 
{
  *(.foo)
  BYTE(0x1)
} > ram

where BYTE overflows the ram region, we do not report it currently.
Patch fixes that.

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

llvm-svn: 326545
2018-03-02 08:11:58 +00:00
Ed Maste dfcd846b26 Update man page for long opts that accept = after r326506
Also remove the space between --lto-O and value, as the option with a
space is not accepted at present.

Leave --opt-remarks-filename as it does not currently accept the = form.

llvm.org/pr36563

llvm-svn: 326536
2018-03-02 02:57:12 +00:00
Rui Ueyama dcf6234dad [WebAssembly] Simplify COMDAT handling.
Differential Revision: https://reviews.llvm.org/D43966

llvm-svn: 326509
2018-03-01 23:29:05 +00:00
Rui Ueyama cdd5fb5087 Report an error if you try to link against .dll instead of .lib.
It is a usage error to feed a .dll file instead of a .dll to COFF linker.
Previously, lld failed with a mysterious error message. Now we reject
it at the driver.

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

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

llvm-svn: 326507
2018-03-01 23:11:30 +00:00
Rui Ueyama 036ed36f0a Accept both `--foo bar` and `--foo=bar` styles options.
GNU linkers by convention supports both `--foo bar` and `--foo=bar` styles
for all long options that take arguments.

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

llvm-svn: 326506
2018-03-01 23:06:10 +00:00
Rui Ueyama b3ee432b6b Rename a test file and fix indentation.
llvm-svn: 326504
2018-03-01 23:01:41 +00:00
Rui Ueyama 7c18abf99a Set DF_TEXTREL to executables that need text relocations.
Summary:
If an executable needs text relocations, it should be marked as such so
that the loader can prepare for text relocations. We currently create a
dummy segment with DT_TEXTREL for that purpose.

Generic ABI as of 2000 [1] mentioned that "Its [DT_TEXTREL's] use
has been superseded by the DF_TEXTREL flag". However, it's actually not
superseded even after 18 years. OpenBSD and musl recognize only DT_TEXTREL.
So we still need to set both.

[1] http://www.sco.com/developers/gabi/2000-07-17/ch5.dynamic.html

Reviewers: rafael

Subscribers: emaste, llvm-commits, arichardson

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

llvm-svn: 326503
2018-03-01 22:56:52 +00:00
Rafael Espindola 2e4bcb0095 Don't ingoned --enable-new-dtags.
llvm-svn: 326498
2018-03-01 22:23:51 +00:00
Rui Ueyama b34bd34fd2 [MinGW] Fix --{start,end}-group.
Currently --start-group=foo is accidentally accepted by the MinGW driver.

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

llvm-svn: 326478
2018-03-01 20:38:38 +00:00
Ed Maste 9a289f7b72 Correct man page description for --section-start
The argument is section=address, not just address.

(For compatibility with GNU linkers we need to, but do not yet, accept
--section-start=section=address.)

llvm-svn: 326463
2018-03-01 19:02:41 +00:00
Ed Maste dde3a9170c Where possible use --long-opt=value in lld man page
We intend to maintain compatibility with GNU ld, and in the GNU world
long options are conventionally specified as --long-option=value. For
whatever reason GNU ld.bfd accepts both --long-option value and
--long-option=value, but documents the former. Follow suit.

Some lld long options do not accept the = form; this is probably a bug
to be fixed (along with a man page update).

Reported by Ingo Schwarze, for --entry.

llvm-svn: 326459
2018-03-01 18:40:11 +00:00
Sam Clegg 8518e7ded5 [WebAssembly] Use uint8_t for single byte values to match the spec
Differential Revision: https://reviews.llvm.org/D43922

llvm-svn: 326455
2018-03-01 18:06:39 +00:00
Zachary Turner c6a75a69f1 [PDB] Defer writing the build id until the rest of the PDB is written.
For now this is NFC, but this small refactor opens the door to
letting us embed a hash of the PDB in the build id field of the
PDB.

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

llvm-svn: 326453
2018-03-01 18:00:29 +00:00
Ed Maste a83e226c2f Correct markup and nits in ld.lld man page
Patch by Ingo Schwarze

llvm-svn: 326446
2018-03-01 16:02:19 +00:00
Rafael Espindola e75b42ee4e Don't allocate a header bellow address 0.
With the current code if the script has a PHDRS we always obey and try
to allocate a header. This can cause Min - HeaderSize to underflow.

It looks like bfd actually prints an error for this case. With this
patch we do the same.

Found while looking at pr36515.

llvm-svn: 326441
2018-03-01 15:25:46 +00:00
George Rimar b068b03793 [ELF] - Don't crash on broken MEMORY declaration.
LLD crashes with broken scripts shown in testcase,
because fails to read memory regon name and accesses
MemoryRegions's element which is nullptr.
Patch fixes it.

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

llvm-svn: 326431
2018-03-01 12:36:01 +00:00
George Rimar c4df670dea [ELF] - Do not remove empty sections that use symbols in expressions.
This is PR36515.

Currenly if we have a script like .debug_info 0 : { *(.debug_info) },
we would not remove this section and keep it in the output.
That does not work, because it is common case for
debug sections to have a zero address expression.
Patch changes behavior so that we remove only sections
that do not use symbols in its expressions.

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

llvm-svn: 326430
2018-03-01 12:27:04 +00:00
George Rimar f3e93b23f7 [ELF] - Fix eh-frame-reloc-out-of-range.test.
Was broken after recent testcases changes.

llvm-svn: 326427
2018-03-01 10:38:51 +00:00
Nicholas Wilson 4cdf5b8fa0 [WebAssembly] Reorder exports to match symbol table order
This fixes a TODO introduced in rLLD325861.

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

llvm-svn: 326424
2018-03-01 09:38:02 +00:00
Rui Ueyama 05660daced Convert more tests as linker scripts instead of assembly.
llvm-svn: 326415
2018-03-01 04:21:42 +00:00
Rui Ueyama 0931e957ff [WebAssembly] Remove unused forward declaration.
llvm-svn: 326411
2018-03-01 02:37:26 +00:00
Rui Ueyama 37ad8161e4 Do not create multiple NOTE segments.
Previously, we didn't try to make effort to put .note sections next
to each other in the output file, so two .note sections were likely
to be stored to two separate NOTE segments. That's undesirable because
we should create as few segments as possible in general.

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

llvm-svn: 326410
2018-03-01 02:31:29 +00:00
Rafael Espindola b4267dfc10 Expand test a bit.
It now includes both linkerscript and non linkerscript variants.

Extracted from a patch by Rui while I was trying to figure out what
exactly was changing.

llvm-svn: 326409
2018-03-01 02:25:40 +00:00
Rui Ueyama dc32dc1770 Convert more .s files to linker script files.
Summary:
This change removes large "echo" commands from the test by writing
tests themselves as linker scripts.

Reviewers: rafael

Subscribers: emaste, javed.absar, llvm-commits, arichardson

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

llvm-svn: 326403
2018-03-01 01:19:12 +00:00
Rafael Espindola 852bd5c062 Simplify removing empty output sections.
With this the meaning of the Live bit in output sections is clear: we
have at some point added a input section into it.

llvm-svn: 326401
2018-03-01 01:08:00 +00:00
Fangrui Song 3816c78490 [ELF] Fix a test comment. NFC
llvm-svn: 326400
2018-03-01 01:05:04 +00:00
Sam Clegg ea397f67e3 [WebAssembly] Use Twine rather than StringRef for logging messages
Also add missing tracing to writeU8.

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

llvm-svn: 326398
2018-03-01 00:42:57 +00:00
Rui Ueyama 67d6908f59 Use DenseMap::lookup() instead of find() and a hand-written null check.
llvm-svn: 326382
2018-02-28 23:03:06 +00:00
Rui Ueyama b961abc886 [WebAssembly] Reduce code repetition. NFC.
Differential Revision: https://reviews.llvm.org/D43910

llvm-svn: 326379
2018-02-28 22:51:51 +00:00
Rui Ueyama 3fffe1f02d Make sure that clang-format doesn't reorder include files.
clang-format won't reorder include files if there is a blank line.
Thanks to Nico for the tips.

llvm-svn: 326371
2018-02-28 21:32:24 +00:00
Rui Ueyama 2dfe49a441 Write some tests as linker scripts instead of assembly files.
Some linker script test cases contain only a few lines of assembly
and a long linker script. Such tests are easier to maintain if we
write the main test file as a linkier script instead of assembly.

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

llvm-svn: 326363
2018-02-28 20:22:42 +00:00
Rui Ueyama 7440135e62 Attempt to build breakage caused by r326339.
clang-format automatically sorted the #include lines, but I believe
Windows.h needs to be included before Dbghelp.h.

llvm-svn: 326360
2018-02-28 20:11:33 +00:00
Sam Clegg 45f984e625 [WebAssembly] Remove unneeded --no-gc-sections flag from tests. NFC.
Differential Revision: https://reviews.llvm.org/D43889

llvm-svn: 326356
2018-02-28 19:40:03 +00:00
Rui Ueyama 39ba31ff50 Add "%" operator to the linker script.
This patch improves compatibility with GNU linkers.

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

llvm-svn: 326348
2018-02-28 18:38:13 +00:00
Rui Ueyama 1d20222a48 Inline a trivial function. NFC.
llvm-svn: 326347
2018-02-28 18:25:00 +00:00
Zachary Turner 3868cfd503 Fix use after free in PDB linker.
When merging in types from a type server PDB, we would use a
pointer into the type server PDB's mapped file buffer directly
to avoid copying data.  However, we would close the type server
PDB after we finished merging in its types, which would unmap
all of its memory.  This would lead to a use after free.

We fix this by making a strong reference in the PDBLinker class
to all referenced type server PDBs, thereby making it safe to
hold pointers into its memory mapped contents.

This fixes llvm.org/pr36455

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

llvm-svn: 326345
2018-02-28 18:09:18 +00:00
Rafael Espindola 367bfce611 Simplify. NFC.
llvm-svn: 326344
2018-02-28 18:05:37 +00:00
Rui Ueyama 29abfe4a8f [WebAssembly] Use toArrayRef. NFC.
Differential Revision: https://reviews.llvm.org/D43855

llvm-svn: 326340
2018-02-28 17:43:15 +00:00
Rui Ueyama ee17371897 Merge {COFF,ELF}/Strings.cpp to Common/Strings.cpp.
This should resolve the issue that lld build fails in some hosts
that uses case-insensitive file system.

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

llvm-svn: 326339
2018-02-28 17:38:19 +00:00