Summary:
This was causing large addresses to be emitted as negative numbers,
which rightfully caused crashes in binaryen.
Reviewers: aheejin, dschuff
Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64612
llvm-svn: 365930
This patch does the same thing as r365595 to other subdirectories,
which completes the naming style change for the entire lld directory.
With this, the naming style conversion is complete for lld.
Differential Revision: https://reviews.llvm.org/D64473
llvm-svn: 365730
This puts handling of undefined symbols in a single location. Its
also more in line with the ELF backend which only reports undefined
symbols based on relocations.
One side effect is that we no longer report undefined symbols that are
only referenced in GC'd sections.
This also fixes a crash reported in the emscripten toolchain:
https://github.com/emscripten-core/emscripten/issues/8930.
Differential Revision: https://reviews.llvm.org/D64280
llvm-svn: 365553
This should always have been ".data". Without this we treat the
section as a user-defined section in other places (such as the
generation of __start/__stop symbols).
Differential Revision: https://reviews.llvm.org/D64439
llvm-svn: 365547
We should be generating one __start/__stop pair per output segment
not per input segment. The test wasn't catching this because it was
only linking a single object file.
Fixes PR41565
Differential Revision: https://reviews.llvm.org/D64148
llvm-svn: 365308
Summary:
Adds `--passive-segments` and `--active-segments` flags to control
what kind of segments are emitted. For now the default is always
to emit active segments so this is not a breaking change, but in
the future the default will be changed to passive segments when
shared memory is requested and active segments otherwise. When
passive segments are emitted, corresponding memory.init and
data.drop instructions are emitted in a `__wasm_init_memory`
function that is automatically called at the beginning of
`__wasm_call_ctors`.
Reviewers: sbc100, aheejin, dschuff
Subscribers: azakai, dschuff, jgravelle-google, sunfish, jfb, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59343
llvm-svn: 365088
Summary:
This is needed for address sanitizer on Emscripten. As everything in
memory starts at the value passed to --global-base, everything before
that can be used as shadow memory.
This symbol is added so that the library for the ASan runtime can know
where the shadow memory ends and real memory begins.
This is split from D63742.
Reviewers: tlively, aheejin, sbc100
Subscribers: sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63833
llvm-svn: 364467
When a function is excluded via comdat we shouldn't add it to the
final list of init functions.
Differential Revision: https://reviews.llvm.org/D62983
llvm-svn: 362769
Summary:
Add the names of the input files responsible for each error to the
messages.
Reviewers: sbc100, azakai
Subscribers: dschuff, jgravelle-google, aheejin, sunfish, jfb, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62704
llvm-svn: 362162
This can be useful for post-link tools and for testing. Sometimes
it can be useful to produces a regular executable but with relocations
preserved.
Differential Revision: https://reviews.llvm.org/D62378
llvm-svn: 361635
Summary:
Before we can assign entries in the function of global index space
we need to know the total number of function and global imports
respectively.
To avoid programmer error this change seals that imports section before
assigned function and global index space. Any attempt to add an import
after the section is sealed will assert.
The lack this such as check caused https://reviews.llvm.org/D61876
to be reverted. I'm also trying to craft a test case the this
failure.
Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62240
llvm-svn: 361470
This reverts commit 7804dbddcc.
This change broke a bunch of tests of the WebAssembly waterfall.
Will hopefully reland with increased test coverage.
llvm-svn: 361273
Major refactor to better match the structure of the ELF linker.
- Split out relocation processing into scanRelocations
- Split out synthetic sections into their own classes.
Differential Revision: https://reviews.llvm.org/D61811
llvm-svn: 361233
Previously these sections were being generated during their
constructors. This moves the work to finalizeContent, and also does
the same for the relocation sections because their contents depends
on the final layout too.
This change is part of a larger refactor to how we deal with synthetic
sections: https://reviews.llvm.org/D61811
Differential Revision: https://reviews.llvm.org/D61971
llvm-svn: 360941
The current PIC model for WebAssembly is more like ELF in that it
allows symbol interposition.
This means that more functions end up being addressed via the GOT
and fewer directly added to the wasm table.
One effect is a reduction in the number of wasm table entries similar
to the previous attempt in https://reviews.llvm.org/D61539 which was
reverted.
Differential Revision: https://reviews.llvm.org/D61772
llvm-svn: 360402
When generating PIC output only relocations of type
R_WASM_TABLE_INDEX_REL_SLEB should generate table entries.
R_WASM_TABLE_INDEX_I32 get resolved at runtime via the auto-generated
__wasm_apply_relocs functions.
R_WASM_TABLE_INDEX_SLEB are not allowed in PIC code.
Differential Revision: https://reviews.llvm.org/D61539
llvm-svn: 360165
Make some small adjustment while touching the code: make parameters
const, use less_first(), etc.
Differential Revision: https://reviews.llvm.org/D60989
llvm-svn: 358943
We can't (currently) meaningfully resolve certain types of relocations
against undefined data symbols. Previously when `--allow-undefined` was
used we were treating such relocation much like weak data symbols and
simply inserting zeros. This change turns such use cases in to an
error.
This means that `--allow-undefined` is no longer effective for data
symbols.
Fixes https://bugs.llvm.org/show_bug.cgi?id=40364
Differential Revision: https://reviews.llvm.org/D60882
llvm-svn: 358899
Summary:
The DataCount section is necessary for the bulk memory operations
memory.init and data.drop to validate, but it is not recognized by
engines that do not support bulk memory, so emit the section only if
bulk-memory is enabled.
Reviewers: aheejin, dschuff, sbc100
Subscribers: jgravelle-google, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60637
llvm-svn: 358798
This should have been part of rL357710 but was overlooked because
in our test code the function in question was also used in other
relocations that caused it to be added to the table anyway.
Differential Revision: https://reviews.llvm.org/D60296
llvm-svn: 357737
See https://reviews.llvm.org/D59860
The initial version of this change effected more than just the
error message. This version is scoped down to only effect the error
itself.
llvm-svn: 357328
Summary:
Makes it a linker error if the "atomics" feature is used but the user
does not opt in to shared memory or if "atomics" is disallowed but the
user does opt in to shared memory. Also check that an appropriate max
memory size is supplied if shared memory is used.
Reviewers: sbc100, aheejin
Subscribers: dschuff, jgravelle-google, sunfish, jfb, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59281
llvm-svn: 357310
Also Revert "[WebAssembly] Fix typo from rL357143"
This reverts commit 0805ec5f7b and
a9958fc30d
(rL357143 and rL357144)
They cause failures with address-taken extern (JS) functions
in emscripten.
llvm-svn: 357224
This change implements lowering of references global symbols in PIC
mode.
This change implements lowering of global references in PIC mode using a
new @GOT reference type. @GOT references can be used with function or
data symbol names combined with the get_global instruction. In this case
the linker will insert the wasm global that stores the address of the
symbol (either in memory for data symbols or in the wasm table for
function symbols).
For now I'm continuing to use the R_WASM_GLOBAL_INDEX_LEB relocation
type for this type of reference which means that this relocation type
can refer to either a global or a function or data symbol. We could
choose to introduce specific relocation types for GOT entries in the
future. See the current dynamic linking proposal:
https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md
Differential Revision: https://reviews.llvm.org/D54647
llvm-svn: 357022
Do not pipe binary data between processes in lit tests this time,
since it turns out that can break on Windows.
This reverts commit 84c8652fc3.
llvm-svn: 356975
Summary:
Adds --check-features and --no-check-features. The default for now is
to enable the checking, but this might change in the future.
Also adds --features=foo,bar for precisely controlling the features
used in the output binary.
Depends on D59173.
Reviewers: sbc100, aheejin
Subscribers: dschuff, jgravelle-google, sunfish, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59274
llvm-svn: 356805
Summary:
Implements a new target features section in assembly and object files
that records what features are used, required, and disallowed in
WebAssembly objects. The linker uses this information to ensure that
all objects participating in a link are feature-compatible and records
the set of used features in the output binary for use by optimizers
and other tools later in the toolchain.
The "atomics" feature is always required or disallowed to prevent
linking code with stripped atomics into multithreaded binaries. Other
features are marked used if they are enabled globally or on any
function in a module.
Future CLs will add linker flags for ignoring feature compatibility
checks and for specifying the set of allowed features, implement using
the presence of the "atomics" feature to control the type of memory
and segments in the linked binary, and add front-end flags for
relaxing the linkage policy for atomics.
Reviewers: aheejin, sbc100, dschuff
Subscribers: jgravelle-google, hiraditya, sunfish, mgrang, jfb, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59173
llvm-svn: 356610
For these types of relocations an absolute memory address is
required which is not possible for undefined data symbols. For symbols
that can be undefined at link time (i.e. external data symbols in
shared libraries) a different type of relocation (i.e. via a GOT) will
be needed.
Differential Revision: https://reviews.llvm.org/D59337
llvm-svn: 356310
When linking shared libraries, we import a mutable wasm global
to represent the address of each undefined data symbol.
This is a step towards supporting dynamic linking and shared
libraries.
Differential Revision: https://reviews.llvm.org/D59270
llvm-svn: 355988
This matches the ELF does. Update the comment in ELF/Symbols.h and
duplicate it in wasm/Symbols.h
This a followup on rL355580 and rL355577.
Differential Revision: https://reviews.llvm.org/D59075
llvm-svn: 355737