summaryrefslogtreecommitdiffstats
path: root/lld/lib
Commit message (Collapse)AuthorAgeFilesLines
* [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
* [mach-o] wire up -t optionNick Kledzik2014-07-312-0/+6
| | | | llvm-svn: 214414
* 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-305-45/+145
| | | | | | | | | | | | 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
* [PECOFF] Add /profile command line option.Rui Ueyama2014-07-252-0/+8
| | | | llvm-svn: 213984
* Fix unsafe memory accessRui Ueyama2014-07-251-2/+11
| | | | | | | | | | | | | | The following expression m[i] = m[j] where m is a DenseMap and i != j is not safe. m[j] returns a reference, which would be invalidated when a rehashing occurs. If rehashing occurs to make room for m[i], m[j] becomes invalid, and that invalid reference would be used as the RHS value of the expression. llvm-svn: 213969
* [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
* Change the signature of insertElementAt and rename addInputElementFrontRui Ueyama2014-07-242-13/+5
| | | | | | | | | | 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] 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-232-5/+8
| | | | | | | | | 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-234-83/+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
* [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] 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
* Remove all uses of llvm::function_ref from LLD.Rui Ueyama2014-07-171-1/+1
| | | | llvm-svn: 213313
* Use std::function instead of llvm::function_ref.Rui Ueyama2014-07-172-16/+2
| | | | 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-1624-2377/+2270
| | | | | | | | | | | 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-153-6/+46
| | | | | | | | | | | | | | | | | | 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] 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-102-147/+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-103-4/+164
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-098-71/+111
| | | | llvm-svn: 212652
* [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
* [PECOFF] Fix .bss section alignmentRui Ueyama2014-07-081-4/+5
| | | | | | | | | | Previously the alignment of the .bss section was not properly set because of a bug in AtomizeDefinedSymbolsInSection. We set the alignment of the section at the end of the function, but we use an eraly return for the .bss section, so the code had been skipped. llvm-svn: 212571
* Update for llvm api change.Rafael Espindola2014-07-065-19/+23
| | | | llvm-svn: 212407
* Update for llm api change.Rafael Espindola2014-07-057-14/+18
| | | | llvm-svn: 212372
* [mach-o] Add parsing of arm/thumb relocationsNick Kledzik2014-07-045-95/+528
| | | | | | | | | | This converts the very complicated mach-o arm relocations into the simple Reference Kinds in lld. The next patch will use the internal Reference kinds to fix up arm/thumb code. llvm-svn: 212306
* [mach-o] add x86 test case to build hello world. Fix bugs it uncovered.Nick Kledzik2014-07-034-35/+43
| | | | llvm-svn: 212247
* [mach-o] Fix warning on enumeration cases not handledNick Kledzik2014-07-031-0/+10
| | | | llvm-svn: 212241
* [mach-o] add parsing of x86 relocationsNick Kledzik2014-07-024-30/+259
| | | | llvm-svn: 212239
OpenPOWER on IntegriCloud