summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] --gdb-index: fix SIGSEGV when a DWARFAddressRange has invalid SectionIndexFangrui Song2019-05-142-0/+142
| | | | | | | | | | 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
* Move SymbolTable::addFile to InputFiles.cpp.Rui Ueyama2019-05-145-86/+95
| | | | | | | | | | | | | | | | | The symbol table used to be a container of vectors of input files, but that's no longer the case because the vectors are moved out of SymbolTable and are now global variables. Therefore, addFile doesn't have to belong to any class. This patch moves the function out of the class. This patch is a preparation for my RFC [1]. [1] http://lists.llvm.org/pipermail/llvm-dev/2019-April/131902.html Differential Revision: https://reviews.llvm.org/D61854 llvm-svn: 360666
* [Object] Change ObjectFile::getSectionContents to return ↵Fangrui Song2019-05-143-3/+4
| | | | | | | | | | | | | | | | | | | Expected<ArrayRef<uint8_t>> Change std::error_code getSectionContents(DataRefImpl, StringRef &) const; to Expected<ArrayRef<uint8_t>> getSectionContents(DataRefImpl) const; Many object formats use ArrayRef<uint8_t> as the underlying type, which is generally better than StringRef to represent binary data, so change the type to decrease the number of type conversions. Reviewed By: ruiu, sbc100 Differential Revision: https://reviews.llvm.org/D61781 llvm-svn: 360648
* [WebAssembly] Refactor relocation processing. NFC.Sam Clegg2019-05-131-19/+17
| | | | | | | | | This is the remaining NFC part of https://reviews.llvm.org/D61539 which was reverted. Differential Revision: https://reviews.llvm.org/D61800 llvm-svn: 360598
* [ELF] Full support for -n (--nmagic) and -N (--omagic) via common pagePeter Smith2019-05-1314-22/+515
| | | | | | | | | | | | | | | | | | | | | | 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-109-59/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-104-12/+23
| | | | | | | | | | | | | | | | 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
* [COFF] Simplify Chunk::writeTo and remove OutputSectionOff, NFCReid Kleckner2019-05-095-83/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Prior to this change, every implementation of writeTo would add OutputSectionOff to the output section buffer start before writing data. Instead, do this math in the caller, so that it can be written once instead of many times. The output section offset is always equivalent to the difference between the chunk RVA and the output section RVA, so we can replace the one remaining usage of OutputSectionOff with that subtraction. This doesn't change the size of SectionChunk because of alignment requirements, but I will rearrange the fields in a follow-up change to accomplish that. Reviewers: ruiu, aganea Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61696 llvm-svn: 360376
* Revert "[WebAssembly] Don't generate unused table entries."Sam Clegg2019-05-094-28/+26
| | | | | | | | This reverts commit b33fdb7768e5de5fbeb23f65d8d455e7ca88b021. This change apparently broke am emscripten test. llvm-svn: 360367
* [LLD][NFC] Refactor: BuildID hash size now computed in one place.Ben Dunbobbin2019-05-092-25/+19
| | | | | | Differential Revision: https://reviews.llvm.org/D61078 llvm-svn: 360316
* [ELF] Initialize Target before it may be dereferenced by findAux when ↵Fangrui Song2019-05-092-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-082-7/+28
| | | | | | | | | | | | | | | | | | | | | | | | 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
* [WebAssembly] Handle command line options consistently with the ELF backend.Sam Clegg2019-05-084-22/+34
| | | | | | Differential Revision: https://reviews.llvm.org/D61645 llvm-svn: 360266
* [COFF] Store Chunk RVAs and section offsets as uint32_tReid Kleckner2019-05-072-9/+15
| | | | | | | Saves 8 bytes on SectionChunk, one of the most commonly allocated data structures. llvm-svn: 360188
* [mips] Fix ld instruction in PLT entries on MIPS64Simon Atanasyan2019-05-072-5/+6
| | | | | | | | | | | 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-074-26/+28
| | | | | | | | | | | | | | 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
* lld-link: Allow /? as option prefix, like -? is allowedNico Weber2019-05-071-9/+12
| | | | | | | | | | link.exe seems to allow `/?foo` and `-?foo` in addition to `/foo` and `-foo`. Since lld-link already supports the `-?foo` spelling, support `/?foo` as well. Differential Revision: https://reviews.llvm.org/D61375 llvm-svn: 360150
* Add typo correction for command-line flags to ELF and COFF lld driversNico Weber2019-05-078-11/+34
| | | | | | | | | | | | 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
* [ELF] Reorder BitcodeFiles.empty() to call thinLTOCreateEmptyIndexFiles() in ↵Fangrui Song2019-05-073-15/+8
| | | | | | | | | | | | | | | | | only one place It makes the --plugin-opt=obj-path= and --plugin-opt=thinlto-index-only= behavior more consistent - the files will be created in the BitcodeFiles.empty() case, but I assume whether it behaves this way is not required by anyone. LTOObj->run() cannot run with empty BitcodeFiles. There would be an error: ld.lld: error: No available targets are compatible with triple "" Differential Revision: https://reviews.llvm.org/D61635 llvm-svn: 360129
* [PPC64] toc-indirect to toc-relative relaxationFangrui Song2019-05-0715-147/+403
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Shrink SectionChunk by combining Relocs and SectionName sizesReid Kleckner2019-05-036-34/+60
| | | | | | | | | | | | | | | | | SectionChunk is one of the most frequently allocated data structures in LLD, since there are about four per function when optimizations and debug info are enabled (.text, .pdata, .xdata, .debug$S). A PE COFF file cannot be larger than 2GB, so there is an inherent limit on the length of the section name and the number of relocations. Decompose the ArrayRef and StringRef into pointer and size, and put them back together in the accessors for section name and relocation list. I plan to gather complete performance numbers later by padding SectionChunk with dead data and measuring performance after all the size optimizations are done. llvm-svn: 359923
* [ELF] Place SHT_NOTE sections with the same alignment into one PT_NOTEFangrui Song2019-05-033-5/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-027-1/+38
| | | | | | | 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-024-19/+31
| | | | | | | | | | | | | | | | | | | 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
* [Object] Change getSectionName() to return Expected<StringRef>Fangrui Song2019-05-022-4/+8
| | | | | | | | | | Summary: It currently receives an output parameter and returns std::error_code. Expected<StringRef> fits for this purpose perfectly. Differential Revision: https://reviews.llvm.org/D61421 llvm-svn: 359774
* [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
* lld-link: Make "duplicate resource" error message a bit more conciseNico Weber2019-05-021-1/+1
| | | | | | | | | | | | | | | | Reduces the error message from: lld-link: error: failed to parse .res file: duplicate resource: type STRINGTABLE (ID 6)/name ID 3/language 1033, in test1.res and in test2.res To: lld-link: error: duplicate resource: type STRINGTABLE (ID 6)/name ID 3/language 1033, in test1.res and in test2.res Make sure every error message emitted by cvtres contains the name of at least one ".res" file, so that removing the "failed to parse .res file" string doesn't lose information. Differential Revision: https://reviews.llvm.org/D61388 llvm-svn: 359749
* 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-012-5/+24
| | | | | | | | | | 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-302-0/+37
| | | | | | | | | | /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-302-3/+44
| | | | | | | | | | 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
* Add more lld release notesNico Weber2019-04-291-0/+3
| | | | llvm-svn: 359518
* Add some lld-link 9.0 release notesNico Weber2019-04-291-0/+11
| | | | llvm-svn: 359412
* [LLD][ELF] - Do not remove empty sections referenced in LOADADDR/ADDR commands.George Rimar2019-04-264-3/+36
| | | | | | | | | | | | | | | 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
* [ELF] Change std::max<uint64_t> to uint32_t for section alignmentFangrui Song2019-04-261-3/+3
| | | | | | | | | | | | | Summary: We use `uint32_t SectionBase::Alignment` and `uint32_t PhdrEntry::p_align` despite alignments being 64 bits in ELF64. Fix the std::max template arguments accordingly. The currently 160-byte InputSection will become 168 bytes if we make SectionBase::Alignment uint64_t. Differential Revision: https://reviews.llvm.org/D61171 llvm-svn: 359268
* [WebAssembly] Always take into account added when applying runtime relocationsSam Clegg2019-04-253-29/+42
| | | | | | | | | | | 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-257-2/+78
| | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud