summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [lld] Fix trivial typos in commentsKazuaki Ishizaki2020-01-061-2/+2
| | | | | | Reviewed By: ruiu, MaskRay Differential Revision: https://reviews.llvm.org/D72196
* Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song2019-08-051-1/+1
| | | | | | F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
* 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 Object format code to lib/BinaryFormat.Zachary Turner2017-06-071-0/+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
* Prevent at compile time converting from Error::success() to Expected<T>Mehdi Amini2016-11-111-1/+1
| | | | | | | | This would trigger an assertion at runtime otherwise. Differential Revision: https://reviews.llvm.org/D26482 llvm-svn: 286562
* Fix Clang-tidy readability-redundant-member-init warnings; other minor fixesEugene Zelenko2016-10-251-13/+16
| | | | | | Differential revision: https://reviews.llvm.org/D25931 llvm-svn: 285086
* Fix some Include What You Use warnings; other minor fixes.Eugene Zelenko2016-04-291-9/+20
| | | | | | Differential revision: http://reviews.llvm.org/D19735 llvm-svn: 268093
* Add missing header (NFC)Mehdi Amini2016-04-181-1/+2
| | | | | From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266597
* Convert lld file writing to llvm::Error. NFC.Pete Cooper2016-03-301-3/+3
| | | | | | | This converts the writeFile method, as well as some of the ones it calls in the normalized binary file writer and yaml writer. llvm-svn: 264961
* Remove dead flags.Rui Ueyama2016-03-281-16/+5
| | | | | | | | | | | searchArchivesToOverrideTentativeDefinitions and searchSharedLibrariesToOverrideTentativeDefinitions are always false. For the dead flags, we have a fairly large amount of code which is never be executed. http://reviews.llvm.org/D17791 llvm-svn: 264653
* Use owning pointers instead of raw pointers for Atom's to fix leaks.Pete Cooper2016-03-221-31/+111
| | | | | | | | | | | | | | | | | | | | | | | | This is a re-commit of r264022 with a fix for MSVC. The issue there was that the code was running DefinedAtom::~Atom() for some value and instead needed to cast to Atom before running ~Atom. Original commit message follows. Currently each File contains an BumpPtrAllocator in which Atom's are allocated. Some Atom's contain data structures like std::vector which leak as we don't run ~Atom when they are BumpPtrAllocate'd. Now each File actually owns its Atom's using an OwningAtomPtr. This is analygous to std::unique_ptr and may be replaced by it if possible. An Atom can therefore only be owned by a single File, so the Resolver now moves them from one File to another. The MachOLinkingContext owns the File's and so clears all the Atom's in ~MachOLinkingContext, then delete's all the File's. This makes sure all Atom's have been destructed before any of the BumpPtrAllocator's in which they run have gone away. Should hopefully fix the remaining leaks. Will keep an eye on the bots to make sure. llvm-svn: 264067
* Revert "Use owning pointers instead of raw pointers for Atom's to fix leaks."Pete Cooper2016-03-221-111/+31
| | | | | | | | | | | | This reverts commit r264022. This breaks the Window's bots which don't like that i'm calling ~Atom when the this pointer is a sublcass of Atom. Reverting for now until I try find a better fix. I tried using std::unique_ptr with a custom deleter as a quick fix, but it didn't work well in the YAML parser. llvm-svn: 264023
* Use owning pointers instead of raw pointers for Atom's to fix leaks.Pete Cooper2016-03-221-31/+111
| | | | | | | | | | | | | | | | | | | | Currently each File contains an BumpPtrAllocator in which Atom's are allocated. Some Atom's contain data structures like std::vector which leak as we don't run ~Atom when they are BumpPtrAllocate'd. Now each File actually owns its Atom's using an OwningAtomPtr. This is analygous to std::unique_ptr and may be replaced by it if possible. An Atom can therefore only be owned by a single File, so the Resolver now moves them from one File to another. The MachOLinkingContext owns the File's and so clears all the Atom's in ~MachOLinkingContext, then delete's all the File's. This makes sure all Atom's have been destructed before any of the BumpPtrAllocator's in which they run have gone away. Should hopefully fix the remaining leaks. Will keep an eye on the bots to make sure. llvm-svn: 264022
* Always pass an allocator to YAMLTraits.Pete Cooper2016-03-171-4/+9
| | | | | | | | | | | The YAML traits new's when not passed an allocator to parse data. For atom types, this is a leak as we don't destruct atoms. For the File here, we do actually destruct File's so that single case of not using an allocator will be fine. Should fix a bunch more leaks. llvm-svn: 263680
* Use allocator in YAML code to avoid leaking atom content.Pete Cooper2016-03-161-4/+6
| | | | | | | | | | In lld we allocate atoms on an allocator and so don't run their destructors. This means we also shouldn't allocate memory inside them without that also being on an allocator. Reviewed by Lang Hames and Rafael Espindola. llvm-svn: 263677
* Delete more COFF and ELF bits from the old linker.Rafael Espindola2016-02-281-7/+2
| | | | llvm-svn: 262184
* Delete more ELF bits from the old linker.Rafael Espindola2016-02-281-47/+1
| | | | llvm-svn: 262181
* Remove a few bits of elf from the old linker.Rafael Espindola2016-02-281-2/+0
| | | | llvm-svn: 262164
* Fix handling of mach header and DSO handle symbols.Pete Cooper2016-02-021-0/+1
| | | | | | | | | | | | | | | | | The magic file which contained these symbols inherited from archive which meant that the resolver didn't add the required atoms as archive members only get added when referenced. Instead we now inherit from SimpleFile which always links in the atoms needed. The second issue was in the handling of these symbols when we emit the MachO. The mach header symbol needs to be in the atom list as it gets an offset (0), and being in the atom list makes sure it is emitted to the symbol table. DSO handles are not emitted to the symbol table. rdar://problem/24450654 llvm-svn: 259574
* Add ObjC method list atom type. NFC.Pete Cooper2016-02-011-0/+2
| | | | | | | | | | An upcoming patch will use this to create lists of ObjC methods. Adding it now to reduce the amount of code in that patch. Test cases will follow in the other patch too. llvm-svn: 259440
* Move SimpleDefinedAtom::addReference to DefinedAtom.Pete Cooper2016-02-011-0/+10
| | | | | | | | | | | | Most of the other methods to access Reference's were on DefinedAtom so this just keeps them all together. This will be used in a future patch in ObjCPass which needs to add new references. The method is virtual because we may add references to different data structures depending on whether we parsed a macho file or yaml. llvm-svn: 259436
* Add an ObjCPass to the MachO linker.Pete Cooper2016-01-191-0/+2
| | | | | | | | | This pass currently emits an objc image info section if one is required. This section contains the aggregated version and flags for all of the input files. llvm-svn: 258197
* Add File::kind's for all subclasses of File.Pete Cooper2016-01-141-3/+5
| | | | | | | | | | | | This is to enable isa<> support for any files which need it. It will be used in an upcoming patch to differentiate MachOFile from other implicitly generated files. Reviewed by Lang Hames. Differential Revision: http://reviews.llvm.org/D16103 llvm-svn: 257830
* [lld][Darwin] Add support for the -sectcreate option.Lang Hames2015-10-241-0/+1
| | | | llvm-svn: 251183
* Simplify. NFC.Rafael Espindola2015-10-021-2/+2
| | | | llvm-svn: 249128
* Fix Clang-tidy misc-use-override warnings, other minor fixes.Rui Ueyama2015-09-101-7/+11
| | | | | | Patch from Eugene Zelenko! llvm-svn: 247323
* Use MemoryBufferRef instead of MemoryBuffer&. NFC.Rafael Espindola2015-04-241-1/+1
| | | | | | This just reduces the noise from another patch. llvm-svn: 235776
* Return an ErrorOr<std::unique_ptr<File>>. NFC.Rafael Espindola2015-04-241-5/+4
| | | | llvm-svn: 235741
* Delete unnecessary generality in loadFile.Rafael Espindola2015-04-241-10/+10
| | | | | | | | | | | | | loadFile could load mulitple files just because yaml has a feature for putting multiple documents in one file. Designing a linker around what yaml can do seems like a bad idea to me. This patch changes it to read a single file. There are further improvements to be done to the api and they will follow shortly. llvm-svn: 235724
* Do s/_context/_ctx/g globally.Rui Ueyama2015-04-101-4/+4
| | | | | | | | I believe this patch eliminates all remaining uses of _context or _linkingContext variable names. Consistent naming improves readability. llvm-svn: 234645
* Rename atom_collection -> AtomVector.Rui Ueyama2015-04-081-9/+9
| | | | | | Type names should start with an uppercase letter in the LLVM coding style. llvm-svn: 234452
* Separate atom_collection type into two different types. NFC.Rui Ueyama2015-04-081-5/+13
| | | | | | | | | | | | | | | | | | | | atom_collection is basically a wrapper for std::vector. The class provides begin and end member functions, so that it "hides" the other member functions provided by std::vector. However, you can still directly access _atoms member since the member is not protected. We cannot simply make the member private because we need that member when we are constructing atom vectors. This patch splits atom_collection into two types: std::vector<Atom *> and AtomRange. When we are constructing atom vectors, we use the former class. We return instances of the latter class from File objects so that callers cannot add or remove atoms from the lists. std::vector<Atom *> is automatically converted to AtomRange. llvm-svn: 234450
* Merge atom_collection_vector with atom_collection.Rui Ueyama2015-04-081-2/+1
| | | | | | | atom_collection_vector is the only derived class of atom_collection. This patch merges the two. llvm-svn: 234443
* YAML: Remove blank class using alias template.Rui Ueyama2015-04-081-29/+6
| | | | llvm-svn: 234435
* Remove a parameter for file extension from canParse.Rui Ueyama2015-04-041-2/+4
| | | | | | | | canParse took three parameters -- file magic, filename extension and memory buffer. All but YAMLReader ignored the second parameter. This patch removes the parameter. llvm-svn: 234080
* [ARM] Handle mapping symbolsDenis Protivensky2015-03-261-0/+3
| | | | | | | | | | | Mapping symbols should have their own code models, and in some places must be treated in a specific way. Make $t denote Thumb code, and $a and $d denote ARM code. Set size, binding and type of mapping symbols to what the specification says. Differential Revision: http://reviews.llvm.org/D8601 llvm-svn: 233259
* Use alignment values everywhere instead of log2.Rui Ueyama2015-03-261-5/+5
| | | | | | | | This patch defines implicit conversion between integers and PowerOf2 instances, so uses of the classes is now implicit and look like regular integers. Now we are ready to remove the scaffolding. llvm-svn: 233245
* Define an implicit constructor which takes actual alignment value to PowerOf2.Rui Ueyama2015-03-261-1/+1
| | | | | | | 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-1/+1
| | | | | | | 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-3/+3
| | | | | | | | | | 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
* YAML: Do not use 2^x notation to represent alignments.Rui Ueyama2015-03-251-11/+7
| | | | llvm-svn: 233222
* [Mips] Support MIPS N64 relocation record formatSimon Atanasyan2015-03-241-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | N64 ABI relocation record r_info field in fact consists of five subfields: * r_sym - symbol index * r_ssym - special symbol * r_type3 - third relocation type * r_type2 - second relocation type * r_type - first relocation type Up to three these relocations applied one by one. The first relocation uses an addendum from the relocation record. Each subsequent relocation takes as its addend the result of the previous operation. Only the final operation actually modifies the location relocated. The first relocation uses as a reference symbol specified by the `r_sym` field. The third relocation assumes NULL symbol. The patch represents these data using LLD model and takes in account additional relocation types during a relocation calculation. Additional relocations do not introduce any new relations between two atoms and just specify operations need to be done during a relocation calculation. The first relocation type (`r_type`) stored in the `Reference::_kindValue`. The rest of relocations and `r_ssym` value are stored in the new `Reference::_tag` field "as-is". I decided to do not "decode" these data on the core LLD level to prevent pollution of the core LLD model by very target specific data. Also I have to override writing of relocation records in the `RelocationTable` class to convert MIPS N64 ABI relocation information from the `Reference` class back to the ELF relocation record. http://reviews.llvm.org/D8533 llvm-svn: 233057
* Remove sectionPosition attribute.Rui Ueyama2015-03-081-14/+0
| | | | | | | | This code is simply dead. No one is using it. http://reviews.llvm.org/D8125 llvm-svn: 231583
* Define DefinedAtom::sectionSize.Rui Ueyama2015-03-041-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | Merge::mergeByLargestSection is half-baked since it's defined in terms of section size, there's no way to get the section size of an atom. Currently we work around the issue by traversing the layout edges to both directions and calculate the sum of all atoms reachable. I wrote that code but I knew it's hacky. It's even not guaranteed to work. If you add layout edges before the core linking, it miscalculates a size. Also it's of course slow. It's basically a linked list traversal. In this patch I added DefinedAtom::sectionSize so that we can use that for mergeByLargestSection. I'm not very happy to add a new field to DefinedAtom base class, but I think it's legitimate since mergeByLargestSection is defined for section size, and the section size is currently just missing. http://reviews.llvm.org/D7966 llvm-svn: 231290
* Make File non-const in the resolver.Rui Ueyama2015-03-041-3/+3
| | | | | | | | | | | | | | | File objects are not really const in the resolver. We set ordinals to them and call beforeLink hooks. Also, File's member functions marked as const are not really const. ArchiveFile never returns the same member file twice, so it remembers files returned before. find() has side effects. In order to deal with the inconsistencies, we sprinkled const_casts and marked member varaibles as mutable. This patch removes const from there to reflect the reality. llvm-svn: 231212
* [Core] Fix handling of Section Groups.Shankar Easwaran2015-02-221-9/+0
| | | | | | | | | There is code(added by me) in the YAMLReader which isn't correct when it handles references for section groups. The test case was also checking for wrong outputs. This fixes the bug and the testcase so that they check for proper outputs. llvm-svn: 230190
* Use Reference::KindValue instead of uint16_t to pass and save a relocation kindSimon Atanasyan2015-01-271-1/+1
| | | | | | No functional changes. llvm-svn: 227233
* [lld] Correct forming of ARM/Thumb atomsDenis Protivensky2015-01-271-0/+1
| | | | | | | | | | | | Symbols addressing Thumb code have zero bit set in st_value to distinguish them from ARM instructions. This caused wrong atoms' forming because of offset of one byte brought in by that corrected st_value. Fixed reading of st_value & st_value-related things in ARMELFFile while forming atoms. Symbol table generation is also fixed for Thumb atoms. Differential Revision: http://reviews.llvm.org/D7161 llvm-svn: 227174
* path.data() may return a non null terminated stringJean-Daniel Dupas2015-01-261-1/+1
| | | | | | and raw_fd_ostream constructor expects a StringRef. llvm-svn: 227081
OpenPOWER on IntegriCloud