summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/WasmObjectFile.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [WebAssembly] Add version to object file metadataSam Clegg2018-04-261-0/+8
| | | | | | | | | | Summary: See https://github.com/WebAssembly/tool-conventions/issues/54 Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D46069 llvm-svn: 330969
* [WebAssembly] Implement getRelocationValueString()Sam Clegg2018-04-261-4/+8
| | | | | | | | And use it in llvm-objdump. Differential Revision: https://reviews.llvm.org/D46092 llvm-svn: 330957
* [WebAssebmly] Add Module name to WasmSymbolSam Clegg2018-04-251-0/+1
| | | | | | | | | | | | Imports in a wasm module can have custom module name. This change adds the module name to the WasmSymbol structure so that the linker can preserve this module name. This is needed to fix: https://bugs.llvm.org/show_bug.cgi?id=37168 Differential Revision: https://reviews.llvm.org/D45797 llvm-svn: 330854
* [WebAssembly] Use section index in relocation section headerSam Clegg2018-04-241-29/+6
| | | | | | | | | | | Rather than referring to sections my their code, use the absolute index of the target section within the module. See https://github.com/WebAssembly/tool-conventions/issues/52 Differential Revision: https://reviews.llvm.org/D45980 llvm-svn: 330749
* [WebAssembly] Distinguish debug/symbol names in the Wasm structs. NFCNicholas Wilson2018-04-201-15/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D45021 llvm-svn: 330448
* [WebAssembly] libObject: Don't include the name the size of custom sectionsSam Clegg2018-04-121-1/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D45579 llvm-svn: 329947
* [WebAssembly] Identify COMDATs by index rather than string. NFCNicholas Wilson2018-03-141-6/+11
| | | | | | | | This will enable an optimisation in LLD. Differential Revision: https://reviews.llvm.org/D44343 llvm-svn: 327522
* [WebAssembly] Disallow weak undefined globals in the object formatNicholas Wilson2018-03-091-0/+5
| | | | | | | | This implements https://github.com/WebAssembly/tool-conventions/pull/47 Differential Revision: https://reviews.llvm.org/D44201 llvm-svn: 327146
* [WebAssebmly] Remove reloc ordering constraintSam Clegg2018-03-061-3/+1
| | | | | | | | | | | | | The MC layer doesn't currently emit relocations in offset order for the entire code section so this check was causing failures on the wasm waterfall. Perhaps we can re-instate this check if we divide the relocations per-function, or add extra ordering the MC object writer. Differential Revision: https://reviews.llvm.org/D44136 llvm-svn: 326765
* [WebAssembly] Add validation to reloc sectionNicholas Wilson2018-03-051-4/+40
| | | | | | | | | | | | We now check relocations offsets are within range, and the relocation index is valid. Also updated tests which contained invalid Wasm files that were previously not checked. Differential Revision: https://reviews.llvm.org/D43684 llvm-svn: 326697
* [WebAssembly] Attach a name to globals similarly to function namingNicholas Wilson2018-03-051-2/+8
| | | | | | | | | This allows LLD to print the name for an InputGlobal when encountering an error. Differential Revision: https://reviews.llvm.org/D44033 llvm-svn: 326691
* [WebAssembly] Check function type indexesNicholas Wilson2018-03-021-1/+6
| | | | | | | | Also update tests containing invalid Wasm files, exposed by the check Differential Revision: https://reviews.llvm.org/D43954 llvm-svn: 326577
* [WebAssembly] Use uint8_t for single byte values to match the specSam Clegg2018-03-011-23/+11
| | | | | | | | | | | | | The original BinaryEncoding.md document used to specify that these values were `varint7`, but the official spec lists them explicitly as single byte values and not LEB. A similar change for wabt is in flight: https://github.com/WebAssembly/wabt/pull/782 Differential Revision: https://reviews.llvm.org/D43921 llvm-svn: 326454
* [WebAssembly] Fix copy-paste error in debugging stringNicholas Wilson2018-02-281-1/+1
| | | | llvm-svn: 326326
* [WebAssembly] Remove DataSize from linking metadata sectionSam Clegg2018-02-271-5/+0
| | | | | | | | | | | Neither the linker nor the runtime need this information anymore. We were originally using this to model BSS size but the plan is now to use the segment metadata to allow for BSS segments. Differential Revision: https://reviews.llvm.org/D41366 llvm-svn: 326267
* [WebAssembly] Add first claass symbol table to wasm objectsSam Clegg2018-02-231-135/+169
| | | | | | | | | | | | | | | | | | | | This is combination of two patches by Nicholas Wilson: 1. https://reviews.llvm.org/D41954 2. https://reviews.llvm.org/D42495 Along with a few local modifications: - One change I made was to add the UNDEFINED bit to the binary format to avoid the extra byte used when writing data symbols. Although this bit is redundant for other symbols types (i.e. undefined can be implied if a function or global is a wasm import) - I prefer to be explicit and consistent and not have derived flags. - Some field renaming. - Some reverting of unrelated minor changes. - No test output differences. Differential Revision: https://reviews.llvm.org/D43147 llvm-svn: 325860
* [WebAssebmly] Report undefined symbols correctly in objdumpSam Clegg2018-02-091-8/+13
| | | | | | | | | | | | | | Peviously we were reporting undefined symbol as being defined by the IMPORT sections. This change reports undefined symbols in the same that other formats do, and also removes the need to store the section with each symbol (since it can be derived from the symbol type). Differential Revision: https://reviews.llvm.org/D43101 llvm-svn: 324770
* [WebAssembly] MC: Remove unused code for handling of wasm globalsSam Clegg2018-01-311-4/+4
| | | | | | | | | | | | | | | For now, we are not using wasm globals, except for modeling of the stack points. Alos, factor out common struct WasmGlobalType, which matches the name for that tuple in the Wasm spec and rename methods to "isBindingGlobal", "isTypeGlobal" to avoid ambiguity. Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D42750 llvm-svn: 323901
* [WebAssembly] Add minor helper functions to WasmObjectFileSam Clegg2018-01-241-9/+18
| | | | | | | | Also, fix crash when exporting an imported function. Differential Revision: https://reviews.llvm.org/D42454 llvm-svn: 323290
* [WebAssembly] Remove debug names from symbol tableSam Clegg2018-01-171-10/+25
| | | | | | | | | | | | | | | | | | | | | | | | | Get rid of DEBUG_FUNCTION_NAME symbols. When we actually debug data, maybe we'll want somewhere to put it... but having a symbol that just stores the name of another symbol seems odd. It means you have multiple Symbols with the same name, one containing the actual function and another containing the name! Store the names in a vector on the WasmObjectFile when reading them in. Also stash them on the WasmFunctions themselves. The names are //not// "symbol names" or aliases or anything, they're just the name that a debugger should show against the function body itself. NB. The WasmObjectFile stores them so that they can be exported in the YAML losslessly, and hence the tests can be precise. Enforce that the CODE section has been read in before reading the "names" section. Requires minor adjustment to some tests. Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D42075 llvm-svn: 322741
* [WebAssembly] Don't allow functions to be named twiceSam Clegg2018-01-121-1/+6
| | | | | | | | The spec doesn't allow this. Differential Revision: https://reviews.llvm.org/D41974 llvm-svn: 322343
* [WebAssembly] Add COMDAT supportSam Clegg2018-01-091-0/+54
| | | | | | | | | | | | | | This adds COMDAT support to the Wasm object-file format. Spec: https://github.com/WebAssembly/tool-conventions/pull/31 Corresponding LLD change: https://bugs.llvm.org/show_bug.cgi?id=35533, and D40845 Patch by Nicholas Wilson Differential Revision: https://reviews.llvm.org/D40844 llvm-svn: 322135
* [WebAssembly] Explicitly specify function/global index space in YAMLSam Clegg2018-01-091-1/+3
| | | | | | | | | | | These indexes are useful because they are not always zero based and functions and globals are referenced elsewhere by their index. This matches what we already do for the type index space. Differential Revision: https://reviews.llvm.org/D41877 llvm-svn: 322121
* [WebAssembly] Remove unneeded sub-directorySam Clegg2017-12-211-1/+1
| | | | | | | | | This is the only wasm def (and likely likely will be for the foreseeable) file so no need for a sub-directory Differential Revision: https://reviews.llvm.org/D41476 llvm-svn: 321246
* [WebAssembly] Fix local references to weak aliasesSam Clegg2017-12-211-9/+18
| | | | | | | | | | | | | | | | When weak aliases are used with in same translation unit we need to be able to directly reference to alias and not just the thing it is aliases. We do this by defining both a wasm import and a wasm export in this case that result in a single Symbol. This change is a partial revert of rL314245. A corresponding lld change address the previous issues we had with this. See: https://github.com/WebAssembly/tool-conventions/issues/34 Differential Revision: https://reviews.llvm.org/D41472 llvm-svn: 321242
* [WebAssembly] Export some more info on wasm funtionsSam Clegg2017-12-171-4/+7
| | | | | | | | | | | | | Summary: These fields are useful for lld's gc-sections support Also remove an unused field. Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish Differential Revision: https://reviews.llvm.org/D41320 llvm-svn: 320946
* Fix many -Wsign-compare and -Wtautological-constant-compare warnings.Zachary Turner2017-12-141-1/+1
| | | | | | | | | | | | Most of the -Wsign-compare warnings are due to the fact that enums are signed by default in the MS ABI, while the tautological comparison warnings trigger on x86 builds where sizeof(size_t) is 4 bytes, so N > numeric_limits<unsigned>::max() is always false. Differential Revision: https://reviews.llvm.org/D41256 llvm-svn: 320750
* [WebAssembly] Add support for init functions linking metadataSam Clegg2017-12-141-1/+20
| | | | | | | | | | | | | | | Summary: This change lays the groundwork lowering of @llvm.global_ctors and @llvm.global_dtors for the wasm object format. Some parts of this patch are subset of: https://reviews.llvm.org/D40759 See https://github.com/WebAssembly/tool-conventions/issues/25 Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish Differential Revision: https://reviews.llvm.org/D41208 llvm-svn: 320742
* [WebAssembly] Commit a file I accidentally omitted from r319956.Dan Gohman2017-12-061-1/+0
| | | | llvm-svn: 319962
* Reland "[WebAssembly] Add visibility flag to Wasm symbol flags""Sam Clegg2017-12-031-1/+3
| | | | | | | | | | 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-3/+1
| | | | | | | | | 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-1/+3
| | | | | | | | | | | | | | 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
* [wasm] readSection: Avoid reading past eof (fixes oss-fuzz #3219)Vedant Kumar2017-10-231-3/+5
| | | | | | | | | | | | | A wasm file crafted with a bogus section size can trigger an ASan issue in the DWARFObjInMemory constructor. Nip the problem in the bud when we read the wasm section. Found by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3219 Differential Revision: https://reviews.llvm.org/D38777 llvm-svn: 316357
* [WebAssembly] Allow each data segment to specify its own alignmentSam Clegg2017-09-291-6/+7
| | | | | | | | | 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-13/+5
| | | | | | | | | | | | | 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] Use function/global index space in WasmSymbolSam Clegg2017-09-261-11/+9
| | | | | | | | | | | | | | | | | | | It is useful for the symbol to contain the index of the function of global it represents in the function/global index space. For imports we also store the import index so that the linker can find, for example, the signature of the corresponding function, which is defined by the import In the long run we need to decide whether this API surface should be closer to binary (where imported functions are seperate) or the wasm spec (where the function index space is unified). Differential Revision: https://reviews.llvm.org/D38189 llvm-svn: 314230
* [WebAssembly] Weak symbols should be defined in SF_GlobalSam Clegg2017-09-201-1/+1
| | | | | | | | | | | | Summary: This manifested itself in lld since it meant that weak symbols were not appearing in archive symbol tables. Subscribers: jfb, dschuff, jgravelle-google, aheejin Differential Revision: https://reviews.llvm.org/D38111 llvm-svn: 313838
* [WebAssembly] Add support for local symbol bindingsSam Clegg2017-09-201-5/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D38096 llvm-svn: 313817
* Reland "[WebAssembly] Add support for naming wasm data segments"Sam Clegg2017-09-201-0/+9
| | | | | | | | | 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-9/+0
| | | | | | 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-0/+9
| | | | | | | | | 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] Only treat imports/exports as symbols when reading relocatable ↵Sam Clegg2017-09-061-33/+67
| | | | | | | | | | | | | | | | | | | object files This change only treats imported and exports functions and globals as symbol table entries the object has a "linking" section (i.e. it is relocatable object file). In this case all globals must be of type I32 and initialized with i32.const. This was previously being assumed but not checked for and was causing a failure on big endian machines due to using the wrong value of then union. See: https://bugs.llvm.org/show_bug.cgi?id=34487 Differential Revision: https://reviews.llvm.org/D37497 llvm-svn: 312674
* [WebAssembly] Update relocation names to match specSam Clegg2017-09-011-3/+3
| | | | | | | | Summary: See https://github.com/WebAssembly/tool-conventions/blob/master/Linking.md Differential Revision: https://reviews.llvm.org/D37385 llvm-svn: 312342
* [WebAssembly] Fix getSymbolValue for exported globalsSam Clegg2017-09-011-1/+1
| | | | | | | | | | | | The code wasn't previously taking into account that the global index space is not same as the into in the Globals array since the latter does not include imported globals. This fixes the WebAssembly waterfall failures. Differential Revision: https://reviews.llvm.org/D37384 llvm-svn: 312340
* [WebAssembly] Fix getSymbolValue() for data symbolsSam Clegg2017-08-311-1/+6
| | | | | | | | | | This is mostly a fix for the output of `llvm-nm` See Bug 34392: https://bugs.llvm.org//show_bug.cgi?id=34392 Differential Revision: https://reviews.llvm.org/D37359 llvm-svn: 312294
* [WebAssembly] Validate exports when parsing object filesSam Clegg2017-08-311-0/+8
| | | | | | | | Subscribers: jfb, dschuff, jgravelle-google, aheejin Differential Revision: https://reviews.llvm.org/D37358 llvm-svn: 312286
* [WebAssembly] Fix overflow for input with missing versionJonas Devlieghere2017-08-231-1/+9
| | | | | | Differential revision: https://reviews.llvm.org/D37070 llvm-svn: 311605
* [WebAssembly] Expose the offset of each data segmentSam Clegg2017-07-121-4/+6
| | | | | | | | | | | | | | Summary: This allows tools like lld that process relocations to apply data relocation correctly. This information is required because relocation are stored as section offset. Subscribers: jfb, dschuff, jgravelle-google, aheejin Differential Revision: https://reviews.llvm.org/D35234 llvm-svn: 307741
* [WebAssembly] Support weak defined symbolsSam Clegg2017-07-071-10/+20
| | | | | | | | | | | | 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] Add support for printing relocations with llvm-objdumpSam Clegg2017-06-271-1/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D34658 llvm-svn: 306461
OpenPOWER on IntegriCloud