summaryrefslogtreecommitdiffstats
path: root/lld/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* [mach-o] Add support for -order_file optionNick Kledzik2014-11-074-9/+177
| | | | | | | | | | | The darwin linker lets you rearrange functions and data for better locality (less paging). You do this with the -order_file option which supplies a text file containing one symbol per line. Implementing this required a small change to LayoutPass to add a custom sorter hook. llvm-svn: 221545
* Fix FileArchive member MemoryBuffer early destructionNick Kledzik2014-11-071-6/+16
| | | | | | | | | | | | | | | When FileArchive loads a member, it instantiates a temporary MemoryBuffer which points to the member range of the archive file. The problem is that the object file parsers call getBufferIndentifer() on that temporary MemoryBuffer and store that StringRef as the _path data member for that lld::File. When FileArchive::instantiateMember() goes out of scope the MemoryBuffer is deleted and the File::._path becomes a dangling reference. The fix adds a vector<> to FileArchive to own the instantiated MemoryBuffers. In addition it fixes member's path to be the standard format (e.g. "/path/libfoo.a(foo.o)") instead of just the leaf name. llvm-svn: 221544
* [Mips] Do not hard-code the paired relocation typeSimon Atanasyan2014-11-071-11/+15
| | | | | | | | Request `getPairRelocation()` function to get paired relocation type. That allows us to look up another pairs like R_MICROMIPS_HI16/LO16 in the future. llvm-svn: 221539
* [ELF] Remove is64bits() and isLittlEndian().Shankar Easwaran2014-11-0711-45/+18
| | | | | | | | | | ELFLinkingContext had these two functions, which is really not needed since the Writer uses a llvm::object template composed of Endianness, Alignment, Is32bit/64bit. We could just use that and not duplicate functionality. No Change In Functionality. llvm-svn: 221523
* [PECOFF] Improve subsystem inferenceRui Ueyama2014-11-063-15/+72
| | | | | | | | | | | | | | | | | | | | | | | | | If /subsystem option is not given, the linker needs to infer the subsystem based on the entry point symbol. If it fails to infer that, the linker should error out on it. LLD was almost correct, but it would fail to infer the subsystem if the entry point is specified with /entry. This is because the subsystem inference was coupled with the entry point function searching (if no entry point name is specified, the linker needs to find the right entry name). This patch makes the subsystem inference an independent pass to fix the issue. Now, as long as an entry point function is defined, LLD can infer the subsystem no matter how it resolved the entry point. I don't think scanning all the defined symbols is fast, although it shouldn't be that slow. The file class there does not provide any easy way to find an atom by name, so this is what we can do at this moment. I'd like to revisit this later to make it more efficient. llvm-svn: 221499
* remove unneeded { }Nick Kledzik2014-11-061-2/+1
| | | | llvm-svn: 221478
* [mach-o] Add support for -force_load optionNick Kledzik2014-11-062-0/+7
| | | | | | | | The darwin linker has two ways to force all members of an archive to be loaded. The -all_load option applies to all static libraries. The -force_load takes a path to a library and just that library's members are force loaded. llvm-svn: 221477
* [Mips] Take into account that PIC code is inherently CPICSimon Atanasyan2014-11-061-2/+7
| | | | | | Follow-up to r221439. llvm-svn: 221442
* [Mips] Follow-up to r221439. Include header to fix build on Windows.Simon Atanasyan2014-11-061-0/+1
| | | | llvm-svn: 221440
* [Mips] Check ELF flags to prevent linking of incompatible filesSimon Atanasyan2014-11-069-29/+191
| | | | | | | | | | | | | | | | | 1. The path checks ELF header flags to prevent linking of incompatible files. For example we do not allow to link files with different ABI, -mnan flags, some combination of target CPU etc. 2. The patch merge ELF header flags from input object files to put their combination to the generated file. For example, if some input files have EF_MIPS_NOREORDER flag we need to put this flag to the output file header. I use the `parseFile()` (not `canParse()`) method because in case of recognition of incorrect input flags combination we should show detailed error message and stop the linking process and should not try to use another `Reader`. llvm-svn: 221439
* [ELF] Remove llvm::Twine usageShankar Easwaran2014-11-061-2/+2
| | | | llvm-svn: 221433
* [mach-o] Add support for -S optionNick Kledzik2014-11-063-1/+9
| | | | | | | | | | | | The darwin linker does not process dwarf debug info. Instead it produces a "debug map" in the output file which points back to the original .o files for anything that wants debug info (e.g. debugger). The -S option means "don't add a debug map". lld for mach-o currently does not generate the debug map, so there is nothing to do when this option is used. But we need to process the option to get existing projects building. llvm-svn: 221432
* [ELF] Remove includes that are not usedShankar Easwaran2014-11-061-2/+0
| | | | llvm-svn: 221430
* [ELF] Use llvm::TwineShankar Easwaran2014-11-061-6/+2
| | | | llvm-svn: 221428
* [ELF] Implement isLittleEndian for all architecturesShankar Easwaran2014-11-065-5/+16
| | | | llvm-svn: 221427
* [ELF] Use std::find_if insteadShankar Easwaran2014-11-062-20/+15
| | | | llvm-svn: 221426
* [mach-o] remove extra leading underscore on __bss and __gotNick Kledzik2014-11-062-4/+4
| | | | llvm-svn: 221425
* [PECOFF] Add a comment for SECREL relocation.Rui Ueyama2014-11-061-0/+2
| | | | llvm-svn: 221423
* [mach-o] Add support for interposing tuples sectionNick Kledzik2014-11-064-0/+6
| | | | | | | | | | Darwin uses two-level-namespace lookup for symbols which means the static linker records where each symbol must be found at runtime. Thus defining a symbol in a dylib loaded earlier will not effect where symbols needed by later dylibs will be found. Instead overriding is done through a section of type S_INTERPOSING which contains tuples of <interposer, interposee>. llvm-svn: 221421
* [PECOFF] Fix SECREL relocations.Rui Ueyama2014-11-061-1/+1
| | | | | | | | | | SECREL relocation's value is the offset to the beginning of the section. Because of the off-by-one error, if a SECREL relocation target is at the beginning of a section, it got wrong value. Added a test that would have caught this. llvm-svn: 221420
* Fix shadowed variable warningNick Kledzik2014-11-051-4/+4
| | | | llvm-svn: 221414
* MachO: Remove an unused variable from processSectionDavid Majnemer2014-11-051-2/+0
| | | | | | | | | The local variable `cfi` became dead in r220730 when it's use was obviated; it was replaced with a call to read32. No functionality change intended. llvm-svn: 221412
* [ELF] Use getVisibility() function to access st_other fieldSimon Atanasyan2014-11-051-4/+4
| | | | | | | The st_other field can contains not only visibility flag so we should retrieve a visibility flag using a bit-mask. llvm-svn: 221397
* PECOFF: Set the AddressOfRelocationTable in the DOS headerDavid Majnemer2014-11-051-0/+1
| | | | | | | | | Many programs, for reasons unknown, really like to look at the AddressOfRelocationTable to determine whether or not they are looking at a bona fide PE file. Without this, programs like the UNIX `file' utility will insist that they are looking at a MS DOS executable. llvm-svn: 221335
* [PECOFF] Do not skip COMDAT section symbols.Rui Ueyama2014-11-051-11/+0
| | | | | | | | | LLD skipped COMDAT section symbols when reading them because I thought we don't want to have symbols with the same name. But they are actually needed because relocations may refer to the section symbols. So we shoulnd't skip them. llvm-svn: 221329
* [PECOFF] Fix symbols in module-definition file.Rui Ueyama2014-11-041-1/+9
| | | | llvm-svn: 221303
* [mach-o] remove __compact_unwind atoms once __unwind_info has been generatedTim Northover2014-11-043-7/+12
| | | | | | | | | | The job of the CompactUnwind pass is to turn __compact_unwind data (and __eh_frame) into the compressed final form in __unwind_info. After it's done, the original atoms are no longer relevant and should be deleted (they cause problems during actual execution, quite apart from the fact that they're not needed). llvm-svn: 221301
* Use llvm::sys::findProgramByName. NFC.Rafael Espindola2014-11-042-25/+31
| | | | llvm-svn: 221257
* [ELF] Update TODOShankar Easwaran2014-11-041-2/+6
| | | | llvm-svn: 221235
* [ELF] Fix MSVC buildbot.Shankar Easwaran2014-11-041-3/+3
| | | | | | | | For some reason, MSVC doesnot like the style. Checking to make sure this fixes the problem with the build. llvm-svn: 221234
* [ELF] Fix program headers.Shankar Easwaran2014-11-047-210/+189
| | | | | | | | | The ELF writer creates a invalid binary for few cases with large filesize and memory size for segments. This patch addresses the functionality and updates the test. This patch also cleans up parts of the ELF writer for future enhancements to support Linker scripts. llvm-svn: 221233
* PECOFF: Use the string table for long section names in EXEs/DLLsDavid Majnemer2014-11-041-13/+69
| | | | | | | | | | | | | Normally, PE files have section names of eight characters or less. However, this is problematic for DWARF because DWARF section names are things like .debug_aranges. Instead of truncating the section name, redirect the section name into the string table. Differential Revision: http://reviews.llvm.org/D6104 llvm-svn: 221212
* Fix leak found by asan.Rafael Espindola2014-11-031-4/+4
| | | | llvm-svn: 221180
* Fix a leak found by asan.Rafael Espindola2014-11-031-12/+15
| | | | llvm-svn: 221179
* Fix warnings about missing override.Rafael Espindola2014-11-037-14/+10
| | | | llvm-svn: 221165
* [LinkerScript] Change ErrorOr usage to fix MSVC2012 buildbotsRafael Auler2014-11-031-4/+4
| | | | | | | Number parsing functions used an ErrorOr<> idiom that is not supported in MSVC2012. This patch fixes this. llvm-svn: 221128
* [lld] Teach LLD how to parse most linker scriptsRafael Auler2014-11-031-66/+1597
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch does *not* implement any semantic actions, but it is a first step to teach LLD how to read complete linker scripts. The additional linker scripts statements whose parsing is now supported are: * SEARCH_DIR directive * SECTIONS directive * Symbol definitions inside SECTIONS including PROVIDE and PROVIDE_HIDDEN * C-like expressions used in many places in linker scripts * Input to output sections mapping The goal of this commit was guided towards completely parsing a default GNU ld linker script and the linker script used to link the FreeBSD kernel. Thus, it also adds a test case based on the default linker script used in GNU ld for x86_64 ELF targets. I tested SPEC userland programs linked by GNU ld, using the linker script dump'ed by this parser, and everything went fine. I then tested linking the FreeBSD kernel with a dump'ed linker script, installed the new kernel and booted it, everything went fine. Directives that still need to be implemented: * MEMORY * PHDRS Reviewers: silvas, shankarke and ruiu http://reviews.llvm.org/D5852 llvm-svn: 221126
* [mach-o] explicitly cast little_n uses to ints to silence MSVCTim Northover2014-10-314-18/+24
| | | | | | Hopefully this'll fix the build failure in the bot. llvm-svn: 221007
* [mach-o] use the addend in GOT-based relocations.Tim Northover2014-10-301-1/+1
| | | | | | | These are used to reference typeinfo data in the exception table section, for example. llvm-svn: 220916
* [mach-o] generate LC_DATA_IN_CODE in final linked imagesNick Kledzik2014-10-281-0/+18
| | | | | | | | | lld was regenerating LC_DATA_IN_CODE in .o output files, but not into final linked images. Update test case to verify data-in-code info makes it into final linked images. llvm-svn: 220827
* [mach-o] Turn -single_module error into a warningNick Kledzik2014-10-281-2/+2
| | | | | | To be more compatible with existing darwin linker. llvm-svn: 220822
* TMP: fix readN & writeN to not encourage UBTim Northover2014-10-2710-345/+375
| | | | llvm-svn: 220730
* Fix unicode chars into ascii in comment lines.NAKAMURA Takumi2014-10-271-1/+1
| | | | llvm-svn: 220668
* Remove #ifdef __FreeBSDRui Ueyama2014-10-272-8/+4
| | | | | | | r220665 makes configure or CMake to set HAVE_CXXABI_H on FreeBSD 10.0. We don't need this ugly ifdef condition anymore. llvm-svn: 220666
* [mach-o] Support old style objc class names in export listsNick Kledzik2014-10-241-0/+20
| | | | | | | | | Objective-C switched to a new ABI which uses a different mangling for class names. But to keep projects building that use export lists that use the old class name mangling, the linker recognizes the old names and transforms them to the new mangling. llvm-svn: 220598
* [mach-o] Support data-only dylibsNick Kledzik2014-10-243-2/+19
| | | | | | | | In final linked shared images, the __TEXT segment contains both code and the mach-o header/load-commands. In the case of a data-only dylib, there is no code, so we need to force the addition of the __TEXT segment. llvm-svn: 220597
* [PECOFF] Do not write duplicate directives to .def file.Rui Ueyama2014-10-221-3/+22
| | | | | | | | | | | This is a follow-up patch for r220333. r220333 renames exported symbols. That raised another issue; if we have both decorated and undecorated names for the same symbol, we'll end up have two duplicate exported symbol entries. This is a fix for that issue by removing duplciate entries. llvm-svn: 220350
* [mach-o] Support missing MH_SUBSECTIONS_VIA_SYMBOLSNick Kledzik2014-10-216-21/+47
| | | | | | | | | | | | | All compiler generated mach-o object files are marked with MH_SUBSECTIONS_VIA_SYMBOLS. But hand written assembly files need to opt-in if they are written correctly. The flag means the linker can break up a sections at symbol addresses and dead strip or re-order functions. This change recognizes object files without the flag and marks its atoms as not dead strippable and adds a layout-after chain of references so that the atoms cannot be re-ordered. llvm-svn: 220348
* [PECOFF] Fix exported symbol in the import libraryRui Ueyama2014-10-214-4/+4
| | | | | | | | | | | | | | | | | | | | | | There are two ways to specify a symbol to be exported in the module definition file. 1) EXPORT <external name> = <symbol> 2) EXPORT <symbol> In (1), you give both external name and internal name. In that case, the linker tries to find a symbol using the internal name, and write that address to the export table with the external name. Thus, from the outer world, the symbol seems to be exported as the external name. In (2), internal name is basically the same as the external name with an exception: if you give an undecorated symbol to the EXPORT directive, and if the linker finds a decorated symbol, the external name for the symbol will become the decorated symbol. LLD didn't implement that exception correctly. This patch fixes that. llvm-svn: 220333
* Subclass InputGraph to get darwin linker library semanticsNick Kledzik2014-10-213-3/+48
| | | | | | | | | | | | | | | | | | | The darwin linker operates differently than the gnu linker with respect to libraries. The darwin linker first links in all object files from the command line, then to resolve any remaining undefines, it repeatedly iterates over libraries on the command line until either all undefines are resolved or no undefines were resolved in the last pass. When Shankar made the InputGraph model, the plan for darwin was for the darwin driver to place all libraries in a group at the end of the InputGraph. Thus making the darwin model a subset of the gnu model. But it turns out that does not work because the driver cannot tell if a file is an object or library until it has been loaded, which happens later. This solution is to subclass InputGraph for darwin and just iterate the graph the way darwin linker needs. llvm-svn: 220330
OpenPOWER on IntegriCloud