summaryrefslogtreecommitdiffstats
path: root/lld/wasm/InputChunks.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [WebAssembly] Wrap definitions in namespace lld { namespace wasm {. NFCFangrui Song2019-10-101-4/+7
| | | | | | | | | | Similar to D68323, but for wasm. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D68759 llvm-svn: 374279
* [WebAssembly][lld] Fix crash when applying relocations to debug sectionsSam Clegg2019-08-201-1/+1
| | | | | | | | | | | | | | Debug sections are special in that they can contain relocations against symbols that are not present in the final output (i.e. not live). However it is also possible to have R_WASM_TABLE_INDEX relocations against symbols that don't have a table index assigned (since they are not address taken by actual code. Fixes: https://github.com/emscripten-core/emscripten/issues/9023 Differential Revision: https://reviews.llvm.org/D66435 llvm-svn: 369423
* [Coding style change][lld] Rename variables for non-ELF portsRui Ueyama2019-07-111-145/+145
| | | | | | | | | | | 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
* [lld][WebAssembly] Fix __start/__stop symbols when combining input segmentsSam Clegg2019-07-081-2/+4
| | | | | | | | | | | | 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
* [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] Always take into account added when applying runtime relocationsSam Clegg2019-04-251-26/+25
| | | | | | | | | | | 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] Assign GOT entries symbols used in data relocationsSam Clegg2019-04-101-6/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D60492 llvm-svn: 358090
* [WebAssembly] Apply data relocations at runtime in shared objectsSam Clegg2019-04-041-0/+55
| | | | | | | | | | | | | See: https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md Data section relocations in wasm shared libraries are applied by the library itself at static constructor time. This change adds a new synthetic function that applies relocations to relevant memory locations on startup. Differential Revision: https://reviews.llvm.org/D59278 llvm-svn: 357715
* [WebAssembly] Add new explicit relocation types for PIC relocationsSam Clegg2019-04-041-0/+4
| | | | | | | | See https://github.com/WebAssembly/tool-conventions/pull/106 Differential Revision: https://reviews.llvm.org/D59907 llvm-svn: 357710
* Re-land "[WebAssembly] Improve invalid relocation error message""Sam Clegg2019-03-291-3/+3
| | | | | | | | | | 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
* Revert "[WebAssembly] Improve invalid relocation error message"Derek Schuff2019-03-291-1/+1
| | | | | | This reverts commit 0805ec5f7b5c80474352531a99e721c30e73e77f. llvm-svn: 357225
* Revert "[WebAssembly] Improve invalid relocation error message"Derek Schuff2019-03-291-3/+3
| | | | | | | | | | | | | Also Revert "[WebAssembly] Fix typo from rL357143" This reverts commit 0805ec5f7b5c80474352531a99e721c30e73e77f and a9958fc30d0c6d4c140be892c5a824b827d2eb5d (rL357143 and rL357144) They cause failures with address-taken extern (JS) functions in emscripten. llvm-svn: 357224
* [WebAssembly] Fix typo from rL357143Sam Clegg2019-03-281-3/+3
| | | | llvm-svn: 357144
* [WebAssembly] Improve invalid relocation error messageSam Clegg2019-03-281-1/+1
| | | | | | | | This message now matches the equivalent message in the ELF linker. Differential Revision: https://reviews.llvm.org/D59860 llvm-svn: 357143
* [WebAssembly] Initial implementation of PIC code generationSam Clegg2019-03-261-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | 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
* [WebAssembly] clang-tidy (NFC)Heejin Ahn2019-02-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | Summary: This patch fixes clang-tidy warnings on wasm-only files. The list of checks used is: `-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming,modernize-*` (LLVM's default .clang-tidy list is the same except it does not have `modernize-*`.) The list of fixes are: - Variable names start with an uppercase letter - Function names start with a lowercase letter - Use `auto` when you use casts so the type is evident Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D57499 llvm-svn: 353076
* [WebAssembly] Update relocation naming to match llvm change. NFC.Sam Clegg2019-02-041-41/+41
| | | | | | Differential Revision: https://reviews.llvm.org/D57698 llvm-svn: 353066
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [WebAssembly] Add support for the event sectionHeejin Ahn2018-12-081-0/+4
| | | | | | | | | | | | | | | | | Summary: This adds support for the 'event section' specified in the exception handling proposal. Wasm exception handling binary model spec: https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md#changes-to-the-binary-model Reviewers: sbc100, ruiu Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D54875 llvm-svn: 348703
* [WebAssembly] Update Config member to match command line optionSam Clegg2018-09-271-2/+2
| | | | | | | | Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D50976 llvm-svn: 343157
* [WebAssembly] clang-format (NFC)Heejin Ahn2018-08-291-2/+5
| | | | | | | | | | | | Summary: This patch runs clang-format on all wasm-only files. Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D51449 llvm-svn: 340970
* [WebAssembly] Optimise relocation processing. NFC.Sam Clegg2018-08-221-11/+1
| | | | | | | | | | | | | | | | | This is a rebased version https://reviews.llvm.org/D42176 which is patch by Nicolas Wilson. Addresses issue: https://github.com/WebAssembly/tool-conventions/issues/32, and https://bugs.llvm.org/show_bug.cgi?id=38650 Previously, for each function/segment we iterated over every relocation to find the relevant ones, which is an n^2 operation. Now, we just make a single pass. Differential Revision: https://reviews.llvm.org/D51063 llvm-svn: 340428
* Replace last DEBUG occurrence with LLVM_DEBUG in lld.Nicola Zaghen2018-05-231-9/+9
| | | | llvm-svn: 333084
* [WebAssembly] Remove dead code from LEB compression pass.Sam Clegg2018-05-221-9/+2
| | | | | | | | | | There are only certain relocation types that can exist in the wasm code section and they are all LEB types. Remove the dead code for handling the other (I32) reloc types. Differential Revision: https://reviews.llvm.org/D47226 llvm-svn: 333030
* [WebAssembly] Fix two bugs in LEB compression: properly calculate function ↵Sam Clegg2018-05-221-1/+2
| | | | | | | | | | | | | body offset, and write I32 values. * Gets function size field from right location * Writes I32 values during compression Patch by Yury Delendik Differential Revision: https://reviews.llvm.org/D47204 llvm-svn: 333002
* Fix unused variable warning in non-debug builds.Richard Trieu2018-05-191-1/+1
| | | | llvm-svn: 332789
* [WebAssembly] Add option to remove LEB padding at relocate sitesSam Clegg2018-05-181-1/+121
| | | | | | | | | | | | | | | | | This change adds the ability for lld to remove LEB padding from code section. This effectively shrinks the size of the resulting binary in proportion to the number of code relocations. Since there will be a performance cost this is currently only active for -O1 and above. Some toolchains may instead want to perform this compression as a post linker step (for example running a binary through binaryen will automatically compress these values). I imagine we might want to make this the default in the future. Differential Revision: https://reviews.llvm.org/D46416 llvm-svn: 332783
* [lld] Make helpers static. NFC.Benjamin Kramer2018-05-151-1/+1
| | | | llvm-svn: 332408
* [lld] Update uses of DEBUG macro to LLVM_DEBUG.Nicola Zaghen2018-05-151-11/+12
| | | | | | | | | | | The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM Differential Revision: https://reviews.llvm.org/D44977 llvm-svn: 332351
* [WebAssembly] Only perform sanity checking of relocation targets in debug buildsSam Clegg2018-05-051-10/+41
| | | | | | | | | | | Also: - Reduce the error to a warning so that debug and release versions can still link the same inputs. - Add another check to verify the input LEB is padded to 5 bytes Differential Revision: https://reviews.llvm.org/D46479 llvm-svn: 331571
* [WebAssembly] Add support for debug (DWARF) sectionsSam Clegg2018-05-041-1/+5
| | | | | | | | | | | | | | Specifically add support for custom sections that contain relocations, and for the two new relocation types needed by DWARF sections. See: https://reviews.llvm.org/D44184 Patch by Yury Delendik! Differential Revision: https://reviews.llvm.org/D44184 llvm-svn: 331566
* [WebAssembly] Fix bug where reloc addends were written as unsignedSam Clegg2018-04-191-1/+1
| | | | | | | | | | | Relocation addends can be negative so should be written as signed LEBs. This bug meant that writing value between 64 and 128 would be incorrectly interpreted as negative by the object file readers. Differential Revision: https://reviews.llvm.org/D45825 llvm-svn: 330374
* [WebAssembly] Match llvm change to custom section sizeSam Clegg2018-04-121-10/+0
| | | | | | | | | | | | | | Summary: The content of custome sections no longer includes the name itself. See: https://reviews.llvm.org/D45579 Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D45580 llvm-svn: 329948
* [WebAssembly] Add support for custom sectionsSam Clegg2018-04-101-0/+10
| | | | | | | | | Copy user-defined custom sections into the output, concatenating sections with the same name. Differential Revision: https://reviews.llvm.org/D45340 llvm-svn: 329717
* [WebAssembly] Avoid COMDAT hashmap lookup for each symbol. NFCNicholas Wilson2018-03-141-0/+7
| | | | | | | | | This reduces the number of lookups to one per COMDAT group, rather than one per symbol in a COMDAT group. Differential Revision: https://reviews.llvm.org/D44344 llvm-svn: 327523
* [WebAssembly] Fix expected contents of relocations with addendsSam Clegg2018-03-141-1/+2
| | | | | | | | | | | This fixes issues found on the wasm waterfall related to relocations with addends. Undefined symbols, even those with addends should always have a provisional value of zero. At least this is what llvm emits (and I believe this is true for ELF too). Differential Revision: https://reviews.llvm.org/D44451 llvm-svn: 327468
* [WebAssembly] Refactor to avoid conflating global and fucntion index space. NFCSam Clegg2018-03-121-4/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D44358 llvm-svn: 327326
* [WebAssembly] Verify contents of relocation target before writing itSam Clegg2018-03-121-0/+10
| | | | | | | | | | | | 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
* [WebAssembly] Improve logging and comments around relocations. NFC.Sam Clegg2018-03-111-4/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D44350 llvm-svn: 327232
* [WebAssembly] Run clang-format. NFCNicholas Wilson2018-03-071-2/+4
| | | | llvm-svn: 326896
* [WebAssembly] Inline translateVA as it's trivial.Rui Ueyama2018-02-281-6/+0
| | | | | | | | | | | The problem I want to address now is that chunks have too many data members for "offsets", and their origins are not well defined. For example, InputSegment has OutputSegmentOffset, but it's base class also has OutputOffset. That's very confusing. Differential Revision: https://reviews.llvm.org/D43726 llvm-svn: 326291
* [WebAssembly] Add explicit symbol tableSam Clegg2018-02-231-6/+4
| | | | | | | | | | | | | | | | | | This change modified lld to in response the llvm change which moved to a more explicit symbol table in the object format. Based on patches by Nicholas Wilson: 1. https://reviews.llvm.org/D41955 2. https://reviews.llvm.org/D42585 The primary difference that we see in the test output is that for relocatable (-r) output we now have symbol table which replaces exports/imports and globals. See: https://github.com/WebAssembly/tool-conventions/issues/38 Differential Revision: https://reviews.llvm.org/D43264 llvm-svn: 325861
* Do not create a temporary data structure for relocations.Rui Ueyama2018-02-201-60/+54
| | | | | | | | | | | | This patch removes `OutRelocations` vector from the InputChunk and directly consume `Relocations` vector instead. This should make the linker faster because we don't create a temporary data structure, and it matches the lld's design principle that we don't create temporary data structures for object files but instead directly consume mmap'ed data whenever possible. Differential Revision: https://reviews.llvm.org/D43491 llvm-svn: 325549
* Merge two small functions and add comments.Rui Ueyama2018-02-191-9/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D43406 llvm-svn: 325538
* Removed a variable that is used only once.Rui Ueyama2018-02-191-3/+3
| | | | llvm-svn: 325537
* [WebAssembly] Define toString(wasm::InputChunk *) and use that in MarkLive.cpp.Rui Ueyama2018-02-191-0/+4
| | | | | | | | Define toString(wasm::InputChunk *) and use that in MarkLive.cpp. Differential Revision: https://reviews.llvm.org/D43434 llvm-svn: 325535
* Use write32le instead of write32<little>.Rui Ueyama2018-02-161-1/+2
| | | | llvm-svn: 325384
* [WebAssembly] Add getName and getFileName methods to InputChunk base class. NFC.Sam Clegg2018-01-281-2/+2
| | | | | | | | | | Summary: These are useful to upcoming addition of --gc-sections support. Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D42626 llvm-svn: 323623
* [WebAssembly] Don't duplicate functions in table outputSam Clegg2018-01-241-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | Previously, we were ensuring that the "output index" for InputFunctions was unique across all symbols that referenced a function body, but allowing the same function body to have multiple table indexes. Now, we use the same mechanism for table indexes as we already do for output indexes, ensuring that each InputFunction is only placed in the table once. This makes the LLD output table denser and smaller, but should not change the behaviour. Note that we still need the `Symbol::TableIndex` member, to store the table index for function Symbols that don't have an InputFunction, i.e. for address-taken imports. Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D42476 llvm-svn: 323379
* [WebAssembly] Update to match llvm changes to TABLE relocationsSam Clegg2018-01-231-18/+4
| | | | | | | | | | | | | TABLE relocations now store the function that is being refered to indirectly. See rL323165. Also extend the call-indirect.ll a little. Based on a patch by Nicholas Wilson! llvm-svn: 323168
OpenPOWER on IntegriCloud