History log of /llvm-project/lld/wasm/SymbolTable.cpp (Results 1 – 25 of 146)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init
# 617278e7 29-Jan-2025 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Fix for shared library symbols WRT replacing lazy symbols (#124619)

The rule here, which I'm copying from the ELF linker, is that shared
library symbols should take presence, unl

[lld][WebAssembly] Fix for shared library symbols WRT replacing lazy symbols (#124619)

The rule here, which I'm copying from the ELF linker, is that shared
library symbols should take presence, unless the symbol has already be
extracted from the archive. e.g:

```
$ wasm-ld foo.a foo.so ref.o // .so wins
$ wasm-ld foo.a ref.o foo.so // .a wins
```

In the first case the shared library takes precedence because the lazy
symbol is replaced by the .so symbol before it is extracted from the
archive. In the second example the ref.o file causes the archive to be
exracted before the .so file is processed, so in that case the archive
file wins.

Fixes: https://github.com/emscripten-core/emscripten/issues/23501

show more ...


Revision tags: llvmorg-19.1.7
# fd87188c 12-Jan-2025 Kazu Hirata <kazu@google.com>

[wasm] Avoid repeated hash lookups (NFC) (#122626)


# 3792b362 03-Jan-2025 Fangrui Song <i@maskray.me>

[lld][WebAssembly] Replace config-> with ctx.arg.

Change the global variable reference to a member access of another
variable `ctx`. In the future, we may pass through `ctx` to functions to
eliminat

[lld][WebAssembly] Replace config-> with ctx.arg.

Change the global variable reference to a member access of another
variable `ctx`. In the future, we may pass through `ctx` to functions to
eliminate global variables.

Pull Request: https://github.com/llvm/llvm-project/pull/119835

show more ...


Revision tags: llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4
# 9a450a00 01-Nov-2024 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Implement various thinlto flags (#114327)

The changes in this PR (both in the code and the tests) are largely
copied directly from the ELF linker.

Partial fix for #79604.


Revision tags: llvmorg-19.1.3, llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0
# 0367305a 04-Sep-2024 mzukovec <113346157+mzukovec@users.noreply.github.com>

[lld][WebAssembly] Add allow-multiple-definition flag (#97699)

Add `allow-multiple-definition` flag to `wasm-ld`. This follows the ELF
linker logic. In case of duplication, the first symbol met is

[lld][WebAssembly] Add allow-multiple-definition flag (#97699)

Add `allow-multiple-definition` flag to `wasm-ld`. This follows the ELF
linker logic. In case of duplication, the first symbol met is used.

This PR resolves the #97543

show more ...


Revision tags: llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init
# 22b7b848 12-Jul-2024 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Report undefined symbols in -shared/-pie builds (#75242)

Previously we would ignore all undefined symbols when using
`-shared` or `-pie`. All undefined symbols would be treated a

[lld][WebAssembly] Report undefined symbols in -shared/-pie builds (#75242)

Previously we would ignore all undefined symbols when using
`-shared` or `-pie`. All undefined symbols would be treated as imports
regardless of whether those symbols we defined in any shared library.
With this change we now track symbol in shared libraries and report
undefined symbols in the main program by default.
The old behavior is still available via the
`--unresolved-symbols=import-dynamic` command line flag.

This rationale for allowing this type of breaking change is that `-pie`
and `-shared` are both still experimental will warn as such, unless
`--experimental-pic` is passed.

As part of this change the linker now models shared library symbols
via new SharedFunctionSymbol and SharedDataSymbol types.

I've also added a new `--no-shlib-sigcheck` option that bypassed the
checking of functions signature in shared libraries. This is
specifically required by emscripten the case where the imports/exports
of shared libraries have been modified by via JS type legalization (this
is only needed when targeting old JS engines where bigint is not yet
available

See https://github.com/emscripten-core/emscripten/issues/18198

show more ...


# 0fb33515 02-Jul-2024 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Fix for --import-table when combined with reference types (#97451)

When reference types are enabled clang will generate call_indirect
instructions that explicitly reference the g

[lld][WebAssembly] Fix for --import-table when combined with reference types (#97451)

When reference types are enabled clang will generate call_indirect
instructions that explicitly reference the global
`__indirect_function_table` symbol.

In this case the resulting global symbol was not being correctly marked
with explicit import name/module, resulting in the linker reporting
errors when it was referenced.

This issue was reported in
https://github.com/WebAssembly/tool-conventions/issues/158

show more ...


Revision tags: llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init
# 58d5a486 20-Jan-2024 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Fix regression in function signature checking (#78831)

Followup to #78658, which caused a regression in emscripten.

When a lazy symbol is added, which resolved and existing und

[lld][WebAssembly] Fix regression in function signature checking (#78831)

Followup to #78658, which caused a regression in emscripten.

When a lazy symbol is added, which resolved and existing undefined
symbol, we don't need/want to replace the undefined symbol with the lazy
one. Instead we called extract, which replaces the undefined symbol with
the defined one.

The fact that we were first replacing the undefined symbol with a lazy
one before extracting the archive member doesn't normally matter but, in
the case of the function symbol, replacing the undefined symbol with a
lazy symbol means that `addDefinedFunction` sees the existing symbol as
lazy and simply replaces it.

Note that this is consistent with both the ELF code in
`Symbol::resolve(const LazySymbol &other)` and the wasm code prior to
#78658, neither of which replace the existing symbol with the lazy one
in this case.

show more ...


# bcc9b9d8 20-Jan-2024 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Match the ELF linker in transitioning away from archive indexes. (#78658)

The ELF linker transitioned away from archive indexes in
https://reviews.llvm.org/D117284.

This paves

[lld][WebAssembly] Match the ELF linker in transitioning away from archive indexes. (#78658)

The ELF linker transitioned away from archive indexes in
https://reviews.llvm.org/D117284.

This paves the way for supporting `--start-lib`/`--end-lib` (See #77960)

The ELF linker unified library handling with `--start-lib`/`--end-lib` and removed
the ArchiveFile class in https://reviews.llvm.org/D119074.

show more ...


# 3c584570 18-Jan-2024 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Move input vectors from symtab to ctx. NFC (#78640)

Also convert from std::vector to SmallVector.

This matches the ELF linker where these were moved into the ctx object
in 9a5

[lld][WebAssembly] Move input vectors from symtab to ctx. NFC (#78640)

Also convert from std::vector to SmallVector.

This matches the ELF linker where these were moved into the ctx object
in 9a572164d592e and converted to SmallVector in ba948c5a9c524b.

show more ...


# 184c22dd 18-Jan-2024 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Move linker global state in to context object. NFC (#78629)

See lld/ELF/Config.h


# f2684959 18-Jan-2024 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Rename fetch() to extract() to match ELF linker. NFC (#78625)


# 103fa325 17-Jan-2024 Derek Schuff <dschuff@chromium.org>

[WebAssembly] Use ValType instead of integer types to model wasm tables (#78012)

LLVM models some features found in the binary format with raw integers
and others with nested or enumerated types. T

[WebAssembly] Use ValType instead of integer types to model wasm tables (#78012)

LLVM models some features found in the binary format with raw integers
and others with nested or enumerated types. This PR switches modeling of
tables and segments to use wasm::ValType rather than uint32_t. This NFC
change is in preparation for modeling more reference types, but IMO is
also cleaner and closer to the spec.

show more ...


# 83305fae 29-Nov-2023 Heejin Ahn <aheejin@gmail.com>

[lld][WebAssembly] Fix bitcode LTO order in archive parsing (#73095)

When doing LTO on multiple archives, the order with which bitcodes are
linked to the LTO module is hard to control, given that p

[lld][WebAssembly] Fix bitcode LTO order in archive parsing (#73095)

When doing LTO on multiple archives, the order with which bitcodes are
linked to the LTO module is hard to control, given that processing
undefined symbols can lead to parsing of an object file, which in turn
lead to parsing of another object file before finishing parsing of the
previous file. This can result in encountering a non-prevailing comdat
first when linking, which can make the the symbol undefined, and the
real definition is added later with an additional prefix to avoid
duplication (e.g. `__cxx_global_var_init` and `__cxx_global_var_init.2`)

So this one-line fix ensures we compile bitcodes in the order that we
process comdats, so that when multiple archived bitcode files have the
same variable with the same comdat, we make sure that the prevailing
comdat will be linked first in the LTO.

Fixes #62243.

show more ...


Revision tags: llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3
# afe957ea 03-Oct-2023 Sam Clegg <sbc@chromium.org>

[WebAssembly] Allow absolute symbols in the linking section (symbol table) (#67493)

Fixes a crash in `-Wl,-emit-relocs` where the linker was not able to
write linker-synthetic absolute symbols to t

[WebAssembly] Allow absolute symbols in the linking section (symbol table) (#67493)

Fixes a crash in `-Wl,-emit-relocs` where the linker was not able to
write linker-synthetic absolute symbols to the symbol table.

This change adds a new symbol flag (`WASM_SYMBOL_ABS`), which means that
the symbol's offset is absolute and not relative to a given segment.
Such symbols include `__stack_low` and `__stack_low`.

Note that wasm object files never contains such symbols, only binaries
linked with `-Wl,-emit-relocs`.

Fixes: #67111

show more ...


Revision tags: llvmorg-17.0.2, llvmorg-17.0.1
# 7bac0bc1 18-Sep-2023 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Improve error message on adding LTO object post-LTO. NFC (#66688)

We have been getting errors from emscripten users where including the
name of the symbol that triggered the incl

[lld][WebAssembly] Improve error message on adding LTO object post-LTO. NFC (#66688)

We have been getting errors from emscripten users where including the
name of the symbol that triggered the inclusion would be useful in the
diagnosis. e.g:
https://github.com/emscripten-core/emscripten/issues/20275

show more ...


Revision tags: llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7
# 3111784f 07-Dec-2022 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Initial support for stub libraries

See the docs in lld/docs/WebAssembly.rst for more on this.

This feature unlocks a lot of simplification in the emscripten toolchain
since we ca

[lld][WebAssembly] Initial support for stub libraries

See the docs in lld/docs/WebAssembly.rst for more on this.

This feature unlocks a lot of simplification in the emscripten toolchain
since we can represent the JS libraries to wasm-ld as stub libraries.

See https://github.com/emscripten-core/emscripten/issues/18875

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

show more ...


# d32f71a9 06-Mar-2023 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Use C++17 nested namespace syntax in most places. NFC

Like D131405, but for wasm-ld.

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


# 8aef04fa 06-Mar-2023 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Implement --why-extract flag from the ELF backend

See https://reviews.llvm.org/D109572 for the original ELF version.

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


# d65ed8cd 24-Feb-2023 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Fix handling of mixed strong and weak references

When adding a undefined symbols to the symbol table, if the existing
reference is weak replace the symbol flags with (potentially)

[lld][WebAssembly] Fix handling of mixed strong and weak references

When adding a undefined symbols to the symbol table, if the existing
reference is weak replace the symbol flags with (potentially) non-weak
binding.

Fixes: https://github.com/llvm/llvm-project/issues/60829

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

show more ...


# b9ef5648 03-Jan-2023 Kazu Hirata <kazu@google.com>

[lld] Use std::optional instead of llvm::Optional (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-

[lld] Use std::optional instead of llvm::Optional (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

show more ...


Revision tags: llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, working, llvmorg-15.0.2, llvmorg-15.0.1
# f46245c3 17-Sep-2022 Kazu Hirata <kazu@google.com>

[lld] Don't include SetVector.h (NFC)


Revision tags: llvmorg-15.0.0, llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2
# 113b5688 05-Aug-2022 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Rename SymbolTable::getSymbols to match ELF backend. NFC

The ELF backend originally used `getSymbols()` but went though a
sequence of changes that resulted in this method being ca

[lld][WebAssembly] Rename SymbolTable::getSymbols to match ELF backend. NFC

The ELF backend originally used `getSymbols()` but went though a
sequence of changes that resulted in this method being called
`symbols()`.

d8f8abbd4a2823f223bd7bc56445541fb221b512 replaced `getSymbols()` with
`forEachSymbol`.

a2fc96441788fba1e4709d63677f34ed8e321dae replaced `forEachSymbol` with
`llvm::iterator_range`.

e9262edf0d11a907763098d8e101219ccd9c43e9 replaced `llvm::iterator_range`
with `symbols()`.

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

show more ...


Revision tags: llvmorg-15.0.0-rc1
# b0f18af3 28-Jul-2022 Sam Clegg <sbc@chromium.org>

[lld][WebAssemby] Demote LazySymbols back to undefined symbols if they are not loaded

A LazySymbol is one that lives in `.a` archive and gets pulled in by a
strong reference. However, weak referenc

[lld][WebAssemby] Demote LazySymbols back to undefined symbols if they are not loaded

A LazySymbol is one that lives in `.a` archive and gets pulled in by a
strong reference. However, weak references to such symbols do not
result in them be loaded from the archive. In this case we want to
treat such symbols at undefined rather then lazy, once symbols
resolution is complete.

This fixes a crash bug in the linker when weakly referenced symbol that
lives in an archive file is live at the end of the link. In the case of
dynamic linking this is expected to turn into an import with (in the
case of a function symbol) a function index.

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

show more ...


Revision tags: llvmorg-16-init, llvmorg-14.0.6, llvmorg-14.0.5
# 0e8f4ce3 27-May-2022 Sam Clegg <sbc@chromium.org>

[lld][WebAssembly] Fix crash on undefined+weak function syms in LTO objects

Symbols from LTO objects don't contain Wasm signatures, but we need a
signature when we create undefined/stub functions fo

[lld][WebAssembly] Fix crash on undefined+weak function syms in LTO objects

Symbols from LTO objects don't contain Wasm signatures, but we need a
signature when we create undefined/stub functions for missing weakly
undefined symbols.

Luckily, after LTO, we know that symbols that are not referenced by a
regular object file must not be needed in the final output so there
is no need to generate undefined/stub function for them.

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

show more ...


123456