summaryrefslogtreecommitdiffstats
path: root/lld/test
Commit message (Collapse)AuthorAgeFilesLines
...
* [LLD][ELF] - Support discarding .dynstr section.George Rimar2018-12-101-3/+2
| | | | | | | | | This is a part of https://bugs.llvm.org/show_bug.cgi?id=39810. The patch allows discarding the .dynstr section using linker script. Differential revision: https://reviews.llvm.org/D55215 llvm-svn: 348746
* [WebAssembly] Add support for the event sectionHeejin Ahn2018-12-083-0/+52
| | | | | | | | | | | | | | | | | Summary: This adds support for the 'event section' specified in the exception handling proposal. Wasm exception handling binary model spec: https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md#changes-to-the-binary-model Reviewers: sbc100, ruiu Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D54875 llvm-svn: 348703
* [test] Fix reproduce-blackslash.s test with NetBSD tarMichal Gorny2018-12-071-1/+1
| | | | | | | | | | Unlike GNU tar and libarchive bsdtar, NetBSD 'tar -t' output does not use C-style escapes and instead outputs paths literally. Fix the test to account both for escaped and literal backslash output. Differential Revision: https://reviews.llvm.org/D55441 llvm-svn: 348628
* [test] Mark atime-based tests unsupported on NetBSDMichal Gorny2018-12-073-0/+6
| | | | | | | Mark tests requiring 'touch' to set atime unsupported on NetBSD due to kernel limitation preventing it from working with noatime. llvm-svn: 348607
* [ELF] - (-Map file) Implement printing of LMA for assignments outside of ↵George Rimar2018-12-062-14/+16
| | | | | | | | | | | | | section declarations. This was a missing piece. We started to print LMAs and information about assignments, but did not do that for assignments outside of section declarations yet. The patch implements it. Differential revision: https://reviews.llvm.org/D45314 llvm-svn: 348468
* Fixup r348306: Require x86 for testDiana Picus2018-12-061-0/+1
| | | | | | | | The test breaks on buildbots that don't enable the x86 backend. Other tests in this directory explicitly require x86, so this should do the trick. llvm-svn: 348466
* [LLD][ELF] - Linker script: accept using a file name without a list of sections.George Rimar2018-12-062-5/+17
| | | | | | | | | | | | | | | | This is a part of https://bugs.llvm.org/show_bug.cgi?id=39885 Linker script specification says: "You can specify a file name to include sections from a particular file. You would do this if one or more of your files contain special data that needs to be at a particular location in memory." LLD did not accept this syntax. The patch implements it. Differential revision: https://reviews.llvm.org/D55324 llvm-svn: 348463
* [PDB] Emit S_UDT records in LLD.Zachary Turner2018-12-044-7/+492
| | | | | | | | | | | Previously these were dropped. We now understand them sufficiently well to start emitting them. From the debugger's perspective, this now enables us to have debug info about typedefs (both global and function-locally scoped) Differential Revision: https://reviews.llvm.org/D55228 llvm-svn: 348306
* ELF: allow non allocated sections to go into allocated sectionsRui Ueyama2018-12-041-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch from Andrew Kelley. For context, see https://bugs.llvm.org/show_bug.cgi?id=39862 The use case is embedded / OS programming where the kernel wants access to its own debug info via mapped dwarf info. I have a proof of concept of this working, using this linker script snippet: .rodata : ALIGN(4K) { *(.rodata) __debug_info_start = .; KEEP(*(.debug_info)) __debug_info_end = .; __debug_abbrev_start = .; KEEP(*(.debug_abbrev)) __debug_abbrev_end = .; __debug_str_start = .; KEEP(*(.debug_str)) __debug_str_end = .; __debug_line_start = .; KEEP(*(.debug_line)) __debug_line_end = .; __debug_ranges_start = .; KEEP(*(.debug_ranges)) __debug_ranges_end = .; } Differential revision: https://reviews.llvm.org/D55276 llvm-svn: 348291
* [ELF] Allow discarding of .rela.pltMartell Malone2018-12-041-5/+0
| | | | | | | | | | | | | | | | When linking the linux kernel on ppc64le ld.lld -EL -m elf64lppc -Bstatic --orphan-handling=warn --build-id -o .tmp_vmlinux1 -T ./arch/powerpc/kernel/vmlinux.lds --whole-archive built-in.a --no-whole-archive --start-group lib/lib.a --end-group ld.lld: error: discarding .rela.plt section is not allowed The linker script discards with the following matches *(.glink .iplt .plt .rela* .comment) Differential Revision: https://reviews.llvm.org/D54871 llvm-svn: 348258
* [PPC][PPC64] PPC_REL14 and PPC64_REL14 relocationsMartell Malone2018-12-042-21/+43
| | | | | | | | | | When linking the linux kernel on ppc64 and ppc ld.lld: error: unrecognized reloc 11 11 is PPC_REL14 and PPC64_REL14 Differential revision: https://reviews.llvm.org/D54868 llvm-svn: 348255
* [WebAssembly] Don't set a maximum size when importing the tableSam Clegg2018-12-032-4/+0
| | | | | | | | | We shouldn't be setting setting a max size for a table that is being imported. Differential Revision: https://reviews.llvm.org/D55231 llvm-svn: 348204
* Show a proper error message if output file is too large.Rui Ueyama2018-12-031-0/+6
| | | | | | | | | At least on Linux, if a file size given to FileOutputBuffer is greater than 2^63, it fails with "Invalid argument" error, which is not a user-friendly error message. With this patch, lld prints out "output file too large" instead. llvm-svn: 348153
* [LLD][ELF] - Improve the DWARF v5 suport for building .gdb_index.George Rimar2018-12-031-0/+202
| | | | | | | | | | | | Now LLD might build the broken/incomplete .gdb_index when some DWARF v5 sections (like .debug_rnglists and .debug_addr) are used. Particularly, for the case above, we emit an empty address area. A test case is provided and patch fixes the issue. Differential revision: https://reviews.llvm.org/D55109 llvm-svn: 348119
* [PDB] Quote linker arguments containing spaces (mimic MSVC)Alexandre Ganea2018-11-301-2/+2
| | | | | | | | Initial patch by Will Wilson (@lantictac) Differential Revision: https://reviews.llvm.org/D55074 llvm-svn: 348001
* Do not assume .idata is zero-initialized.Rui Ueyama2018-11-301-0/+9
| | | | | | | | | | | | | We initialize .text section with 0xcc (INT3 instruction), so we need to explicitly write data even if it is zero if it can be in a .text section. If you specify /merge:.rdata=.text, .rdata (which contains .idata) is put to .text, so we need to do this. Fixes https://bugs.llvm.org/show_bug.cgi?id=39826 Differential Revision: https://reviews.llvm.org/D55098 llvm-svn: 348000
* [WebAssembly] Allow undefined symbols when building shared librariesSam Clegg2018-11-291-10/+17
| | | | | | Differential Revision: https://reviews.llvm.org/D55043 llvm-svn: 347909
* [LLD][ELF] Error if _GLOBAL_OFFSET_TABLE_ is defined in input objectsPeter Smith2018-11-291-0/+14
| | | | | | | | | | | | | | | | | The _GLOBAL_OFFSET_TABLE_ is a linker defined symbol that is placed at some location relative to the .got, .got.plt or .toc section. On some targets such as Arm the correctness of some code sequences using a relocation to _GLOBAL_OFFSET_TABLE_ depend on the value of the symbol being in the linker defined place. Follow the ld.gold example and give a multiple symbol definition error. The ld.bfd behaviour is to ignore the definition in the input object and redefine it, which seems like it could be more surprising. fixes pr39587 Differential Revision: https://reviews.llvm.org/D54624 llvm-svn: 347854
* [ELF] --gdb-index: use lower_bound to compute relative CU index in the ↵Fangrui Song2018-11-291-14/+37
| | | | | | | | | | | | | | | | | | | | | | object file Summary: This reinstates what I originally intended to do in D54361. It removes the assumption that .debug_gnu_pubnames has increasing CuOffset. Now we do better than gold here: when .debug_gnu_pubnames contains multiple sets, gold would think every set has the same CU index as the first set (incorrect). Reviewed By: ruiu Reviewers: ruiu, dblaikie, espindola Subscribers: emaste, arichardson, arphaman, llvm-commits Differential Revision: https://reviews.llvm.org/D54483 llvm-svn: 347820
* [ELF][MIPS] Handle mips in the OUTPUT_FORMAT directiveSimon Atanasyan2018-11-281-0/+74
| | | | | | Differential Revision: http://reviews.llvm.org/D54920 llvm-svn: 347742
* [ELF] Use more specific method to calculate DT_PLTRELSZPeter Smith2018-11-284-0/+181
| | | | | | | | | | | | | | | | | | | | The DT_PLTRELSZ dynamic tag is calculated using the size of the OutputSection containing the In.RelaPlt InputSection. This will work for the default no linker script case and the majority of linker scripts. Unfortunately it doesn't work for some 'almost' sensible linker scripts. It is permitted by ELF to have a single OutputSection containing both In.RelaDyn, In.RelaPlt and In.RelaIPlt. It is also permissible for the range of memory [DT_RELA, DT_RELA + DT_RELASZ) and the range [DT_JMPREL, DT_JMPREL + DT_JMPRELSZ) to overlap as long as the the latter range is at the end. To support this type of linker script use the specific InputSection sizes. Fixes pr39678 Differential Revision: https://reviews.llvm.org/D54759 llvm-svn: 347736
* [COFF] Remove empty sections before calculating the size of section headersMartin Storsjo2018-11-271-0/+12
| | | | | | | | | | | | | The number of sections is used in assignAddresses (in finalizeAddresses) and the space for all sections is permanent from that point on, even if we later decide we won't write some of them. The VirtualSize field also gets calculated in assignAddresses, so we need to manually check whether the section is empty here instead. Differential Revision: https://reviews.llvm.org/D54495 llvm-svn: 347704
* [ELF] - Fix R_AARCH64_ADR_GOT_PAGE, R_AARCH64_LD64_GOT_LO12 handling against ↵George Rimar2018-11-271-0/+52
| | | | | | | | | | | | | | | | | | | | IFUNC symbols. This is https://bugs.llvm.org/show_bug.cgi?id=38074. The issue is that when calling a function, LLD generates a .got entry that points to the IFUNC resolver function when instead, it should use the PLT entries properly for handling the IFUNC. So we should create a got entry that points to PLT entry, which itself loads the value from .got.plt, relocated with R_*_IRELATIVE to make things work. Patch do that. Differential revision: https://reviews.llvm.org/D54314 llvm-svn: 347650
* [AArch64] Cortex-a53-843419 erratum should not apply to relaxed TLS.Peter Smith2018-11-271-0/+38
| | | | | | | | | | | | | | | | The changes to the instructions performed by TLS relaxation and the errata patching are performed with relocations. As these are applied so late the errata scanning won't see the changes in the section data made by the TLS relaxation. This can lead to a TLS relaxed sequence being patched when it doesn't need to be. The fix checks to see if there is a R_RELAX_TLS_IE_TO_LE instruction at the same address as the ADRP as this indicates the presence of a relaxation of a sequence that might get recognised as a patch. Differential Revision: https://reviews.llvm.org/D54854 llvm-svn: 347649
* [ELF] - Implement -z nodefaultlibGeorge Rimar2018-11-271-3/+3
| | | | | | | | | | | | | | | | | | | | This is https://bugs.llvm.org//show_bug.cgi?id=38978 Spec says that: "Objects may be built with the -z nodefaultlib option to suppress any search of the default locations at runtime. Use of this option implies that all the dependencies of an object can be located using its runpaths. Without this option, which is the most common case, no matter how you augment the runtime linker's library search path, its last element is always /usr/lib for 32-bit objects and /usr/lib/64 for 64-bit objects." The patch implements this option. Differential revision: https://reviews.llvm.org/D54577 llvm-svn: 347647
* [COFF] Generate a codeview build id signature for MinGW even when not ↵Martin Storsjo2018-11-271-0/+24
| | | | | | | | | | | | | | | | | | creating a PDB GNU ld, which doesn't generate PDBs, can optionally generate a build id by passing the --build-id option. LLD's MinGW frontend knows about this option but ignores it, as I had falsely assumed that LLD already generated build IDs even in those cases. If debug info is requested and no PDB path is set, generate a build id signature as a hash of the binary itself. This allows associating a binary to a minidump, even if debug info isn't written in PDB form by the linker. Differential Revision: https://reviews.llvm.org/D54828 llvm-svn: 347645
* [COFF] Add exported functions to gfids table for /guard:cfReid Kleckner2018-11-271-0/+44
| | | | | | | | | | | | | | | | | | | | | | | Summary: MSVC does this, and we should to. The .gfids table is a table of RVAs, so it's impossible for a DLL to indicate that an imported symbol is address taken. Therefore, exports appear to be listed as address taken by the DLL that exports them. This fixes an issue that Firefox ran into here: https://bugzilla.mozilla.org/show_bug.cgi?id=1485016#c12 In Firefox, the export directive came from a .def file, but we need to do this for any kind of export. Reviewers: dmajor, hans, amccarth, alex Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D54723 llvm-svn: 347623
* [LLD][ELF] - Added a test for "-image-base: number expected" message. NFC.George Rimar2018-11-261-0/+3
| | | | | | We had no such test. llvm-svn: 347553
* [LLD][ELF] - Add a test for "unbalanced --push-state/--pop-state" error.George Rimar2018-11-261-0/+3
| | | | | | We had no such test. llvm-svn: 347552
* [LLD][ELF] - Add a check for --split-stack-adjust-size error message. NFCI.George Rimar2018-11-261-0/+2
| | | | | | | "--split-stack-adjust-size: size must be >= 0" message was never tested. llvm-svn: 347550
* [LLD][ELF] - Do not crash when parsing the -defsym option from a error state.George Rimar2018-11-261-0/+6
| | | | | | | | | | | | | | When we are in a error state, script parser will not parse the -defsym expression and hence will not tokenize it. Then ScriptLexer::Pos will be 0 and LLD will assert and crash here: MemoryBufferRef ScriptLexer::getCurrentMB() { assert(!MBs.empty() && Pos > 0); // Bang ! Solution - stop parsing the defsym in a error state. That is consistent with the regular case (when we parse the linker script). llvm-svn: 347549
* [ELF] - Added test case for invalid relocation target errors. NFCI.George Rimar2018-11-262-0/+50
| | | | | | We had a proper error reporting, but no test cases. llvm-svn: 347536
* [LLD][ELF] - Add a test for non-null terminated mergeable strings section. NFCI.George Rimar2018-11-261-0/+8
| | | | | | LLD reports an error in this case, but we had no test. llvm-svn: 347535
* [ELF] Write IPLT header in -static -z retpolineplt modeFangrui Song2018-11-211-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes PR39711: -static -z retpolineplt does not produce retpoline PLT header. -z now is not relevant. Statically linked executable does not have PLT, but may have IPLT with no header. When -z retpolineplt is specified, however, the repoline PLT header should still be emitted. I've checked that this fixes the FreeBSD reproduce in PR39711 and a Linux program statically linked against glibc. The programm print "Hi" rather than SIGILL/SIGSEGV. getPltEntryOffset may look dirty after this patch, but it can be cleaned up later. Another possible improvement is that when there are non-preemptible IFUNC symbols (rare case, e.g. -Bsymbolic), both In.Plt and In.Iplt can be non-empty and we'll emit the retpoline PLT header twice. Reviewers: espindola, emaste, chandlerc, ruiu Reviewed By: emaste Subscribers: emaste, arichardson, krytarowski, llvm-commits Differential Revision: https://reviews.llvm.org/D54782 llvm-svn: 347404
* [ARM] Change REQUIRES: ARM to Requires: armPeter Smith2018-11-212-4/+3
| | | | | | | | | | When REQUIRES: ARM is used the test is skipped as ARM is not recognized. Change to REQUIRES: arm so that it is run. This required updating one of the tests due to changes in expected output. Differential Revision: https://reviews.llvm.org/D54786 llvm-svn: 347388
* [ELF] Allow --noinhibit-exec to produce corrupted executable with relocation ↵Fangrui Song2018-11-201-0/+2
| | | | | | | | | | | | | | | | | | | overflow Summary: When --noinhibit-exec is used, ld.bfd/gold emit errors but allow to produce corrupted executable, which is handy for debugging purpose. lld's --noinhibit-exec has a different meaning and changes some errors to warnings. This patch replaces "error" with "errorOrWarn" to exploit that property. We may revisit this: if we should keep them as errors (as ld.bfd/gold do) but allow to produce a (corrupted) executable. Reviewers: ruiu, grimar, espindola Reviewed By: grimar Subscribers: Timmmm, jhenderson, emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D54651 llvm-svn: 347327
* Support ARM_V4BX relocationFangrui Song2018-11-161-0/+38
| | | | | | | | | | | | | | | | Summary: This patch implementation the handler for ARM_V4BX. This relocation is used by GNU runtime files and other armv4 applications. Patch by Yin Ma Reviewers: espindola, MaskRay, ruiu, peter.smith, pcc Reviewed By: ruiu Subscribers: yinma, pcc, peter.smith, MaskRay, rovka, efriedma, emaste, javed.absar, arichardson, kristof.beyls, chrib, llvm-commits Differential Revision: https://reviews.llvm.org/D53444 llvm-svn: 347077
* [ELF][MIPS] Use MIPS R6 `sigrie` as a trap instructionSimon Atanasyan2018-11-165-124/+80
| | | | | | | | | | | | | | | Current value using as a trap instruction (0xefefefef) is not a good choice for MIPS because it's a valid MIPS instruction `swc3 $15,-4113(ra)`. This patch replaces 0xefefefef by 0x04170001. For all MIPS ISA revisions before R6, this value is just invalid instruction. Starting from MIPS R6 it's a valid instruction `sigrie 1` which signals a Reserved Instruction exception. mips-traps.s test case is added to test trap encoding. Other test cases are modified to remove redundant checking. Differential revision: https://reviews.llvm.org/D54154 llvm-svn: 347029
* [WebAssembly] Import the stack pointer when building shared librariesSam Clegg2018-11-151-2/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D54558 llvm-svn: 346974
* [WebAssembly] Initial support for shared objects (-shared)Sam Clegg2018-11-151-0/+70
| | | | | | | | | | | | Based on the initial spec proposal: https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md The llvm/codegen side of this is still missing but I believe this change is still worth landing as an incremental step Differential Revision: https://reviews.llvm.org/D54249 llvm-svn: 346918
* [PPC64] Long branch thunks.Sean Fertile2018-11-145-47/+346
| | | | | | | | | | | | | | | | | | On PowerPC64, when a function call offset is too large to encode in a call instruction the address is stored in a table in the data segment. A thunk is used to load the branch target address from the table relative to the TOC-pointer and indirectly branch to the callee. When linking position-dependent code the addresses are stored directly in the table, for position-independent code the table is allocated and filled in at load time by the dynamic linker. For position-independent code the branch targets could have gone in the .got.plt but using the .branch_lt section for both position dependent and position independent binaries keeps it consitent and helps keep this PPC64 specific logic seperated from the target-independent code handling the .got.plt. Differential Revision: https://reviews.llvm.org/D53408 llvm-svn: 346877
* [NFC] Change address __tls_getaddr is defined at so it does not need a thunk.Sean Fertile2018-11-141-2/+2
| | | | | | | Minor update to a ppc64 tls test so that it won't need to use a thunk once the range-extending thunk patch is landed. llvm-svn: 346876
* [AArch64] Fix resolution of R_PLT_PAGE RelExprPeter Smith2018-11-141-0/+49
| | | | | | | | | | | | | The R_AARCH64_ADR_PREL_PG_HI21 relocation type is given the R_PAGE_PC RelExpr. This can be transformed to R_PLT_PAGE_PC via toPlt(). Unfortunately the resolution is identical to R_PAGE_PC so instead of getting the address of the PLT entry we get the address of the symbol which may not be correct in the case of static ifuncs. The fix is to handle the cases separately and use getPltVA() + A with R_PLT_PAGE_PC. Differential Revision: https://reviews.llvm.org/D54474 llvm-svn: 346863
* Fix r346747 and r346796Diana Picus2018-11-142-0/+2
| | | | | | | Require x86 for the tests in order to fix non-x86 bots. This seems to be the case for all other tests in that directory. llvm-svn: 346842
* [ELF] Add a better test for the multi-CU .gdb_index bug that D54361 fixedFangrui Song2018-11-133-2/+82
| | | | | | | | gdb-index-multiple-cu-2.s puts the symbol in question to another object file %t1.o, so that its CuIndex is affected by the number of CUs in %t.o Also change `Kind:` in a comment to `Attributes:` as a follow-up of D54480 and D54481 llvm-svn: 346796
* [ELF] .gdb_index: fix CuOff when a .debug_info section contains more than 1 ↵Fangrui Song2018-11-131-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | DW_TAG_compile_unit Summary: Idx passed to readPubNamesAndTypes was an index into Chunks, not an index into the CU list. This would be incorrect if some .debug_info section contained more than 1 DW_TAG_compile_unit. In real world, glibc Scrt1.o is a partial link of start.os abi-note.o init.o and contains 2 CUs in debug builds. Without this patch, any application linking such Scrt1.o would have invalid .gdb_index The issue could be demonstrated by: (gdb) py print(gdb.lookup_global_symbol('main')) None Reviewers: espindola, ruiu Reviewed By: ruiu Subscribers: Higuoxing, grimar, dblaikie, emaste, aprantl, arichardson, JDevlieghere, arphaman, llvm-commits Differential Revision: https://reviews.llvm.org/D54361 llvm-svn: 346747
* [ELF] Fix relocation-common.s after rL346610Fangrui Song2018-11-111-6/+6
| | | | llvm-svn: 346614
* [ELF] Fix objdump tests after rL346610Fangrui Song2018-11-1110-27/+27
| | | | llvm-svn: 346613
* [lld][test] Update tests using objdumpKristina Brooks2018-11-111-1/+1
| | | | | | Followup fix for LLD test for new format in rL346610. llvm-svn: 346612
* [WebAssembly] Respect `--no-mangle` in more locationsSam Clegg2018-11-091-4/+6
| | | | | | | | | | | | | `--no-demangle` now also applies to the name section. This change was motivated by the rust team that have a slightly different name mangling scheme to the standard C++ itanium one and prefer to do their de-mangling as a post-link setp. Patch by Alex Crichton! Differential Revision: https://reviews.llvm.org/D54279 llvm-svn: 346516
OpenPOWER on IntegriCloud