summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
* Sort headers. NFC.Rafael Espindola2016-02-061-1/+1
| | | | llvm-svn: 259959
* ELF: Simplify readEntryLength.Rui Ueyama2016-02-055-18/+18
| | | | | | | | | I removed "CIE/FIE size is too large" error because that was not checking for correct error conditions. [UINT_MAX - 4, UINT_MAX) is a correct range as a size of a CIE/FDE record. It's just that the size cannot be larger than the section size. llvm-svn: 259951
* ELF: Make EHOutputSection::readEntryLength a non-member function.Rui Ueyama2016-02-052-28/+26
| | | | | | This function did not use any fields of the class. llvm-svn: 259946
* Fix PT_GNU_RELRO computation.Rafael Espindola2016-02-052-2/+25
| | | | | | We were not including TLS sections. llvm-svn: 259945
* Simplify. NFC.Rui Ueyama2016-02-051-2/+1
| | | | llvm-svn: 259903
* ELF: Make Out<ELFT> initialization less error-prone.Rui Ueyama2016-02-051-46/+47
| | | | | | | | | | | Previously, it was easy to leave some Out<ELFT> fields uninitialized because assignments to the fields are mixed with output section instantiations. In this patch, I separate initializations from assignments to improve readability. http://reviews.llvm.org/D16864 llvm-svn: 259899
* Rename IsUsedInDynamicReloc to MustBeInDynSym.Rafael Espindola2016-02-055-12/+10
| | | | | | | | The variable was marking various cases where a symbol must be included in the dynamic symbol table. Being used by a dynamic relocation was only one of them. llvm-svn: 259889
* Centralize most calls to setUsedInDynamicReloc.Rafael Espindola2016-02-053-10/+10
| | | | llvm-svn: 259887
* ELF: Make names for TLS module indices shorter.Rui Ueyama2016-02-054-11/+13
| | | | | | | | | | The previous names contained "Local" and "Current", but what we are handling is always local and current, so they were redundant. TlsIndex comes from "tls_index" struct that Ulrich Drepper is using in this document to describe this data structure in GOT. llvm-svn: 259852
* Simplify. NFC.Rui Ueyama2016-02-041-1/+1
| | | | llvm-svn: 259848
* Do not round uintX_t to uint32_t.Rui Ueyama2016-02-041-1/+1
| | | | | | On 64-bit computers, this value can be larger than UINT32_MAX. llvm-svn: 259847
* Merge conditions of two nested `if`s.Rui Ueyama2016-02-041-6/+5
| | | | llvm-svn: 259843
* Don't push relocation sections onto InputSection<ELFT>::Discarded.RelocSectionsSean Silva2016-02-043-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: LLVM3.3 (and earlier) would fail to include a relocation section in the group that the section it was relocating is in. Object files affected by this issue have been encountered in the wild when using LLD. This would result in a siutation like: Section { Index: 5 Name: .text._Z3fooIiEvv (6) Type: SHT_PROGBITS (0x1) Flags [ (0x206) SHF_ALLOC (0x2) SHF_EXECINSTR (0x4) SHF_GROUP (0x200) ] Address: 0x0 Offset: 0x48 Size: 5 Link: 0 Info: 0 AddressAlignment: 1 EntrySize: 0 } Section { Index: 6 Name: .rela.text._Z3fooIiEvv (1) Type: SHT_RELA (0x4) Flags [ (0x0) ] Address: 0x0 Offset: 0x3F0 Size: 24 Link: 8 Info: 5 AddressAlignment: 8 EntrySize: 24 } In LLD, during symbol resolution, we discard the section containing the weak symbol, but this amounts to replacing it with InputSection<ELFT>::Discarded. When we later saw the corresponding relocation section, we would then end up pusing onto InputSection<ELFT>::Discarded.RelocSections, which is bogus. Reviewers: ruiu, rafael Subscribers: llvm-commits, Bigcheese Differential Revision: http://reviews.llvm.org/D16898 llvm-svn: 259831
* Avoid code duplication when creating dynamic relocations.Rafael Espindola2016-02-043-143/+144
| | | | | | | | | | | | | | | | | Another case where we currently have almost duplicated code is the creation of dynamic relocations. First to decide if we need one, then to decide what to write. This patch fixes it by passing more information from the relocation scan to the section writing code. This is the same idea used for r258723. I actually think it should be possible to simplify this further by reordering things a bit in the writer. For example, we should be able to represent almost every position in the file with an OutputSeciton and offset. When writing it out we then just need to add the offset to the OutputSection VA. llvm-svn: 259829
* Set CPU_SUBTYPE_LIB64 in mach_header.Pete Cooper2016-02-042-1/+48
| | | | | | | | | | | On Mac OS 10.5 and later, with X86_64 and outputting a dynamic executable, ld64 set the CPU_SUBTYPE_LIB64 mask on the cpusubtype in the mach_header. This adds the same functionality to lld. rdar://problem/24507177 llvm-svn: 259826
* [ELF][MIPS] Support R_MIPS_PC32 relocation handlingSimon Atanasyan2016-02-042-11/+23
| | | | llvm-svn: 259782
* [ELF][MIPS] Add handling for __gnu_local_gp symbolSimon Atanasyan2016-02-045-1/+25
| | | | | | | This symbol is a "fake" symbol like "_gp_disp" and denotes the GOT + 0x7FF0 value. llvm-svn: 259781
* [ELF][MIPS] Replace needsMipsLocalGot function by canBePreemptedSimon Atanasyan2016-02-044-22/+7
| | | | | | | Symbol does not need an entry i the 'global' part of GOT if it cannot be preempted. So canBePreempted fully satisfies us at least for now. llvm-svn: 259779
* [ELF][MIPS] Always create global GOT entry for symbols defined in DSOSimon Atanasyan2016-02-042-3/+62
| | | | | | | | | | If relocation against symbol requires GOT entry creation and this symbol is defined in DSO, the GOT entry should be created in the 'global' part of the GOT even if we link executable file. Also we do not need to create a dynamic symbol table entry for global symbol corresponding to the local GOT entry. llvm-svn: 259778
* Use unsigned long long instead of uint64_t to appease botsPete Cooper2016-02-041-1/+1
| | | | llvm-svn: 259748
* Add test missed from r259746Pete Cooper2016-02-041-0/+28
| | | | llvm-svn: 259747
* Add support for the source_version cmdline option.Pete Cooper2016-02-046-0/+67
| | | | | | | | | This is of the form A.B.C.D.E and to match ld64's behaviour, is always output to files, even when the version is 0. rdar://problem/24472630 llvm-svn: 259746
* Set S_ATTR_SOME_INSTRUCTIONS on __text section.Pete Cooper2016-02-042-1/+31
| | | | | | | | | ld64 sets both S_ATTR_PURE_INSTRUCTIONS and S_ATTR_SOME_INSTRUCTIONS on __TEXT, __text. We only had the S_ATTR_PURE_INSTRUCTIONS attribute. rdar://problem/24495801 llvm-svn: 259744
* Generate version min load commands when the platform is unknown.Pete Cooper2016-02-049-32/+184
| | | | | | | | | | | In the case where we are emitting to an object file, the platform is possibly unknown, and the source object files contained load commands for version min, we can take the maximum of those min versions and emit in in the output object file. This test also tests r259739. llvm-svn: 259742
* Default to an unknown OS instead of MacOSX.Pete Cooper2016-02-042-19/+25
| | | | | | | | | | | | Defaulting to unknown matches ld64, but it also makes sure that all of our code can handle not knowing the platform. For example, a later commit will add support for version min load commands with an unknown platform, which is a feature supported by ld64. No test case here. The next commit will have one with the version min code that needed this patch. llvm-svn: 259739
* Add support for -sdk_version cmdline option.Pete Cooper2016-02-036-1/+61
| | | | | | | | | | | | This option is emitted in the min_version load commands. Note, there's currently a difference in behaviour compared to ld64 in that we emit a warning if we generate a min_version load command and didn't give an sdk_version. We need to decide what the correct behaviour is here as its possible we want to emit an error and force clients to provide the option. llvm-svn: 259729
* Add generation of LC_VERSION_MIN load commands.Pete Cooper2016-02-037-2/+151
| | | | | | | | | | | | | If the command line contains something like -macosx_version_min and we don't explicitly disable generation with -no_version_load_command then we generate the LC_VERSION_MIN command in the output file. There's a couple of FIXME's in here. These will be handled soon with more tests but I didn't want to grow this patch any more than it already was. rdar://problem/24472630 llvm-svn: 259718
* Fix addend computation for IRELATIVE relocations.Rafael Espindola2016-02-032-13/+36
| | | | llvm-svn: 259692
* ELF: Remove dead code.Rui Ueyama2016-02-031-3/+0
| | | | | | | R_X86_64_DTPOFF64 relocs are for the dynamic linker. Static linkers create them but don't consume them. llvm-svn: 259679
* Do not expect /dev/null (or NUL) non-mmap'able.Rui Ueyama2016-02-031-2/+2
| | | | | | | On some Windows environment, this test did not fail, because opening NUL with FileOutputBuffer didn't fail. Thanks to George Rimar for reporting. llvm-svn: 259669
* Simplify. NFC.Rafael Espindola2016-02-031-5/+1
| | | | llvm-svn: 259660
* Define SymbolBody::getSize instead of getSymSize(SymbolBody&). NFC.Rui Ueyama2016-02-033-9/+15
| | | | llvm-svn: 259613
* ELF: Write about the current policy to README.Rui Ueyama2016-02-021-0/+13
| | | | llvm-svn: 259606
* ELF: Make link() to take an output stream to which error messages are written.Rui Ueyama2016-02-026-5/+13
| | | | | | http://reviews.llvm.org/D16668 llvm-svn: 259597
* ELF: Do not exit if it cannot open an output file.Rui Ueyama2016-02-022-5/+20
| | | | | | | | It can fail to open an output file for various reasons, including lack of permission, too long filename, or the output file is not a mmap'able file. llvm-svn: 259596
* __mh_execute_header atoms should be global and never dead strippped.Pete Cooper2016-02-023-2/+9
| | | | | | | | | | | | | | In r259574 I fixed some of the issues with the mach header symbols and DSO handles. This is the next issue whereby the __mh_execute_header has to not be dead stripped, and (to match ld64) should be dynamically referenced. The test here should also have been added in r259574 to make sure that we emit this symbol. But checking that it is not only emitted but also has the correct reference type is fine. llvm-svn: 259589
* Add "REQUIRES: shell" to fix Windows buildbot.Rui Ueyama2016-02-021-0/+9
| | | | llvm-svn: 259584
* Fix handling of mach header and DSO handle symbols.Pete Cooper2016-02-028-40/+62
| | | | | | | | | | | | | | | | | The magic file which contained these symbols inherited from archive which meant that the resolver didn't add the required atoms as archive members only get added when referenced. Instead we now inherit from SimpleFile which always links in the atoms needed. The second issue was in the handling of these symbols when we emit the MachO. The mach header symbol needs to be in the atom list as it gets an offset (0), and being in the atom list makes sure it is emitted to the symbol table. DSO handles are not emitted to the symbol table. rdar://problem/24450654 llvm-svn: 259574
* Re-submit ELF: Report multiple errors from the driver.Rui Ueyama2016-02-028-47/+78
| | | | | | This reverts r259395 which reverted r259143. llvm-svn: 259572
* ELF: Rewrite "echo" command arguments in hope that would fix a test breakage.Rui Ueyama2016-02-024-19/+19
| | | | | | | | | | | Previously, we used both single quotes and double quotes, and some single-quoted tokens are concatenated with next tokens because there were no spaces between them. That may be a cause of test flakiness on Windows, which is reported as https://llvm.org/bugs/show_bug.cgi?id=26388. The new test commands are more straightforward than before. llvm-svn: 259559
* ELF: Do not use fatal in LinkerScript.cpp.Rui Ueyama2016-02-022-22/+101
| | | | | | | | | | | | This patch adds "Error" field to LinkerScript class. That field is false by default, and set to true if there is a syntax error in an input file. The linker script parser is a recursive-descedent parser. Each function returns if Error is true -- so that eventually the whole parser returns to a caller. http://reviews.llvm.org/D16667 llvm-svn: 259557
* Do not use filename in a lit test.Rui Ueyama2016-02-021-7/+7
| | | | | | So that the file is move-safe. llvm-svn: 259555
* ELF: Use StringRef instead of std::string.Rui Ueyama2016-02-021-1/+1
| | | | | | | | All MemoryBuffers for archive files are guaranteed to exist as long as their children are used in the linker. So we don't need to copy strings here. Thanks to Sean Silva for pointing this out. llvm-svn: 259554
* Expand comment a bit.Rafael Espindola2016-02-021-0/+5
| | | | | | | I have spent some time prototyping this idea. While it seems to work, I now think it is probably not worth it. llvm-svn: 259516
* [ELF] Implemented -Bsymbolic-functions command line optionGeorge Rimar2016-02-027-11/+58
| | | | | | | | | | | | | -Bsymbolic-functions: When creating a shared library, bind references to global function symbols to the definition within the shared library, if any. This patch also fixed behavior of already existent -Bsymbolic: previously PLT entries were created even if -Bsymbolic was specified. Differential revision: http://reviews.llvm.org/D16411 llvm-svn: 259481
* [ELF] Remove redundant empty line. NFCSimon Atanasyan2016-02-021-1/+0
| | | | llvm-svn: 259479
* [ELF] Finalize .dynamic section at the endSimon Atanasyan2016-02-022-5/+16
| | | | | | | | | | Some dynamic table tags like RELSZ and PLTRELSZ depens on result of finalizing corresponding relocation sections. Therefore we have to finalize .dynamic section at the end. Differential Revision: http://reviews.llvm.org/D16799 llvm-svn: 259478
* ELF: Include archive names in error messages.Rui Ueyama2016-02-027-14/+43
| | | | | | | | If object files are drawn from archive files, the error message should be something like "conflict symbols in foo.a(bar.o) and baz.o" instead of "conflict symbols in bar.o and baz.o". This patch implements that. llvm-svn: 259475
* ELF: Simplify and add comments.Rui Ueyama2016-02-021-8/+16
| | | | llvm-svn: 259474
* Do not use "No" prefix for boolean variables to make it simpler. NFC.Rui Ueyama2016-02-021-6/+4
| | | | llvm-svn: 259472
OpenPOWER on IntegriCloud