summaryrefslogtreecommitdiffstats
path: root/lld/test
Commit message (Collapse)AuthorAgeFilesLines
...
* [WebAssembly] Don't generate empty type sections.Sam Clegg2019-05-161-0/+10
| | | | | | Differential Revision: https://reviews.llvm.org/D61991 llvm-svn: 360940
* [lld-link] Add missing "REQUIRES: x86" to COFF/lib-module-asm.ll test.Yvan Roux2019-05-161-0/+1
| | | | | | This should fix ARM bots. llvm-svn: 360875
* Add missing "REQUIRES: x86" to the lto/irmover-warning.ll test.Igor Kudrin2019-05-161-0/+1
| | | | llvm-svn: 360866
* [LTO] Improve readability of module IDsIgor Kudrin2019-05-162-0/+32
| | | | | | | | | Module IDs can appear in diagnostic messages. This patch adds some auxiliary symbols to improve their readability. Differential Revision: https://reviews.llvm.org/D61857 llvm-svn: 360858
* [lld] Remove 2>&1 from --trace-symbol testsSam Clegg2019-05-152-13/+13
| | | | | | | | | | | | | The tracing goes to stdout so this is not needed. Also remove the "not" from the final check in ELF/trace-symbols.s. According the comment the check is that we don't crash, so we should be checking for success here. Previously this step is error'ing with undefined symbols because it didn't include all the needed objects. Differential Revision: https://reviews.llvm.org/D61928 llvm-svn: 360794
* [WebAssembly] LTO: Honor comdat groups when loading bitcode filesSam Clegg2019-05-151-0/+15
| | | | | | | | | But don't apply comdat groups when loading the LTO object files. This is basically the same logic used by the ELF linker. Differential Revision: https://reviews.llvm.org/D61924 llvm-svn: 360782
* [LLD][ELF] Add the -z ifunc-noplt optionFangrui Song2019-05-143-0/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by Mark Johnston! Summary: When the option is configured, ifunc calls do not go through the PLT; rather, they appear as regular function calls with relocations referencing the ifunc symbol, and the resolver is invoked when applying the relocation. This is intended for use in freestanding environments where text relocations are permissible and is incompatible with the -z text option. The option is motivated by ifunc usage in the FreeBSD kernel, where ifuncs are used to elide CPU feature flag bit checks in hot paths. Instead of replacing the cost of a branch with that of an indirect function call, the -z ifunc-noplt option is used to ensure that ifunc calls carry no hidden overhead relative to normal function calls. Test Plan: I added a couple of regression tests and tested the FreeBSD kernel build using the latest lld sources. To demonstrate the effects of the change, I used a micro-benchmark which results in frequent invocations of a FreeBSD kernel ifunc. The benchmark was run with and without IBRS enabled, and with and without -zifunc-noplt configured. The observed speedup is small and consistent, and is significantly larger with IBRS enabled: https://people.freebsd.org/~markj/ifunc-noplt/noibrs.txt https://people.freebsd.org/~markj/ifunc-noplt/ibrs.txt Reviewed By: ruiu, MaskRay Differential Revision: https://reviews.llvm.org/D61613 llvm-svn: 360685
* [ELF] --gdb-index: fix SIGSEGV when a DWARFAddressRange has invalid SectionIndexFangrui Song2019-05-141-0/+140
| | | | | | | | | | See D61891: llvm had a bug that might create invalid (DW_AT_low_pc,DW_AT_high_pc) pairs or range list entries due to missing DW_AT_addr_base. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D61889 llvm-svn: 360679
* [ELF] Full support for -n (--nmagic) and -N (--omagic) via common pagePeter Smith2019-05-135-3/+441
| | | | | | | | | | | | | | | | | | | | | | The -n (--nmagic) disables page alignment, and acts as a -Bstatic The -N (--omagic) does what -n does but also marks the executable segment as writeable. As page alignment is disabled headers are not allocated unless explicit in the linker script. To disable page alignment in LLD we choose to set the page sizes to 1 so that any alignment based on the page size does nothing. To set the Target->PageSize to 1 we implement -z common-page-size, which has the side effect of allowing the user to set the value as well. Setting the page alignments to 1 does mean that any use of CONSTANT(MAXPAGESIZE) or CONSTANT(COMMONPAGESIZE) in a linker script will return 1, unlike in ld.bfd. However given that -n and -N disable paging these probably shouldn't be used in a linker script where -n or -N is in use. Differential Revision: https://reviews.llvm.org/D61688 llvm-svn: 360593
* [COFF] Update LLD yaml test cases to include .bss sizeReid Kleckner2019-05-106-3/+7
| | | | | | | | | | | | | | These yaml test cases appear to have been affected by PR41836 Right now what happens is that these empty .bss sections are merged into .data, then the .data output section ends up having a zero virtual size, and it is discarded from the output after addresses are assigned. However, we've already assigned OutputSections to Chunks, so we don't correctly report the zero-sized chunks that were in there as having been discarded. Soon, we will report them as discarded, so these test cases need to be updated to have a non-zero size so they aren't discarded. llvm-svn: 360476
* [llvm-objdump] Print st_otherFangrui Song2019-05-103-6/+6
| | | | | | | | | | | Add support for ".hidden" ".internal" ".protected" and " 0x%02x" for other st_other bits used by some architectures. Reviewed By: sfertile Differential Revision: https://reviews.llvm.org/D61718 llvm-svn: 360439
* [PPC64] Define getThunkSectionSpacing() based on the range of R_PPC64_REL24Fangrui Song2019-05-108-59/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Suggested by Sean Fertile and Peter Smith. Thunk section spacing decrease the total number of thunks. I measured a decrease of 1% or less in some large programs, with no perceivable slowdown in link time. Override getThunkSectionSpacing() to enable it. 0x2000000 is the farthest point R_PPC64_REL24 can reach. I tried several numbers and found 0x2000000 works the best. Numbers near 0x2000000 work as well but let's just use the simpler number. As demonstrated by the updated tests, this essentially changes placement of most thunks to the end of the output section. We leverage this property to fix PR40740 reported by Alfredo Dal'Ava Júnior: The output section .init consists of input sections from several object files (crti.o crtbegin.o crtend.o crtn.o). Sections other than the last one do not have a terminator. With this patch, we create the thunk after the last .init input section and thus fix the issue. This is not foolproof but works quite well for such sections (with no terminator) in practice. Reviewed By: ruiu, sfertile Differential Revision: https://reviews.llvm.org/D61720 llvm-svn: 360405
* [WebAssembly] Don't assume that strongly defined symbols are DSO-localSam Clegg2019-05-102-9/+14
| | | | | | | | | | | | | | | | The current PIC model for WebAssembly is more like ELF in that it allows symbol interposition. This means that more functions end up being addressed via the GOT and fewer directly added to the wasm table. One effect is a reduction in the number of wasm table entries similar to the previous attempt in https://reviews.llvm.org/D61539 which was reverted. Differential Revision: https://reviews.llvm.org/D61772 llvm-svn: 360402
* Revert "[WebAssembly] Don't generate unused table entries."Sam Clegg2019-05-092-6/+6
| | | | | | | | This reverts commit b33fdb7768e5de5fbeb23f65d8d455e7ca88b021. This change apparently broke am emscripten test. llvm-svn: 360367
* [ELF] Initialize Target before it may be dereferenced by findAux when ↵Fangrui Song2019-05-091-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | reporting "duplicate symbol" error for (InputFile *F : Files) Symtab->addFile<ELFT>(F); // if there is a duplicate symbol error ... Target = getTarget(); When parsing .debug_info in the object file (for better diagnostics), DWARF.cpp findAux may dereference the null pointer Target auto *DR = dyn_cast<Defined>(&File->getRelocTargetSym(Rel)); if (!DR) { // Broken debug info may point to a non-defined symbol, // some asan object files may also contain R_X86_64_NONE RelType Type = Rel.getType(Config->IsMips64EL); if (Type != Target->NoneRel) /// Target is null Move the assignment of Target to an earlier place to fix this. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D61712 llvm-svn: 360305
* [lld-link] initialize targets and asmparsers before invoking libBob Haarman2019-05-081-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | Summary: When using lld-link to build static libraries containing object files with module assembly, the program would crash with "Assertion `T && T->hasMCAsmParser()' failed". This change causes the code in lld-link that initialized Targets, TargetInfos, and AsmParsers (which already existed) to be run before entering the lib building path (which needs it). This avoids the error (and is what llvm-lib and llvm-ar do, too). Fixes PR41803. Reviewers: ruiu, rnk, hans Reviewed By: ruiu Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61699 llvm-svn: 360295
* [mips] Fix ld instruction in PLT entries on MIPS64Simon Atanasyan2019-05-071-3/+2
| | | | | | | | | | | Use `ld` and `daddiu` instructions in MIPS64 PLT records. That fixes a segmentation fault. Patch by Qiao Pengcheng. Differential Revision: https://reviews.llvm.org/D61586 llvm-svn: 360187
* [mips] Rename test case. NFCSimon Atanasyan2019-05-071-0/+0
| | | | | | | This test case checks MIPS PLT records for N64 ABI. For the N32 ABI case there is a separate test case `mips-plt-n32.s`. llvm-svn: 360186
* [WebAssembly] Don't generate unused table entries.Sam Clegg2019-05-072-6/+6
| | | | | | | | | | | | | | When generating PIC output only relocations of type R_WASM_TABLE_INDEX_REL_SLEB should generate table entries. R_WASM_TABLE_INDEX_I32 get resolved at runtime via the auto-generated __wasm_apply_relocs functions. R_WASM_TABLE_INDEX_SLEB are not allowed in PIC code. Differential Revision: https://reviews.llvm.org/D61539 llvm-svn: 360165
* Add typo correction for command-line flags to ELF and COFF lld driversNico Weber2019-05-076-7/+18
| | | | | | | | | | | | For lld-link, unknown '/'-style flags are treated as filenames on POSIX systems, so only '-'-style flags get typo correction for now. This matches clang-cl. PR37006. Differential Revision: https://reviews.llvm.org/D61443 llvm-svn: 360145
* [LLD][ELF] - Remove symbol-name-offset.elf binary from test cases.George Rimar2019-05-073-7/+15
| | | | | | | It was possible to convert the test case to YAML test. After that, we have only one binary test left in LLD/ELF. llvm-svn: 360139
* [PPC64] toc-indirect to toc-relative relaxationFangrui Song2019-05-078-133/+273
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is based on D54720 by Sean Fertile. When accessing a global symbol which is not defined in the translation unit, compilers will generate instructions that load the address from the toc entry. If the symbol is defined, non-preemptable, and addressable with a 32-bit signed offset from the toc pointer, the address can be computed directly. e.g. addis 3, 2, .LC0@toc@ha # R_PPC64_TOC16_HA ld 3, .LC0@toc@l(3) # R_PPC64_TOC16_LO_DS, load the address from a .toc entry ld/lwa 3, 0(3) # load the value from the address .section .toc,"aw",@progbits .LC0: .tc var[TC],var can be relaxed to addis 3,2,var@toc@ha # this may be relaxed to a nop, addi 3,3,var@toc@l # then this becomes addi 3,2,var@toc ld/lwa 3, 0(3) # load the value from the address We can delete the test ppc64-got-indirect.s as its purpose is covered by newly added ppc64-toc-relax.s and ppc64-toc-relax-constants.s Reviewed By: ruiu, sfertile Differential Revision: https://reviews.llvm.org/D60958 llvm-svn: 360112
* [WebAssembly] Add more test coverage for reloctions against section symbolsSam Clegg2019-05-071-0/+51
| | | | | | | | | | | | | The only known user of this relocation type and symbol type is the debug info sections, but we were not testing the `--relocatable` output path. This change adds a minimal test case to cover relocations against section symbols includes `--relocatable` output. Differential Revision: https://reviews.llvm.org/D61623 llvm-svn: 360110
* [AMDGPU][test] Define local symbols used in amdgpu-relocs.sFangrui Song2019-05-061-7/+19
| | | | | | Differential Revision: https://reviews.llvm.org/D61594 llvm-svn: 360046
* [lld] A better version of the fix in r359942.Alexander Kornienko2019-05-061-1/+1
| | | | | | Thanks to George Rimar for the suggestion. llvm-svn: 360040
* [lld] Specify output file explicitlyAlexander Kornienko2019-05-031-1/+1
| | | | | | | The test shouldn't try to create `a.out` in the current directory, which can be read-only (and it is in our test setup). llvm-svn: 359942
* [ELF] Place SHT_NOTE sections with the same alignment into one PT_NOTEFangrui Song2019-05-032-3/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: While the generic ABI requires notes to be 8-byte aligned in ELF64, many vendor-specific notes (from Linux, NetBSD, Solaris, etc) use 4-byte alignment. In a PT_NOTE segment, if 4-byte aligned notes are followed by an 8-byte aligned note, the possible 4-byte padding may make consumers fail to parse the 8-byte aligned note. See PR41000 for a recent report about .note.gnu.property (NT_GNU_PROPERTY_TYPE_0). (Note, for NT_GNU_PROPERTY_TYPE_0, the consumers should probably migrate to PT_GNU_PROPERTY, but the alignment issue affects other notes as well.) To fix the issue, don't mix notes with different alignments in one PT_NOTE. If compilers emit 4-byte aligned notes before 8-byte aligned notes, we'll create at most 2 segments. sh_size%sh_addralign=0 is actually implied by the rule for linking unrecognized sections (in generic ABI), so we don't have to check that. Notes that match in name, type and attribute flags are concatenated into a single output section. The compilers have to ensure sh_size%sh_addralign=0 to make concatenated notes parsable. An alternative approach is to create a PT_NOTE for each SHT_NOTE, but we'll have to incur the sizeof(Elf64_Phdr)=56 overhead every time a new note section is introduced. Reviewers: ruiu, jakehehrlich, phosek, jhenderson, pcc, espindola Subscribers: emaste, arichardson, krytarowski, fedor.sergeev, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61296 llvm-svn: 359853
* lld-link: Add /force:multipleres extension to make dupe resource diag non-fatalNico Weber2019-05-022-0/+21
| | | | | | | As a side benefit, lld-link now reports more than one duplicate resource entry before exiting with an error even if the new flag is not passed. llvm-svn: 359829
* [ELF] --plugin-opt=thinlto-index-only: create empty index files even if all ↵Fangrui Song2019-05-021-0/+6
| | | | | | | | | | | | | | | | | | | bitcode files are lazy Summary: The gold plugin behavior (creating empty index files for lazy bitcode files) was added in D46034, but it missed the case when there is no non-lazy bitcode files, e.g. ld.lld -shared crti.o crtbeginS.o --start-lib bitcode.o --end-lib ... crti.o crtbeginS.o are not bitcode, but our distributed build system wants bitcode.o.thinlto.bc to confirm all expected outputs are created based on all of the modules provided to the linker. Differential Revision: https://reviews.llvm.org/D61420 llvm-svn: 359788
* [ELF] Delete a cant-write test from test/lto/thinlto-index-only.llFangrui Song2019-05-021-10/+0
| | | | | | The test is performed by thinlto-cant-write-index.ll llvm-svn: 359769
* Delete trailing \r. NFCFangrui Song2019-05-027-398/+398
| | | | llvm-svn: 359745
* [LLD] Emit dynamic relocations for references to script symbols in -pie linksBen Dunbobbin2019-05-011-0/+19
| | | | | | | | | | https://reviews.llvm.org/D55423 caused LLD to stop emitting dynamic relocations for references to script symbols in -pie links. This patch fixes that regression. https://reviews.llvm.org/D61298 llvm-svn: 359683
* [llvm-objdump] Print newlines before and after "Disassembly of section ...:"Fangrui Song2019-05-01171-23/+395
| | | | | | | | | | | This improves readability and the behavior is consistent with GNU objdump. The new test test/tools/llvm-objdump/X86/disassemble-section-name.s checks we print newlines before and after "Disassembly of section ...:" Differential Revision: https://reviews.llvm.org/D61127 llvm-svn: 359668
* [llvm-readobj] llvm-readobj --elf-output-style=GNU => llvm-readelfFangrui Song2019-05-0120-27/+27
| | | | | | | While updating the test, change -l -S to -S -l as the output of -S goes before -l. llvm-svn: 359653
* [test] Change llvm-readobj -long-option to --long-option or well-known short ↵Fangrui Song2019-05-01597-1016/+1016
| | | | | | | | | | | | options. NFC Also change some options that have different semantics (cause confusion) in llvm-readelf mode: -s => -S -t => --symbols -sd => --section-data llvm-svn: 359651
* [LLD][ELF] /DISCARD/ output sections should not be orphansAndrew Ng2019-04-301-0/+36
| | | | | | | | | | /DISCARD/ output sections were being treated as orphans. As a result, if a /DISCARD/ output section has been assigned a PHDR, it could cause incorrect assignment of sections to segments. Differential Revision: https://reviews.llvm.org/D61186 llvm-svn: 359565
* [LLD][ELF] Fix getRankProximity to "ignore" not live sectionsAndrew Ng2019-04-301-0/+42
| | | | | | | | | | This is a follow up to r358979 which made findOrphanPos only consider live sections. Unfortunately, this required change to getRankProximity, used by findOrphanPos, was missed. Differential Revision: https://reviews.llvm.org/D61197 llvm-svn: 359554
* [LLD][ELF] - Do not remove empty sections referenced in LOADADDR/ADDR commands.George Rimar2019-04-261-0/+24
| | | | | | | | | | | | | | | This is https://bugs.llvm.org//show_bug.cgi?id=38750. If script references empty sections in LOADADDR/ADDR commands .empty : { *(.empty ) } .text : AT(LOADADDR (.empty) + SIZEOF (.empty)) { *(.text) } then an empty section will be removed and LOADADDR/ADDR will evaluate to null. It is not that user may expect from using of the generic script, what is a common case. Differential revision: https://reviews.llvm.org/D54621 llvm-svn: 359279
* [WebAssembly] Always take into account added when applying runtime relocationsSam Clegg2019-04-251-3/+14
| | | | | | | | | | | The code we generate for applying data relocations at runtime omitted the symbols with GOT entries. Also refactor the code to reduce duplication. Differential Revision: https://reviews.llvm.org/D61111 llvm-svn: 359207
* [LLD][ELF] - Convert symbol-index.s testcase to a YAML test case. NFCI.George Rimar2019-04-253-10/+25
| | | | | | | | | | | | | | | This removes one more binary object from the inputs and fixes the test case description. Previously it said that: "symbol-index.elf has incorrect type of .symtab section. There is no symbol bodies because of that and any symbol index becomes incorrect." But the real reason of the failture was not the incorrect type of a symbol table, but invalid index of the symbol used in a relocation, what happened because previous test tried to read .symtab as a SHT_RELA section. llvm-svn: 359197
* [LLD][ELF] - Move the test to a correct folder, remove excessive input. NFCI.George Rimar2019-04-253-50/+51
| | | | | | | | | This test should live in `invalid` folder. Also it was possible to avoid adding input with use of `-docnum=x` yaml2obj argument. llvm-svn: 359194
* lld-link: Implement /swaprun: flagNico Weber2019-04-251-0/+40
| | | | | | | | | | | | | | | | r191276 added this to old LLD, but it never made it to new LLD -- except that the flag was in Options.td, so it was silently ignored. I figured it should be easy to implement, so I did that instead of removing the flags from Options.td. I then discovered that link.exe also supports comma-separated lists of 'cd' and 'net', which made the parsing code a bit annoying. The Alias technique in Options.td is to get nice help output. Differential Revision: https://reviews.llvm.org/D61067 llvm-svn: 359192
* llvm-cvtres: Make new dupe resource error a bit friendlierNico Weber2019-04-242-2/+2
| | | | | | | | | | | | For well-known type IDs, include the name of the type. To not duplicate the ID->name map, make llvm-readobj call this new function as well. It has slightly different output, so this also requires updating a few tests. Differential Revision: https://reviews.llvm.org/D61086 llvm-svn: 359153
* [COFF] Don't emit .gfids sections when CFG is offReid Kleckner2019-04-241-0/+10
| | | | | | | Put them on the list of GuardFidChunks instead of the main Chunks list, even with CFG is off. It will be ignored if CFG is disabled. llvm-svn: 359137
* [PPC64] Consider localentry offset when computing branch distanceFangrui Song2019-04-241-0/+30
| | | | | | | | | | | | | | | Summary: We don't take localentry offset into account, and thus may fail to create a long branch when the gap is just a few bytes smaller than 2^25. relocation R_PPC64_REL24 out of range: 33554432 is not in [-33554432, 33554431] relocation R_PPC64_REL24 out of range: 33554436 is not in [-33554432, 33554431] Fix that by adding the offset to the symbol VA. Differential Revision: https://reviews.llvm.org/D61058 llvm-svn: 359094
* [LLD][ELF] - Remove binding.elf binary from test case. NFCI.George Rimar2019-04-243-7/+21
| | | | | | This introduces YAML based invalid-binding.test instead. llvm-svn: 359086
* [LLD][ELD] - Remove excessive lines from test. NFC.George Rimar2019-04-241-5/+0
| | | | | | They are not used. llvm-svn: 359084
* [WebAssembly] Fix typo in relocation checkingSam Clegg2019-04-231-0/+53
| | | | | | | | | | | Runtime relocation are generated for relocations of type R_WASM_MEMORY_ADDR_I32 when in PIC mode (either -shared or -pie). Followup on https://reviews.llvm.org/D60882. Differential Revision: https://reviews.llvm.org/D60992 llvm-svn: 358995
* [LLD][ELF] - Remove dynamic-section-sh_size.elf binary, convert test to ↵George Rimar2019-04-233-4/+36
| | | | | | | | | | | | | yaml. NFCI. dynamic-section-sh_size.elf was introduced in D25090. Now it is possible to use yaml2obj instead. That is what this patch does. Also I added one more case of a possibly broken .dynamic section just in case. llvm-svn: 358990
* [LLD][ELF] - Remove file-class.a binary from inputs and improve the test case.George Rimar2019-04-233-4/+19
| | | | | | | | | | | | | file-class.a was used to diagnose the "corrupted ELF file: invalid file class" error when the object was fetched from the archive. file-class.a contained an object of 16 bytes size. I replaced it with an echo call (because it is impossible to use yaml2obj for that, and I am not sure it is worth to support), and also increased its size to 18 bytes. That allowed to also test a case when such object is a regular input and not an archive member (we have a bit different logic for these cases). llvm-svn: 358985
OpenPOWER on IntegriCloud