summaryrefslogtreecommitdiffstats
path: root/lld/lib/Driver
Commit message (Collapse)AuthorAgeFilesLines
...
* [mach-o] Let darwin driver infer arch from .o files if -arch not used.Nick Kledzik2014-09-041-0/+14
| | | | | | | | | | | | | | | | Mach-O has a "fat" (or "universal") variant where the same contents built for different architectures are concatenated into one file with a table-of-contents header at the start. But this leaves a dilemma for the linker - which architecture to use. Normally, the linker command line -arch is used to force which slice of any fat files are used. The clang compiler always passes -arch to the linker when invoking it. But some Makefiles invoke the linker directly and don’t specify the -arch option. For those cases, the linker scans all input files in command line order and finds the first non-fat object file. Whatever architecture it is becomes the architecture for the link. llvm-svn: 217189
* If lld binary is named 'ld' on darwin, use darwin driver modeNick Kledzik2014-09-041-1/+7
| | | | llvm-svn: 217112
* [PECOFF] Add /HighEntropyVA.Rui Ueyama2014-08-252-0/+2
| | | | | | | This is yet another command line flag to set a bit in DLLCharacteristics. Default on Win64 is "on". llvm-svn: 216414
* Use LLD naming style.Rui Ueyama2014-08-251-8/+8
| | | | llvm-svn: 216402
* Update for LLVM api changeRafael Espindola2014-08-251-9/+8
| | | | llvm-svn: 216395
* [PECOFF] Fix PE+ relocationsRui Ueyama2014-08-221-1/+1
| | | | | | | | | | | | | The implementation of AMD64 relocations was imcomplete and wrong. On AMD64, we of course have to use AMD64 relocations instead of i386 ones. This patch fixes the issue. LLD is now able to link hello64.obj (created from hello64.asm) against user32.lib and kernel32.lib to create a Win64 binary. llvm-svn: 216253
* [mach-o] Add support for -single_module and -multi_moduleNick Kledzik2014-08-212-0/+20
| | | | | | These are both obsolete options that controled how dylibs were built. llvm-svn: 216205
* [mach-o] Add support for -exported_symbols_list and -keep_private_externsNick Kledzik2014-08-212-3/+110
| | | | | | | | | | | | | | Both options control the final scope of atoms. When -exported_symbols_list <file> is used, the file is parsed into one symbol per line in the file. Only those symbols will be exported (global) in the final linked image. The -keep_private_externs option is only used with -r mode. Normally, -r mode reduces private extern (scopeLinkageUnit) symbols to non-external. But add the -keep_private_externs option keeps them private external. llvm-svn: 216146
* [mach-o] improve darwin driver 'usage' message when run with no argsNick Kledzik2014-08-152-56/+66
| | | | llvm-svn: 215781
* [mach-o] Support -filelist option in darwin driverNick Kledzik2014-08-152-34/+110
| | | | | | | | | | | | The darwin linker has an option, heavily used by Xcode, in which, instead of listing all input files on the command line, the input file paths are written to a text file and the path of that text file is passed to the linker with the -filelist option (similar to @file). In order to make test cases for this, I generalized the -test_libresolution option to become -test_file_usage. llvm-svn: 215762
* [mach-o] Support -F and -framework options in darwin driverNick Kledzik2014-08-142-1/+37
| | | | | | | | | | | Darwin has a packaging mechanism for shared libraries and headers called frameworks. A directory Foo.framework contains a shared library binary file "Foo" and a subdirectory "Headers". Most OS frameworks are all in one directory /System/Library/Frameworks/. As a linking convenience, the linker option "-framework Foo" means search the framework directories specified with -F (analogous to -L) looking for a shared library Foo.framework/Foo. llvm-svn: 215680
* [mach-o] Support re-exported dylibsNick Kledzik2014-08-132-7/+8
| | | | | | | | | | | | | | | | | | | | In general two-level namespace means each program records exactly which dylib each undefined (imported) symbol comes from. But, sometimes the implementor wants to hide the implementation dylib. For instance libSytem.dylib is the base dylib all Darwin programs must link with. A few years ago it was split up into two dozen dylibs by all are hidden behind libSystem.dylib which re-exports each sub-dylib. All clients still think libSystem.dylib is the implementor. To support this, the linker must load "indirect" dylibs and not just the "direct" dylibs specified on the command line. This is done in the createImplicitFiles() method after all command line specified files are loaded. Since an indirect dylib may have already been loaded as a direct dylib (or indirectly via a previous direct dylib), the MachOLinkingContext keeps a list of all loaded dylibs. With this change hello world can now be linked against the real OS or SDK. llvm-svn: 215605
* [AArch64] Initial ELF/AArch64 SupportChad Rosier2014-08-131-0/+4
| | | | | | | | | | This patch adds the initial ELF/AArch64 support to lld. Only a basic "Hello World" app has been successfully tested for both dynamic and static compiling. Differential Revision: http://reviews.llvm.org/D4778 Patch by Daniel Stewart <stewartd@codeaurora.org>! llvm-svn: 215544
* [PECOFF] Fix /profile option.Rui Ueyama2014-08-111-2/+2
| | | | | | | /profile implies /fixed:no -- so we had to *enable* base relocations rather than disabling it. llvm-svn: 215389
* Fix mach-o tests on WindowsRui Ueyama2014-08-061-1/+6
| | | | | | | | | | | The tests assume the path separator is '/', but if you run them on Windows it is '\'. As a result the tests are failing on Windows. This should be the minimal change to make these tests to pass on Windows platform. Differential Revision: http://reviews.llvm.org/D4710 llvm-svn: 214990
* [PECOFF] Fix /include option in .drectve section.Rui Ueyama2014-08-041-3/+10
| | | | | | | | | | | | | | | | | | | | | | | /INCLUDE arguments passed as command line options are handled in the same way as Unix -u. All option values are converted to an undefined symbol and added to a dummy input file, so that the specified symbols are resolved. One tricky thing on Windows is that the option is also allowed to appear in the object file's directive section. At the time when it's being read, all (regular) command line options have already been processed. We cannot add undefined atoms to the dummy file anymore. Previously, we added such /INCLUDE to a set that has already been processed. As a result the options were ignored. This patch fixes the issue. Now, /INCLUDE symbols in the directive section are handled as real undefined symbol in the COFF file. We create an undefined symbol for each /INCLUDE argument and add it to the file being parsed. llvm-svn: 214824
* [mach-o] wire up -t optionNick Kledzik2014-07-312-0/+6
| | | | llvm-svn: 214414
* [mach-o] Add support for -sectalign optionNick Kledzik2014-07-302-0/+28
| | | | | | | | | | | | The -sectalign option is used to increase the alignment required for a section. It required some reworking of how the __TEXT segment is laid out because that segment also contains the mach_header and load commands. And the size of load commands depend on the number of segments, sections, and dependent dylibs used. Using this option will simplify some future test cases because the final address of code can be pinned down, making tests of its content easier. llvm-svn: 214268
* [PECOFF] Add /profile command line option.Rui Ueyama2014-07-252-0/+8
| | | | llvm-svn: 213984
* Change the signature of insertElementAt and rename addInputElementFrontRui Ueyama2014-07-241-2/+1
| | | | | | | | | | insertElementAt(x, END) does the identical thing as addInputElement(x), so the only reasonable use of insertElementAt is to call it with the other possible argument, BEGIN. That means the second parameter of the function is just redundant. This patch is to remove the second parameter and rename the function accordingly. llvm-svn: 213821
* [PECOFF] Add the entry point file at the right place.Rui Ueyama2014-07-231-1/+7
| | | | | | | | | The entry point file needs to be processed after all other object files and before all .lib files. It was processed after .lib files. That caused an issue that the entry point function was not resolved from the standard library files. llvm-svn: 213804
* [PECOFF] Fix entry point functions selectionRui Ueyama2014-07-231-23/+0
| | | | | | | | | | | | | | | | | | | | | On Windows there are four "main" functions -- main, wmain, WinMain, or wWinMain. Their parameter types are diffferent. The standard library provides four different entry functions (i.e. {w,}{WinMain,main}CRTStartup) for them. You need to use the right entry routine for your "main" function. If you give an /entry option, the specified name is used unconditionally. Otherwise, the linker needs to select the right one based on user-supplied entry point function. This can be done after the linker reads all the input files. This patch moves the code to determine the entry point function from the driver to a virtual input file. It also implements the correct logic for the entry point function selection. llvm-svn: 213713
* [PECOFF] Remember /noentry option so that later passes can handle it.Rui Ueyama2014-07-221-1/+5
| | | | | | | | | | This is a part of a larger change to move the entry point processing to a later pass than the driver. On Windows the default entry point function varies depending on user-provided functions. That means the driver is not able to correctly know the entry point function name. Only passes after the core linker can infer it. llvm-svn: 213697
* [mach-o] refactor KindHandler into ArchHandler and simplify passes.Nick Kledzik2014-07-161-1/+1
| | | | | | | | | | | All architecture specific handling is now done in the appropriate ArchHandler subclass. The StubsPass and GOTPass have been simplified. All architecture specific variations in stubs are now encoded in a table which is vended by the current ArchHandler. llvm-svn: 213187
* [ELF] Implement parsing `-l` prefixed items in the `GROUP` linker script ↵Simon Atanasyan2014-07-151-0/+1
| | | | | | | | | | | | | | | | | | command. There are two forms of `-l` prefixed expression: * -l<libname> * -l:<filename> In the first case a linker should construct a full library name `lib + libname + .[so|a]` and search this library as usual. In the second case a linker should use the `<filename>` as is and search this file through library search directories. The patch reviewed by Shankar Easwaran. llvm-svn: 213077
* [PECOFF] s/context/ctx/ for consistency.Rui Ueyama2014-07-101-16/+16
| | | | llvm-svn: 212766
* [PECOFF] Invoke cvtres.exe in the driver.Rui Ueyama2014-07-101-38/+99
| | | | | | | | | | | | | | | | | Previously we invoked cvtres.exe for each compiled Windows resource file. The generated files were then concatenated and embedded to the executable. That was not the correct way to merge compiled Windows resource files. If you just concatenate generated files, only the first file would be recognized and the rest would be ignored as trailing garbage. The right way to merge them is to call cvtres.exe with multiple input files. In this patch we do that in the Windows driver. llvm-svn: 212763
* [mach-o]: support -Z option to skip standard library pathsTim Northover2014-07-102-2/+7
| | | | llvm-svn: 212713
* [mach-o]: support user-specified (-L) library search pathsTim Northover2014-07-102-3/+7
| | | | llvm-svn: 212712
* [mach-o]: support -syslibroot and -l optionsTim Northover2014-07-102-3/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | These behave slightly idiosyncratically in the best of cases, and have additional hacks layered on top of that for compatibility with badly behaved build systems (via ld64). For -lXYZ: + If XYZ is actually XY.o then search all library paths for XY.o + Otherwise search all library paths, first for libXYZ.dylib, then libXYZ.a + By default the library paths are /usr/lib and /usr/local/lib in that order. For -syslibroot: + -syslibroot options apply to absolute paths in the search order. + All -syslibroot prefixes that exist are added to the search path *instead* of the original. + If no -syslibroot prefixed path exists, the original is kept. + Hacks^WExceptions: + If only 1 -syslibroot is given and doesn't contain /usr/lib or /usr/local/lib, that path is dropped entirely. (rdar://problem/6438270). + If the last -syslibroot is "/", all of them are ignored entirely. (rdar://problem/5829579). At least, that's my best interpretation of what ld64 does in buildSearchPaths. llvm-svn: 212706
* [all]: Use range-based ArgList adapter instead of filtered_begin/filtered_endTim Northover2014-07-093-31/+17
| | | | | | Some of those loops were pretty monstrous. llvm-svn: 212616
* Update for llvm api change.Rafael Espindola2014-07-061-7/+7
| | | | llvm-svn: 212407
* [mach-o]: make the default dylib install-name the output filename.Tim Northover2014-07-011-0/+4
| | | | llvm-svn: 212094
* [Driver] Improve the `isPathUnderSysroot()` function. Now it returns aSimon Atanasyan2014-06-261-7/+5
| | | | | | | correct result even if checking paths: a) symlinks and/or b) contains relative parts like /dir1/dir2/../dir2. llvm-svn: 211772
* MachO: rename _outputFileType to avoid shadowing parent field.Tim Northover2014-06-201-2/+2
| | | | llvm-svn: 211367
* Update for llvm api change.Rafael Espindola2014-06-131-1/+2
| | | | llvm-svn: 210919
* Don't import error_code into the lld namespace.Rafael Espindola2014-06-124-28/+28
| | | | llvm-svn: 210785
* Use std::error_code instead of llvm::error_code.Rafael Espindola2014-06-111-1/+1
| | | | | | This is an update for a llvm api change. llvm-svn: 210689
* [ELF] Fix the bug -- LLD crashes if the --whole-archive optionSimon Atanasyan2014-06-101-1/+1
| | | | | | is around non-archive. llvm-svn: 210530
* Initial set of MakefilesIain Sandoe2014-06-041-0/+38
| | | | | | | | This provides support for the autoconfing & make build style. The format, style and implementation follows that used within the llvm and clang projects. TODO: implement out-of-source documentation builds. llvm-svn: 210177
* Use error_code() instead of error_code::succes()Rafael Espindola2014-05-313-5/+5
| | | | | | | There is no std::error_code::success, so this removes much of the noise in transitioning to std::error_code. llvm-svn: 209948
* Add -print_atoms options to DarwinLdDriver which dumps final state of all ↵Nick Kledzik2014-05-142-0/+7
| | | | | | atoms in yaml llvm-svn: 208813
* Revert "temporary commit."Rui Ueyama2014-05-091-16/+0
| | | | | | This reverts accidental commit r208427. llvm-svn: 208433
* [PECOFF] DLL extension can be omitted in .def file.Rui Ueyama2014-05-091-0/+2
| | | | llvm-svn: 208428
* temporary commit.Rui Ueyama2014-05-091-0/+16
| | | | llvm-svn: 208427
* Call normalize() in the common driver.Rui Ueyama2014-05-072-5/+1
| | | | | | | | | | | Previously only GNU driver calls InputGraph::normalize, but its functionality is not and should not be limited to GNU ld. Other driver should be able to use it. Currently only linker scripts use the feature, so this change won't change the existing behavior. llvm-svn: 208266
* Trivial simplificationRui Ueyama2014-05-071-5/+1
| | | | llvm-svn: 208145
* [PECOFF] Support =internalName syntax in .def file.Rui Ueyama2014-05-021-0/+11
| | | | | | | | | | | Export definitions in a module definition file is as follows: exportedname[=internalname] [@ordinal [NONAME]] [PRIVATE] [DATA] Previously we did not support =internalname, so users couldn't export symbols from a DLL with a different name. llvm-svn: 207827
* Sort.Joerg Sonnenberger2014-05-011-1/+1
| | | | llvm-svn: 207798
* [ELF] Fix the file look up algorithm used in the linker script GROUP command.Simon Atanasyan2014-05-012-3/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud