summaryrefslogtreecommitdiffstats
path: root/lld/wasm/OutputSections.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [WebAssembly] Elide data segments for .bss sectionsThomas Lively2019-10-151-1/+15
| | | | | | | | | | | | | | | | | | | Summary: WebAssembly memories are zero-initialized, so when module does not import its memory initializing .bss sections is guaranteed to be a no-op. To reduce binary size and initialization time, .bss sections are simply not emitted into the final binary unless the memory is imported. Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68965 llvm-svn: 374940
* [WebAssembly] Wrap definitions in namespace lld { namespace wasm {. NFCFangrui Song2019-10-101-9/+13
| | | | | | | | | | Similar to D68323, but for wasm. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D68759 llvm-svn: 374279
* [Coding style change][lld] Rename variables for non-ELF portsRui Ueyama2019-07-111-115/+115
| | | | | | | | | | | 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-6/+6
| | | | | | style change. NFC. llvm-svn: 365605
* Add parentheses to silence warnings.Bill Wendling2019-07-081-3/+2
| | | | llvm-svn: 365397
* [WebAssembly] Add option to emit passive segmentsThomas Lively2019-07-031-11/+17
| | | | | | | | | | | | | | | | | | | | | | | 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
* [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] Refactor synthetic sections and relocation processing. NFC.Sam Clegg2019-05-211-6/+1
| | | | | | | | | | | 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-161-10/+9
| | | | | | | | | | | | | | 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] Emit the DataCount section when bulk memory is enabledThomas Lively2019-04-191-0/+2
| | | | | | | | | | | | | | | | | | 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
* Fix a crash bug caused by a nested call of parallelForEach.Rui Ueyama2019-04-171-6/+6
| | | | | | | | | | | | parallelForEach is not reentrant. We use parallelForEach to call each section's writeTo(), so calling the same function within writeTo() is not safe. Fixes https://bugs.llvm.org/show_bug.cgi?id=41508 Differential Revision: https://reviews.llvm.org/D60757 llvm-svn: 358547
* 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] Instruction renamingThomas Lively2019-01-081-1/+1
| | | | | | | | | | | | Summary: Associated with D56338. Reviewers: aheejin, aardappel Subscribers: dschuff, sbc100, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D56339 llvm-svn: 350610
* [WebAssembly] Add support for the event sectionHeejin Ahn2018-12-081-0/+2
| | | | | | | | | | | | | | | | | 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] Import the stack pointer when building shared librariesSam Clegg2018-11-151-2/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D54558 llvm-svn: 346974
* [WebAssembly] Initial support for shared objects (-shared)Sam Clegg2018-11-151-3/+12
| | | | | | | | | | | | Based on the initial spec proposal: https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md The llvm/codegen side of this is still missing but I believe this change is still worth landing as an incremental step Differential Revision: https://reviews.llvm.org/D54249 llvm-svn: 346918
* [WebAssembly] Add option to remove LEB padding at relocate sitesSam Clegg2018-05-181-1/+2
| | | | | | | | | | | | | | | | | 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] Add support for debug (DWARF) sectionsSam Clegg2018-05-041-0/+12
| | | | | | | | | | | | | | 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] Add support for custom sectionsSam Clegg2018-04-101-0/+35
| | | | | | | | | 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] Remove another trivial accessor.Rui Ueyama2018-04-051-4/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D43725 llvm-svn: 329336
* [WebAssembly] Run clang-format. NFCNicholas Wilson2018-03-071-3/+2
| | | | llvm-svn: 326896
* [WebAssembly] Return a StringRef instead of std::string from ↵Rui Ueyama2018-02-281-7/+7
| | | | | | | | getSectionName(). NFC. Differential Revision: https://reviews.llvm.org/D43854 llvm-svn: 326337
* [WebAssembly] Do not use inheritance to define SubSection.Rui Ueyama2018-02-281-4/+1
| | | | | | | | | | | | | | SubSection inherited from SyntheticSection, and SyntheticSection inherits from OutputSection, so SubSection was an OutputSection. But that's wrong because SubSection is not actually a WebAssembly output section. It shares some functionalities with OutputSection, but overall it's very different. This patch removes that inheritance. Differential Revision: https://reviews.llvm.org/D43719 llvm-svn: 326286
* [WebAssembly] Remove redundant local variables.Rui Ueyama2018-02-281-10/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D43709 llvm-svn: 326280
* Consistent (non) use of empty lines in include blocksSam Clegg2018-02-201-1/+0
| | | | | | | | | The profailing style in lld seem to be to not include such empty lines. Clang-tidy/clang-format seem to handle this just fine. Differential Revision: https://reviews.llvm.org/D43528 llvm-svn: 325629
* Do not create a temporary data structure for relocations.Rui Ueyama2018-02-201-12/+10
| | | | | | | | | | | | 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
* Refactor wasm/WriterUtil.{cpp,h}.Rui Ueyama2018-02-161-1/+2
| | | | | | | | | | | | | | | | Summary: - Makes code more in line with LLVM style (e.g. const char * -> StringRef) - Do not use formatv since we can construct message just by `+` - Replace some odd types such as `const StringRef` with more common type - Do not use default arguments if they are not necessary Reviewers: sbc100 Subscribers: jfb, aheejin, llvm-commits, sunfish Differential Revision: https://reviews.llvm.org/D43403 llvm-svn: 325383
* [WebAssembly] Move relocation handling InputChunks.cppSam Clegg2018-01-101-135/+10
| | | | | | | | | Teach each input chunk how to write itself and apply its own relocations. Differential Revision: https://reviews.llvm.org/D41891 llvm-svn: 322212
* [WebAssembly] Add InputChunk as common base class for InputSegment and ↵Sam Clegg2018-01-101-23/+18
| | | | | | | | InputFunction. NFC. Differential Revision: https://reviews.llvm.org/D41419 llvm-svn: 322148
* [WebAssembly] Output functions individuallySam Clegg2018-01-091-39/+26
| | | | | | | | | | | | | The code section is now written out one function at a time rather than all the functions in a given objects being serialized at once. This change lays the groundwork for supporting --gc-sections. Differential Revision: https://reviews.llvm.org/D41315 llvm-svn: 322138
* [WebAssembly] Write out undefined symbol addresses as zeroSam Clegg2018-01-081-5/+1
| | | | | | | | | | | | | The addresses of undefined symbols that make it into the final executable (i.e. weak references to non-existent symbols) should resolve to zero. Also, make sure to not include function in the indirect function table if they are not included in the output. Differential Revision: https://reviews.llvm.org/D41839 llvm-svn: 322045
* [WebAssembly] Improve toString(OutputSection). NFC.Sam Clegg2017-12-201-9/+9
| | | | llvm-svn: 321146
* [WebAssembly] Apply data relocations in parallel. NFC.Sam Clegg2017-12-191-10/+19
| | | | | | | | | | Store data relocations with their respective segment. This allows relocations to be applied as each segment is written (and therefore in parallel). Differential Revision: https://reviews.llvm.org/D41410 llvm-svn: 321105
* [WebAssembly] Add support for writing out init functions in linking sectionSam Clegg2017-12-191-2/+9
| | | | | | | | | This change add support for init functions in the linking section, but only in -r/--relocatable mode. Differential Revision: https://reviews.llvm.org/D41375 llvm-svn: 321088
* [WebAssebmly] Fix the single clang-format issue in `wasm` directorySam Clegg2017-12-181-2/+1
| | | | llvm-svn: 321020
* Prefer `ArrayRef` over `const std::vector&`Sam Clegg2017-12-081-3/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D40993 llvm-svn: 320125
* [WebAssembly] Fix symbol exports under -r/--relocatableSam Clegg2017-12-071-7/+10
| | | | | | | | | | | | | | | This change cleans up the way wasm exports and globals are generated, particualrly for -r/--relocatable where globals need to be created and exported in order for output relocations which reference them. Remove the need for a per file GlobalIndexOffset and instead set the output index for each symbol directly. This simplifies the code in several places. Differential Revision: https://reviews.llvm.org/D40859 llvm-svn: 320001
* Move Memory.{h,cpp} to Common.Rui Ueyama2017-11-281-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D40571 llvm-svn: 319221
* [WebAssembly] Initial wasm linker implementationSam Clegg2017-11-171-0/+330
This linker backend is still a work in progress but is enough to link simple programs including linking against library archives. Differential Revision: https://reviews.llvm.org/D34851 llvm-svn: 318539
OpenPOWER on IntegriCloud