summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/Native/ReaderNative.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove the Native file format.Rui Ueyama2015-04-101-881/+0
| | | | | | | | | | | | | The Native file format was designed to be the fastest on-memory or on-disk file format for object files. The problem is that no one is working on that. No LLVM tools can produce object files in the Native, thus the feature of supporting the format is useless in the linker. This patch removes the Native file support. We can add it back if we really want it in future. llvm-svn: 234641
* Rename atom_collection -> AtomVector.Rui Ueyama2015-04-081-10/+10
| | | | | | 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-6/+6
| | | | | | | | | | | | | | | | | | | | 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-5/+5
| | | | | | | atom_collection_vector is the only derived class of atom_collection. This patch merges the two. llvm-svn: 234443
* Native: Remove AtomArray and use atom_collection_vector instead.Rui Ueyama2015-04-081-76/+28
| | | | llvm-svn: 234434
* Native: Use tempalte to remove duplicate code. NFC.Rui Ueyama2015-04-081-117/+36
| | | | llvm-svn: 234432
* Native: Simplify expressions. NFC.Rui Ueyama2015-04-081-9/+6
| | | | llvm-svn: 234431
* Remove a parameter for file extension from canParse.Rui Ueyama2015-04-041-2/+1
| | | | | | | | 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
* Store non-log2 values to Native files.Rui Ueyama2015-03-261-1/+1
| | | | llvm-svn: 233247
* Use alignment values everywhere instead of log2.Rui Ueyama2015-03-261-1/+2
| | | | | | | | 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
* [Mips] Support MIPS N64 relocation record formatSimon Atanasyan2015-03-241-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-7/+1
| | | | | | | | 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-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix five of the shared library build targetsGreg Fitzgerald2015-01-211-1/+1
| | | | | | | | | | | | | | | | | | Before this patch there was a cyclic dependency between lldCore and lldReaderWriter. Only lldConfig could be built as a shared library. * Moved Reader and Writer base classes into lldCore. * The following shared libraries can now be built: lldCore lldYAML lldNative lldPasses lldReaderWriter Differential Revision: http://reviews.llvm.org/D7105 From: Greg Fitzgerald <garious@gmail.com> llvm-svn: 226732
* Re-commit r225674: Convert other drivers to use WrapperNode.Rui Ueyama2015-01-151-2/+2
| | | | | | | | The original commit had an issue with Mac OS dylib files. It didn't handle fat binary dylib files correctly. This patch includes a fix. A test for that case has already been committed in r225764. llvm-svn: 226123
* Revert "Convert other drivers to use WrapperNode" and subsequent commits.Rui Ueyama2015-01-141-2/+2
| | | | | | | r225764 broke a basic functionality on Mac OS. This change reverts r225764, r225766, r225767, r225769, r225814, r225816, r225829, and r225832. llvm-svn: 225859
* Convert other drivers to use WrapperNode.Rui Ueyama2015-01-131-2/+2
| | | | llvm-svn: 225764
* Make File always take the ownership of a MemoryBuffer.Rui Ueyama2014-12-121-1/+1
| | | | | | | | | | | | | | The documentation of parseFile() said that "the resulting File object may take ownership of the MemoryBuffer." So, whether or not the ownership of a MemoryBuffer would be taken was not clear. A FileNode (a subclass of InputElement, which is being deprecated) keeps the ownership if a File doesn't take it. This patch makes File always take the ownership of a buffer. Buffers lifespan is not always the same as File instances. Files are able to deallocate buffers after parsing the contents. llvm-svn: 224113
* Separate file parsing from File's constructors.Rui Ueyama2014-12-121-38/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a second patch for InputGraph cleanup. Sorry about the size of the patch, but what I did in this patch is basically moving code from constructor to a new method, parse(), so the amount of new code is small. This has no change in functionality. We've discussed the issue that we have too many classes to represent a concept of "file". We have File subclasses that represent files read from disk. In addition to that, we have bunch of InputElement subclasses (that are part of InputGraph) that represent command line arguments for input file names. InputElement is a wrapper for File. InputElement has parseFile method. The method instantiates a File. The File's constructor reads a file from disk and parses that. Because parseFile method is called from multiple worker threads, file parsing is processed in parallel. In other words, one reason why we needed the wrapper classes is because a File would start reading a file as soon as it is instantiated. So, the reason why we have too many classes here is at least partly because of the design flaw of File class. Just like threads in a good threading library, we need to separate instantiation from "start" method, so that we can instantiate File objects when we need them (which should be very fast because it involves only one mmap() and no real file IO) and use them directly instead of the wrapper classes. Later, we call parse() on each file in parallel to let them do actual file IO. In this design, we can eliminate a reason to have the wrapper classes. In order to minimize the size of the patch, I didn't go so far as to replace the wrapper classes with File classes. The wrapper classes are still there. In this patch, we call parse() immediately after instantiating a File, so this really has no change in functionality. Eventually the call of parse() should be moved to Driver::link(). That'll be done in another patch. llvm-svn: 224102
* Remove unreachable return statement.Rui Ueyama2014-12-101-1/+0
| | | | llvm-svn: 223920
* [ELF] Add CodeModel attribute to the DefinedAtom classSimon Atanasyan2014-11-131-0/+4
| | | | | | | | | | | | | | | | | | | | | | MIPS ELF symbols might contain some additional MIPS-specific flags in the st_other field besides visibility ones. These flags indicate code properties like microMIPS / MIPS16 encoding, position independent code etc. We need to transfer the flags from input objects to the output linked file to write them into the symbol table, adjust symbols addresses etc. I add new attribute CodeModel to the DefinedAtom class to hold target specific flag and to get over YAML/Native format conversion barrier. Other architectures/targets can extend CodeModel enumeration by their own flags. MIPS specific part of this patch adds support for STO_MIPS_MICROMIPS flag. This flag marks microMIPS symbols. Such symbol should: a) Has STO_MIPS_MICROMIPS in the corresponding .symtab record. b) Has adjusted (odd) address in the corresponding .symtab and .dynsym records. llvm-svn: 221864
* Sort include files according to convention.Shankar Easwaran2014-10-181-3/+0
| | | | llvm-svn: 220131
* Don't import error_code into the lld namespace.Rafael Espindola2014-06-121-36/+37
| | | | llvm-svn: 210785
* Move Simple.h and Alias.h to include/Core.Rui Ueyama2014-06-111-3/+2
| | | | | | | | Because the files in Core actually depend on these files. Differential Revision: http://reviews.llvm.org/D4000 llvm-svn: 210710
* 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
* Re-submit r207884: Remove dead codeRui Ueyama2014-05-051-4/+0
| | | | | | Differential Revision: http://reviews.llvm.org/D3599 llvm-svn: 207989
* Revert "Remove dead code."Rui Ueyama2014-05-021-0/+4
| | | | | | This reverts commit r207884 which was prematurely committed by accident. llvm-svn: 207886
* Remove dead code.Rui Ueyama2014-05-021-4/+0
| | | | | | | | | | | | | | | isAlias always returns false and no one is using it. It was originally added Atom to query if an atom is an alias for another atom, assuming that alias atoms are different from normal atoms. We now support atom aliasing, but the way that's implemented is in a different way than what isAlias assumed. An alias atom is just a regular defined atom with no content, and it has a layout- before edge to alias-to atom so that they are layed out at the same location in the result. So this is dead code, and it doesn't make much sense to keep it. llvm-svn: 207884
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-131-2/+1
| | | | | | | | This results in some simplifications to the code where an OwningPtr had to be used with the previous api and then ownership moved to a unique_ptr for the rest of lld. llvm-svn: 203809
* [Cleanup] Sort includes.Ahmed Charles2014-03-121-3/+3
| | | | llvm-svn: 203666
* Add "override" and remove "virtual" where appropriate.Rui Ueyama2014-03-061-51/+51
| | | | | | | For the record, I used clang-modernize to add "override" and perl to remove "virtual". llvm-svn: 203164
* Restore vertical alignment lost by clang-formatNick Kledzik2013-12-201-4/+4
| | | | llvm-svn: 197834
* Run clang-format on r197727.Rui Ueyama2013-12-201-26/+20
| | | | llvm-svn: 197788
* [lld] Introduce registry and Reference kind tupleNick Kledzik2013-12-191-27/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix a variety of typos in function names and commentsAlp Toker2013-12-011-3/+3
| | | | | | No change in functionality. llvm-svn: 196053
* Use NativeReferenceIvarsV2 if necessary.Rui Ueyama2013-11-201-52/+130
| | | | | | | | | | | | | | | | | | | | NativeReferenceIvarsV1 cannot handle more than 65535 relocation targets because its field to point to the target table is of type uint16_t. Because of that limitation, the LLD couldn't link a file containing more than 65535 relocations. 65535 is not a big number - the LLD couldn't even link itself with V1. This patch solves the issue by adding NativeReferenceIvarsV2 support. The new structure has more bits for the target table, so it can handle a large number of relocatinos. V2 structure is larger than V1. In order to prevent file bloating, V2 format is used only when the resulting file cannot be represented in V1 format. The writer and the reader support both V1 and V2 formats. Differential Revision: http://llvm-reviews.chandlerc.com/D2217 llvm-svn: 195270
* Move the entire debug print loop into DEBUG_WITH_TYPE.Rui Ueyama2013-11-161-18/+13
| | | | | | No functionality change. llvm-svn: 194914
* Replace one more magic number with sizeof().Rui Ueyama2013-11-161-1/+2
| | | | llvm-svn: 194913
* Add explictly exported atoms and export R_*_COPY'ed atoms.Michael J. Spencer2013-11-081-0/+4
| | | | llvm-svn: 194278
* Remove unnecessary namespace qualifier.Rui Ueyama2013-11-051-2/+2
| | | | llvm-svn: 194037
* [ELF] Fix typo in the expression calculates an absolute atom offset.Simon Atanasyan2013-11-041-1/+1
| | | | | | Patch reviewed by Shankar Easwaran. llvm-svn: 194010
* Update error classes from all lowercase to camel case.Rui Ueyama2013-10-091-29/+29
| | | | llvm-svn: 192261
* [lld][InputGraph] Change the Resolver to use inputGraphShankar Easwaran2013-10-071-14/+13
| | | | | | | | | | | | Changes :- a) Functionality in InputGraph to insert Input elements at any position b) Functionality in the Resolver to use nextFile c) Move the functionality of assigning file ordinals to InputGraph d) Changes all inputs to MemoryBuffers e) Remove LinkerInput, InputFiles, ReaderArchive llvm-svn: 192081
* [Core] Add type and size to SharedLibraryAtom.Michael J. Spencer2013-09-261-0/+8
| | | | llvm-svn: 191466
* Add a fallback mechanism for undefined atom.Rui Ueyama2013-09-121-2/+11
| | | | | | | | | | | | | | | | | In COFF, an undefined symbol can have up to one alternative name. If a symbol is resolved by its regular name, then it's linked normally. If a symbol is not found in any input files, all references to the regular name are resolved using the alternative name. If the alternative name is not found, it's a link error. This mechanism is called "weak externals". To support this mechanism, I added a new member function fallback() to undefined atom. If an undefined atom has the second name, fallback() returns a new undefined atom that should be used instead of the original one to resolve undefines. If it does not have the second name, the function returns nullptr. Differential Revision: http://llvm-reviews.chandlerc.com/D1550 llvm-svn: 190625
* Change the parseFile argument from MemoryBuffer pointer to LinkerInputJoerg Sonnenberger2013-09-071-7/+8
| | | | | | reference. Move readFile logic into FileNode::createLinkerInput. llvm-svn: 190253
* [lld] handle typeZeroFill atoms in ELF/Native/YAMLShankar Easwaran2013-08-231-3/+2
| | | | | | | | | | | | | BSS atoms dont take any file space in the Input file. They are associated with a contentType(typeZeroFill). Similiar zero fill types also exist which have the same meaning in terms of occupying file space in the Input. These atoms have to be handled seperately when writing to the lld's intermediate file or the lld test infrastructure. Also adds a test. llvm-svn: 189136
* Rename TargetInfo -> LinkingContext.Rui Ueyama2013-08-061-16/+16
| | | | | | | | | Also change some local variable names: "ti" -> "context" and "_targetInfo" -> "_context". Differential Revision: http://llvm-reviews.chandlerc.com/D1301 llvm-svn: 187823
* Removed unnecessary "class" keyword.Rui Ueyama2013-06-211-10/+10
| | | | llvm-svn: 184589
* [ARM] Remove isThumb() as it's not used and it's not in the right place.Rui Ueyama2013-06-131-4/+0
| | | | | | | | | | | | | | Architecture specific code should reside in architecture specific directory not in Atom. Looks like there are no efforts being made at this moment to support ARM, so let's remove it for now. Reviewers: Bigcheese CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D959 llvm-svn: 183877
OpenPOWER on IntegriCloud