Commit Graph

18 Commits

Author SHA1 Message Date
Sam Clegg 0f0a428738 [WebAssembly] Remove special handling of entry point export.
Its much easier to export it via setHidden(false), now that
that is a thing.

As a side effect the start function is not longer always exports first
(becuase its being exported just like all the other function).

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

llvm-svn: 323025
2018-01-20 01:44:45 +00:00
Sam Clegg 096aa50ba4 [WebAssembly] Remove redundant function: addSyntheticUndefinedFunction. NFC.
Differential Revision: https://reviews.llvm.org/D42327

llvm-svn: 323024
2018-01-20 01:40:17 +00:00
Sam Clegg e0f6fcd0d9 [WebAssembly] Add COMDAT support
See https://bugs.llvm.org/show_bug.cgi?id=35533, and D40844

Things covered:
* Removing duplicate data segments (as determined by COMDATs emitted
  by the frontend)
* Removing duplicate globals and functions in COMDATs
* Checking that each time a COMDAT is seen it has the same symbols
  as at other times (ie it's a stronger check than simply giving all
  the symbols in the COMDAT weak linkage)

Patch by Nicholas Wilson!

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

llvm-svn: 322415
2018-01-12 22:25:17 +00:00
Sam Clegg 5068685678 [WebAssembly] Create synthetic __wasm_call_ctors function
This change create a new synthetic function in the final
output binary which calls the static constructors in sequence.

See: https://github.com/WebAssembly/tool-conventions/issues/25

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

llvm-svn: 322388
2018-01-12 18:35:13 +00:00
Sam Clegg 5fa274bea4 [WebAssembly] Add InputChunk as common base class for InputSegment and InputFunction. NFC.
Differential Revision: https://reviews.llvm.org/D41419

llvm-svn: 322148
2018-01-10 01:13:34 +00:00
Sam Clegg 20db381b90 [WebAssembly] Refactor symbol and symbol table to remove WasmSymbol references
This WasmSymbol types comes directly from the input objects
but we want to be able to represent synthetic symbols too.

This is more in line with how the ELF linker represents symbols.

This change also removes the logic from Symbol::getVirtualAddress
for finding the global address and instead has the InputFile
provide this.

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

llvm-svn: 322145
2018-01-10 00:52:20 +00:00
Sam Clegg 8d146bbc0c [WebAssembly] Output functions individually
The code section is now written out one function
at a time rather than all the functions in a given
objects being serialized at once.

This change lays the groundwork for supporting
--gc-sections.

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

llvm-svn: 322138
2018-01-09 23:56:44 +00:00
Sam Clegg 1cf31bbca5 [WebAssmebly] Fix references to weak aliases
Corresponding LLVM change: https://reviews.llvm.org/D41472

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

llvm-svn: 321244
2017-12-21 02:43:39 +00:00
Sam Clegg f738bccd76 [WebAssembly] Fix typo
Patch by Nicholas Wilson

llvm-svn: 321097
2017-12-19 18:36:31 +00:00
Sam Clegg 31de2f0ccf [WebAssembly] Add -u/--undefined argument handling
Adds a new argument to wasm-lld, `--undefined`, with
similar semantics to the ELF linker. It pulls in symbols
from files contained within a `.a` archive, forcing them
to be included even if the translation unit would not
otherwise be pulled in.

Patch by Nicholas Wilson

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

llvm-svn: 320004
2017-12-07 03:19:53 +00:00
Sam Clegg 74fe0ba105 [WebAssembly] Fix symbol exports under -r/--relocatable
This change cleans up the way wasm exports and globals
are generated, particualrly for -r/--relocatable where
globals need to be created and exported in order for
output relocations which reference them.

Remove the need for a per file GlobalIndexOffset and
instead set the output index for each symbol directly.
This simplifies the code in several places.

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

llvm-svn: 320001
2017-12-07 01:51:24 +00:00
Sam Clegg a681a1167e [WebAssembly] Remove wasm/Strings.cpp+h
This file contained only a single function that was only
really needed in one place, so just inline it.

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

llvm-svn: 319876
2017-12-06 03:10:39 +00:00
Sam Clegg 49ed926287 [WebAssembly] Fix typos
Patch by Nicholas Wilson

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

llvm-svn: 319506
2017-12-01 00:53:21 +00:00
Sam Clegg b862159683 [WebAssembly] Allow function signature checking at link time
This change allows checking of function signatures but
does not yes enable it by default.  In this mode, linking
two objects that were compiled with a different signatures
for the same function will produce a link error.

New options for enabling and disabling this feature have been
added: (--check-signatures/--no-check-signatures).

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

llvm-svn: 319396
2017-11-30 01:40:08 +00:00
Rui Ueyama 2017d52b54 Move Memory.{h,cpp} to Common.
Differential Revision: https://reviews.llvm.org/D40571

llvm-svn: 319221
2017-11-28 20:39:17 +00:00
Sam Clegg a80d94d52b Rename `Symtab` private memory to avoid confusion with global `Symtab`
This is also consistent with SymVector that exists in COFF port
and soon to be added to the wasm port.

Split off as part of https://reviews.llvm.org/D40371

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

llvm-svn: 319113
2017-11-27 23:16:06 +00:00
Sam Clegg e2ed092e01 Consistent use of <internal> when displaying internal symbol names
Differential Revision: https://reviews.llvm.org/D40510

llvm-svn: 319108
2017-11-27 22:49:16 +00:00
Sam Clegg c94d393ad5 [WebAssembly] Initial wasm linker implementation
This linker backend is still a work in progress but is
enough to link simple programs including linking against
library archives.

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

llvm-svn: 318539
2017-11-17 18:14:09 +00:00