summaryrefslogtreecommitdiffstats
path: root/lld/test/core
Commit message (Collapse)AuthorAgeFilesLines
* Remove CoreDriver.Rui Ueyama2016-03-0181-1539/+0
| | | | | | | | | | | CoreDriver implements a driver for a hypothetical platform. It is intended to be used in unittests. However, it is actually redundant because the features are tested using the real driver for the real platforms. So we can remove this. http://reviews.llvm.org/D17698 llvm-svn: 262421
* Delete more COFF and ELF bits from the old linker.Rafael Espindola2016-02-281-29/+0
| | | | llvm-svn: 262184
* Delete more ELF bits from the old linker.Rafael Espindola2016-02-2817-788/+0
| | | | llvm-svn: 262181
* Delete unnecessary generality in loadFile.Rafael Espindola2015-04-2481-616/+609
| | | | | | | | | | | | | 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
* Test: Use layout-after instead of layout-before.Rui Ueyama2015-03-094-28/+14
| | | | | | | Update the tests so that they use layout-after instead of layout-before. In all other places, we use layout-afters as primary edges. llvm-svn: 231627
* PECOFF: Create layout-afters instead of layout-befores.Rui Ueyama2015-03-091-7/+7
| | | | | | | | | | | | | | | | All readers except PE/COFF reader create layout-after edges to preserve the original symbol order. PE/COFF uses layout-before edges as primary edges for no reason. This patch makes PE/COFF reader to create layout-after edges. Resolver is updated to recognize reverse edges of layout-after edges in the garbage collection pass. Now we can retire layout-before edges. I don't do that in this patch because if I do, I would have updated many tests to replace all occurrrences of "layout-before" with "layout-after". So that's a TODO. llvm-svn: 231615
* [Core] Do not reclaim absolute atoms in resolver.Davide Italiano2015-02-261-1/+1
| | | | | | | | | | | | | This fixes a linker crash (found out while testing --gc-sections, testcase provided by Rafael Avila de Espindola). While this behaviour was found while testing ELF, it' not necessarily ELF specific and this change is (apparently) harmless on all the other drivers. Differential Revision: D7823 Reviewed by: ruiu llvm-svn: 230614
* [Core] Fix handling of Section Groups.Shankar Easwaran2015-02-225-47/+28
| | | | | | | | | 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
* MachO: Move LayoutPass to MachO directory.Rui Ueyama2015-02-053-149/+0
| | | | | | | | | | | | | | | | | | | | | | The real user of the LayoutPass is now only Mach-O, so move that pass out of the common directory to Mach-O directory. "Core" architecture were using the LayoutPass. I modified that to use a simple OrderPass. I think no one actually have authority what feature should be in Core and what's not, but I believe the LayoutPass is not very suitable for Core. Before more code starts depending on the complex pass, it's better to remove that from Core. I could have simplified that pass because Mach-O is the only user of the LayoutPass. For example, the second parameter of the LayoutPass constructor can be converted from optional to mandatory. I didn't do that in this patch to keep it simple. I'll do in a followup patch. http://reviews.llvm.org/D7311 llvm-svn: 228341
* [test] Add test for section groups and deadstripShankar Easwaran2015-02-011-0/+92
| | | | | | | This adds a test that deadstrip should preserve the section group even if there is only one reference to a function in the group. llvm-svn: 227711
* Remove kindInGroup reference.Rui Ueyama2015-01-274-165/+0
| | | | | | | | | | | | That kind of reference was used only in ELFFile, and the use of that reference there didn't seem to make sense. All test still pass (after adjusting symbol names) without that code. LLD is still be able to link LLD and Clang. Looks like we just don't need this. http://reviews.llvm.org/D7189 llvm-svn: 227259
* Convert CoreInputGraph.Rui Ueyama2015-01-061-11/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a part of InputGraph cleanup to represent input files as a flat list of Files (and some meta-nodes for group etc.) We cannot achieve that goal in one gigantic patch, so I split the task into small steps as shown below. (Recap the progress so far: Currently InputGraph contains a list of InputElements. Each InputElement contain one File (that used to have multiple Files, but I eliminated that use case in r223867). Files are currently instantiated in Driver::link(), but I already made a change to separate file parsing from object instantiation (r224102), so we can safely instantiate Files when we need them, instead of wrapping a file with the wrapper class (FileNode class). InputGraph used to act like a generator class by interpreting groups by itself, but it's now just a container of a list of InputElements (r223867).) 1. Instantiate Files in the driver and wrap them with WrapperNode. WrapperNode is a temporary class that allows us to instantiate Files in the driver while keep using the current InputGraph data structure. This patch demonstrates how this step 1 looks like, using Core driver as an example. 2. Do the same thing for the other drivers. When step 2 is done, an InputGraph consists of GroupEnd objects or WrapperNodes each of which contains one File. Other types of FileNode subclasses are removed. 3. Replace InputGraph with std::vector<std::unique_ptr<InputElement>>. InputGraph is already just a container of list of InputElements, so this step removes that needless class. 4. Remove WrapperNode. We need some code cleanup between each step, because many classes do a bit odd things (e.g. InputGraph::getGroupSize()). I'll straight things up as I need to. llvm-svn: 225313
* [ELF] Add CodeModel attribute to the DefinedAtom classSimon Atanasyan2014-11-131-0/+50
| | | | | | | | | | | | | | | | | | | | | | 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
* Preserve custom section names when coalescing.Nick Kledzik2014-10-021-0/+78
| | | | | | | | | | | | The mergeByContent attribute on DefinedAtoms triggers the symbol table to coalesce atoms with the exact same content. The problem is that atoms can also have a required custom section. The coalescing should never change the custom section of an atom. The fix is to only consider to atoms to have the same content if their sectionChoice() and customSectionName() attributes match. llvm-svn: 218893
* Move GOTPass and StubsPass from Core to MachONick Kledzik2014-07-092-129/+0
| | | | llvm-svn: 212652
* [PECOFF] Support COMDAT associative sections.Rui Ueyama2014-06-171-0/+30
| | | | | | | | | | | | | | | | | | | COFF supports a feature similar to ELF's section groups. This patch implements it. In ELF, section groups are identified by their names, and they are treated somewhat differently from regular symbols. In COFF, the feature is realized in a more straightforward way. A section can have an annotation saying "if Nth section is linked, link this section too." I added a new reference type, kindAssociate. If a target atom is coalesced away, the referring atom is removed by Resolver, so that they are treated as a group. Differential Revision: http://reviews.llvm.org/D4028 llvm-svn: 211106
* Remove group-parent references.Rui Ueyama2014-06-039-288/+4
| | | | | | | | | | | | | | | | | | | Previously section groups are doubly linked to their children. That is, an atom representing a group has group-child references to its group contents, and content atoms also have group-parent references to the group atom. That relationship was invariant; if X has a group-child edge to Y, Y must have a group-parent edge to X. However we were not using group-parent references at all. The resolver only needs group-child edges. This patch simplifies the section group by removing the unused reverse edge. No functionality change intended. Differential Revision: http://reviews.llvm.org/D3945 llvm-svn: 210066
* Make dead-striping to handle reverse edges.Rui Ueyama2014-06-031-0/+25
| | | | | | | | | | | | | | | Layout-before edges are no longer used for layout, but they are still there for dead-stripping. If we would just remove them from code, LLD would wrongly remove live atoms that were referenced by layout-befores. This patch fixes the issue. Before dead-stripping, it scans all atoms to construct a reverse map for layout-after edges. Dead- stripping pass uses the map to traverse the graph. Differential Revision: http://reviews.llvm.org/D3986 llvm-svn: 210057
* Remove trailing whitespaces.Rui Ueyama2014-05-141-1/+1
| | | | llvm-svn: 208815
* [core] support .gnu.linkonce sectionsShankar Easwaran2014-04-015-0/+561
| | | | | | | | | | | | | | | | | | .gnu.linkonce sections are similar to section groups. They were supported before section groups existed and provided a way to resolve COMDAT sections using a different design. There are few implementations that use .gnu.linkonce sections to store simple floating point constants which doesnot require complex section group support but need a way to store only one copy of the floating point constant in a binary. .gnu.linkonce based symbol resolution achieves that. Review : http://llvm-reviews.chandlerc.com/D3242 llvm-svn: 205280
* Revert "[core] support .gnu.linkonce sections"Shankar Easwaran2014-03-315-561/+0
| | | | | | | | | This reverts commit 5d5ca72a7876c3dd3dd1db83dc6a0d74be9e2cd1. Discuss on a better design to raise error when there is a similar group with Gnu linkonce sections and COMDAT sections. llvm-svn: 205224
* [core] support .gnu.linkonce sectionsShankar Easwaran2014-03-315-0/+561
| | | | | | | | | | | .gnu.linkonce sections are similar to section groups. They were supported before section groups existed and provided a way to resolve COMDAT sections using a different design. There are few implementations that use .gnu.linkonce sections to store simple floating point constants which doesnot require complex section group support but need a way to store only one copy of the floating point constant. .gnu.linkonce based symbol resolution achieves that. llvm-svn: 205163
* Do not use layout-before to layout atoms.Rui Ueyama2014-03-272-47/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we use both layout-after and layout-before edges to specify atom orders in the resulting executable. We have a complex piece of code in LayoutPass.cpp to deal with both types of layout specifiers. (In the following description, I denote "Atom A having a layout-after edge to B" as "A -> B", and A's layout-before to B as "A => B".) However, that complexity is not really needed for this reason: If there are atoms such that A => B, B -> A is always satisifed, so using only layout- after relationships will yield the same result as the current code. Actually we have a piece of complex code that verifies that, for each A -> B, B => [ X => Y => ... => Z => ] A is satsified, where X, Y, ... Z are all zero-size atoms. We can get rid of the code from our codebase because layout- before is basically redundant. I think we can simplify the code for layout-after even more than this, but I want to just remove this pass for now for simplicity. Layout-before edges are still there for dead-stripping, so this change won't break it. We will remove layout-before in a followup patch once we fix the dead-stripping pass. Differential Revision: http://llvm-reviews.chandlerc.com/D3164 llvm-svn: 204966
* [core] add SectionGroup supportShankar Easwaran2014-03-264-0/+473
| | | | | | Review : http://llvm-reviews.chandlerc.com/D3182 llvm-svn: 204830
* [lld] Include reference kind in cycle detector debug outputNico Rieck2014-02-241-3/+0
| | | | | | | | This restores the debug output to how it was before r197727 broke it. This went undetected because the corresponding test was never run due to broken feature detection. llvm-svn: 202079
* Fix feature detection in lld's lit.cfgNico Rieck2014-02-241-0/+3
| | | | llvm-svn: 202078
* Fix trailing whitespace.Shankar Easwaran2014-01-2732-98/+98
| | | | llvm-svn: 200182
* [mach-o] enable mach-o and native yaml to be intermixedNick Kledzik2014-01-113-18/+14
| | | | | | | | | | | | | | | | | | 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
* REQUIRES: debug doesn't actually do anything!Joey Gouly2013-12-201-1/+1
| | | | | | Makes the tests pass (rather, not run) on release builds. llvm-svn: 197838
* Fix Weak External symbol handling.Rui Ueyama2013-11-202-17/+25
| | | | | | | | | | | | | | | | | | | | | | | | | The fallback atom was used only when it's searching for a symbol in a library; if an undefined symbol was not found in a library, the LLD looked for its fallback symbol in the library. Although it worked in most cases, because symbols with fallbacks usually occur only in OLDNAMES.LIB (a standard library), that behavior was incompatible with link.exe. This patch fixes the issue so that the semantics is the same as MSVC's link.exe The new (and correct, I believe) behavior is this: - If there's no definition for an undefined atom, replace the undefined atom with its fallback and then proceed (e.g. look in the next file or stop linking as usual.) Weak External symbols are underspecified in the Microsoft PE/COFF spec. However, as long as I observed the behavior of link.exe, this seems to be what we want for compatibility. Differential Revision: http://llvm-reviews.chandlerc.com/D2162 llvm-svn: 195269
* Select new undefined atom rather than old one if other conditions are the same.Rui Ueyama2013-11-151-40/+30
| | | | | | | | | | | | | | | | | | | | | | | | We can add multiple undefined atoms having the same name to the symbol table. If such atoms are added, the symbol table compares their canBeNull attributes, and select one having a stronger constraint. If their canBeNulls are the same, the choice is arbitrary. Currently it choose the existing one. This patch changes the preference, so that the symbol table choose the new one if the new atom has a greater canBeNull or a fallback atom. This shouldn't change the behavior except the case described below. A new undefined atom may have a new fallback atom attribute. By choosing the new atom, we can update the fallback atom during Core Linking. PE/COFF actually need that. For example, _lseek is an alias for __lseek on Windows. One of an object file in OLDNAMES.LIB has an undefined atom for _lseek with the fallback to __lseek. When the linker tries to resolve _read, it supposed to read the file from OLDNAMES.LIB and use the new fallback from the file. Currently LLD cannot handle such case because duplicate undefined atoms with the same attributes are ignored. Differential Revision: http://llvm-reviews.chandlerc.com/D2161 llvm-svn: 194777
* Test: Move input redirections at the end of the line.Rui Ueyama2013-11-149-10/+10
| | | | | | | Writing arguments after the redirection of input ("< somefile") seems a bit strange. Changes the order. llvm-svn: 194727
* Test for r194671.Rui Ueyama2013-11-141-0/+24
| | | | llvm-svn: 194723
* Fix misleading indentation.Rui Ueyama2013-11-131-12/+12
| | | | llvm-svn: 194550
* Run layout-transitivity test only when debugging is enabled.Rui Ueyama2013-10-231-5/+1
| | | | | | Because it depends on "-mllvm -debug" flag, the test fails in Release build. llvm-svn: 193271
* Disable layout-transitivity test on FreeBSD for now.Rui Ueyama2013-10-231-3/+4
| | | | llvm-svn: 193259
* Disable layout-transitivity test on Darwin for now.Rui Ueyama2013-10-211-0/+4
| | | | llvm-svn: 193121
* Fix bug that CompareAtoms::compare is not transitive.Rui Ueyama2013-10-191-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes a bug in r190608. The results of a comparison function passed to std::sort must be transitive, which is, if a < b and b < c, and if a != b, a < c must be also true. CompareAtoms::compare did not actually guarantee the transitivity. As a result the sort results were sometimes just wrong. Consider there are three atoms, X, Y, and Z, whose file ordinals are 1, 2, 3, respectively. Z has a property "layout-after X". In this case, all the following conditionals become true: X < Y because X's ordinal is less than Y's Y < Z because Y's ordinal is less than Z's Z < X because of the layout-after relationship This is not of course transitive. The reason why this happened is because we used follow-on relationships for comparison if two atoms falls in the same follow-on chain, but we used each atom's properties if they did not. This patch fixes the issue by using follow-on root atoms for comparison to get consistent results. Differential Revision: http://llvm-reviews.chandlerc.com/D1980 llvm-svn: 193029
* [Core] Add type and size to SharedLibraryAtom.Michael J. Spencer2013-09-261-0/+11
| | | | llvm-svn: 191466
* Add a fallback mechanism for undefined atom.Rui Ueyama2013-09-121-0/+18
| | | | | | | | | | | | | | | | | 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
* [lld][test] organize test directory. No change in functionalityShankar Easwaran2013-08-3145-0/+1791
* Renames few tests which had extension objtxt to test * created core directory that contains all the core tests llvm-svn: 189720
OpenPOWER on IntegriCloud