summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* [YAML] Fix mustQuote return type changed in r320996Francis Visoiu Mistrih2017-12-181-3/+3
| | | | llvm-svn: 320997
* Move new lld's code to Common subdirectory.Rui Ueyama2017-10-021-1/+1
| | | | | | | | | | New lld's files are spread under lib subdirectory, and it isn't easy to find which files are actually maintained. This patch moves maintained files to Common subdirectory. Differential Revision: https://reviews.llvm.org/D37645 llvm-svn: 314719
* Fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTORRichard Smith2017-06-301-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | This is a short-term fix for PR33650 aimed to get the modules build bots green again. Remove all the places where we use the LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR macros to try to locally specialize a global template for a global type. That's not how C++ works. Instead, we now centrally define how to format vectors of fundamental types and of string (std::string and StringRef). We use flow formatting for the former cases, since that's the obvious right thing to do; in the latter case, it's less clear what the right choice is, but flow formatting is really bad for some cases (due to very long strings), so we pick block formatting. (Many of the cases that were using flow formatting for strings are improved by this change.) Other than the flow -> block formatting change for some vectors of strings, this should result in no functionality change. Differential Revision: https://reviews.llvm.org/D34907 Corresponding LLVM change is r306878. llvm-svn: 306880
* Move Object format code to lib/BinaryFormat.Zachary Turner2017-06-071-2/+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
* [lld][MachO] Add support for S_ATTR_DEBUG to the MachO YAML reader/writer.Lang Hames2016-07-261-0/+2
| | | | | | | This enables proper recognition of debug sections by attribute, which will be used in the near future by test-cases for MachO debugging support. llvm-svn: 276770
* [lld][MachO] Clean up some unnecessarily verbose code. NFC.Lang Hames2016-04-061-4/+1
| | | | | | Suggested by Dave Blaikie in review of r265447. Thanks Dave! llvm-svn: 265566
* [lld][MachO] Check Expected<T> for error prior to destruction.Lang Hames2016-04-051-15/+17
| | | | | | This should fix the failures on the LLD bots caused by r265446. llvm-svn: 265477
* Use Expected<T> instead of ErrorOr<T>in yaml reader. NFCPete Cooper2016-03-311-3/+4
| | | | llvm-svn: 264981
* Convert normalized file to atoms methods to new error handling. NFC.Pete Cooper2016-03-301-5/+11
| | | | | | | This converts almost all of the error handling in atom creation to llvm::Error instead of std::error_code. llvm-svn: 264968
* Use None to construct an empty ArrayRef. NFC.Pete Cooper2016-03-241-1/+1
| | | | | | Suggested by David Blaikie in response to r264234. llvm-svn: 264311
* Avoid UB when creating empty atoms. NFC.Pete Cooper2016-03-241-0/+2
| | | | | | | | | The stack-size.yaml test had an empty atom content array. This is legal, but asking a BumpPtrAllocator for 0 sized data may not be legal. Instead just avoid requesting any data when we can just return an empty ArrayRef instead. llvm-svn: 264234
* Parsed alignment should be a power of 2.Pete Cooper2016-03-241-1/+24
| | | | | | | | | | The .o path always makes sure to store a power of 2 value in the Section alignment. However, the YAML code didn't verify this. Added verification and updated all the tests which had a 3 but meant to have 2^3. llvm-svn: 264228
* Set max segment protection level.Pete Cooper2016-02-061-4/+5
| | | | | | | | | | | The initial segment protection was also being used to set the maximum segment protection level. Instead, the maximum should be set according to the architecture we are linking. For example on Mac OS it should be RWX on most pages, but on iOS is often on R_X. rdar://problem/24515136 llvm-svn: 259966
* Generate version min load commands when the platform is unknown.Pete Cooper2016-02-041-0/+9
| | | | | | | | | | | In the case where we are emitting to an object file, the platform is possibly unknown, and the source object files contained load commands for version min, we can take the maximum of those min versions and emit in in the output object file. This test also tests r259739. llvm-svn: 259742
* [lld][MachO] Recognize __thread_bss sections as zero-fill and set all theLang Hames2015-12-111-1/+1
| | | | | | | | | appropriate bits. This fixes the remaining clang regression test failures when linking clang with lld on Darwin. llvm-svn: 255390
* [lld] Make the MachO -stack_size default '0', add a test case.Lang Hames2015-05-221-1/+1
| | | | | | Addresses some review comments for r237841. llvm-svn: 237979
* [LLD] Add support for the -stack_size option to Darwin ld.Lang Hames2015-05-201-0/+1
| | | | llvm-svn: 237841
* Use arithmetic type to represent alignments (not in log2) everywhere.Rui Ueyama2015-03-261-15/+1
| | | | | | | This is the final step of conversion. Now log2 numbers are removed from everywhere! llvm-svn: 233246
* Define an implicit constructor which takes actual alignment value to PowerOf2.Rui Ueyama2015-03-261-2/+2
| | | | | | | The new constructor's type is the same, but this one takes not a log2 value but an alignment value itself, so the meaning is totally differnet. llvm-svn: 233244
* Make PowerOf2's constructor private.Rui Ueyama2015-03-261-2/+2
| | | | | | | Ban conversion from integers to PowerOf2 even if explicit to make all places we create PowerOf2 instances visible. llvm-svn: 233243
* Remove implicit constructor and operator int from PowerOf2.Rui Ueyama2015-03-261-2/+15
| | | | | | | | | | This patch is to make instantiation and conversion to an integer explicit, so that we can mechanically replace all occurrences of the class with integer in the next step. Now get() returns an alignment value rather than its log2 value. llvm-svn: 233242
* [mach-o] propagate dylib version numbersNick Kledzik2014-11-191-4/+30
| | | | | | | | | | | | | | Mach-o does not use a simple SO_NEEDED to track dependent dylibs. Instead, the linker copies four things from each dylib to each client: the runtime path (aka "install name"), the build time, current version (dylib build number), and compatibility version The build time is no longer used (it cause every rebuild of a dylib to be different). The compatibility version is usually just 1.0 and never changes, or the dylib becomes incompatible. This patch copies that information into the NormalizedMachO format and propagates it to clients. llvm-svn: 222300
* [mach-o] Add support for arm64 (AAarch64)Nick Kledzik2014-09-091-0/+26
| | | | | | | | | | Most of the changes are in the new file ArchHandler_arm64.cpp. But a few things had to be fixed to support 16KB pages (instead of 4KB) which iOS arm64 requires. In addition the StubInfo struct had to be expanded because arm64 uses two instruction (ADRP/LDR) to load a global which requires two relocations. The other mach-o arches just needed one relocation. llvm-svn: 217469
* [mach-o] Add support for using export triesNick Kledzik2014-09-031-4/+7
| | | | | | | | | | | On Darwin at runtime, dyld will prefer to use the export trie of a dylib instead of the traditional symbol table (which is large and requires a binary search). This change enables the linker to generate an export trie and to prefer it if found in a dylib being linked against. This also simples the yaml for dylibs because the yaml form of the trie can be reduced to just a sequence of names. llvm-svn: 217066
* [mach-o] Add support for LC_DATA_IN_CODENick Kledzik2014-07-241-0/+27
| | | | | | | | | | | | | | Sometimes compilers emit data into code sections (e.g. constant pools or jump tables). These runs of data can throw off disassemblers. The solution in mach-o is that ranges of data-in-code are encoded into a table pointed to by the LC_DATA_IN_CODE load command. The way the data-in-code information is encoded into lld's Atom model is that that start and end of each data run is marked with a Reference whose offset is the start/end of the data run. For arm, the switch back to code also marks whether it is thumb or arm code. llvm-svn: 213901
* [mach-o] add representation for LC_ID_DYLIB to MachONormalizedFileTim Northover2014-07-011-1/+0
| | | | | | | It still needs to be tied into BinaryReader, but this allows reasonably sensible creation of SharedLibrary atoms on MachO. llvm-svn: 212093
* [mach-o] improve errors when mixing architecturesNick Kledzik2014-06-301-1/+9
| | | | llvm-svn: 212072
* MachO: support atomization of dylibs.Tim Northover2014-06-301-0/+2
| | | | | | | For .dylib files, we refrain from actually creating any atoms until they're requested via the "exports" method. llvm-svn: 212027
* Refer to error_code with an std prefix.Rafael Espindola2014-06-121-4/+2
| | | | llvm-svn: 210820
* include system_error directly.Rafael Espindola2014-06-121-1/+1
| | | | llvm-svn: 210801
* Run llvm/utils/sort_includes.py in a few files.Rafael Espindola2014-06-121-4/+2
| | | | | | This will reduce the noise in a followup patch. llvm-svn: 210800
* replace llvm::error_code with std::error_code.Rafael Espindola2014-06-121-1/+1
| | | | llvm-svn: 210781
* Use error_code() instead of error_code::succes()Rafael Espindola2014-05-311-1/+1
| | | | | | | There is no std::error_code::success, so this removes much of the noise in transitioning to std::error_code. llvm-svn: 209948
* [mach-o] Fix so that mach-o semantic errors return an error rather than assertNick Kledzik2014-05-221-1/+3
| | | | llvm-svn: 209469
* [mach-o] Add support for zero-fill sections.Nick Kledzik2014-05-151-2/+12
| | | | llvm-svn: 208928
* [mach-o] Add support and test cases for parsing tentative definitionsNick Kledzik2014-05-151-2/+12
| | | | llvm-svn: 208919
* Update to match changes made in r205955David Majnemer2014-04-101-0/+1
| | | | llvm-svn: 205956
* s/llvm::dyn_cast/dyn_cast/Rui Ueyama2014-04-021-1/+0
| | | | llvm-svn: 205404
* Fix trailing whitespace.Shankar Easwaran2014-01-271-80/+80
| | | | llvm-svn: 200182
* [mach-o] enable mach-o and native yaml to be intermixedNick Kledzik2014-01-111-17/+50
| | | | | | | | | | | | | | | | | | The main goal of this patch is to allow "mach-o encoded as yaml" and "native encoded as yaml" documents to be intermixed. They are distinguished via yaml tags at the start of the document. This will enable all mach-o test cases to be written using yaml instead of checking in object files. The Registry was extend to allow yaml tag handlers to be registered. The mach-o Reader adds a yaml tag handler for the tag "!mach-o". Additionally, this patch fixes some buffer ownership issues. When parsing mach-o binaries, the mach-o atoms can have pointers back into the memory mapped .o file. But with yaml encoded mach-o, name and content are ephemeral, so a copyRefs parameter was added to cause the mach-o atoms to make their own copy. llvm-svn: 198986
* Use the mach-o MH_* name for file types in yamlNick Kledzik2014-01-081-4/+4
| | | | llvm-svn: 198725
* [MachO] Add some missing NListTypes.Joey Gouly2014-01-041-0/+2
| | | | llvm-svn: 198468
* [MachO] Begin to add some MachO specific File/Atoms, and add the start ofJoey Gouly2014-01-031-1/+23
| | | | | | normalizedToAtoms. llvm-svn: 198459
* Fix a gcc-4.8 warning, about extraneous semicolons.Joey Gouly2013-12-281-6/+6
| | | | llvm-svn: 198091
* Run clang-format on r197727.Rui Ueyama2013-12-201-1/+1
| | | | llvm-svn: 197788
* [lld] Introduce registry and Reference kind tupleNick Kledzik2013-12-191-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main changes are in: include/lld/Core/Reference.h include/lld/ReaderWriter/Reader.h Everything else is details to support the main change. 1) Registration based Readers Previously, lld had a tangled interdependency with all the Readers. It would have been impossible to make a streamlined linker (say for a JIT) which just supported one file format and one architecture (no yaml, no archives, etc). The old model also required a LinkingContext to read an object file, which would have made .o inspection tools awkward. The new model is that there is a global Registry object. You programmatically register the Readers you want with the registry object. Whenever you need to read/parse a file, you ask the registry to do it, and the registry tries each registered reader. For ease of use with the existing lld code base, there is one Registry object inside the LinkingContext object. 2) Changing kind value to be a tuple Beside Readers, the registry also keeps track of the mapping for Reference Kind values to and from strings. Along with that, this patch also fixes an ambiguity with the previous Reference::Kind values. The problem was that we wanted to reuse existing relocation type values as Reference::Kind values. But then how can the YAML write know how to convert a value to a string? The fix is to change the 32-bit Reference::Kind into a tuple with an 8-bit namespace (e.g. ELF, COFFF, etc), an 8-bit architecture (e.g. x86_64, PowerPC, etc), and a 16-bit value. This tuple system allows conversion to and from strings with no ambiguities. llvm-svn: 197727
* [mach-o] binary reader and writer Nick Kledzik2013-11-061-37/+3
| | | | | | | | | | This patch adds support for converting normalized mach-o to and from binary mach-o. It also changes WriterMachO (which previously directly wrote a mach-o binary given a set of Atoms) to instead do it in two steps. The first step uses normalizedFromAtoms() to convert Atoms to normalized mach-o, and the second step uses writeBinary() which to generate the mach-o binary file. llvm-svn: 194167
* Remove unnecessary namespace qualifier.Rui Ueyama2013-11-051-2/+2
| | | | llvm-svn: 194037
* Bug 17569: add namespaces to work with gcc-4.7Nick Kledzik2013-10-141-7/+17
| | | | llvm-svn: 192627
OpenPOWER on IntegriCloud