summaryrefslogtreecommitdiffstats
path: root/lld/lib/Core/SymbolTable.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Removed the redundant comment. NFC.Galina Kistanova2017-06-071-1/+0
| | | | llvm-svn: 304874
* Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.Galina Kistanova2017-06-071-0/+1
| | | | llvm-svn: 304873
* [Core] Retire yet another unused member function.Davide Italiano2016-08-121-6/+0
| | | | | | The code in lib/ could use a lot of love :( llvm-svn: 278506
* [Core] Simplify a bit. NFCI.Davide Italiano2016-08-121-6/+2
| | | | llvm-svn: 278505
* [Core] Retire addReplacement() member function.Davide Italiano2016-08-111-5/+0
| | | | llvm-svn: 278327
* [Core] tentativeDefinition() is now unused.Davide Italiano2016-08-101-13/+0
| | | | llvm-svn: 278181
* Remove dead code for ELF.Rui Ueyama2016-02-281-46/+10
| | | | llvm-svn: 262195
* Delete more COFF and ELF bits from the old linker.Rafael Espindola2016-02-281-16/+1
| | | | llvm-svn: 262184
* Delete more ELF bits from the old linker.Rafael Espindola2016-02-281-19/+0
| | | | llvm-svn: 262181
* Do s/_context/_ctx/g globally.Rui Ueyama2015-04-101-7/+6
| | | | | | | | I believe this patch eliminates all remaining uses of _context or _linkingContext variable names. Consistent naming improves readability. llvm-svn: 234645
* Remove unused function.Rui Ueyama2015-03-061-4/+0
| | | | llvm-svn: 231444
* Remove dead code.Rui Ueyama2015-03-051-1/+0
| | | | | | This hook is called from one of the hottest loops in LLD and does nothing. llvm-svn: 231345
* Define DefinedAtom::sectionSize.Rui Ueyama2015-03-041-34/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Follow-up to r221913. Fix some -Wcast-qual warning reasons.Simon Atanasyan2014-11-141-7/+9
| | | | llvm-svn: 221974
* Sort include files according to convention.Shankar Easwaran2014-10-181-3/+1
| | | | llvm-svn: 220131
* Use isa<> and cast<> instead of definition().Rui Ueyama2014-10-141-5/+3
| | | | | | No functionality change intended. llvm-svn: 219727
* Preserve custom section names when coalescing.Nick Kledzik2014-10-021-0/+6
| | | | | | | | | | | | 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
* [ELF] Export strong defined symbol if it coalesces away a weak symbolSimon Atanasyan2014-09-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | defined in a shared library. Now LLD does not export a strong defined symbol if it coalesces away a weak symbol defined in a shared library. This bug affects all ELF architectures and leads to segfault: % cat foo.c extern int __attribute__((weak)) flag; int foo() { return flag; } % cat main.c int flag = 1; int foo(); int main() { return foo() == 1 ? 0 : -1; } % clang -c -fPIC foo.c main.c % lld -flavor gnu -target x86_64 -shared -o libfoo.so ... foo.o % lld -flavor gnu -target x86_64 -o a.out ... main.o libfoo.so % ./a.out Segmentation fault The problem is caused by the fact that we lose all information about coalesced symbols after the `Resolver::resolve()` method is finished. The patch solves the problem by overriding the `LinkingContext::notifySymbolTableCoalesce()` method and saving names of coalesced symbols. Later in the `buildDynamicSymbolTable()` routine we use this information to export these symbols. llvm-svn: 217363
* Simplify. No functionality changes.Rui Ueyama2014-08-221-6/+3
| | | | llvm-svn: 216257
* Add notifier hooks to symbol table.Nick Kledzik2014-08-201-0/+4
| | | | | | | | | | This is the one interesting aspect from: http://reviews.llvm.org/D4965 These hooks are useful for flavor specific processing, such as recording that a DefinedAtom replaced a weak SharedLibraryAtom. llvm-svn: 216122
* Add SymbolTable::isCoalescedAwayRui Ueyama2014-06-051-0/+4
| | | | | | | isCoalescedAway(x) is faster than replacement(x) != x as the former does not follow the replacement atom chain. Also it's easier to use. llvm-svn: 210242
* [mach-o] Support parsing of non-lazy-pointer sectionsNick Kledzik2014-05-281-3/+4
| | | | llvm-svn: 209704
* Fix regression introduced in r205566.Rui Ueyama2014-05-141-11/+17
| | | | | | | | | | | | | | | In r205566, I made a change to Resolver so that Resolver revisit only archive files in --start-group and --end-group pair. That's not correct, as it also has to revisit DSO files. This patch is to fix the issue. Added a test to demonstrate the fix. I confirmed that it succeeded before r205566, failed after r205566, and is ok with this patch. Differential Revision: http://reviews.llvm.org/D3734 llvm-svn: 208797
* Split a utility function not to use goto statement.Rui Ueyama2014-04-041-14/+17
| | | | llvm-svn: 205643
* useNew is set to false in all branches, so set it to false outside the if-else.Rui Ueyama2014-04-041-21/+15
| | | | llvm-svn: 205642
* Replace dyn_cast<T>s immediately followed by asserts with cast<T>s.Rui Ueyama2014-04-041-9/+4
| | | | llvm-svn: 205641
* Fix indentation.Rui Ueyama2014-04-041-34/+28
| | | | llvm-svn: 205639
* Revert "temporary commit."Rui Ueyama2014-04-041-28/+34
| | | | | | This reverts commit r205635 that was submitted by mistake. llvm-svn: 205637
* temporary commit.Rui Ueyama2014-04-041-34/+28
| | | | llvm-svn: 205635
* Return a vector rather than mutating a given one.Rui Ueyama2014-04-041-4/+9
| | | | | | | | This is cleaner and as efficient as before. Differential Revision: http://llvm-reviews.chandlerc.com/D3284 llvm-svn: 205590
* Update comment.Rui Ueyama2014-04-031-1/+2
| | | | llvm-svn: 205579
* Minor cleanups.Rui Ueyama2014-04-031-4/+3
| | | | llvm-svn: 205578
* Replace a recursion with a loop for speed.Rui Ueyama2014-04-031-5/+7
| | | | llvm-svn: 205576
* [ELF] Add --allow-multiple-definition option.Rui Ueyama2014-03-281-10/+13
| | | | | | | | | If --allow-multiple-definition option is given, LLD does not treat duplicate symbol error as a fatal error. GNU LD supports this option. Differential Revision: http://llvm-reviews.chandlerc.com/D3211 llvm-svn: 205015
* [core] add SectionGroup supportShankar Easwaran2014-03-261-14/+27
| | | | | | Review : http://llvm-reviews.chandlerc.com/D3182 llvm-svn: 204830
* [PECOFF] Support yet another new type of weak symbol.Rui Ueyama2014-03-181-14/+45
| | | | | | | | | | COMDAT_SELECT_LARGEST is a COMDAT type that make linker to choose the largest definition from among all of the definition of a symbol. If the size is the same, the choice is arbitrary. Differential Revision: http://llvm-reviews.chandlerc.com/D3011 llvm-svn: 204172
* Fix a bug that mergeCases table does not match the merge constants.Rui Ueyama2014-03-081-0/+2
| | | | | | | | | | MergeCases table should not have an entry for MergeContents because atoms with MergeContents attribute should never have name. This issue was not caught by a test because getting a value of 6th element of an array of array actually gets the first element's value of the next array, and that happened to be a valid value. Added asserts to catch that error. llvm-svn: 203322
* [PECOFF] Support a new type of weak symbol.Rui Ueyama2014-03-071-20/+22
| | | | | | | | | | | | | | | Summary: COMDAT_SELECT_SAME_SIZE is a COMDAT type that I presume exist only in COFF. The semantics of the type is that linker should merge such COMDAT sections if their sizes are the same. Otherwise it's an error. Reviewers: Bigcheese, shankarke, kledzik CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2996 llvm-svn: 203308
* Early return.Rui Ueyama2013-11-251-2/+4
| | | | llvm-svn: 195663
* Use range-based for loop.Rui Ueyama2013-11-251-3/+2
| | | | llvm-svn: 195662
* Indentation.Rui Ueyama2013-11-251-21/+21
| | | | llvm-svn: 195661
* Simplify. No functionality change.Rui Ueyama2013-11-181-3/+1
| | | | llvm-svn: 195051
* Select new undefined atom rather than old one if other conditions are the same.Rui Ueyama2013-11-151-20/+34
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Terminate if there are un-mergeable duplicate atoms.Rui Ueyama2013-11-141-0/+2
| | | | llvm-svn: 194671
* Remove default label from fully covered switch.Rui Ueyama2013-11-131-3/+0
| | | | llvm-svn: 194624
* Show error message if two atoms are not mergeable.Rui Ueyama2013-11-131-0/+4
| | | | llvm-svn: 194620
* Fix indentation, use early return.Rui Ueyama2013-11-131-121/+115
| | | | llvm-svn: 194619
* [lld][InputGraph] Change the Resolver to use inputGraphShankar Easwaran2013-10-071-1/+0
| | | | | | | | | | | | 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
* Add a fallback mechanism for undefined atom.Rui Ueyama2013-09-121-1/+10
| | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud