summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] Sectionkey should also contain path.Shankar Easwaran2014-11-191-14/+18
| | | | | | No change in functionality. llvm-svn: 222309
* [mach-o] propagate dylib version numbersNick Kledzik2014-11-198-20/+84
| | | | | | | | | | | | | | Mach-o does not use a simple SO_NEEDED to track dependent dylibs. Instead, the linker copies four things from each dylib to each client: the runtime path (aka "install name"), the build time, current version (dylib build number), and compatibility version The build time is no longer used (it cause every rebuild of a dylib to be different). The compatibility version is usually just 1.0 and never changes, or the dylib becomes incompatible. This patch copies that information into the NormalizedMachO format and propagates it to clients. llvm-svn: 222300
* Fix MSVC warning.Rui Ueyama2014-11-191-6/+9
| | | | | | | | | This patch fixes the following MSVC warning. warning C4334: '<<' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) llvm-svn: 222293
* [mach-o] for 32-bit arm, in -r mode support B (not BL) to undefined symbolNick Kledzik2014-11-181-1/+3
| | | | | | | | | | | | | When fixing up BL instructions, the linker has to compare the thumbness of the target to decide if the instruction needs to be converted to BLX. But with B instruction there is no BX, so the linker asserts if the target is not the same thumbness. This assert was firing in -r mode when the target was undefined which it interpreted as being non-thumb. Test case change is to add a B (in both thumb and arm code) to an undefined symbol and round trip through -r mode. llvm-svn: 222266
* [mach-o] zero-fill sections have no file offsetNick Kledzik2014-11-182-11/+22
| | | | | | | In mach-o, sections of type S_ZEROFILL are special cased and to always have their section.offset field be zero. llvm-svn: 222202
* [mach-o] extract atom alignment information from mach-o filesNick Kledzik2014-11-183-11/+21
| | | | llvm-svn: 222201
* [mach-o] enhance arm64 reloc parser to support local pointer relocationsNick Kledzik2014-11-181-1/+5
| | | | | | | | | | | The arm64 assembler almost always uses r_extern=1 relocations in which the r_symbolnum field is the index of the symbol the relocation references. But sometimes it will set r_extern=0 in which case the linker needs to read the content of the reloction to determine the target. Add test case that the r_extern=0 relocation round trips. llvm-svn: 222200
* [mach-o] fix typos. No function changeNick Kledzik2014-11-181-5/+1
| | | | llvm-svn: 222199
* [mach-o] enhance arm64 reloc parser to support local pointer relocationsNick Kledzik2014-11-181-5/+19
| | | | | | | | | | | The arm64 assembler almost always uses r_extern=1 relocations in which the r_symbolnum field is the index of the symbol the relocation references. But sometimes it will set r_extern=0 in which case the linker needs to read the content of the reloction to determine the target. Add test case that the r_extern=0 relocation round trips. llvm-svn: 222198
* [mach-o] fix typos. No function changeNick Kledzik2014-11-181-4/+3
| | | | llvm-svn: 222197
* [PECOFF] Fix 32-bit delay-import table.Rui Ueyama2014-11-171-1/+1
| | | | llvm-svn: 222116
* [PECOFF] Fix section alignment.Rui Ueyama2014-11-141-12/+31
| | | | | | | | | | | | | | | | | If you have something like __declspec(align(8192)) int foo = 1; in your code, the compiler makes the data to be aligned to 8192-byte boundary, and the linker align the section containing the data to 8192. LLD always aligned the section to 4192. So, as long as alignment requirement is smaller than 4192, it was correct, but for larger requirements, it's wrong. This patch fixes the issue. llvm-svn: 222043
* [PECOFF] Remove dead codeRui Ueyama2014-11-141-4/+0
| | | | | | | | | AddressOfEntryPoint is overridden after we layout all atoms (until then, we don't know the entry point address for obvious reason.) I believe this code is leftover from very early version of the PE/COFF port that we only had an entry function in a test object file. llvm-svn: 222026
* Silence inconsistent override warnings.Eric Christopher2014-11-141-3/+3
| | | | llvm-svn: 222021
* Follow-up to r221913. Fix some -Wcast-qual warning reasons.Simon Atanasyan2014-11-1412-73/+81
| | | | llvm-svn: 221974
* [ELF] Dynamic section was not aligned properly.Shankar Easwaran2014-11-141-4/+14
| | | | | | | The dynamic section was not aligned properly. The alignment of the section is determined by the word size of the architecture. llvm-svn: 221972
* [ELF] Fix the fileoffset according to the ELF spec.Shankar Easwaran2014-11-131-1/+2
| | | | | | | | | With --no-align-segments, there is a bug that the fileoffset may not be congruent to virtual address modulo page alignment. This patch fixes the problem. llvm-svn: 221890
* [ELF] Add CodeModel attribute to the DefinedAtom classSimon Atanasyan2014-11-139-8/+118
| | | | | | | | | | | | | | | | | | | | | | MIPS ELF symbols might contain some additional MIPS-specific flags in the st_other field besides visibility ones. These flags indicate code properties like microMIPS / MIPS16 encoding, position independent code etc. We need to transfer the flags from input objects to the output linked file to write them into the symbol table, adjust symbols addresses etc. I add new attribute CodeModel to the DefinedAtom class to hold target specific flag and to get over YAML/Native format conversion barrier. Other architectures/targets can extend CodeModel enumeration by their own flags. MIPS specific part of this patch adds support for STO_MIPS_MICROMIPS flag. This flag marks microMIPS symbols. Such symbol should: a) Has STO_MIPS_MICROMIPS in the corresponding .symtab record. b) Has adjusted (odd) address in the corresponding .symtab and .dynsym records. llvm-svn: 221864
* [ELF] Fix segment alignment.Shankar Easwaran2014-11-131-4/+11
| | | | | | | | | The segment alignment for PT_LOAD segments is set to page size by default, but if any of the sections require an alignment more than the page size, the segment alignment property is set to the maximum alignment of the sections that are part of the segment. llvm-svn: 221862
* [ELF] Fix max-page-size option.Shankar Easwaran2014-11-131-2/+1
| | | | | | | | | | The user can use the max-page-size option and set the maximum page size. Dont check for maximum allowed values for page size, as its what the kernel is configured with. Fix the test as well. llvm-svn: 221858
* [PECOFF] Fix delay-import address table contents.Rui Ueyama2014-11-132-3/+9
| | | | | | | | | | | Each entry in the delay-import address table had a wrong alignment requirement if 32 bit. As a result it got wrong delay-import table. Because llvm-readobj doesn't print out that field, we don't have a test for that. I'll submit a test that would catch this bug after improving llvm-readobj. llvm-svn: 221853
* [mach-o] Sort GOT entries by name to make links reproducibleNick Kledzik2014-11-121-5/+18
| | | | | | | | | | | | | The GOT slots were being laid out in a random order by the GOTPass which caused randomness in the output file. Note: With this change lld now bootstraps on darwin. That is: 1) link lld using system linker to make lld.1 2) link lld using lld.1 to make lld.2 3) link lld using lld.2 to make lld.3 Now lld.2 and lld.3 are identical. llvm-svn: 221831
* [mach-o] Support linker synthesized mach_header symbols.Nick Kledzik2014-11-124-1/+87
| | | | | | | | | | | | | | | | | | | | | | | On darwin in final linked images, the __TEXT segment covers that start of the file. That means in memory a process can see the mach_header (and load commands) for every loaded image in a process. There are APIs that take and return the mach_header addresses as a way to specify a particular loaded image. For completeness, any code can get the address of the mach_header of the image it is in by using &__dso_handle. In addition there are mach-o type specific symbols like __mh_execute_header. The linker needs to supply a definition for any of these symbols if used. But the address the symbol it resolves to is not in any section. Instead it is the address of the start of the __TEXT segment. I needed to make a small change to SimpleFileNode to not override resetNextIndex() because the Driver creates a SimpleFileNode to hold the internal/implicit files that the context/writer can create. For some reason SimpleFileNode overrode resetNextIndex() to do nothing instead of reseting the index (which mach-o needs if the internal file is an archive). llvm-svn: 221822
* [mach-o] Fix lazy binding offsetsNick Kledzik2014-11-117-123/+114
| | | | | | | | | | The way lazy binding works in mach-o is that the linker generates a helper function and has the stub (PLT) initially jump to it. The helper function pushes an extra parameter then jumps into dyld. The extra parameter is an offset into the lazy binding info where dyld will find the information about which symbol to bind and way lazy binding pointer to update. llvm-svn: 221654
* [ELF] Change order of section match.Shankar Easwaran2014-11-111-1/+1
| | | | | | Addressed comments from Sean silva. llvm-svn: 221650
* Revert "Add support library."Shankar Easwaran2014-11-112-3/+107
| | | | | | This reverts commit r221583. llvm-svn: 221649
* [Mips] Replace the redundant condition by assert callSimon Atanasyan2014-11-101-3/+3
| | | | | | No functional changes. llvm-svn: 221603
* [Mips] Do not read addends for relocations which do not use themSimon Atanasyan2014-11-102-11/+8
| | | | | | No functional changes. llvm-svn: 221602
* [ELF] Fix DT_INIT_ARRAY{SZ} and DT_FINI_ARRAY{SZ}Shankar Easwaran2014-11-101-4/+26
| | | | | | | | | | The dynamic table was creating the entry DT_FINI_ARRAY{SZ} even when there was no .fini_array section. The entries should be creating in the dynamic section only if there are sections .init_array/.fini_array in the output. Fixes the tests that checked for errroneous outputs. llvm-svn: 221588
* [ELF] Fix values of linker created dynamic variables.Shankar Easwaran2014-11-101-0/+3
| | | | | | | | The value of _DYNAMIC should be pointing at the start of the .dynamic segment. This was pointing to the end of the dynamic segment. Similarly the value of _GLOBAL_OFFSET_TABLE_ was not proper too. llvm-svn: 221587
* [ELF] .dynamic should have SHT_DYNAMIC flagShankar Easwaran2014-11-101-0/+5
| | | | llvm-svn: 221586
* [ELF] Support -z max-page-size optionShankar Easwaran2014-11-101-1/+2
| | | | | | | The GNU linker allows the user to change the page size by using the option -z max-page-size. llvm-svn: 221584
* Add support library.Shankar Easwaran2014-11-102-107/+3
| | | | | | | | | The parsing routines in the linker script to parse strings encoded in various formats(hexadecimal, octal, decimal, etc), is needed by the GNU driver too. This library provides helper functions for all flavors and flavors to add helper functions which other flavors may make use of. llvm-svn: 221583
* [ELF] Remove unused variableShankar Easwaran2014-11-081-1/+0
| | | | llvm-svn: 221572
* [ELF] Support --no-align-segments.Shankar Easwaran2014-11-082-13/+23
| | | | | | | | | | | | | lld generates an ELF by adhering to the ELF spec by aligning vma/fileoffset to a page boundary, but this becomes an issue when dealing with large pages. This adds support so that lld generated executables adheres to the ELF spec with the rule vma % p_align = offset % p_align. This is supported by the flag --no-align-segments. This could be the default in few targets like X86_64 to save space on disk. llvm-svn: 221571
* [mach-o] remove stray debug outputNick Kledzik2014-11-071-3/+0
| | | | llvm-svn: 221553
* [mach-o] Add support for -order_file optionNick Kledzik2014-11-071-2/+86
| | | | | | | | | | | 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
* [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-061-1/+2
| | | | | | | | | | | | 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
OpenPOWER on IntegriCloud