summaryrefslogtreecommitdiffstats
path: root/lld/lib
Commit message (Collapse)AuthorAgeFilesLines
* [PECOFF] Drop stdcall's atsign suffix only.Rui Ueyama2014-05-011-2/+4
| | | | | | | You can omit @number suffix when specifying /export option, but you can do that only for stdcall functions. llvm-svn: 207809
* Fix FreeBSD buildbots.Rui Ueyama2014-05-011-1/+1
| | | | llvm-svn: 207802
* Sort.Joerg Sonnenberger2014-05-011-1/+1
| | | | llvm-svn: 207798
* [PECOFF] Do not call addDllExport to mutate export descriptors.Rui Ueyama2014-05-011-4/+4
| | | | | | This is more efficient than before. llvm-svn: 207791
* [ELF] Fix the file look up algorithm used in the linker script GROUP command.Simon Atanasyan2014-05-013-3/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | In general the linker scripts's GROUP command works like a pair of command line options --start-group/--end-group. But there is a difference in the files look up algorithm. The --start-group/--end-group commands use a trivial approach: a) If the path has '-l' prefix, add 'lib' prefix and '.a'/'.so' suffix and search the path through library search directories. b) Otherwise, use the path 'as-is'. The GROUP command implements more compicated approach: a) If the path has '-l' prefix, add 'lib' prefix and '.a'/'.so' suffix and search the path through library search directories. b) If the path does not have '-l' prefix, and sysroot is configured, and the path starts with the / character, and the script being processed is located inside the sysroot, search the path under the sysroot. Otherwise, try to open the path in the current directory. If it is not found, search through library search directories. https://www.sourceware.org/binutils/docs-2.24/ld/File-Commands.html The patch reviewed by Shankar Easwaran, Rui Ueyama. llvm-svn: 207769
* [PECOFF] Fix exported symbol name.Rui Ueyama2014-05-012-3/+13
| | | | | | | | When creating a .lib file, we should strip the leading underscore, but should not strip stdcall atsign suffix. Otherwise produced .lib files cannot be linked. llvm-svn: 207729
* [PECOFF] Add a test for lib.exe subcommand.Rui Ueyama2014-05-013-18/+50
| | | | | | | | | | | | Previously the input file for the lib.exe command would be removed as soon as the command exits, so we couldn't write a test to check the file contents are correct. This patch adds /lldmoduledeffile: option to retain a copy of the temporary file at the given file path, so that you can see the file if you want. llvm-svn: 207727
* [Driver] Check type of InputElement before request a error message. If theSimon Atanasyan2014-04-301-2/+7
| | | | | | | | element is a FileNode, request error description. If the element is Group, print hard coded error message. We need to implement a better diagnostics here but even current solution is better than a segmentation fault output. llvm-svn: 207691
* [ELF] Return result from the function ASAP.Simon Atanasyan2014-04-301-16/+6
| | | | | | No functional changes. llvm-svn: 207690
* [ELF] Factor out the code builds a library search directory pathSimon Atanasyan2014-04-301-14/+12
| | | | | | | | into the separate function. No functional changes. llvm-svn: 207689
* [Driver] Remove the redundant cast.Simon Atanasyan2014-04-301-1/+1
| | | | | | No functional changes. llvm-svn: 207688
* [Mips] Recognize MIPS emulation name 'elf32ltsmip'.Simon Atanasyan2014-04-301-0/+4
| | | | llvm-svn: 207687
* [PECOFF] Fix priority of locally imported symbols.Rui Ueyama2014-04-301-1/+2
| | | | | | | | | | | | | | | | Linker should create _imp_ symbols for local use only when such symbols cannot be resolved in any other way. If it overrides real imported symbols, such symbols remain virtually unresolved without error, causing odd issues. I observed that a program linked with LLD entered an infinite loop before reaching main() because of this issue. This patch moves the virtual file creating _imp_ symbols to the very end of the input file list. Previously, the file is at the end of the library file group. Linker might revisit the group many times, so it was not really at the end of the input file list. llvm-svn: 207605
* [Mips] Re-order include headers.Simon Atanasyan2014-04-291-3/+1
| | | | llvm-svn: 207495
* [Mips] Implement emitting of R_MIPS_REL32 relocations:Simon Atanasyan2014-04-297-25/+269
| | | | | | | | | | | | | 1. Re-implement PLT entries and dynamic relocations emitting to keep PLT and relocations table in a consistent state. 2. Initialize st_value and st_other fields for dynamic symbols table entry if this entry corresponds to an external function which address is taken in a non-PIC executable. In that case the st_value field holds an address of the function's PLT entry. Also set STO_MIPS_PLT bit in the st_other field. llvm-svn: 207494
* [Mips] 80 column.Simon Atanasyan2014-04-291-2/+6
| | | | llvm-svn: 207493
* [PECOFF] /export accepts non-decorated symbols.Rui Ueyama2014-04-291-1/+8
| | | | | | | You usually have to specify the exact name of a symbol to export it, but for stdcall functions you can omit the @numbers suffix. llvm-svn: 207491
* [PECOFF] Fix _imp_ implicit symbols.Rui Ueyama2014-04-292-20/+88
| | | | | | | | | | | | | | | | | | | | | | | Implicit symbol for local use implemented in r207141 was not fully compatible with MSVC link.exe. In r207141, I implemented the feature in such way that implicit symbols are defined only when they are exported with /EXPORT option. After that I found that implicit symbols are defined not only for dllexported symbols but for all defined symbols. Actually _imp_ implicit symbols have no relationship with the dllexport feature. You could add _imp_ to any symbol to get a pointer to the symbol, whether the symbol is dllexported or not. It looks pretty weird to me but that's what we want if link.exe behaves that way. Here is a bit about the implementation: Creating all implicit symbols beforehand is going to be a huge waste of resource. This feature is rarely used, and MSVC link.exe even prints out a warning message when it finds this feature is being used. So we create implicit symbols on demand. There is an archive file that creates implicit symbols when they are needed. llvm-svn: 207476
* [Mips] Convert MipsDynamicSymbolTable to the class template.Simon Atanasyan2014-04-283-10/+14
| | | | llvm-svn: 207435
* [Mips] Add the 'const' qualifier to the couple RelocationPass classSimon Atanasyan2014-04-281-4/+4
| | | | | | member functions. llvm-svn: 207434
* [PECOFF] Allow multiple directives in one module-definition file.Rui Ueyama2014-04-262-44/+66
| | | | | | | | I'm a bit surprised that I have not implemented this yet. This is definitely needed to handle real-world module definition files. This patch contains a unit test for r207294. llvm-svn: 207297
* [PECOFF] Fix off-by-one error in .def file parser.Rui Ueyama2014-04-251-1/+1
| | | | | | | | I'm fixing another bug in the parser, and I wanted to submit this fix as a separate change as it's logically independent from the other. I'll add a test for this shortly. llvm-svn: 207294
* [PECOFF] Add /IMPLIB command line option.Rui Ueyama2014-04-254-8/+14
| | | | | | This option is to override the default import file path. llvm-svn: 207175
* [PECOFF] Assign unique ordinals to __imp_ symbols.Rui Ueyama2014-04-251-4/+10
| | | | llvm-svn: 207168
* [PECOFF] Do not copy-construct ExportDesc.Rui Ueyama2014-04-241-1/+1
| | | | llvm-svn: 207154
* [PECOFF] Define implicit symbols for exported ones.Rui Ueyama2014-04-241-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is to fix a compatibility issue with MSVC link.exe as to use of dllexported symbols inside DLL. A DLL exports two symbols for a function. One is non-decorated one, and the other is with __imp_ prefix. The former is a function that you can directly call, and the latter is a pointer to the function. These dllexported symbols are created by linker for programs that link against the DLL. So, I naturally believed that __imp_ symbols become available when you once create a DLL and link against it, but they don't exist until then. And that's not true. MSVC link.exe is smart enough to allow users to use __imp_ symbols locally. That is, if a symbol is specified with /export option, it implicitly creates a new symbol with __imp_ prefix as a pointer to the exported symbol. This feature allows the following program to be linked and run, although _imp__hello is not defined in this code. #include <stdio.h> __declspec(dllexport) void hello(void) { printf("Hello\n"); } extern void (*_imp__hello)(void); int main() { _imp__hello(); return 0; } MSVC link.exe prints out the following warning when linking it. LNK4217: locally defined symbol _hello imported in function _main Using __imp_ symbols locally is I think not a good coding style. One should just take an address using "&" operator rather than appending __imp_ prefix. However, there are programs in the wild that depends on this link.exe's behavior, so we need this feature. llvm-svn: 207141
* [PECOFF] Allow symbols not starting with '_' in x86Rui Ueyama2014-04-241-1/+2
| | | | | | | | Not all symbols are decorated with an underscore in x86. You can write undecorated symbols in assembly, for example. Thus this assertion is too strong. llvm-svn: 207125
* [PECOFF] Skip IMAGE_SYM_DEBUG sections correctly.Rui Ueyama2014-04-221-6/+8
| | | | | | | | | We don't use sections with IMAGE_SYM_DEBUG attribute so we basically want to the symbols for them when reading symbol table. When we skip them, we need to skip auxiliary symbols too. Otherwise weird error would happen because aux symbols would be interpreted as regular ones. llvm-svn: 206931
* [PECOFF] Better handling of /OPT option.Rui Ueyama2014-04-222-11/+17
| | | | | | | | | | | Previously LLD would fail if /OPT:icf, /OPT:lbr or such are specified, because these command line flags would be handled as unknown ones. We rather want LLD to ignore these known but yet-to-be-implemented options for now. Added tests for the driver as well. llvm-svn: 206863
* [Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth2014-04-226-12/+12
| | | | | | | | | | definition below all of the header #include lines, LLD edition. IF you want to know more details about this, you can see the recent commits to Debug.h in LLVM. This is just the LLD segment of a cleanup I'm doing globally for this macro. llvm-svn: 206851
* [PECOFF] Handle line comment in module-definition file.Rui Ueyama2014-04-221-41/+48
| | | | | | In .def files, ';' is the start of line comment. llvm-svn: 206831
* [PECOFF] Win64 DLL entry function name is _DllMainCRTStartup.Rui Ueyama2014-04-181-4/+7
| | | | | | Unlike Win32/x86, it has no "@12" suffix. llvm-svn: 206648
* [PECOFF] Support LIBRARY directive.Rui Ueyama2014-04-182-0/+14
| | | | | | | LIBRARY directive in a module definition file specifies the output DLL file name. It also takes an optional value for the base address. llvm-svn: 206647
* Use switch for readability.Rui Ueyama2014-04-181-12/+15
| | | | llvm-svn: 206638
* [PECOFF] Ignore /ignore option.Rui Ueyama2014-04-181-0/+1
| | | | | | | | /ignore:<number> is a linker option to disable warning specified by the number. We ignore the option because it does not make sense for LLD. llvm-svn: 206636
* [PECOFF] Support /manifestuac:NO.Rui Ueyama2014-04-181-20/+26
| | | | | | | If the value for /manifestuac is "NO", LLD will create a manifest XM file but won't emit <trustinfo> element. llvm-svn: 206633
* [ELF] Fix GNU_RELRO section name.Rui Ueyama2014-04-181-1/+1
| | | | llvm-svn: 206560
* [ELF] Support --defsym=<symbol>=<symbol>.Rui Ueyama2014-04-162-7/+95
| | | | | | | | | | | | | | | | | | | | | Currently LLD supports --defsym only in the form of --defsym=<symbol>=<integer>, where the integer is interpreted as the absolute address of the symbol. This patch extends it to allow other symbol name to be given as an RHS value. If a RHS value is a symbol name, the LHS symbol will be defined as an alias for the RHS symbol. Internally, a LHS symbol is represented as a zero-size defined atom who has an LayoutAfter reference to an undefined atom, whose name is the RHS value. Everything else is already implemented -- Resolver will resolve the undefined symbol, and the layout pass will layout the two atoms at the same location. Looks like it's working fine. Note that GNU LD supports --defsym=<symbol>=<symbol>+<addend>. That feature is out of scope of this patch. Differential Revision: http://reviews.llvm.org/D3332 llvm-svn: 206417
* [Mips] Emit PLT entries for more static relocations.Simon Atanasyan2014-04-161-6/+18
| | | | llvm-svn: 206358
* Add missing includes.Benjamin Kramer2014-04-122-0/+2
| | | | llvm-svn: 206113
* [ELF] Regroup code creates ELF relocations references ELFReference intoSimon Atanasyan2014-04-123-118/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a couple of new virtual functions. Follow-up to the rL203408. Two virtual functions `createRelocationReference()` responsible for creation of `ELFReference` have been replaced by a couple of new virtual functions `createRelocationReferences()` (plural). Each former function creates a //single// ELFReference for a specified `Elf_Rela` or `Elf_Rel` relocation records. The new functions responsible for creation of //all// relocation references for provided symbol. For all targets except MIPS there are no functional changes. MIPS ABI has a notion of //paired// relocations. An effective addend of such relocations are calculated using addends of both pair's members. Each `R_MIPS_HI16` and `R_MIPS_GOT16` (for local symbols) relocations must have an associated `R_MIPS_LO16` entry immediately following it in the list of relocations. Immediately does not mean "next record" in relocations section but "next record referenced the same symbol". Moreover a single `R_MIPS_LO16` relocation can be paired with multiple preceding `R_MIPS_HI16/R_MIPS_GOT16` relocations. The paired relocation can have offsets belong to the different symbols. That is why we need to have access to list of all relocations during construction of `ELFReference` for MIPS target. The patch reviewed by Shankar Easwaran. llvm-svn: 206102
* [Mips] Factor out MIPS relocation addend reading to the separateSimon Atanasyan2014-04-111-8/+12
| | | | | | | | function. No functional changes. llvm-svn: 206023
* [ELF] Remove redundant conversion of section content from ArrayRef toSimon Atanasyan2014-04-111-8/+3
| | | | | | | | | StringRef before calling the createSectionAtom() method and reverse conversion inside the method. No functional changes. llvm-svn: 206022
* [Mips] R_MIPS_PC32 relocation support.Simon Atanasyan2014-04-114-0/+12
| | | | llvm-svn: 206018
* Update to match changes made in r205955David Majnemer2014-04-102-0/+7
| | | | llvm-svn: 205956
* [PECOFF] Fix common symbol alignment.Rui Ueyama2014-04-091-0/+8
| | | | | | Differential Revision: http://reviews.llvm.org/D3322 llvm-svn: 205826
* Early continue to reduce nesting.Rui Ueyama2014-04-071-13/+13
| | | | llvm-svn: 205737
* No else after return.Rui Ueyama2014-04-071-4/+3
| | | | llvm-svn: 205736
* [ELF] Accept "-rpath=<foo>" as well as "-rpath <foo>".Rui Ueyama2014-04-061-2/+2
| | | | llvm-svn: 205694
* [ELF] Fix driver bug.Rui Ueyama2014-04-061-3/+3
| | | | | | | | GNU LD-comptaible driver wrongly requires a space after '=' for a few options such as "-init=<symbol>" or "-entry=<symbol>". This patch is to fix that bug and add a few tests for it. llvm-svn: 205693
OpenPOWER on IntegriCloud