summaryrefslogtreecommitdiffstats
path: root/lld/wasm/InputChunks.h
Commit message (Collapse)AuthorAgeFilesLines
* [lld] Fix trivial typos in commentsKazuaki Ishizaki2020-01-061-2/+2
| | | | | | Reviewed By: ruiu, MaskRay Differential Revision: https://reviews.llvm.org/D72196
* [WebAssembly] Add new `export_name` clang attribute for controlling wasm ↵Sam Clegg2019-12-111-0/+3
| | | | | | | | | | | | | | | | | | | | export names This is equivalent to the existing `import_name` and `import_module` attributes which control the import names in the final wasm binary produced by lld. This maps the existing This attribute currently requires a string rather than using the symbol name for a couple of reasons: 1. Avoid confusion with static and dynamic linking which is based on symbol name. Exporting a function from a wasm module using this directive is orthogonal to both static and dynamic linking. 2. Avoids name mangling. Differential Revision: https://reviews.llvm.org/D70520
* [Coding style change][lld] Rename variables for non-ELF portsRui Ueyama2019-07-111-77/+77
| | | | | | | | | | | 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
* Make functions and member variables distinguishable even after the name ↵Rui Ueyama2019-07-101-1/+1
| | | | | | style change. NFC. llvm-svn: 365605
* [WebAssembly] Fix for discarded init functionsSam Clegg2019-06-071-1/+4
| | | | | | | | | 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] Refactor synthetic sections and relocation processing. NFC.Sam Clegg2019-05-211-0/+3
| | | | | | | | | | | 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] Apply data relocations at runtime in shared objectsSam Clegg2019-04-041-0/+2
| | | | | | | | | | | | | 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
* Re-land "[WebAssembly] Improve invalid relocation error message""Sam Clegg2019-03-291-0/+2
| | | | | | | | | | 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-2/+0
| | | | | | This reverts commit 0805ec5f7b5c80474352531a99e721c30e73e77f. llvm-svn: 357225
* Revert "[WebAssembly] Improve invalid relocation error message"Derek Schuff2019-03-291-1/+1
| | | | | | | | | | | | | 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-1/+1
| | | | llvm-svn: 357144
* [WebAssembly] Improve invalid relocation error messageSam Clegg2019-03-281-0/+2
| | | | | | | | This message now matches the equivalent message in the ELF linker. Differential Revision: https://reviews.llvm.org/D59860 llvm-svn: 357143
* 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] Remove `using` statements from header files. NFC.Sam Clegg2018-11-271-10/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D54758 llvm-svn: 347621
* [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] Optimise relocation processing. NFC.Sam Clegg2018-08-221-14/+11
| | | | | | | | | | | | | | | | | 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
* [WebAssembly] Add option to remove LEB padding at relocate sitesSam Clegg2018-05-181-2/+23
| | | | | | | | | | | | | | | | | 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
* [WebAssembly] Fix R_WEBASSEMBLY_FUNCTION_OFFSET_I32 relocation entriesSam Clegg2018-05-151-1/+1
| | | | | | | | | | | | | | | | | Fixes: lld: warning: unexpected existing value for R_WEBASSEMBLY_FUNCTION_OFFSET_I32: existing=839 expected=838 The existing solution is trying to erroneously recover correct offset of the function code from the body (which is not a function segment that includes its size, locals, and code). The D46763 is trying to maintain the offset of the function code allowing properly calculate the new relocation entry. Patch by Yury Delendik Differential Revision: https://reviews.llvm.org/D46765 llvm-svn: 332412
* [WebAssembly] Only perform sanity checking of relocation targets in debug buildsSam Clegg2018-05-051-0/+4
| | | | | | | | | | | 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-0/+2
| | | | | | | | | | | | | | 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] Implement --print-gc-sections for synthetic functionsNicholas Wilson2018-04-201-3/+10
| | | | | | | | | | Enables cleaning up confusion between which name variables are mangled and which are unmangled, and --print-gc-sections then excersises and tests that. Differential Revision: https://reviews.llvm.org/D44440 llvm-svn: 330449
* [WebAssembly] Match llvm change to custom section sizeSam Clegg2018-04-121-3/+5
| | | | | | | | | | | | | | 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-1/+20
| | | | | | | | | 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-4/+5
| | | | | | | | | 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] 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] Refactor order of creation for SyntheticFunctionNicholas Wilson2018-03-091-5/+13
| | | | | | | | | | Previously we created __wasm_call_ctors with null InputFunction, and added the InputFunction later. Now we create the SyntheticFunction with null body, and set the body later. Differential Revision: https://reviews.llvm.org/D44206 llvm-svn: 327149
* [WebAssembly] Run clang-format. NFCNicholas Wilson2018-03-071-3/+2
| | | | llvm-svn: 326896
* [WebAssembly] Use StringSaver to retain ownership of ctor function body. NFCNicholas Wilson2018-03-071-5/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D44149 llvm-svn: 326885
* [WebAssembly] Pass ownership of body to SyntheticFunction. NFCNicholas Wilson2018-03-021-5/+5
| | | | | | | | | This avoids the Writer unnecessarily having a member to retain ownership of the function body. Differential Revision: https://reviews.llvm.org/D43933 llvm-svn: 326580
* [WebAssembly] Inline translateVA as it's trivial.Rui Ueyama2018-02-281-4/+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] Remove trivial accessors.Rui Ueyama2018-02-281-8/+1
| | | | | | | | {set,get}OutputSegment don't hide anything, so remove them. Differential Revision: https://reviews.llvm.org/D43724 llvm-svn: 326276
* [WebAssembly] Add explicit symbol tableSam Clegg2018-02-231-5/+9
| | | | | | | | | | | | | | | | | | 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
* [WebAssembly] Remove unused headerSam Clegg2018-02-201-1/+0
| | | | | | | | | This header used to be needed here for the `OutRelocation` struct but that no longer exists. Differential Revision: https://reviews.llvm.org/D43516 llvm-svn: 325608
* Do not create a temporary data structure for relocations.Rui Ueyama2018-02-201-9/+8
| | | | | | | | | | | | 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
* [WebAssembly] Define toString(wasm::InputChunk *) and use that in MarkLive.cpp.Rui Ueyama2018-02-191-0/+2
| | | | | | | | Define toString(wasm::InputChunk *) and use that in MarkLive.cpp. Differential Revision: https://reviews.llvm.org/D43434 llvm-svn: 325535
* [WebAssembly] Remove unneeded Chunk::getFileName() method. NFC.Sam Clegg2018-02-161-1/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D43405 llvm-svn: 325414
* [WebAssembly] Unify concepts of discarded and non-live input chunks. NFC.Sam Clegg2018-02-131-3/+3
| | | | | | | | | It seems redundant to store this information twice. None of the locations where this bit is checked care about the distinction. Differential Revision: https://reviews.llvm.org/D43250 llvm-svn: 325046
* [WebAssebmly] Remvoe trailing semicolon. NFC.Sam Clegg2018-02-091-1/+1
| | | | llvm-svn: 324716
* [WebAssembly] Write minimal types sectionSam Clegg2018-01-311-4/+4
| | | | | | | | | | | | | | | | | | Don't include type signatures that are not referenced by some relocation. We don't include this in the -gc-sections settings since we are always building the type section from scratch, just like we do the table elements. In the future we might want to unify the relocation processing which is currently done once for gc-sections and then again for building the sympathetic type and table sections. Differential Revision: https://reviews.llvm.org/D42747 llvm-svn: 323931
* [WebAssembly] Add support for --gc-sectionsSam Clegg2018-01-311-2/+8
| | | | | | | | | | | | | | | In this initial version we only GC symbols with `hidden` visibility since other symbols we export to the embedder. We could potentially modify this the future and only use symbols explicitly passed via `--export` as GC roots. This version of the code only does GC of data and code. GC for the types section is coming soon. Differential Revision: https://reviews.llvm.org/D42511 llvm-svn: 323842
* [WebAssembly] Add getName and getFileName methods to InputChunk base class. NFC.Sam Clegg2018-01-281-2/+4
| | | | | | | | | | 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
* clang formatSam Clegg2018-01-281-1/+3
| | | | llvm-svn: 323622
* [WebAssemly] Associate symbol with InputChunk in which they are defined. NFC.Sam Clegg2018-01-281-3/+12
| | | | | | | | | | | | | | | | Summary: Rather than explicit Function or InputSegment points store a pointer to the base class (InputChunk) and use llvm dynamic casts when we need a subtype. This change is useful for add the upcoming gc-section support wants to deal with all input chunks. Subscribers: aheejin, llvm-commits Differential Revision: https://reviews.llvm.org/D42625 llvm-svn: 323621
* [WebAssembly] Don't duplicate functions in table outputSam Clegg2018-01-241-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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-0/+1
| | | | | | | | | | | | | 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
* [WebAssembly] Simplify generation of "names" sectionSam Clegg2018-01-171-5/+8
| | | | | | | | | | | | | | | | Simplify generation of "names" section by simply iterating over the DefinedFunctions array. This even fixes some bugs, judging by the test changes required. Some tests are asserting that functions are named multiple times, other tests are asserting that the "names" section contains the function's alias rather than its original name Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D42076 llvm-svn: 322751
* [WebAssembly] Refactor InputChunk.getSize(). NFCSam Clegg2018-01-171-8/+5
| | | | | | | | Also, remove trailing semicolons. Patch by Nicholas Wilson! llvm-svn: 322726
* [WebAssembly] Use ArrayRef over raw pointersSam Clegg2018-01-131-12/+10
| | | | | | Differential Revision: https://reviews.llvm.org/D42013 llvm-svn: 322423
* [WebAssembly] Add COMDAT supportSam Clegg2018-01-121-1/+6
| | | | | | | | | | | | | | | | | | 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
* [WebAssembly] Create synthetic __wasm_call_ctors functionSam Clegg2018-01-121-13/+24
| | | | | | | | | | | 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
OpenPOWER on IntegriCloud