summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/WasmObjectWriter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [WebAssembly] Remove an obsolete comment.Dan Gohman2017-12-201-2/+1
| | | | llvm-svn: 321127
* [WebAssembly] Implement @llvm.global_ctors and @llvm.global_dtorsSam Clegg2017-12-151-4/+75
| | | | | | | | | | | | | | | Summary: - lowers @llvm.global_dtors by adding @llvm.global_ctors functions which register the destructors with `__cxa_atexit`. - impements @llvm.global_ctors with wasm start functions and linker metadata See [here](https://github.com/WebAssembly/tool-conventions/issues/25) for more background. Subscribers: jfb, dschuff, mgorny, jgravelle-google, aheejin, sunfish Differential Revision: https://reviews.llvm.org/D41211 llvm-svn: 320774
* Remove redundant includes from lib/MC.Michael Zolotukhin2017-12-131-2/+0
| | | | llvm-svn: 320624
* Reland "[WebAssembly] Import the linear memory and function table."Sam Clegg2017-12-111-40/+42
| | | | | | Original change: https://reviews.llvm.org/D40875 llvm-svn: 320432
* Revert "[WebAssembly] Import the linear memory and function table."Sam Clegg2017-12-071-42/+40
| | | | | | | | | We need to a little time to prepare and lld-side change that supports this. Original change: https://reviews.llvm.org/D40875 llvm-svn: 320003
* [WebAssembly] Import the linear memory and function table.Dan Gohman2017-12-061-40/+42
| | | | | | | | | | | | Instead of having .o files contain linear-memory and function table definitions, use imports. This is more consistent with the stack pointer being imported, and it's consistent with the linker being the one to decide whether linear memory and function table are imported or defined in the linked output. This implements tool-conventions #23. Differential Revision: https://reviews.llvm.org/D40875 llvm-svn: 319989
* [WebAssembly] Remove WASM_STACK_POINTER.Dan Gohman2017-12-061-35/+4
| | | | | | | WASM_STACK_POINTER and the .stack_pointer directive are no longer needed now that the stack pointer global is an import. llvm-svn: 319956
* [WebAssembly] Make stack-pointer imports mutable.Dan Gohman2017-12-051-40/+47
| | | | | | | | | | | | This is not currently valid by the wasm spec, however: - It replaces doing set_global on an immutable global, which is also not valid. - It's expected be valid in the near future: https://github.com/WebAssembly/threads/blob/master/proposals/threads/Globals.md - This only occurs before linking, so a fully linked object will be valid. llvm-svn: 319810
* [WebAssembly] Implement WASM_STACK_POINTER.Dan Gohman2017-12-051-11/+12
| | | | | | | Use the .stack_pointer directive to implement WASM_STACK_POINTER for specifying a global variable to be the stack pointer. llvm-svn: 319797
* Reland "[WebAssembly] Add visibility flag to Wasm symbol flags""Sam Clegg2017-12-031-2/+6
| | | | | | | | | | Original change was rL319488. This was reverted rL319602 due to a gcc 7.1 warning. Differential Revision: https://reviews.llvm.org/D40772 llvm-svn: 319626
* [WebAssembly] Revert r319488 "Add visibility flag to Wasm symbol flags"Heejin Ahn2017-12-021-6/+2
| | | | | | | | | This patch reportedly broke one of LLVM bots (ubuntu-gcc7.1-werror). See http://lab.llvm.org:8011/builders/ubuntu-gcc7.1-werror/builds/3369 for details. llvm-svn: 319602
* Add visibility flag to Wasm symbol flagsSam Clegg2017-11-301-2/+6
| | | | | | | | | | | | | | The LLVM "hidden" flag needs to be passed through the Wasm intermediate objects in order for the linker to apply it to the final Wasm object. The corresponding change in LLD is here: https://github.com/WebAssembly/lld/pull/14 Patch by Nicholas Wilson Differential Revision: https://reviews.llvm.org/D40442 llvm-svn: 319488
* [WebAssembly] Support bitcasted function addresses with varargs.Dan Gohman2017-11-281-3/+6
| | | | | | | | | | | | | Generalize FixFunctionBitcasts to handle varargs functions. This in particular fixes the case where clang bitcasts away a varargs when calling a K&R-style function. This avoids interacting with tricky ABI details because it operates at the LLVM IR level before varargs ABI details are exposed. This fixes PR35385. llvm-svn: 319186
* [WebAssembly] MC: Don't allow zero sized data segmentsSam Clegg2017-10-271-0/+8
| | | | | | | | | | | This ensures that each segment has a unique address. Without this, consecutive zero sized symbols would end up with the same address and the linker cannot map symbols to unique data segments. Differential Revision: https://reviews.llvm.org/D39107 llvm-svn: 316717
* [WebAssembly] MC: Fix crash when -g specified.Sam Clegg2017-10-201-6/+11
| | | | | | | | | At this point we don't output any debug sections or thier relocations. Differential Revision: https://reviews.llvm.org/D39076 llvm-svn: 316240
* Reverting r315590; it did not include changes for llvm-tblgen, which is ↵Aaron Ballman2017-10-151-1/+1
| | | | | | | | causing link errors for several people. Error LNK2019 unresolved external symbol "public: void __cdecl `anonymous namespace'::MatchableInfo::dump(void)const " (?dump@MatchableInfo@?A0xf4f1c304@@QEBAXXZ) referenced in function "public: void __cdecl `anonymous namespace'::AsmMatcherEmitter::run(class llvm::raw_ostream &)" (?run@AsmMatcherEmitter@?A0xf4f1c304@@QEAAXAEAVraw_ostream@llvm@@@Z) llvm-tblgen D:\llvm\2017\utils\TableGen\AsmMatcherEmitter.obj 1 llvm-svn: 315854
* [dump] Remove NDEBUG from test to enable dump methods [NFC]Don Hinton2017-10-121-1/+1
| | | | | | | | | | | | | | | Summary: Add LLVM_FORCE_ENABLE_DUMP cmake option, and use it along with LLVM_ENABLE_ASSERTIONS to set LLVM_ENABLE_DUMP. Remove NDEBUG and only use LLVM_ENABLE_DUMP to enable dump methods. Move definition of LLVM_ENABLE_DUMP from config.h to llvm-config.h so it'll be picked up by public headers. Differential Revision: https://reviews.llvm.org/D38406 llvm-svn: 315590
* [MC] Thread unique_ptr<MCObjectWriter> through the create.*ObjectWriterLang Hames2017-10-101-2/+5
| | | | | | | | | | functions. This makes the ownership of the resulting MCObjectWriter clear, and allows us to remove one instance of MCObjectStreamer's bizarre "holding ownership via someone else's reference" trick. llvm-svn: 315327
* [MC] Plumb unique_ptr<MCWasmObjectTargetWriter> through createWasmObjectWriterLang Hames2017-10-101-5/+8
| | | | | | | | | | to WasmObjectWriter's constructor. Fixes the same ownership issue for COFF that r315245 did for MachO: WasmObjectWriter takes ownership of its MCWasmObjectTargetWriter, so we want to pass this through to the constructor via a unique_ptr, rather than a raw ptr. llvm-svn: 315260
* [WebAssembly] Allow each data segment to specify its own alignmentSam Clegg2017-09-291-15/+15
| | | | | | | | | Also, add a flags field as we will almost certainly be needing that soon too. Differential Revision: https://reviews.llvm.org/D38296 llvm-svn: 314534
* [WebAssembly] Model weakly defined symbols as wasm exportsSam Clegg2017-09-261-1/+2
| | | | | | | | | | | | | Previously these were being included as both imports and exports, with the import being satisfied by the export (or some strong symbol) at runtime. However proved unnecessary and actually complicated linking as it meant there was not a 1-to-1 mapping between a wasm function /global index and a linker symbol. Differential Revision: https://reviews.llvm.org/D38246 llvm-svn: 314245
* [WebAssembly] Add support for local symbol bindingsSam Clegg2017-09-201-15/+22
| | | | | | Differential Revision: https://reviews.llvm.org/D38096 llvm-svn: 313817
* Reland "[WebAssembly] Add support for naming wasm data segments"Sam Clegg2017-09-201-3/+16
| | | | | | | | | Add adds support for naming data segments. This is useful useful linkers so that they can merge similar sections. Differential Revision: https://reviews.llvm.org/D37886 llvm-svn: 313795
* Reverting due to Green Dragon bot failure.Mike Edwards2017-09-201-16/+3
| | | | | | http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/42594/ llvm-svn: 313706
* [WebAssembly] Add support for naming wasm data segmentsSam Clegg2017-09-191-3/+16
| | | | | | | | | Add adds support for naming data segments. This is useful useful linkers so that they can merge similar sections. Differential Revision: https://reviews.llvm.org/D37886 llvm-svn: 313692
* [WebAssembly] MC: Create wasm data segments based on MCSectionsSam Clegg2017-09-151-48/+54
| | | | | | | | | | | This means that we can honor -fdata-sections rather than always creating a segment for each symbol. It also allows for a followup change to add .init_array and friends. Differential Revision: https://reviews.llvm.org/D37876 llvm-svn: 313395
* Change encodeU/SLEB128 to pad to certain number of bytesSam Clegg2017-09-151-16/+3
| | | | | | | | | | | | | | | Previously the 'Padding' argument was the number of padding bytes to add. However most callers that use 'Padding' know how many overall bytes they need to write. With the previous code this would mean encoding the LEB once to find out how many bytes it would occupy and then using this to calulate the 'Padding' value. See: https://reviews.llvm.org/D36595 Differential Revision: https://reviews.llvm.org/D37494 llvm-svn: 313393
* [WebAssembly] Pass ArrayRef rather than SmallVectorSam Clegg2017-09-151-26/+20
| | | | | | | | This is more flexible and less verbose. Differential Revision: https://reviews.llvm.org/D37875 llvm-svn: 313384
* [WebAssembly] MC: Fix crash in getProvitionalValue on weak referencesSam Clegg2017-09-151-15/+15
| | | | | | | | | - Create helper function for resolving weak references. - Add test that preproduces the crash. Differential Revision: https://reviews.llvm.org/D37916 llvm-svn: 313381
* [WebAssembly] Use a separate wasm data segment for each global symbolSam Clegg2017-09-141-70/+88
| | | | | | | | | | This is stepping stone towards honoring -fdata-sections and letting the assembler decide how many wasm data segments to create. Differential Revision: https://reviews.llvm.org/D37834 llvm-svn: 313313
* [WebAssembly] Update relocation names to match specSam Clegg2017-09-011-11/+11
| | | | | | | | Summary: See https://github.com/WebAssembly/tool-conventions/blob/master/Linking.md Differential Revision: https://reviews.llvm.org/D37385 llvm-svn: 312342
* Simplify interface now that we don't need to pass IsPCRel. NFC.Rafael Espindola2017-07-111-3/+5
| | | | llvm-svn: 307734
* [WebAssembly] Fix use of cast vs dyn_castSam Clegg2017-07-111-15/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D35233 llvm-svn: 307612
* [WebAssembly] Use the correct size for MCFillFragmentSam Clegg2017-07-101-1/+1
| | | | | | | | | | | Summary: When implementing MCFillFragment, use the size of the fragment, rather than the size of the section. Patch by Dan Gohman Differential Revision: https://reviews.llvm.org/D35090 llvm-svn: 307565
* [WebAssembly] Support weak defined symbolsSam Clegg2017-07-071-65/+68
| | | | | | | | | | | | Model weakly defined symbols as symbols that are both exports and imported and marked as weak. Local references to the symbols refer to the import but the linker can resolve this to the weak export if not strong symbol is found at link time. Differential Revision: https://reviews.llvm.org/D35029 llvm-svn: 307348
* [WebAssembly] Fix types for address taken functionsSam Clegg2017-07-051-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D34966 llvm-svn: 307198
* [WebAssembly] MC: Don't generate extra types for weak aliasSam Clegg2017-07-051-0/+4
| | | | | | | | | | Previously we were generating a void(void) function type for a weak alias. Update the weak-alias test case to catch this. Differential Revision: https://reviews.llvm.org/D34734 llvm-svn: 307194
* [WebAssembly] Add data size and alignement to linking sectionSam Clegg2017-06-271-7/+17
| | | | | | | | | The overal size of the data section (including BSS) is otherwise not included in the wasm binary. Differential Revision: https://reviews.llvm.org/D34657 llvm-svn: 306459
* [WebAssembly] Cleanup WasmObjectWriter.cpp. NFCSam Clegg2017-06-211-78/+70
| | | | | | | | | | | - Use auto where appropriate - Use early return to reduce nesting - Remove stray comment line - Use C++ foreach over explicit iterator Differential Revision: https://reviews.llvm.org/D34477 llvm-svn: 305971
* WasmObjectWriter.cpp: Tweak a comment line. [-Wdocumentation]NAKAMURA Takumi2017-06-201-1/+1
| | | | llvm-svn: 305777
* Fix unused function build error in lldSam Clegg2017-06-201-0/+2
| | | | | | | | | | | | The lld-x86_64-darwin13 is failing with: error: unused function 'operator<<' Wrap the declation in ifndef NDEBUG, which matches what is done in MipsELFObjectWriter.cpp. Differential Revision: https://reviews.llvm.org/D34384 llvm-svn: 305771
* [WebAssembly] Fix build failures introduced in r305769Sam Clegg2017-06-201-2/+1
| | | | | | | | | | | This fixes two build failures that only occur in certain configurations: - error: unused function 'operator<<' - error: control reaches end of non-void function Differential Revision: https://reviews.llvm.org/D34382 llvm-svn: 305770
* [WebAssembly] Add support for weak symbols in the binary formatSam Clegg2017-06-201-46/+123
| | | | | | | | | | | This also introduces the updated format for the "linking" section which can represent extra symbol information. See: https://github.com/WebAssembly/tool-conventions/pull/10 Differential Revision: https://reviews.llvm.org/D34019 llvm-svn: 305769
* [WebAssembly] Use __stack_pointer global when writing wasm binarySam Clegg2017-06-161-2/+6
| | | | | | | | | | | | | | | | | | This ensures that symbolic relocations are generated for stack pointer manipulations. These relocations are of type R_WEBASSEMBLY_GLOBAL_INDEX_LEB. This change also adds support for reading relocations of this type in WasmObjectFile.cpp. Since its a globally imported symbol this does mean that the get_global/set_global instruction won't be valid until the objects are linked that global used in no longer an imported global. Differential Revision: https://reviews.llvm.org/D34172 llvm-svn: 305616
* [WebAssembly] Cleanup WebAssemblyWasmObjectWriterSam Clegg2017-06-131-4/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D34131 llvm-svn: 305316
* [WebAssembly] MC: Fix value of R_WEBASSEMBLY_TABLE_INDEX relocationsSam Clegg2017-06-121-14/+20
| | | | | | | | | | | | | Previously we were writing the value function index space value but for these types of relocations we want to be writing the table element index space value. Add a test case for these relocation types that fails without this change. Differential Revision: https://reviews.llvm.org/D33962 llvm-svn: 305253
* Move Object format code to lib/BinaryFormat.Zachary Turner2017-06-071-0/+1
| | | | | | | | | | | | This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 llvm-svn: 304864
* [WebAssembly] MC: Refactor relocation handlingSam Clegg2017-06-061-151/+94
| | | | | | | | | | | | | The change cleans up and unifies the handling of relocation entries in WasmObjectWriter. Type index relocation no longer need to be handled separately. The only externally visible change should be that type index relocations are no longer grouped at the end. Differential Revision: https://reviews.llvm.org/D33918 llvm-svn: 304816
* [WebAssembly] Remove unused methods from MCWasmObjectTargetWriterSam Clegg2017-06-061-0/+21
| | | | | | | | | | | | | These methods looks like they were originally came from MCELFObjectTargetWriter but they are never called by the WasmObjectWriter. Remove these methods meant the declaration of WasmRelocationEntry could also move into the cpp file. Differential Revision: https://reviews.llvm.org/D33905 llvm-svn: 304804
* [WebAssembly] Refactor WasmObjectWriter::writeObjectSam Clegg2017-06-031-402/+483
| | | | | | | | | | The size of this function was getting a little out of. control. Split code for writing each section type into seperate functions. Differential Revision: https://reviews.llvm.org/D33792 llvm-svn: 304634
OpenPOWER on IntegriCloud