Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lld
AgeCommit message (Collapse)Author
2015-07-06COFF: Support isa<> for Symbol::Body, whose type is std::atomic<SymbolBody *>.Rui Ueyama
llvm-svn: 241477
2015-07-06COFF: Set TLS table header field.Rui Ueyama
TLS table header field is supposed to have address and size of TLS table. The linker doesn't have to understand what TLS table is. TLS table's name is always "_tls_used", so if there's that symbol, the linker simply sets that symbol's RVA to the header. The size of the TLS table is always 40 bytes. llvm-svn: 241426
2015-07-06COFF: Make ArchiveFile::getMember thread-safe.Rui Ueyama
This function is called SymbolTable::readObjects, so in order to parallelize that function, we have to make this function thread-safe. llvm-svn: 241420
2015-07-06COFF: Use CAS to update Sym->Body.Rui Ueyama
Note that the linker is not multi-threaded yet. This is a preparation for that. llvm-svn: 241417
2015-07-06COFF: Use atomic pointers in preparation for parallelizing.Rui Ueyama
In the new design, mutation of Symbol pointers is the name resolution operation. This patch makes them atomic pointers so that they can be mutated by multiple threads safely. I'm going to use atomic compare-exchange on these pointers. dyn_cast<> doesn't recognize atomic pointers as pointers, so we need to call load(). This is unfortunate, but in other places automatic type conversion works fine. llvm-svn: 241416
2015-07-05COFF: Do not warn on identical /merge options.Rui Ueyama
llvm-svn: 241397
2015-07-05COFF: Implement /merge option.Rui Ueyama
/merge:.foo=.bar makes the linker to merge section .foo with section .bar. llvm-svn: 241396
2015-07-04COFF: Numerous fixes for interaction between LTO and weak externals.Peter Collingbourne
We were previously hitting assertion failures in the writer in cases where a regular object file defined a weak external symbol that was defined by a bitcode file. Because /export and /entry name mangling were implemented using weak externals, the same problem affected mangled symbol names in bitcode files. The underlying cause of the problem was that weak external symbols were being resolved before doing LTO, so the symbol table may have contained stale references to bitcode symbols. The fix here is to defer weak external symbol resolution until after LTO. Also implement support for weak external symbols in bitcode files by modelling them as replaceable DefinedBitcode symbols. Differential Revision: http://reviews.llvm.org/D10940 llvm-svn: 241391
2015-07-04Revert "COFF: Do not use VirtualSize section header field for directive ↵Rui Ueyama
sections." This reverts commit r241386 because the issue is addressed in LLVM (r241387). llvm-svn: 241388
2015-07-04COFF: Do not use VirtualSize section header field for directive sections.Rui Ueyama
Looks like clang-cl sets a bogus value to the field, which makes getSectionContents() to truncate section contents. This patch directly uses SizeOfRawData field instead of VirtualSize to see if this can make buildbot green. llvm-svn: 241386
2015-07-04Use map::insert instead of checking existence of a key and insert. NFC.Rui Ueyama
llvm-svn: 241385
2015-07-04COFF: Print directive section contents if /verbose.Rui Ueyama
llvm-svn: 241384
2015-07-04COFF: Fix bug in garbage collector.Rui Ueyama
GC root may have non-regular defined symbols, such as DefinedImportThunk, so this cast<> was a wrong assumption. llvm-svn: 241382
2015-07-04COFF: Don't print warning message for identical /export options.Rui Ueyama
llvm-svn: 241379
2015-07-04[ELF] Fix ELF test cases. Do not provide content for bss sections.Simon Atanasyan
llvm-svn: 241378
2015-07-04COFF: Fix the case where an object defines a weak external and its alias.Peter Collingbourne
This worked before, but only by accident, and only with assertions disabled. We ended up storing a DefinedRegular symbol in the WeakAlias field, and never using it as an Undefined. Differential Revision: http://reviews.llvm.org/D10934 llvm-svn: 241376
2015-07-04[ELF/AArch64] Set correct loader name in linking contextAdhemerval Zanella
This patch reimplements ELFLinkingContext::getDefaultInterpreter for aarch64 with correct loader name. It is required to exclude the loader from DT_NEEDED in shared library creation. llvm-svn: 241371
2015-07-04[ELF/AArch64] Set correct loader name in linking contextAdhemerval Zanella
This patch reimplements ELFLinkingContext::getDefaultInterpreter for aarch64 with correct loader name. It is required to exclude the loader from DT_NEEDED in shared library creation. llvm-svn: 241370
2015-07-03Use getDynamicSymbolName/getStaticSymbolName instead of a constant argument.Rafael Espindola
llvm-svn: 241346
2015-07-03[Mips] Factor out symbol type checking (PIC/non-PIC) into the separate functionSimon Atanasyan
No functional changes. llvm-svn: 241342
2015-07-03[ELF] Define __start_XXX/__stop_XXX symbols where XXX is a section nameSimon Atanasyan
This is GNU ELF linker extension used particularly by LibC code. If input object files contain section named XXX, and the XXX is a valid C identifier, and there are undefined or weak symbols __start_XXX/__stop_XXX, linker should define __start_XXX/__stop_XXX symbols point to the begin/end of the XXX section correspondingly. For example, without support of this extension statically linked executables for X86_64 and Mips (maybe other) targets do not flush IO buffers at the end of executing. llvm-svn: 241341
2015-07-03COFF: Call exit(0) on success to not call destructors.Rui Ueyama
This change cut the link time of chrome.dll from 24 seconds to 22 seconds (5% gain). When the control reaches end of link(), all output files have already been written. All in-memory objects can just vanish. There is no use to call their dtors. llvm-svn: 241320
2015-07-03COFF: Fix ordinal-only delay-imported symbols.Rui Ueyama
DLLs can export symbols only by ordinal, and DLLs are also able to be delay-loaded. The combination of the two is valid. I didn't expect that combination. This patch implements that feature. With this patch, LLD is now able to link a working executable of Chrome for 64-bit debug build. The browser seemed to be working fine. Chrome is good for testing because of its variety and size. It contains various open-source libraries written by various people. The largest file in Chrome is chrome.dll whose size is 496MB. LLD can link it in 24 seconds. MSVC linker takes 48 seconds. So it is exactly 2x faster. (I measured that with debug info and ICF being turned off.) With this achievement, I think I can say that the new COFF linker is now mostly feature complete for x86-64 Windows. I believe there are still many lingering bugs, though. llvm-svn: 241318
2015-07-03COFF: Fix a bug that /delayload was case-sensitive.Rui Ueyama
llvm-svn: 241316
2015-07-03COFF: Fix /base option.Rui Ueyama
Previously, __ImageBase symbol got a different value than the one specified by /base:<number> because the symbol was created in the SymbolTable's constructor. When the constructor is called, no command line options are processed yet, so the symbol was created always with the initial value. This caused wrong relocations and thus caused mysterious crashes of some executables linked by LLD. llvm-svn: 241313
2015-07-03COFF: Define SymbolTable::insert to simplify. NFC.Rui Ueyama
llvm-svn: 241311
2015-07-02Update for llvm changes.Rafael Espindola
llvm-svn: 241298
2015-07-02COFF: Fix locally-imported symbols.Rui Ueyama
Previously, pointers pointed by locally-imported symbols were broken. It has only 4 bytes although the correct size is 8 byte. This patch fixes that bug. llvm-svn: 241295
2015-07-02COFF: Make symbols satisfy weak ordering.Rui Ueyama
Previously, SymbolBody::compare(A, B) didn't satisfy weak ordering. There was a case that A < B and B < A could have been true. This is because we just pick LHS if A and B are consisdered equivalent. This patch is to make symbols being weakly ordered. If A and B are not tie, one of A < B && B > A or A > B && B < A is true. This is not an improtant property for a single-threaded environment because everything is deterministic anyways. However, in a multi- threaded environment, this property becomes important. If a symbol is defined or lazy, ties are resolved by its file index. For simple types that we don't really care about their identities, symbols are compared by their addresses. llvm-svn: 241294
2015-07-02[ELF] Remove dead code. NFCSimon Atanasyan
llvm-svn: 241274
2015-07-02COFF: Merge SymbolTable::find{,Symbol}. NFCRui Ueyama
llvm-svn: 241238
2015-07-02COFF: Infer entry point as early as possible, but not too early.Rui Ueyama
On Windows, we have four different main functions, {w,}{main,WinMain}. The linker has to choose a corresponding entry point function among {w,}{main,WinMain}CRTStartup. These entry point functions are defined in the standard library. The linker resolves one of them by looking at which main function is defined and adding a corresponding undefined symbol to the symbol table. Object files containing entry point functions conflicts each other. For example, we cannot resolve both mainCRTStartup and WinMainCRTStartup because other symbols defined in the files conflict. Previously, we inferred CRT function name at the very end of name resolution. I found that that is sometimes too late. If the linker already linked one of these four archive member objects, it's too late to change the decision. The right thing to do here is to infer entry point name after adding all symbols from command line files and before adding any other files (which are specified by directive sections). This patch does that. llvm-svn: 241236
2015-07-02COFF: Resolve AlternateNames using weak aliases.Rui Ueyama
Previously, we use SymbolTable::rename to resolve AlternateName symbols. This patch is to merge that mechanism with weak aliases, so that we remove that function. llvm-svn: 241230
2015-07-02COFF: Rename getReplacement -> repl.Rui Ueyama
The previous name was too long to my taste. llvm-svn: 241215
2015-07-02COFF: Change GCRoot member type from StringRef to Undefined. NFC.Rui Ueyama
I think Undefined symbols are a bit more convenient than StringRefs since SymbolBodies are handles for symbols. You can get resolved symbols for undefined symbols just by calling getReplacmenet without looking up the symbol table. llvm-svn: 241214
2015-07-02COFF: Simplify and rename findMangle. NFC.Rui Ueyama
Occasionally we have to resolve an undefined symbol to its mangled symbol. Previously, we did that on calling side of findMangle by explicitly updating SymbolBody. In this patch, mangled symbols are handled as weak aliases for undefined symbols. llvm-svn: 241213
2015-07-02COFF: Chagne weak alias' type from SymbolBody** to SymbolBody*. NFC.Rui Ueyama
llvm-svn: 241198
2015-07-02[ELF] Make OutputSection::memSize `const` member function. NFCSimon Atanasyan
llvm-svn: 241194
2015-07-02[ELF/AArch64] Initial General-dynamic TLS supportAdhemerval Zanella
This patch adds initial general-dynamic TLS support for AArch64. Currently no optimization is done to realx for more performance-wise models (initial-exec or local-exec). This patch also only currently handles correctly executable generation, although priliminary DSO support through PLT specific creation is also added. With this change clang/llvm bootstrap with lld is possible in static configuration (some DSO creation fails due missing Linker script support, not AArch64 specific), although make check also shows some issues. llvm-svn: 241192
2015-07-01Update for llvm api change.Rafael Espindola
llvm-svn: 241157
2015-07-01COFF: Simplify SymbolTable::findLazy. NFC.Rui Ueyama
llvm-svn: 241128
2015-06-30COFF: Change the order of adding symbols to the symbol table.Rui Ueyama
Previously, the order of adding symbols to the symbol table was simple. We have a list of all input files. We read each file from beginning of the list and add all symbols in it to the symbol table. This patch changes that order. Now all archive files are added to the symbol table first, and then all the other object files are added. This shouldn't change the behavior in single-threading, and make room to parallelize in multi-threading. In the first step, only lazy symbols are added to the symbol table because archives contain only Lazy symbols. Member object files found to be necessary are queued. In the second step, defined and undefined symbols are added from object files. Adding an undefined symbol to the symbol table may cause more member files to be added to the queue. We simply continue reading all object files until the queue is empty. Finally, new archive or object files may be added to the queues by object files' directive sections (which contain new command line options). The above process is repeated until we get no new files. Symbols defined both in object files and in archives can make results undeterministic. If an archive is read before an object, a new member file gets linked, while in the other way, no new file would be added. That is the most popular cause of an undeterministic result or linking failure as I observed. Separating phases of adding lazy symbols and undefined symbols makes that deterministic. Adding symbols in each phase should be parallelizable. llvm-svn: 241107
2015-06-30Use copy init instead of direct init.Rafael Espindola
llvm-svn: 241089
2015-06-30Update for llvm change.Rafael Espindola
llvm-svn: 241075
2015-06-30Add layout/triple to fix test on platforms where names are mangled.Peter Collingbourne
llvm-svn: 241031
2015-06-30COFF: Implement SymbolBody::getDebugName() for DefinedBitcode symbols.Peter Collingbourne
Differential Revision: http://reviews.llvm.org/D10827 llvm-svn: 241029
2015-06-30COFF: Make DefinedCOFF one pointer smaller.Rui Ueyama
The size of this class actually matters because this is the most popular class among all classes. We create a Defined symbol for each defined symbol in a symbol table. That can be millions for a large program. For example, linking LLD instantiates this class millions times. llvm-svn: 241025
2015-06-30COFF: Use LTOModule::getLinkerOpts() instead of reading the linker ↵Peter Collingbourne
directives ourselves. llvm-svn: 241020
2015-06-30COFF: Split ObjectFile::createSymbolBody into small functions. NFC.Rui Ueyama
llvm-svn: 241011
2015-06-30Move llvm_unreachable out of switch to avoid -Wswitch-covered-defualt.Rui Ueyama
llvm-svn: 241008