summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove dead code.Rui Ueyama2014-08-213-58/+0
| | | | llvm-svn: 216152
* [mach-o] Add support for -exported_symbols_list and -keep_private_externsNick Kledzik2014-08-212-33/+96
| | | | | | | | | | | | | | 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
* [PECOFF] Emit PE+ idata tables.Rui Ueyama2014-08-202-9/+20
| | | | | | | Import tables in the PE+ format is an array of 64 bit numbers, although the executable size is still limited to 4GB in PE+. llvm-svn: 216039
* Update for llvm api change.Rafael Espindola2014-08-192-13/+21
| | | | llvm-svn: 216003
* [mach-o] Support -filelist option in darwin driverNick Kledzik2014-08-151-2/+2
| | | | | | | | | | | | 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-141-5/+48
| | | | | | | | | | | 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-135-42/+202
| | | | | | | | | | | | | | | | | | | | 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
* [mach-o] Fix stub generation to work for dylibs and bundlesNick Kledzik2014-08-132-19/+34
| | | | | | | | | | Split up the CRuntimeFile into one part for output types that need an entry point and another part for output types that use stubs. Add file 'test/mach-o/Inputs/libSystem.yaml' for use by test cases that use -dylib and therefore may now need the helper symbol in libSystem.dylib. llvm-svn: 215602
* [mach-o] set ordinal in n_desc for undefined symbolsNick Kledzik2014-08-131-1/+6
| | | | | | | | | | | Mach-o uses "two-level namespace" where each undefined symbols is associated with a specific dylib. This means at runtime the loader (dyld) does need to search all loaded dylibs for that symbol but rather just the one specified. Now that llvm-nm -m prints out that info, properly set that info, and test it in the hello world test cases. llvm-svn: 215598
* AArch64: replace __func__ with LLVM_FUNCTION_NAMEHans Wennborg2014-08-132-123/+123
| | | | | | MSVC doesn't define __func__. llvm-svn: 215578
* Remove unused private fields from r215544 to appease buildbots.Chad Rosier2014-08-132-8/+2
| | | | llvm-svn: 215547
* [AArch64] Initial ELF/AArch64 SupportChad Rosier2014-08-1320-2/+1698
| | | | | | | | | | 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
* Fix mach-o tests on WindowsRui Ueyama2014-08-061-2/+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] Exported symbols are dead-strip roots.Rui Ueyama2014-08-061-2/+7
| | | | llvm-svn: 214948
* [PECOFF] addDeadStripRoot is not thread-safe.Rui Ueyama2014-08-051-8/+14
| | | | llvm-svn: 214835
* [PECOFF] Fix /include option in .drectve section.Rui Ueyama2014-08-041-3/+20
| | | | | | | | | | | | | | | | | | | | | | | /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
* [PECOFF] Remove unused paraemter.Rui Ueyama2014-08-041-3/+2
| | | | llvm-svn: 214791
* [PECOFF] Fix section header.Rui Ueyama2014-07-311-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The PE/COFF spec says that SizeOfRawData field in the section header must be a multiple of FileAlignment from the optional header. LLD emits 512 as FileAlignment, so it must have been a multiple of 512. LLD did not follow that. It emitted the actual section size without the last padding as the SizeOfRawData. Although it's not correct as per the spec, the Windows loader doesn't seem to actually bother to check that. Executables created by LLD worked fine. However, tools dealing with executalbe files may expect it to be the correct value, and one instance of it is mt.exe tool distributed as a part of Windows SDK. If CMake is invoked with "-E vs_link_exe" option, it silently run mt.exe to embed a resource file to the resulting file. And mt.exe sometimes breaks an input file if it's section header does not follow the standard. That caused a misterous error that CMake with Ninja occasionally produces a broken executable. This patch fixes the section header to make mt.exe and other tools happy. llvm-svn: 214453
* Update for llvm api change.Rafael Espindola2014-07-312-2/+2
| | | | llvm-svn: 214378
* [mach-o] Fix arm interworking with movw/movtNick Kledzik2014-07-301-0/+8
| | | | | | | | In some cases the address of a function will be materialized with a movw/movt pair. If the function is a thumb function, the low bit needs to be set on the movw immediate value. llvm-svn: 214277
* [mach-o] Add support for -sectalign optionNick Kledzik2014-07-303-45/+117
| | | | | | | | | | | | 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
* [mach-o] fix non-debug warningsNick Kledzik2014-07-281-4/+4
| | | | llvm-svn: 214145
* [mach-o] Implement interworking between thumb and arm codeNick Kledzik2014-07-282-45/+120
| | | | | | | | | | | All iOS arm processor support switching between arm and thumb mode at call sites by using the BLX instruction (instead of BL). But the compiler does not know the implementation mode for extern functions, so the linker must update BL/BLX instructions to match what is linked is actually linked together. In addition, pointers to functions (such as vtables) must have the low bit set if the target of the pointer is a thumb mode function. llvm-svn: 214140
* [mach-o] Add support for LC_DATA_IN_CODENick Kledzik2014-07-249-25/+293
| | | | | | | | | | | | | | Sometimes compilers emit data into code sections (e.g. constant pools or jump tables). These runs of data can throw off disassemblers. The solution in mach-o is that ranges of data-in-code are encoded into a table pointed to by the LC_DATA_IN_CODE load command. The way the data-in-code information is encoded into lld's Atom model is that that start and end of each data run is marked with a Reference whose offset is the start/end of the data run. For arm, the switch back to code also marks whether it is thumb or arm code. llvm-svn: 213901
* [PECOFF] Simplify.Rui Ueyama2014-07-231-4/+2
| | | | | | insertElementAt(x, END) is the same as addInputElement(x). llvm-svn: 213818
* [PECOFF] Add the entry point file at the right place.Rui Ueyama2014-07-231-4/+1
| | | | | | | | | 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 address.Rui Ueyama2014-07-232-4/+6
| | | | | | | Because of a bug, the entry point address in the PE/COFF header was not correct. llvm-svn: 213802
* [PECOFF] Fix entry point functions selectionRui Ueyama2014-07-233-60/+108
| | | | | | | | | | | | | | | | | | | | | 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
* [mach-o] add initial support for modes in arm code.Nick Kledzik2014-07-235-7/+97
| | | | | | | | | This patch just supports marking ranges that are thumb code (vs arm code). Future patches will mark data and jump table ranges. The ranges are encoded as References with offsetInAtom being the start of the range and the target being the same atom. llvm-svn: 213712
* [mach-o] add support for round tripping all arm/thumb relocationsNick Kledzik2014-07-222-61/+469
| | | | | | | Update the parse-arm-relocs.yaml test case to run the linker back to back to ensure all relocations round trip in and out of mach-o. llvm-svn: 213700
* [PECOFF] Parameterize ResovalbeSymbols object.Rui Ueyama2014-07-222-10/+10
| | | | | | So that it can be shared by multiple input files. llvm-svn: 213699
* [mach-o] Add test case for armv6 (arm not thumb) hello worldNick Kledzik2014-07-222-7/+11
| | | | llvm-svn: 213592
* [mach-o] add support for old x86 __eh_frame sectionsNick Kledzik2014-07-212-27/+47
| | | | | | | Over time the symbols and relocations have changed for dwarf unwind info in the __eh_frame section. Add test cases for older and new style. llvm-svn: 213585
* Fix lld build for llvm API changes committed in r213557David Blaikie2014-07-211-1/+1
| | | | llvm-svn: 213560
* [Mips] Fix typo in the comment.Simon Atanasyan2014-07-211-1/+1
| | | | llvm-svn: 213520
* swapStruct extracted into include/llvm/Support/MachO.h (no functional change)Artyom Skrobov2014-07-181-155/+0
| | | | llvm-svn: 213362
* [mach-o] Add support for x86 pointers which use scattered relocationsNick Kledzik2014-07-181-4/+20
| | | | llvm-svn: 213344
* [mach-o] Add support for x86 CALL instruction that uses a scattered relocationNick Kledzik2014-07-181-14/+47
| | | | llvm-svn: 213340
* [mach-o] implement more x86 and x86_64 relocation supportNick Kledzik2014-07-176-100/+614
| | | | | | | | | Add support for adding section relocations in -r mode. Enhance the test cases which validate the parsing of .o files to also round trip. They now write out the .o file and then parse that, verifying all relocations survived the round trip. llvm-svn: 213333
* References cannot be bound to null.Joerg Sonnenberger2014-07-171-2/+0
| | | | llvm-svn: 213323
* [PECOFF] Split ExportedSymbolRenameFile.Rui Ueyama2014-07-171-31/+44
| | | | | | | | | The code to manage resolvable symbols is now separated from ExportedSymbolRenameFile so that other class can reuse it. I'm planning to use it to find the entry function symbol based on resolvable symbols. llvm-svn: 213322
* Use std::function instead of llvm::function_ref.Rui Ueyama2014-07-171-15/+1
| | | | llvm-svn: 213312
* [Mips] s/context/ctx/ for consistency and reduce lines lengths.Simon Atanasyan2014-07-178-48/+42
| | | | | | No functional changes. llvm-svn: 213310
* [PECOFF] Set DLL bit in PE header if DLL.Rui Ueyama2014-07-171-0/+2
| | | | | | | Windows loader can load a DLL without this bit but it wouldn't call the initializer function in the DLL if the bit is absent. llvm-svn: 213216
* [mach-o] refactor KindHandler into ArchHandler and simplify passes.Nick Kledzik2014-07-1623-2376/+2269
| | | | | | | | | | | 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-152-6/+45
| | | | | | | | | | | | | | | | | | 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] Set resource table entry in header.Rui Ueyama2014-07-101-0/+3
| | | | | | | The resource table entry should have the RVA of the embedded resource file. llvm-svn: 212765
* [PECOFF] Invoke cvtres.exe in the driver.Rui Ueyama2014-07-101-109/+0
| | | | | | | | | | | | | | | | | 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 -syslibroot and -l optionsTim Northover2014-07-101-1/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Move GOTPass and StubsPass from Core to MachONick Kledzik2014-07-097-65/+280
| | | | llvm-svn: 212652
OpenPOWER on IntegriCloud