summaryrefslogtreecommitdiffstats
path: root/lld/COFF/DriverUtils.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* COFF: Update error messages so that they start with lowercase letters.Rui Ueyama2016-07-151-10/+10
| | | | llvm-svn: 275513
* Make check() always return a value.Rui Ueyama2016-07-151-12/+5
| | | | | | | Previously, one of two check functions didn't return a value. It was confusing. This patch makes both functions return values. llvm-svn: 275511
* COFF: Remove `void error()` functions and use fatal instead.Rui Ueyama2016-07-151-15/+24
| | | | | | This change makes the control flow more explicit. llvm-svn: 275504
* COFF: Remove unnecessary explicit calls of Twine ctor.Rui Ueyama2016-07-141-26/+26
| | | | llvm-svn: 275501
* COFF: Rename noreturn error -> fatal.Rui Ueyama2016-07-141-22/+22
| | | | | | This new name is also consistent with ELF. llvm-svn: 275500
* COFF: Rename non-noreturn error -> check.Rui Ueyama2016-07-141-11/+11
| | | | | | The new name is consistent with ELF. llvm-svn: 275499
* COFF: drop the dependency on LIB.EXE for implibsSaleem Abdulrasool2016-07-131-143/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lld currently relies on lib.exe in order to generate an empty import library. The "empty" import library consists of 5 members: - first linker member - second linker member - Import Descriptor - NULL Import Descriptor - NULl Thunk The first two entries (first and second linker members) are string tables which are never updated. Therefore, they may as well as not be present. A subsequent change to add that is probably warranted. However, this does not prevent the use of the linker. The Import Descriptor is the content which is most important. It provides an Import Name Table entry for the library (as specified by the LIBRARY directive in the DEF file). Additionally, it contains undefined references to the NULL Import Descriptor and the library NULL Thunk Data. This ensures that the linker will pull in the subsequent objects from the import library for the link. The Import Descriptor has a single symbol (__IMPORT_DESCRIPTOR_<Library>) which contains 3 relocations, one to the INT (Import Name Table) entry, one to the ILT (Import Lookup Table) entry, and one to the IAT (Import Address Table) entry. The NULL Import Descriptor is the last import descriptor and terminates the import descriptor array. It contains a single symbol (__NULL_IMPORT_DESCRIPTOR). The NULL Thunk contains a single symbol (\x7f<Library>_NULL_THUNK_DATA) and provides the terminator for the ILT and IAT. These files are currently constructed manually following the example of the Short Import Library format. This is arguably less than ideal, and it may be possible to use MCAssembler and feed it the fragments to construct the object. The major difference between the LIB (LINK) generated objects and the ones generated here is that they are all one section shorter (.debug$S) as they do not contain the debug information and one symbol shorter (@comp.id) as they do not contain the RICH signature. Move the logic related to the librarian into a new source file (Librarian.cpp). llvm-svn: 275242
* COFF: remove unused function (touchFile)Saleem Abdulrasool2016-07-081-7/+0
| | | | | | Remove some dead code. NFC. llvm-svn: 274900
* COFF: Switch to new archive writer interface (D21721).Peter Collingbourne2016-06-291-28/+14
| | | | | | Differential Revision: http://reviews.llvm.org/D21722 llvm-svn: 274184
* Matching change for lld for the llvm change of Archive::create() from ↵Kevin Enderby2016-06-291-3/+3
| | | | | | ErrorOr<...> to Expected<...> in r274160. llvm-svn: 274161
* [COFF] Add /section command line flag.Rui Ueyama2016-06-201-0/+41
| | | | llvm-svn: 273134
* Revert unintentionally commited bits in r266935.Nico Weber2016-04-211-25/+1
| | | | llvm-svn: 266942
* unbreak COFF/out.test after r266929Nico Weber2016-04-201-1/+25
| | | | llvm-svn: 266935
* COFF: Support /manifestinput command line option.Rui Ueyama2016-04-191-6/+47
| | | | | | | | | | | | | | | | | | | Manifest file is a separate or embedded XML file having metadata of an executable. As it is XML, it can contain various types of information. Probably the most popular one is to request escalated priviledges. Usually the linker creates an XML file and embed that file into an executable. However, there's a way to supply an XML file from command line. /manifestniput is it. Apparently it is over-designed here, but if you supply two or more manifest files, then the linker needs to merge the files into a single XML file. A good news is that we don't need to do that ourselves. MT.exe command can do that, so we call the command from the linker in this patch. llvm-svn: 266704
* COFF: Implement DLL symbol forwarding.Rui Ueyama2016-01-091-5/+26
| | | | | | | | | | | | | | | | DLL export tables usually contain dllexport'ed symbol RVAs so that applications which use the DLLs can find symbols from the DLLs. However, there's a minor feature to "forward" DLL symbols to other DLLs. If you set an RVA to a string whose form is "<dllname>.<symbolname>" (e.g. "KERNEL32.ExitProcess") instead of symbol RVA to the export table, the loader interprets that as a forwarder symbol, and resolve that symbol from the specified DLL. This patch implements that feature. llvm-svn: 257243
* Fix a few windows only tests.Rafael Espindola2015-11-061-1/+3
| | | | | | This argument must be non-null. llvm-svn: 252336
* These are the matching changes needed to the lld project for the changes to llvmKevin Enderby2015-11-051-2/+4
| | | | | | | in r252192 that changed the Archive and Child interfaces in libObject. These include Rafael Espindola’s many suggested updates. llvm-svn: 252193
* Update lld to match llvm r250901. OptTable constructor now takes an ↵Craig Topper2015-10-211-1/+1
| | | | | | ArrayRef. NFC llvm-svn: 250904
* Remove unused #includes.Rui Ueyama2015-09-191-1/+0
| | | | llvm-svn: 248081
* [COFF] Remove dead private field. Also fixes build with -Werror.Davide Italiano2015-09-011-1/+0
| | | | llvm-svn: 246553
* COFF: Make import libraries compatible with MSVC link.Rui Ueyama2015-09-011-7/+1
| | | | | | | | | | I have totally no idea why, but MSVC linker is sensitive about file names of archive members. If we do not make import library file names to the same as the DLL name, MSVC link *crashes* when it is processing the library file. This patch is to set the same name. llvm-svn: 246535
* COFF: Set "Data" bit for data symbols in the import descriptor.Rui Ueyama2015-09-011-1/+0
| | | | llvm-svn: 246533
* COFF: Improve dllexported name mangling compatibility.Rui Ueyama2015-08-311-36/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The rules for dllexported symbols are overly complicated due to x86 name decoration, fuzzy symbol resolution, and the fact that one symbol can be resolved by so many different names. The rules are probably intended to be "intuitive", so that users don't have to understand the name mangling schemes, but it seems that it can lead to unintended symbol exports. To make it clear what I'm trying to do with this patch, let me write how the export rules are subtle and complicated. - x86 name decoration: If machine type is i386 and export name is given by a command line option, like /export:foo, the real symbol name the linker has to search for is _foo because all symbols are decorated with "_" prefixes. This doesn't happen on non-x86 machines. This automatic name decoration happens only when the name is not C++ mangled. However, the symbol name exported from DLLs are ones without "_" on all platforms. Moreover, if the option is given via .drectve section, no symbol decoration is done (the reason being that the .drectve section is created by a compiler and the compiler should always know the exact name of the symbol, I guess). - Fuzzy symbol resolution: In addition to x86 name decoration, the linker has to look for cdecl or C++ mangled symbols for a given /export. For example, it searches for not only _foo but also _foo@<number> or ??foo@... for /export:foo. Previous implementation didn't get it right. I'm trying to make it as compatible with MSVC linker as possible with this patch however the rules are. The new code looks a bit messy to me, but I don't think it can be simpler due to the ad-hoc-ness of the rules. llvm-svn: 246424
* COFF: Create short import files instead of using lib.exe.Rui Ueyama2015-08-281-40/+130
| | | | | | | | | | | | | | | | | | | | | | lib.exe has a feature to create import library files (which contain short import files) from module-definition files. Previously, we were using that feature, but it turned out that the feature is not complete for us. There seems no way to specify "Import Types" in module-definition file. lib.exe always adds "_" to given symbols and specify IMPORT_NAME_UNDECORATE. We need more fine-grainded control on that value. This patch teaches LLD to create short import files itself. We are still using lib.exe, but the use of the tool is limited to create empty import library files. We then create short import files and add them to the empty files as new members. This patch does not intend to change the functionality. LLD produces the same import libraries as before. I'll make another change to create different import libraries in a follow-up patch. llvm-svn: 246292
* COFF: Print out module-definition files if /verbose is given.Rui Ueyama2015-08-261-7/+10
| | | | | | This is useful for testing. llvm-svn: 246032
* COFF: Show real command line options if /verbose is given.Rui Ueyama2015-08-261-0/+9
| | | | llvm-svn: 246023
* COFF: Use ErrorOr::operator* instead of ErrorOr::get.Rui Ueyama2015-08-181-1/+1
| | | | | | This patch is to make COFF coding style consistent with ELF. NFC. llvm-svn: 245282
* Update for llvm api change.Rafael Espindola2015-08-131-3/+3
| | | | llvm-svn: 244856
* Port the error functions from ELF to COFF.Rafael Espindola2015-08-061-140/+80
| | | | | | | | | | | | | | | This has a few advantages * Less C++ code (about 300 lines less). * Less machine code (about 14 KB of text on a linux x86_64 build). * It is more debugger friendly. Just set a breakpoint on the exit function and you get the complete lld stack trace of when the error was found. * It is a more robust API. The errors are handled early and we don't get a std::error_code hot potato being passed around. * In most cases the error function in a better position to print diagnostics (it has more context). llvm-svn: 244215
* COFF: Fix error message. Space was missing.Rui Ueyama2015-07-311-1/+1
| | | | llvm-svn: 243794
* COFF: Suppress "Duplicate entry" warning of lib.exeRui Ueyama2015-07-291-3/+2
| | | | | | | | | | | | | | | | | We create a module-definition file and give that to lib.exe to create an import library file. A module-definition has to be syntactically and semantically correct, of course. There was a case that we created a module-definition file that lib.exe would complain for duplicate entries. If a user gives an unmangled and mangled name for the same symbol, we would end up having two duplicate lines for the mangled name in a module- definition file. This patch fixes that issue by uniquefying entries by mangled symbol name. llvm-svn: 243587
* COFF: Fix export symbol names for x86.Rui Ueyama2015-07-281-8/+16
| | | | | | | | | | I don't fully understand the rationale behind the name mangling scheme used for the DLL export table and the import library. Why only leading "_" is dropped for the import library while both "_" and "@" are dropped from DLL symbol table? But this seems to be what MSVC linker does. llvm-svn: 243490
* COFF: Use short identifiers. NFC.Rui Ueyama2015-07-251-12/+12
| | | | llvm-svn: 243229
* COFF: Don't assume !is64() means i386.Rui Ueyama2015-07-251-1/+1
| | | | | | | | In many places we assumed that is64() means AMD64 and i386 otherwise. This assumption is not sound because Windows also supports ARM. The linker doesn't support ARM yet, but this is a first step. llvm-svn: 243188
* COFF: Fix mangled dllexported names.Rui Ueyama2015-07-151-3/+13
| | | | | | | | | If a symbol is exported as /export:foo, and foo is resolved as a mangled name (_foo@<number> or ?foo@@Y...), that mangled name should be written to the export table. Previously, we wrote the original name to the export table. llvm-svn: 242342
* COFF: Fix command line options for external commands.Rui Ueyama2015-07-091-2/+2
| | | | llvm-svn: 241853
* COFF: Make /machine:{i386,amd64} aliases to {x86,x64}.Rui Ueyama2015-07-091-1/+3
| | | | | | MSVC linker accepts these aliases. llvm-svn: 241840
* COFF: Handle /machine option in a similar manner for other options. NFC.Rui Ueyama2015-07-081-14/+9
| | | | llvm-svn: 241701
* COFF: Check for incompatible machine types.Rui Ueyama2015-07-071-0/+13
| | | | llvm-svn: 241647
* COFF: Do not warn on identical /merge options.Rui Ueyama2015-07-041-3/+6
| | | | llvm-svn: 241397
* COFF: Implement /merge option.Rui Ueyama2015-07-041-0/+17
| | | | | | /merge:.foo=.bar makes the linker to merge section .foo with section .bar. llvm-svn: 241396
* Use map::insert instead of checking existence of a key and insert. NFC.Rui Ueyama2015-07-041-4/+5
| | | | llvm-svn: 241385
* COFF: Don't print warning message for identical /export options.Rui Ueyama2015-07-031-4/+9
| | | | llvm-svn: 241379
* COFF: Create an empty file for /pdb.Rui Ueyama2015-06-291-0/+7
| | | | | | | | Most build system depends on existence or time stamp of a file. This patch is to create an empty file for /pdb:<filename> option just to satisfy some build rules. llvm-svn: 240948
* COFF: Remove a function that doesn't do much itself. NFC.Rui Ueyama2015-06-281-11/+4
| | | | llvm-svn: 240901
* COFF: Handle LINK environment variable.Rui Ueyama2015-06-281-0/+11
| | | | | | | If LINK is defined and not empty, it's supposed to contain command line options. llvm-svn: 240900
* Update for LLVM API change to return by InputArgList directly (rather than ↵David Blaikie2015-06-221-7/+7
| | | | | | by pointer) from ParseArgs llvm-svn: 240347
* Fix missed formatting in prior commit (mostly 80 cols violation and some ↵David Blaikie2015-06-221-1/+1
| | | | | | whitespace around *) llvm-svn: 240346
* ArrayRef-ify Driver::parse and related functions.David Blaikie2015-06-211-2/+3
| | | | llvm-svn: 240236
* ArrayRef-ify ParseArgsDavid Blaikie2015-06-211-2/+2
| | | | llvm-svn: 240235
OpenPOWER on IntegriCloud