summaryrefslogtreecommitdiffstats
path: root/lld/wasm
Commit message (Collapse)AuthorAgeFilesLines
...
* [lld][WebAssembly] Report undefined symbols during scanRelocationsSam Clegg2019-07-095-47/+26
| | | | | | | | | | | | | | | | 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
* [lld][WebAssembly] Fix name of data section in PIC modeSam Clegg2019-07-091-2/+2
| | | | | | | | | | 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
* Add parentheses to silence warnings.Bill Wendling2019-07-081-3/+2
| | | | llvm-svn: 365397
* [lld][WebAssembly] Fix __start/__stop symbols when combining input segmentsSam Clegg2019-07-084-14/+16
| | | | | | | | | | | | 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
* [lld][WebAssembly] Fix typo in error messageSam Clegg2019-07-081-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D64315 llvm-svn: 365304
* [WebAssembly] Add static_assert(sizeof(SymbolUnion) <= 96)Fangrui Song2019-07-081-5/+10
| | | | | | | | | | | | | | On Windows, the bitfield layout rule places `ussigned Referenced : 1` at byte offset 40, instead of byte offset 37 on *NIX. The consequence is that sizeof(SymbolUnion) == 104 on Windows while 96 on *NIX. To eliminate this difference, change these unsigned bitfields to bool. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D64238 llvm-svn: 365296
* lld, llvm-dlltool, llvm-lib: Use getAsString() instead of getSpelling() for ↵Nico Weber2019-07-051-1/+1
| | | | | | | | | | | | | | | printing unknown args Since OPT_UNKNOWN args never have any values and consist only of spelling (and are never aliased), this doesn't make any difference in practice, but it's more consistent with Arg's guidance to use getAsString() for diagnostics, and it matches what clang does. Also tweak two tests to use an unknown option that contains '=' for additional coverage while here. (The new tests pass fine with the old code too though.) llvm-svn: 365200
* Make joined instances of JoinedOrSeparate flags point to the unaliased args, ↵Nico Weber2019-07-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | like all other arg types do This fixes an 8-year-old regression. r105763 made it so that aliases always refer to the unaliased option – but it missed the "joined" branch of JoinedOrSeparate flags. (r162231 then made the Args classes non-virtual, and r169344 moved them from clang to llvm.) Back then, there was no JoinedOrSeparate flag that was an alias, so it wasn't observable. Now /U in CLCompatOptions is a JoinedOrSeparate alias in clang, and warn_slash_u_filename incorrectly used the aliased arg id (using the unaliased one isn't really a regression since that warning checks if the undefined macro contains slash or backslash and only then emits the warning – and no valid use will pass "-Ufoo/bar" or similar). Also, lld has many JoinedOrSeparate aliases, and due to this bug it had to explicitly call `getUnaliasedOption()` in a bunch of places, even though that shouldn't be necessary by design. After this fix in Option, these calls really don't have an effect any more, so remove them. No intended behavior change. (I accidentally fixed this bug while working on PR29106 but then wondered why the warn_slash_u_filename broke. When I figured it out, I thought it would make sense to land this in a separate commit.) Differential Revision: https://reviews.llvm.org/D64156 llvm-svn: 365186
* [WebAssembly] Delete static_assert(sizeof(SymbolUnion) <= 96) to fix Windows ↵Fangrui Song2019-07-051-5/+0
| | | | | | | | | | builds http://lab.llvm.org:8011/builders/sanitizer-windows/builds/47944/steps/stage%201%20build/logs/stdio Needs to figure out later the size on Windows. llvm-svn: 365171
* [WebAssembly] Reorder Symbol fields to make it smallerFangrui Song2019-07-051-25/+31
| | | | | | | | | | | | On 64-bit systems, this decreases sizeof(SymbolUnion) from 112 to 96. Add a static_assert to avoid accidental increases in future. Reviewed By: sbc100 Differential Revision: https://reviews.llvm.org/D64208 llvm-svn: 365169
* [WebAssembly] Add option to emit passive segmentsThomas Lively2019-07-0310-40/+120
| | | | | | | | | | | | | | | | | | | | | | | 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
* [wasm-ld] Add __global_base symbol to mark the value of --global-baseGuanzhong Chen2019-06-264-0/+9
| | | | | | | | | | | | | | | | | | | | | | 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
* [WebAssembly] Fix accidental omission from rLLD364367Keno Fischer2019-06-261-0/+1
| | | | | | | | There was another place where handling for this relocation was missing that was accidentally omitted from rLLD364367, causing the newly added test to fail on the buildbots. llvm-svn: 364371
* [lld/WebAssembly] Slightly nicer error message for malformed input filesKeno Fischer2019-06-261-1/+2
| | | | | | | | | | | | | | | | | | | Summary: Before: ``` wasm-ld: error: Relocations not in offset order ``` After ``` wasm-ld: error: While processing `libjulia.so`: Relocations not in offset order ``` At least this way you get to find out which input file is malformed. Reviewers: sbc100 Differential Revision: https://reviews.llvm.org/D63694 llvm-svn: 364368
* [WebAssembly] Fix list of relocations with addends in lldKeno Fischer2019-06-261-8/+1
| | | | | | | | | | | | | Summary: The list of relocations with addend in lld was missing `R_WASM_MEMORY_ADDR_REL_SLEB`, causing `wasm-ld` to generate corrupted output. This fixes that problem and while we're at it pulls the list of such relocations into the Wasm.h header, to avoid duplicating it in multiple places. Reviewers: sbc100 Differential Revision: https://reviews.llvm.org/D63696 llvm-svn: 364367
* [WebAssembly] Error on archives without a symbol indexSam Clegg2019-06-251-4/+12
| | | | | | | | | | | | | | | | | | This is fairly common with wasm since GNU ar (most likely the system ar) doesn't support the wasm object format so user who don't override AR will end up with archives without an index. We don't want to silently ignore this issue. In the future we could choose to instead behave like the ELF backend and read the symbols from each object file in the archive if they are all of the same type. However, error'ing out seem like a conservative approach for now. Fixes: PR42376 Differential Revision: https://reviews.llvm.org/D63739 llvm-svn: 364338
* [WebAssembly] Fix for discarded init functionsSam Clegg2019-06-076-17/+46
| | | | | | | | | 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
* [WebAssembly] Handle object parsing more like the ELF backendSam Clegg2019-06-053-16/+27
| | | | | | Differential Revision: https://reviews.llvm.org/D62886 llvm-svn: 362626
* [lld] Explicitly ignore comdat groups when parsing LTO object(s)Sam Clegg2019-06-051-9/+5
| | | | | | | | | | | | | Any symbols defined in the LTO object are by definition the ones we want in the final output so we skip the comdat group checking in those cases. This change makes the ELF code more explicit about this and means that wasm and ELF do this in the same way. Differential Revision: https://reviews.llvm.org/D62884 llvm-svn: 362625
* [WebAssembly] make wasm-ld --verbose show data section startVA and nameThomas Lively2019-06-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: Make `wasm-ld --verbose` show data section start virtual address and name as well, instead of just showing the size. This makes it much easier to track which global variable is in which address when used in conjunction with `--no-merge-data-sections`. Patch by Guanzhong Chen Reviewers: tlively, aheejin, sbc100, ruiu Reviewed By: sbc100, ruiu Subscribers: ruiu, dschuff, jgravelle-google, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62834 llvm-svn: 362548
* [WebAssembly] Add comment as follow-up to rL362276. NFC.Sam Clegg2019-06-041-1/+3
| | | | | | | | | | Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62824 llvm-svn: 362522
* [WebAssembly] Don't export __data_end and __heap_base by default.Sam Clegg2019-05-315-20/+21
| | | | | | | | These can still be exported via --export if needed. Differential Revision: https://reviews.llvm.org/D62744 llvm-svn: 362276
* [WebAssembly] Improve feature validation error messagesThomas Lively2019-05-301-20/+32
| | | | | | | | | | | | | | | | 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
* [WebAssembly] Move direct call tracking from member to local. NFC.Sam Clegg2019-05-292-10/+10
| | | | | | | | | | | This data structure is only needed temporarily while symbols are being created. This is a followup on rL361678. Differential Revision: https://reviews.llvm.org/D62548 llvm-svn: 361977
* [WebAssembly] Fix signatures of undefined function in LTO object which are ↵Sam Clegg2019-05-291-8/+10
| | | | | | | | | | | | | not called directly. We recently added special handling for function that are not called directly but failed to add testing for the LTO case. See https://reviews.llvm.org/D62153 Differential Revision: https://reviews.llvm.org/D62561 llvm-svn: 361975
* [WebAssembly] Relax signature checking for undefined functions that are not ↵Sam Clegg2019-05-246-21/+46
| | | | | | | | | | | | | | | | | | | | | | | | | called directly When function signatures don't match and the undefined function is not called directly (i.e. only has its address taken) we don't issue a warning or create a runtime thunk for the undefined function. Instead in this case we simply use the defined version of the function. This is possible since checking signatures of dynamic calls happens at runtime so any invalid usage will still result in a runtime error. This is needed to allow C++ programs to link without generating warnings. Its not uncommon in C++ for vtables to be populated by function address whee the signature of the function is not known in the compilation unit. In this case clang declares the method as void(void) and relies on the vtable caller casting the data back to the correct signature. Fixes: https://bugs.llvm.org/show_bug.cgi?id=40412 Differential Revision: https://reviews.llvm.org/D62153 llvm-svn: 361678
* [WebAssebmly] Add support for --wrapSam Clegg2019-05-247-9/+128
| | | | | | | | | | | The code for implementing this features is taken almost verbatim from the ELF backend. Fixes: https://bugs.llvm.org/show_bug.cgi?id=41681 Differential Revision: https://reviews.llvm.org/D62380 llvm-svn: 361639
* [lld] Trace all references with lld --trace-symbolSam Clegg2019-05-243-3/+17
| | | | | | | | | | | Previously undefined symbol references were only traced if they were seen before that definition. Fixes https://bugs.llvm.org/show_bug.cgi?id=41878 Differential Revision: https://reviews.llvm.org/D61929 llvm-svn: 361636
* [WebAssembly] Add support for -emit-relocsSam Clegg2019-05-245-6/+12
| | | | | | | | | | 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
* Reland: [WebAssembly] Add __start_/_stop_ symbols for data sectionsSam Clegg2019-05-234-8/+54
| | | | | | | | | | This is a reland of rL361235. Fixes https://bugs.llvm.org/show_bug.cgi?id=41565 Differential Revision: https://reviews.llvm.org/D61876 llvm-svn: 361476
* [WebAssembly] Seal imports section before counting importsSam Clegg2019-05-233-14/+33
| | | | | | | | | | | | | | | | | | | | | | | 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
* Revert "[WebAssembly] Add __start_/_stop_ symbols for data sections"Sam Clegg2019-05-214-56/+10
| | | | | | | | | This reverts commit 7804dbddccba412087a15cab8db4412939700952. This change broke a bunch of tests of the WebAssembly waterfall. Will hopefully reland with increased test coverage. llvm-svn: 361273
* [WebAssembly] Add --reproduce.Rui Ueyama2019-05-214-0/+60
| | | | | | | | | | | | | | | --reproduce is a convenient option for debugging. If you invoke lld with `--reproduce=repro.tar`, it creates `repro.tar` with all input files and the command line options given to the linker, so that it is very easy to run lld with the exact same inputs. ELF and Windows lld have this option. This patch add that option to lld/wasm. Differential Revision: https://reviews.llvm.org/D62170 llvm-svn: 361244
* [WebAssembly] Add __start_/_stop_ symbols for data sectionsSam Clegg2019-05-214-10/+56
| | | | | | | | Fixes https://bugs.llvm.org/show_bug.cgi?id=41565 Differential Revision: https://reviews.llvm.org/D61876 llvm-svn: 361236
* [WebAssembly] Refactor synthetic sections and relocation processing. NFC.Sam Clegg2019-05-2113-931/+1186
| | | | | | | | | | | 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
* [WebAssembly] Move code and data section generation to finalizeContent. NFC.Sam Clegg2019-05-163-21/+41
| | | | | | | | | | | | | | 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
* [WebAssembly] Don't generate empty type sections.Sam Clegg2019-05-161-0/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D61991 llvm-svn: 360940
* [WebAssembly] LTO: Honor comdat groups when loading bitcode filesSam Clegg2019-05-154-19/+34
| | | | | | | | | But don't apply comdat groups when loading the LTO object files. This is basically the same logic used by the ELF linker. Differential Revision: https://reviews.llvm.org/D61924 llvm-svn: 360782
* [WebAssembly] Refactor relocation processing. NFC.Sam Clegg2019-05-131-19/+17
| | | | | | | | | This is the remaining NFC part of https://reviews.llvm.org/D61539 which was reverted. Differential Revision: https://reviews.llvm.org/D61800 llvm-svn: 360598
* [WebAssembly] Don't assume that strongly defined symbols are DSO-localSam Clegg2019-05-102-3/+9
| | | | | | | | | | | | | | | | 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
* Revert "[WebAssembly] Don't generate unused table entries."Sam Clegg2019-05-092-22/+20
| | | | | | | | This reverts commit b33fdb7768e5de5fbeb23f65d8d455e7ca88b021. This change apparently broke am emscripten test. llvm-svn: 360367
* [WebAssembly] Handle command line options consistently with the ELF backend.Sam Clegg2019-05-082-20/+32
| | | | | | Differential Revision: https://reviews.llvm.org/D61645 llvm-svn: 360266
* [WebAssembly] Don't generate unused table entries.Sam Clegg2019-05-072-20/+22
| | | | | | | | | | | | | | 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
* [WebAssembly] Always take into account added when applying runtime relocationsSam Clegg2019-04-252-26/+28
| | | | | | | | | | | The code we generate for applying data relocations at runtime omitted the symbols with GOT entries. Also refactor the code to reduce duplication. Differential Revision: https://reviews.llvm.org/D61111 llvm-svn: 359207
* [WebAssembly] Fix typo in relocation checkingSam Clegg2019-04-231-1/+3
| | | | | | | | | | | Runtime relocation are generated for relocations of type R_WASM_MEMORY_ADDR_I32 when in PIC mode (either -shared or -pie). Followup on https://reviews.llvm.org/D60882. Differential Revision: https://reviews.llvm.org/D60992 llvm-svn: 358995
* Use llvm::stable_sortFangrui Song2019-04-231-4/+4
| | | | | | | | | 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
* [WebAssembly] Error on relocations against undefined data symbols.Sam Clegg2019-04-222-14/+46
| | | | | | | | | | | | | | | | | 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
* [WebAssembly] Fix R_WASM_FUNCTION_OFFSET_I32 relocation warningsSam Clegg2019-04-221-6/+7
| | | | | | | | | | | | | | | We were incorrectly used the symbol table version of the function rather than the object-local version when checking the existing relocation value. This was causing erroneous warnings for comat symbols defined in multiple object.s Fixes: https://bugs.llvm.org/show_bug.cgi?id=40503 Differential Revision: https://reviews.llvm.org/D60928 llvm-svn: 358871
* [WebAssembly] Emit the DataCount section when bulk memory is enabledThomas Lively2019-04-192-0/+14
| | | | | | | | | | | | | | | | | | 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
* [wasm] Simplify. NFCFangrui Song2019-04-183-4/+4
| | | | llvm-svn: 358663
OpenPOWER on IntegriCloud