summaryrefslogtreecommitdiffstats
path: root/lld/test
Commit message (Collapse)AuthorAgeFilesLines
* [ELF] - implemented @indntpoff (x86) relocation and its optimization.George Rimar2015-12-172-0/+174
| | | | | | | | | | @indntpoff is similar to @gotntpoff, but for use in position dependent code. While @gotntpoff resolves to GOT slot address relative to the start of the GOT in the movl or addl instructions, @indntpoff resolves to the absolute GOT slot address. ("ELF Handling For Thread-Local Storage", Ulrich Drepper). Differential revision: http://reviews.llvm.org/D15494 llvm-svn: 255884
* [ELF] - implement support of extended length field for CIE/FDE records of ↵George Rimar2015-12-174-0/+42
| | | | | | | | | | | | eh_frame. Ian Lance Taylor writes: "Read 4 bytes. If they are not 0xffffffff, they are the length of the CIE or FDE record. Otherwise the next 64 bits holds the length, and this is a 64-bit DWARF format. This is like .debug_frame." (http://www.airs.com/blog/archives/460), that also consistent with spec (https://refspecs.linuxfoundation.org/LSB_3.0.0/LSB-PDA/LSB-PDA/ehframechpt.html). Patch implements support of described extended length field and also adds few more checks for safety. Differential revision: http://reviews.llvm.org/D15532 llvm-svn: 255883
* Fix negDelta32 relocatable fixups for arm64 in mach-o.Pete Cooper2015-12-161-0/+124
| | | | | | | | | | | negDelta32 is only ever implicitly generated as the FDE->CIE reference. We therefore don't emit a relocation for it in the object file in -r mode. The value we write in to the FDE location therefore needs to point to the final target address of the CIE, and not the inAtomAddress as it was currently doing. llvm-svn: 255835
* [ELF][MIPS] Handle R_MIPS_HI16/LO16 relocations against _gp_disp symbolSimon Atanasyan2015-12-161-0/+42
| | | | | | | | | | | | The `_gp_disp` is a magic symbol designates offset between start of function and gp pointer into GOT. Only `R_MIPS_HI16` and `R_MIPS_LO16` relocations are permitted with `_gp_disp`. The patch adds the `_gp_disp` as an ignored symbol and adjusts symbol value before call the `relocateOne` for `R_MIPS_HI16/LO16` relocations. Differential Revision: http://reviews.llvm.org/D15480 llvm-svn: 255768
* [ELF][MIPS] Ignore R_MIPS_JALR relocation for nowSimon Atanasyan2015-12-131-0/+47
| | | | | | | | | | The `R_MIPS_JALR` is a relocation generated by gcc and gas. This relocation points to the `jalr` instruction which might be optimized and converted to the `b` instruction under some conditions. Now we just ignore this relocation and keep instructions unchanged. llvm-svn: 255453
* [ELF][MIPS] Match paired relocation using relocation type and symbol indexSimon Atanasyan2015-12-131-1/+7
| | | | | | | If we have R_MIPS_HI16 relocation, the paired relocation is the next R_MIPS_LO16 relocation with the same symbol as a target. llvm-svn: 255452
* [ELF][MIPS] Fix calculation of the R_MIPS_HI16 relocationSimon Atanasyan2015-12-131-2/+2
| | | | llvm-svn: 255451
* [lld][MachO] Recognize __thread_bss sections as zero-fill and set all theLang Hames2015-12-111-5/+16
| | | | | | | | | appropriate bits. This fixes the remaining clang regression test failures when linking clang with lld on Darwin. llvm-svn: 255390
* [lld] Watch out for tool names inside paths when substituting tool-paths in lit.Lang Hames2015-12-111-3/+3
| | | | | | | If we don't filter these out we can end up, generating bogus paths, for example: /home/user/lld/build/bin -> /home/user/home/user/lld/build/bin/lld/build/bin. llvm-svn: 255378
* Treat unnamed symbols as locals.Rafael Espindola2015-12-112-0/+16
| | | | | | | There is work under way in llvm to avoid creating unnecessary names for symbols. This makes lld capable of handling that. llvm-svn: 255357
* Discard local symbols from SHF_MERGE sections.Rafael Espindola2015-12-111-0/+24
| | | | | | This matches the behavior of both gold and bfd ld. llvm-svn: 255355
* ELF: Allow -e <entry> with -sharedEd Maste2015-12-111-0/+3
| | | | | | | | | | | | It is reasonable to specify an entry point for shared objects - for example, for the FreeBSD rtld ld-elf.so.1. Unlike GNU ld we leave the entry address as 0 if -shared is specified without -e. Differential Revision: http://reviews.llvm.org/D15454 llvm-svn: 255349
* Test that -e <symbol> worksEd Maste2015-12-111-1/+2
| | | | llvm-svn: 255347
* [ELF] - R_X86_64_SIZE64/R_X86_64_SIZE32 relocations implemented.George Rimar2015-12-113-0/+207
| | | | | | | | | | | | R_X86_64_SIZE64/R_X86_64_SIZE32 relocations were introduced in 0.98v of "System V Application Binary Interface x86-64" (http://www.x86-64.org/documentation/abi.pdf). Calculation for them is Z + A, where: Z - Represents the size of the symbol whose index resides in the relocation entry. A - Represents the addend used to compute the value of the relocatable field. Differential revision: http://reviews.llvm.org/D15335 llvm-svn: 255332
* Fix alignment computation for copy relocs.Rafael Espindola2015-12-102-0/+40
| | | | | | | | Fixes PR25798. Thanks to Ed Maste for the bug report and suggested fix. llvm-svn: 255307
* Make commands printed by llvm-lit include the build path in lit.cfg.Pete Cooper2015-12-101-0/+40
| | | | | | | | | | | | When llvm-lit prints a failure, you'll see something like 'lld *command*' However, you can't then take this, paste it in to a terminal and run it, because it's not got the absolute path of lld. llvm and clang's lit.cfg files contain lists of commands to look for which are substituted by their full paths. So now you'd see something like '*build dir*/bin/lld *command*'. This patch adds the same capability to lld's lit.cfg Reviewed by Rafael Espíndola llvm-svn: 255283
* Verify that macho-o delta64 relocs have the same offset.Pete Cooper2015-12-101-0/+65
| | | | | | | | | | The delta64 relocation is represented as the pair ARM64_RELOC_SUBTRACTOR and ARM64_RELOC_UNSIGNED. Those should always have the same offset, so this adds a check and tests to ensure this is the case. Also updated the error printing in this case to shows both relocs when erroring on pair. llvm-svn: 255274
* [ELF] - Implemented --print-gc-sections command line argument.George Rimar2015-12-101-0/+23
| | | | | | | | List all sections removed by garbage collection. This option is only effective if garbage collection has been enabled via the `--gc-sections' option. Differential revision: http://reviews.llvm.org/D15327 llvm-svn: 255235
* [ELF] - Resolve R_386_PLT32 statically in some cases.George Rimar2015-12-101-34/+48
| | | | | | | | | If R_386_PLT32 relocation is applied against symbol that can not be preempted then it can be resolved statically. Patch implements it for x86 target. Differential revision: http://reviews.llvm.org/D15376 llvm-svn: 255233
* [ELF] - Implement the TLS relocation optimization for 32-bit x86.George Rimar2015-12-093-0/+148
| | | | | | | | | | | Implement the TLS relocation optimization for 32-bit x86 that is described in "ELF Handling For Thread-Local Storage" by Ulrich Drepper, chapter 5, "IA-32 Linker Optimizations". Specifically, this patch implements these optimizations: LD->LE, GD->IE, GD->LD, and IE->LE. Differential revision: http://reviews.llvm.org/D15292 llvm-svn: 255103
* Don't bypass the GOT for delta32toGOT references.Pete Cooper2015-12-092-1/+54
| | | | | | | | | | | The gcc_except_tab was generating these references to point to the typeinfo in the data section. gcc_except_tab also had the DW_EH_PE_indirect flag set which means that at runtime we are going to dereference this entry as if it is in the GOT. Reviewed by Nick Kledzik in http://reviews.llvm.org/D15360. llvm-svn: 255085
* [ELF/AArch64] Allow only valid dynamic relocations in the output.Igor Kudrin2015-12-0517-55/+158
| | | | | | | | | All relocations, which cannot be handled by the dynamic linker, cause a linking error "rebuild with -fPIC". Differential revision: http://reviews.llvm.org/D15193 llvm-svn: 254840
* [ELF] - Implemented @tlsgd optimization (GD->IE case, x64).George Rimar2015-12-042-0/+75
| | | | | | | | | "Ulrich Drepper, ELF Handling For Thread-Local Storage" (5.5 x86-x64 linker optimizations, http://www.akkadia.org/drepper/tls.pdf) shows how GD can be optimized to IE. This patch implements the optimization. Differential revision: http://reviews.llvm.org/D15000 llvm-svn: 254713
* [ELF/AArch64] Support R_AARCH64_COPY relocation.Igor Kudrin2015-12-032-3/+96
| | | | | | | | | Generate R_AARCH64_COPY relocations for non-GOT relocations, which reference object symbols from shared libraries. Differential revision: http://reviews.llvm.org/D15043 llvm-svn: 254591
* COFF: Non-external COMDAT sections sholud not be merged by ICF.Rui Ueyama2015-12-031-0/+66
| | | | | | | | | | | | | If a section symbol is not external, that COMDAT section should never be merge with other sections in other compilation unit. Previously, we didn't take visibility into account. Note that COMDAT sections with non-external visibility makes sense because they can be removed by dead-stripping. Fixes https://llvm.org/bugs/show_bug.cgi?id=25686 llvm-svn: 254578
* [ELF] - Implemented some GD, LD and IE TLS access models for x86 target.George Rimar2015-12-021-0/+92
| | | | | | | | | Main aim of the patch to introduce basic support for TLS access models for x86 target. Models using @tlsgd, @tlsldm and @gotntpoff are implemented. Differential revision: http://reviews.llvm.org/D15060 llvm-svn: 254500
* [ELF] MIPS paired R_MIPS_HI16/LO16 relocations supportSimon Atanasyan2015-12-012-0/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Some MIPS relocations including `R_MIPS_HI16/R_MIPS_LO16` use combined addends. Such addend is calculated using addends of both paired relocations. Each `R_MIPS_HI16` relocation is paired with the next `R_MIPS_LO16` relocation. ABI requires to compute such combined addend in case of REL relocation record format only. For details see p. 4-17 at ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf This patch implements lookup of the next paired relocation suing new `InputSectionBase::findPairedRelocLocation` method. The primary disadvantage of this approach is that we put MIPS specific logic into the common code. The next disadvantage is that we lookup `R_MIPS_LO16` for each `R_MIPS_HI16` relocation, while in fact multiple `R_MIPS_HI16` might be paired with the single `R_MIPS_LO16`. From the other side this way allows us to keep `MipsTargetInfo` class stateless and implement later relocation handling in parallel. This patch does not support `R_MIPS_HI16/R_MIPS_LO16` relocations against `_gp_disp` symbol. In that case the relocations use a special formula for the calculation. That will be implemented later. Differential Revision: http://reviews.llvm.org/D15112 llvm-svn: 254461
* [ELF] - Fixed bug leading to miss of tls relocation when @tlsgd and ↵George Rimar2015-12-011-1/+8
| | | | | | | | | | | | | | | | | @gottpoff relocations were used at the same time. Combination of @tlsgd and @gottpoff at the same time leads to miss of R_X86_64_TPOFF64 dynamic relocation. Patch fixes that. @tlsgd(%rip) - Allocate two contiguous entries in the GOT to hold a tls index structure (for passing to tls get addr). @gottpoff(%rip) - Allocate one GOT entry to hold a variable offset in initial TLS block (relative to TLS block end, %fs:0). The same situation can be observed for x86 (probably others too, not sure) with corresponding for that target relocations: @tlsgd, @gotntpoff. Differential revision: http://reviews.llvm.org/D15105 llvm-svn: 254443
* [ELF/AArch64] Fix overflow checks for R_AARCH64_{ABS,PREL}{16,32} relocations.Igor Kudrin2015-11-2612-75/+123
| | | | | | | | | | ABI specifies the allowed range for these relocations as 2^(n-1) <= X < 2^n. The patch fixes checks and introduces precise tests for these relocations. Differential revision: http://reviews.llvm.org/D14957 llvm-svn: 254146
* [ELF] Factor out relocation checks into separate functions.Igor Kudrin2015-11-261-1/+1
| | | | | | | | It helps to standardize common checks and unify error messages. Differential revision: http://reviews.llvm.org/D14943 llvm-svn: 254144
* [ELF] Reapply r254031 - LinkerScript: lookup absolute paths under sysrootSimon Atanasyan2015-11-261-0/+7
| | | | | | | | | | | | | | | In case a sysroot prefix is configured, and the filename starts with the '/' character, and the script being processed was located inside the sysroot prefix, the file's name will be looked for in the sysroot prefix. Otherwise, the linker falls to the common lookup scheme. It is slightly modified version of the commit r254031. The problem of the initial commit was in the `is_absolute` call. On Windows 'C:\' is absolute path but we do not need to find it under sysroot. In this patch linker looks up a path under sysroot only if the paths starts with '/' character. llvm-svn: 254135
* Reapply r254098.George Rimar2015-11-252-24/+111
| | | | | | | | | Fix is (OutputSections.cpp): for (std::pair<const SymbolBody *, size_t> &I : Entries) { => for (std::pair<const SymbolBody *, unsigned> &I : Entries) { llvm-svn: 254105
* Revert r254098 as it seems broke build bot.George Rimar2015-11-252-111/+24
| | | | | | http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/3555 llvm-svn: 254103
* [ELF] - Implemented optimizations for @tlsld and @tlsgdGeorge Rimar2015-11-251-1/+30
| | | | | | | | | Implements @tlsld (LD to LE) and @tlsgd (GD to LE) optimizations. Patch does not implement the GD->IE case for @tlsgd. Differential revision: http://reviews.llvm.org/D14870 llvm-svn: 254101
* [ELF] - Lazy relocations support for x86 target.George Rimar2015-11-252-24/+111
| | | | | | | | | | | Patch implements lazy relocations for x86. One of features of x86 is that executable files and shared object files have separate procedure linkage tables. So patch implements both cases. Detailed information about instructions used can be found in http://docs.oracle.com/cd/E19620-01/805-3050/chapter6-1235/index.html (search: x86: Procedure Linkage Table). Differential revision: http://reviews.llvm.org/D14955 llvm-svn: 254098
* [ELF2][MIPS] Support R_MIPS_CALL16 relocationSimon Atanasyan2015-11-251-0/+40
| | | | | | | | | R_MIPS_CALL16 relocation provides the same result as R_MIPS_GOT16 relocation but does not need to check the result on overflow. Differential Revision: http://reviews.llvm.org/D14916 llvm-svn: 254092
* [ELF/x86] Implemented R_386_TLS_LE_32, R_386_TLS_LE relocations.George Rimar2015-11-251-0/+69
| | | | | | | | | | | | | | | | | | | | | This patch implements next relocations: R_386_TLS_LE - Negative offset relative to static TLS (GNU version). R_386_TLS_LE_32 - Offset relative to static TLS block. These ones are created when using next code sequences: * @tpoff - The operator must be used to compute an immediate value. The linker will report an error if the referenced variable is not defined or it is not code for the executable itself. No GOT entry is created in this case. * @ntpoff Calculate the negative offset of the variable it is added to relative to the static TLS block. The operator must be used to compute an immediate value. The linker will report an error if the referenced variable is not defined or it is not code for the executable itself. No GOT entry is created in this case. Information was found in Ulrich Drepper, ELF Handling For Thread-Local Storage, http://www.akkadia.org/drepper/tls.pdf, (6.2, p76) Differential revision: http://reviews.llvm.org/D14930 llvm-svn: 254090
* [ELF] - R_386_COPY relocation implemented (x86)George Rimar2015-11-251-0/+63
| | | | | | | | | Implements R_386_COPY relocation for x86 target. Similar to one for x64 http://reviews.llvm.org/D14090 which did most of job needed. Differential revision: http://reviews.llvm.org/D14958 llvm-svn: 254065
* Revert r254031: "ELF2: LinkerScript: lookup absolute paths under sysroot"Hans Wennborg2015-11-251-7/+0
| | | | | | | | | | | | | | | | The test fails on Windows: Command 34: "ld.lld" "-o" "D:\src\llvm\build.release\tools\lld\test\ELF\Output\l inkerscript.s.tmp2" "D:\src\llvm\build.release\tools\lld\test\ELF\Output\linkers cript.s.tmp.dir/xyz.script" "--sysroot=D:\src\llvm\build.release\tools\lld\test\ ELF\Output\linkerscript.s.tmp.dir" Command 34 Result: 1 Command 34 Output: Command 34 Stderr: Unable to find /libxyz.a llvm-svn: 254049
* ELF: Omit PT_GNU_STACK segment if -z execstack is provided.Rui Ueyama2015-11-241-37/+21
| | | | | | | | | In the previous patch (r254003), I made the linker emit PT_GNU_STACK unconditionally. But sometimes you want to have a control over the presence of the segment. With this patch, you can omit the segment by passing -z execstack option. llvm-svn: 254039
* ELF2: LinkerScript: lookup absolute paths under sysrootSimon Atanasyan2015-11-241-0/+7
| | | | | | | | | | | | | In case a sysroot prefix is configured, and the filename starts with the '/' character, and the script being processed was located inside the sysroot prefix, the file's name will be looked for in the sysroot prefix. Otherwise, the linker falls to the common lookup scheme. https://www.sourceware.org/binutils/docs-2.24/ld/File-Commands.html Differential Revision: http://reviews.llvm.org/D14916 llvm-svn: 254031
* Revert "ELF: Make .note.GNU-stack more compatible with traditional linkers."Rui Ueyama2015-11-2420-104/+193
| | | | | | | This reverts commit r253797 because it was based on a misunderstanding that lld wouldn't work on NetBSD without this change. llvm-svn: 254003
* Reapply fixed r253967.George Rimar2015-11-2414-51/+294
| | | | llvm-svn: 253971
* Revert r253967 which broke buildbot.George Rimar2015-11-2414-294/+51
| | | | llvm-svn: 253970
* [ELF] Implements -z relro: create an ELF "PT_GNU_RELRO" segment header in ↵George Rimar2015-11-2414-51/+294
| | | | | | | | | | | | | | | | | the object. Partial (-z relro) and full (-z relro, -z now) relro cases are implemented. Partial relro: The ELF sections are reordered so that the ELF internal data sections (.got, .dtors, etc.) precede the program's data sections (.data and .bss). .got is readonly, .got.plt is still writeable. Full relro: Supports all the features of partial RELRO, .got.plt is also readonly. Differential revision: http://reviews.llvm.org/D14218 llvm-svn: 253967
* [ELF2] - Optimization for R_X86_64_GOTTPOFF relocation.George Rimar2015-11-241-0/+64
| | | | | | | | R_X86_64_GOTTPOFF is not always requires GOT entries. Some relocations can be converted to local ones. Differential revision: http://reviews.llvm.org/D14713 llvm-svn: 253966
* [ELF/AArch64] Add support for R_AARCH64_ADR_GOT_PAGE and ↵Igor Kudrin2015-11-241-0/+40
| | | | | | | | | | | R_AARCH64_LD64_GOT_LO12_NC. With these relocations, it is now possible to build a simple "hello world" program for AArch64 Debian. Differential revision: http://reviews.llvm.org/D14917 llvm-svn: 253957
* Fix Elf_Rel processing for .eh_frame.Rafael Espindola2015-11-231-0/+7
| | | | | | Thanks to Simon for the bug report. llvm-svn: 253869
* ELF: Make .note.GNU-stack more compatible with traditional linkers.Rui Ueyama2015-11-2120-191/+102
| | | | | | | | | | | | | With this patch, lld creates PT_GNU_STACK segments only when all input files have .note.GNU-stack sections. This is in line with other linkers with a minor difference (we don't care about .note.GNU-stack rwx bits as you can always remove .note.GNU-stack sections instead of setting x bit.) At least, NetBSD loader does not understand PT_GNU_STACK segments and reject any executables that have the section. This patch makes lld compatible with such operating systems. llvm-svn: 253797
* Remove trailing whitespaces and untabify.Rui Ueyama2015-11-201-9/+8
| | | | llvm-svn: 253727
OpenPOWER on IntegriCloud