aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/WasmObjectFile.cpp
AgeCommit message (Collapse)AuthorFilesLines
2017-12-21[WebAssembly] Remove unneeded sub-directorySam Clegg1-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
2017-12-21[WebAssembly] Fix local references to weak aliasesSam Clegg1-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
2017-12-17[WebAssembly] Export some more info on wasm funtionsSam Clegg1-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
2017-12-14Fix many -Wsign-compare and -Wtautological-constant-compare warnings.Zachary Turner1-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
2017-12-14[WebAssembly] Add support for init functions linking metadataSam Clegg1-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
2017-12-06[WebAssembly] Commit a file I accidentally omitted from r319956.Dan Gohman1-1/+0
llvm-svn: 319962
2017-12-03Reland "[WebAssembly] Add visibility flag to Wasm symbol flags""Sam Clegg1-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
2017-12-02[WebAssembly] Revert r319488 "Add visibility flag to Wasm symbol flags"Heejin Ahn1-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
2017-11-30Add visibility flag to Wasm symbol flagsSam Clegg1-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
2017-10-23[wasm] readSection: Avoid reading past eof (fixes oss-fuzz #3219)Vedant Kumar1-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
2017-09-29[WebAssembly] Allow each data segment to specify its own alignmentSam Clegg1-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
2017-09-26[WebAssembly] Model weakly defined symbols as wasm exportsSam Clegg1-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
2017-09-26[WebAssembly] Use function/global index space in WasmSymbolSam Clegg1-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
2017-09-20[WebAssembly] Weak symbols should be defined in SF_GlobalSam Clegg1-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
2017-09-20[WebAssembly] Add support for local symbol bindingsSam Clegg1-5/+9
Differential Revision: https://reviews.llvm.org/D38096 llvm-svn: 313817
2017-09-20Reland "[WebAssembly] Add support for naming wasm data segments"Sam Clegg1-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
2017-09-20Reverting due to Green Dragon bot failure.Mike Edwards1-9/+0
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/42594/ llvm-svn: 313706
2017-09-19[WebAssembly] Add support for naming wasm data segmentsSam Clegg1-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
2017-09-06[WebAssembly] Only treat imports/exports as symbols when reading relocatable ↵Sam Clegg1-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
2017-09-01[WebAssembly] Update relocation names to match specSam Clegg1-3/+3
Summary: See https://github.com/WebAssembly/tool-conventions/blob/master/Linking.md Differential Revision: https://reviews.llvm.org/D37385 llvm-svn: 312342
2017-09-01[WebAssembly] Fix getSymbolValue for exported globalsSam Clegg1-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
2017-08-31[WebAssembly] Fix getSymbolValue() for data symbolsSam Clegg1-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
2017-08-31[WebAssembly] Validate exports when parsing object filesSam Clegg1-0/+8
Subscribers: jfb, dschuff, jgravelle-google, aheejin Differential Revision: https://reviews.llvm.org/D37358 llvm-svn: 312286
2017-08-23[WebAssembly] Fix overflow for input with missing versionJonas Devlieghere1-1/+9
Differential revision: https://reviews.llvm.org/D37070 llvm-svn: 311605
2017-07-12[WebAssembly] Expose the offset of each data segmentSam Clegg1-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
2017-07-07[WebAssembly] Support weak defined symbolsSam Clegg1-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
2017-06-27[WebAssembly] Add support for printing relocations with llvm-objdumpSam Clegg1-1/+4
Differential Revision: https://reviews.llvm.org/D34658 llvm-svn: 306461
2017-06-27[WebAssembly] Add data size and alignement to linking sectionSam Clegg1-1/+10
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
2017-06-20[WebAssembly] Fix build failures introduced in r305769Sam Clegg1-0/+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
2017-06-20[WebAssembly] Add support for weak symbols in the binary formatSam Clegg1-5/+83
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
2017-06-16[WebAssembly] Use __stack_pointer global when writing wasm binarySam Clegg1-1/+3
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
2017-06-07Move Object format code to lib/BinaryFormat.Zachary Turner1-2/+2
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
2017-05-27Recommit "[DWARF] - Make collectAddressRanges() return section index in ↵George Rimar1-0/+4
addition to Low/High PC" With fix of uninitialized variable. Original commit message: This change is intended to use for LLD in D33183. Problem we have in LLD when building .gdb_index is that we need to know section which address range belongs to. Previously it was solved on LLD side by providing fake section addresses with use of llvm::LoadedObjectInfo interface. We assigned file offsets as addressed. Then after obtaining ranges lists, for each range we had to find section ID's. That not only was slow, but also complicated implementation and was the reason of incorrect behavior when sections share the same offsets, like D33176 shows. This patch makes DWARF parsers to return section index as well. That solves problem mentioned above. Differential revision: https://reviews.llvm.org/D33184 llvm-svn: 304078
2017-05-26Revert r304002 "[DWARF] - Make collectAddressRanges() return section index ↵George Rimar1-4/+0
in addition to Low/High PC" Revert it again. Now another bot unhappy: http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/8750 llvm-svn: 304011
2017-05-26[DWARF] - Make collectAddressRanges() return section index in addition to ↵George Rimar1-0/+4
Low/High PC This change is intended to use for LLD in D33183. Problem we have in LLD when building .gdb_index is that we need to know section which address range belongs to. Previously it was solved on LLD side by providing fake section addresses with use of llvm::LoadedObjectInfo interface. We assigned file offsets as addressed. Then after obtaining ranges lists, for each range we had to find section ID's. That not only was slow, but also complicated implementation and was the reason of incorrect behavior when sections share the same offsets, like D33176 shows. This patch makes DWARF parsers to return section index as well. That solves problem mentioned above. Differential revision: https://reviews.llvm.org/D33184 llvm-svn: 304002
2017-05-26Revert "[DWARF] - Make collectAddressRanges() return section index in ↵George Rimar1-4/+0
addition to Low/High PC" Broked BB again: TEST 'LLVM :: DebugInfo/X86/dbg-value-regmask-clobber.ll' FAILED ... LLVM ERROR: Section was outside of section table. llvm-svn: 303984
2017-05-26Recommit r303978 "[DWARF] - Make collectAddressRanges() return section index ↵George Rimar1-0/+4
in addition to Low/High PC" With fix of test compilation. Initial commit message: This change is intended to use for LLD in D33183. Problem we have in LLD when building .gdb_index is that we need to know section which address range belongs to. Previously it was solved on LLD side by providing fake section addresses with use of llvm::LoadedObjectInfo interface. We assigned file offsets as addressed. Then after obtaining ranges lists, for each range we had to find section ID's. That not only was slow, but also complicated implementation and was the reason of incorrect behavior when sections share the same offsets, like D33176 shows. This patch makes DWARF parsers to return section index as well. That solves problem mentioned above. Differential revision: https://reviews.llvm.org/D33184 llvm-svn: 303983
2017-05-26Revert r303978 "[DWARF] - Make collectAddressRanges() return section index ↵George Rimar1-4/+0
in addition to Low/High PC" It failed BB. llvm-svn: 303981
2017-05-26[DWARF] - Make collectAddressRanges() return section index in addition to ↵George Rimar1-0/+4
Low/High PC This change is intended to use for LLD in D33183. Problem we have in LLD when building .gdb_index is that we need to know section which address range belongs to. Previously it was solved on LLD side by providing fake section addresses with use of llvm::LoadedObjectInfo interface. We assigned file offsets as addressed. Then after obtaining ranges lists, for each range we had to find section ID's. That not only was slow, but also complicated implementation and was the reason of incorrect behavior when sections share the same offsets, like D33176 shows. This patch makes DWARF parsers to return section index as well. That solves problem mentioned above. Differential revision: https://reviews.llvm.org/D33184 llvm-svn: 303978
2017-05-09[WebAssembly] Improve libObject support for wasm imports and exportsSam Clegg1-10/+29
Previously we had only supported the importing and exporting of functions and globals. Also, add usefull overload of getWasmSymbol() and getNumberOfSymbols() in support of lld port. Differential Revision: https://reviews.llvm.org/D33011 llvm-svn: 302601
2017-05-09[WebAssembly] Fix validation of start functionSam Clegg1-1/+1
The check for valid start function was inverted. Added a new test in test/Object to check this case and fixed the existing tests in for ObjectYAML. Differential Revision: https://reviews.llvm.org/D32986 llvm-svn: 302560
2017-05-04[WebAssembly] Add wasm symbol table support to llvm-objdumpSam Clegg1-21/+47
Differential Revision: https://reviews.llvm.org/D32760 llvm-svn: 302185
2017-04-26revert debuggingSam Clegg1-1/+1
llvm-svn: 301370
2017-04-26[WebAssembly] Allow for signed relocation addendsSam Clegg1-2/+3
Summary: Addends are used as offsets to addresses of globals and can be both positive and negative. This change prints libObject in line with the spec and the MC layer. Subscribers: jfb, dschuff Differential Revision: https://reviews.llvm.org/D32507 llvm-svn: 301369
2017-04-25[WebAssembly] Read global index in init expression as LEBSam Clegg1-1/+1
Subscribers: jfb, dschuff Differential Revision: https://reviews.llvm.org/D32462 llvm-svn: 301330
2017-04-21[Object] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko1-2/+5
other minor fixes (NFC). llvm-svn: 301049
2017-04-01[WASM] Remove other comparison of unsigned expression >= 0.Davide Italiano1-3/+3
This should finally fix the GCC 7 build with -Werror. llvm-svn: 299313
2017-04-01[WASM] Remove a set but never used variable.Davide Italiano1-4/+1
llvm-svn: 299312
2017-04-01[WASM] Remove an assertion that can never fire.Davide Italiano1-2/+2
uint* is by definition always >=0. llvm-svn: 299311
2017-03-31Fix MSVC 'not all control paths return a value' warningSimon Pilgrim1-0/+1
llvm-svn: 299195