summaryrefslogtreecommitdiffstats
path: root/lld/lib/Core
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix Weak External symbol handling.Rui Ueyama2013-11-201-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Remove extraneous curly braces and blank lines.Rui Ueyama2013-11-192-6/+1
| | | | llvm-svn: 195107
* Simplify. No functionality change.Rui Ueyama2013-11-181-3/+1
| | | | llvm-svn: 195051
* Refactor copy-paste-and-modifed code using callback.Rui Ueyama2013-11-151-60/+29
| | | | llvm-svn: 194784
* 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
* Move InputGraph from Driver to Core. LinkingContext depends on it.Michael J. Spencer2013-11-142-0/+179
| | | | llvm-svn: 194641
* 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
* Revert "Use empty() instead of size() == 0."Rui Ueyama2013-11-131-1/+1
| | | | | | This reverts commit r194551 because it broke the buildbot. llvm-svn: 194552
* Use empty() instead of size() == 0.Rui Ueyama2013-11-131-1/+1
| | | | llvm-svn: 194551
* Hopefully fix latent bug where lldCore dependency on lldYAML was not in ↵Nick Kledzik2013-11-061-1/+4
| | | | | | CMake files llvm-svn: 194177
* Remove unnecessary namespace qualifier.Rui Ueyama2013-11-051-1/+1
| | | | llvm-svn: 194037
* Replace ErrorOr<void> with error_code.Rafael Espindola2013-11-051-1/+1
| | | | | | It was never transporting any value in addition to the error_code. llvm-svn: 194028
* [PassManager] add ReaderWriter{Native,YAML} to the Driver.Shankar Easwaran2013-10-293-3/+3
| | | | | | | | | | | | | Enable this for the following flavors a) core b) gnu c) darwin Its disabled for the flavor PECOFF. Convenient markers are added with FIXME comments in the Driver that would be removed and code removed from each flavor. llvm-svn: 193585
* Revert "r193300 - [PassManager] add ReaderWriter{Native, YAML} to the Driver"Rui Ueyama2013-10-242-2/+2
| | | | | | | The patch have completely broken COFF port and disabled many tests. This also reverts r193302 (comment fix). llvm-svn: 193362
* [PassManager] add ReaderWriter{Native,YAML} to the Driver.Shankar Easwaran2013-10-242-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Disable tests to be run with REQUIRES: disable. Note disable is not added to the config by the test runner Mkaefiles, so essentially disables the test. Code changes would be required to fix these tests :- test/darwin/hello-world.objtxt test/elf/check.test test/elf/phdr.test test/elf/ppc.test test/elf/undef-from-main-dso.test test/elf/X86_64/note-sections-ro_plus_rw.test test/pecoff/alignment.test test/pecoff/base-reloc.test test/pecoff/bss-section.test test/pecoff/drectve.test test/pecoff/dynamic.test test/pecoff/dynamicbase.test test/pecoff/entry.test test/pecoff/hello.test test/pecoff/imagebase.test test/pecoff/importlib.test test/pecoff/lib.test test/pecoff/multi.test test/pecoff/reloc.test test/pecoff/weak-external.test llvm-svn: 193300
* Make undefines check into an assertion.Rui Ueyama2013-10-161-10/+8
| | | | | | | | | Dead-strip root symbols can be undefined atoms, but should not really be nonexistent, because dead-strip root symbols should be added to initial undefined atoms at startup. Whenever you look up its name in the symbol table, some type of atom will always exist. llvm-svn: 192831
* Propagate deadStripOptimize()'s failure to the caller.Rui Ueyama2013-10-161-5/+7
| | | | | | | We want to make the program to exit with non-zero exit code if there's an error during dead stripping. llvm-svn: 192771
* Propagate Resolver::resolveUndefines()'s failure to caller.Rui Ueyama2013-10-111-6/+7
| | | | llvm-svn: 192424
* Return true from Resolver::resolve() on success.Rui Ueyama2013-10-111-2/+2
| | | | llvm-svn: 192422
* Remove an unused variable added in r192415.Rui Ueyama2013-10-111-1/+0
| | | | llvm-svn: 192416
* Use switch instead of if, and handle all enum values.Rui Ueyama2013-10-111-18/+30
| | | | | | | This patch also handles errors other than no_more_files error. They were silently ignored. llvm-svn: 192415
* [Layout] Dont set ordinals to Files by default.Shankar Easwaran2013-10-091-0/+1
| | | | | | | | | | | | | This change removes code in various places which was setting the File Ordinals. This is because the file ordinals are assigned by the way files are resolved. There was no other way than making the getNextFileAndOrdinal be set const and change the _nextOrdinal to mutable. There are so many places in code, that you would need to cleanup to make LinkingContext non-const! llvm-svn: 192280
* [Layout] Assign ordinals in Resolution order.Shankar Easwaran2013-10-092-7/+19
| | | | llvm-svn: 192277
* [inputGraph] Associate Resolve state with appropriate nodesShankar Easwaran2013-10-092-1/+2
| | | | | | | | | | This associates resolveState to FileNodes. The control node derive their resolution state from the inputElements that are contained in it. This makes --start-group/--end-group to work with ELF linking. llvm-svn: 192269
* Update error classes from all lowercase to camel case.Rui Ueyama2013-10-093-39/+39
| | | | llvm-svn: 192261
* Move a local variable into while-loop scope.Rui Ueyama2013-10-091-2/+1
| | | | llvm-svn: 192260
* [LinkingContext] make LinkingContext non-constShankar Easwaran2013-10-081-2/+2
| | | | llvm-svn: 192183
* Make bitmask an unsigned type.Rui Ueyama2013-10-082-2/+2
| | | | llvm-svn: 192163
* Add comments. Early return.Rui Ueyama2013-10-081-10/+16
| | | | llvm-svn: 192149
* Convert error code structs to scoped enums.Rui Ueyama2013-10-081-37/+27
| | | | | | | | | | | | | | Summary: The original code with enum "_" is intended to emulate scoped enums. Now we have real scoped enums, so use it. Reviewers: Bigcheese CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1852 llvm-svn: 192148
* [lld][InputGraph] Change the Resolver to use inputGraphShankar Easwaran2013-10-076-199/+194
| | | | | | | | | | | | 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
* [lld][LinkingContext][ELF] Allow different output file types.Shankar Easwaran2013-09-231-1/+1
| | | | | | | | | | This adds an option --output-filetype that can be set to either YAML/Native(case insensitive). The linker would create the outputs associated with the type specified by the user. Changes all the tests to use the new option. llvm-svn: 191183
* [lld][ELF] Support non alloc sections in the Writer.Shankar Easwaran2013-09-191-0/+1
| | | | | | | | | This also makes it support debugging executables built with lld. Initial patch done by Bigcheese. This is only a revised patch to have the functionality in the Writer. llvm-svn: 191032
* [PECOFF] Handle weak external symbols.Rui Ueyama2013-09-121-3/+9
| | | | | | Used the fallback mechanism to implement COFF weak external symbols. llvm-svn: 190633
* Add a fallback mechanism for undefined atom.Rui Ueyama2013-09-122-2/+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
* Drop the context forceLoadAllArchives() support. Rename the isForceLoadJoerg Sonnenberger2013-09-081-1/+1
| | | | | | | | | attribute in LinkerInput to isWholeArchive and use that for deciding whether library archives should be expanded. Implement the -all_load option of the Darwin linker using this flag and drop the support for it in GNU mode. llvm-svn: 190275
* Change the parseFile argument from MemoryBuffer pointer to LinkerInputJoerg Sonnenberger2013-09-071-11/+0
| | | | | | reference. Move readFile logic into FileNode::createLinkerInput. llvm-svn: 190253
* [lld][ELF] Differentiate between Note sections(RW/RO)Shankar Easwaran2013-09-041-1/+2
| | | | | | | | | | It looks like there is a possibility of seeing RO/RW note sections and we would need to create an appropriate RO/RW segment associated with them. Adds a test too. llvm-svn: 189907
* [lld][ELF] Emit note sectionsShankar Easwaran2013-09-041-0/+1
| | | | | | | | Emit note sections if the input contains a note section. Also emit a note segment. llvm-svn: 189896
* Resolver: Do not use assert() to notify user input error.Rui Ueyama2013-09-031-1/+5
| | | | llvm-svn: 189775
* [lld][LinkingContext] Atoms created from command line options should be ↵Shankar Easwaran2013-08-311-0/+35
| | | | | | | | | | | | available in YAML This adds an API to the LinkingContext for flavors to add Internal files containing atoms that need to appear in the YAML output as well, when -emit-yaml switch is used. Flavors can add more internal files for other options that are needed. llvm-svn: 189718
* Use do-while instead of a magic number. No functionality change.Rui Ueyama2013-08-271-3/+3
| | | | llvm-svn: 189413
* [lld][ELF] Rename typeTLV content type for ELFShankar Easwaran2013-08-231-0/+2
| | | | | | | | | | | typeTLV content type is used by Darwin to represent thread local storage. A new contentType has to be made to represent ELF thread local storage data. These have been set to - typeThreadZeroFill (represents TBSS storage) - typeThreadData (represents TDATA storage) llvm-svn: 189137
* Fix spelling error. s/Libary/Library/g.Rui Ueyama2013-08-091-1/+1
| | | | llvm-svn: 188049
* Rename TargetInfo -> LinkingContext.Rui Ueyama2013-08-064-33/+32
| | | | | | | | | Also change some local variable names: "ti" -> "context" and "_targetInfo" -> "_context". Differential Revision: http://llvm-reviews.chandlerc.com/D1301 llvm-svn: 187823
* fix typo in error stringNick Kledzik2013-07-231-1/+1
| | | | llvm-svn: 186996
* [PECOFF] Support linking against DLL.Rui Ueyama2013-07-111-0/+1
| | | | | | | | | | | | | | | This patch adds a new pass, IdataPass, to transform shared atom references to real references and to construct the .idata section data. With this patch lld can produce a working Hello World program by linking it against kernel32.dll and user32.dll. Reviewers: Bigcheese CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1096 llvm-svn: 186071
OpenPOWER on IntegriCloud