summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* [WebAssembly] Fix signatures of undefined function in LTO object which are ↵Sam Clegg2019-05-292-10/+28
| | | | | | | | | | | | | not called directly. We recently added special handling for function that are not called directly but failed to add testing for the LTO case. See https://reviews.llvm.org/D62153 Differential Revision: https://reviews.llvm.org/D62561 llvm-svn: 361975
* ELF: Don't reuse a thunk in a different loadable partition.Peter Collingbourne2019-05-293-5/+62
| | | | | | | | | There's no guarantee that the other partition will be loaded, so it can't be reused. Differential Revision: https://reviews.llvm.org/D62365 llvm-svn: 361926
* ELF: Add basic partition data structures and behaviours.Peter Collingbourne2019-05-2918-70/+387
| | | | | | | | | | | | | | This change causes us to read partition specifications from partition specification sections and split output sections into partitions according to their reachability from partition entry points. This is only the first step towards a full implementation of partitions. Later changes will add additional synthetic sections to each partition so that they can be loaded independently. Differential Revision: https://reviews.llvm.org/D60353 llvm-svn: 361925
* Add IR support, ELF section and user documentation for partitioning feature.Peter Collingbourne2019-05-294-0/+250
| | | | | | | | | | | | The partitioning feature was proposed here: http://lists.llvm.org/pipermail/llvm-dev/2019-February/130583.html This is mostly just documentation. The feature itself will be contributed in subsequent patches. Differential Revision: https://reviews.llvm.org/D60242 llvm-svn: 361923
* [ELF] Implement General Dynamic style TLSDESC for x86-64Fangrui Song2019-05-296-41/+172
| | | | | | | | | | | This handles two initial relocation types R_X86_64_GOTPC32_TLSDESC and R_X86_64_TLSDESC_CALL, as well as the GD->LE and GD->IE relaxations. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D62513 llvm-svn: 361911
* Revert r361842 as it breaks LLDB :: tools/lldb-mi/exec/exec-finish.testAlexandre Ganea2019-05-287-235/+141
| | | | llvm-svn: 361876
* [COFF] Add ImportChunkThunk, simplify, deduplicateReid Kleckner2019-05-282-48/+32
| | | | | | | | | | | Removes the isHotPatchable faux-virtual and virtual methods. Follow-up to D62362. Reviewers: aganea Differential Revision: https://reviews.llvm.org/D62422 llvm-svn: 361851
* [LLD][COFF] Early load PDB type server filesAlexandre Ganea2019-05-287-141/+235
| | | | | | | | | | We need to have all input files ready before doing debuginfo type merging. This patch is moving the late PDB type server discovery much earlier in the process, when the explicit inputs (OBJs, LIBs) are loaded. The short term goal is to parallelize type merging. Differential Revision: https://reviews.llvm.org/D60095 llvm-svn: 361842
* Fix 'warning: comparison is always true due to limited range of data type ↵Alexandre Ganea2019-05-281-1/+1
| | | | | | [-Wtype-limits]' with GCC 7.3 llvm-svn: 361840
* Reland D61583 [ELF] Error on relocations to STT_SECTION symbols if the ↵Fangrui Song2019-05-2810-12/+100
| | | | | | | | | | | | | | | | | | | | | | | | | sections were discarded This is implemented by creating Undefined (instead of Defined) for such local STT_SECTION symbols. It allows us to catch errors when there are relocations to such discarded sections (e.g. in PR41693, ld.bfd and gold error but we don't). Updated comdat-discarded-error.s checks we emit friendly error message. For relocatable-eh-frame.s, ld.lld -r a.o a.o will now error "STT_SECTION symbol should be defined" because the section .eh_frame refers to is now an Undefined instead of a Defined. So I have to change `error()` to `warn()` to retain the output. rLLD361144 inadvertently enabled the error for --gdb-index (in LLDDwarfObj<ELFT>::findAux()). Relocations from .debug_info (not in comdat) to .text.* (in comdat) for DW_AT_low_pc are common. If an .text.* was discarded, rLLD361144 would error, which was unexpected. (Note, if we don't error as this patch does, InputSection::relocateNonAlloc() will resolve such relocations). llvm-svn: 361830
* Add release note entries for recent typo correction changesNico Weber2019-05-281-0/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D62523 llvm-svn: 361824
* Revert [ELF] Error on relocations to STT_SECTION symbols if the sections ↵Haojian Wu2019-05-288-33/+11
| | | | | | | | | | were discarded This reverts r361792 (git commit cfca5095df0209c60109696d6cc368d49e2c5939), the revision causes link errors internally, will share more details with the author. llvm-svn: 361806
* [ELF] Replace two addSymbol() call sites with Symbol::resolve(). NFCFangrui Song2019-05-281-6/+5
| | | | | | | If we have a handle of the symbol, insert() called by addSymbol() is redundant. Just call resolve(). llvm-svn: 361802
* [ELF] Error on relocations to STT_SECTION symbols if the sections were discardedFangrui Song2019-05-288-11/+33
| | | | | | | | | | | | | | | | | | | This is implemented by creating Undefined (instead of Defined) for such local STT_SECTION symbols. It allows us to catch errors when there are relocations to such discarded sections (e.g. in PR41693, ld.bfd and gold error but we don't). Updated comdat-discarded-error.s checks we emit friendly error message. For relocatable-eh-frame.s, ld.lld -r a.o a.o will now error "STT_SECTION symbol should be defined" because the section .eh_frame refers to is now an Undefined instead of a Defined. So I have to change `error()` to `warn()` to retain the output. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D61583 llvm-svn: 361792
* Use SymbolTable::insert() to implement --trace.Rui Ueyama2019-05-286-41/+40
| | | | | | Differential Revision: https://reviews.llvm.org/D62381 llvm-svn: 361791
* Merge ELFFileBase::{initSymtab,parseHeader} as ELFFileBase:init. NFC.Rui Ueyama2019-05-282-78/+70
| | | | | | | | This patch simplifies ELFFile instance initialization by merging two similar functions into a single function and call it from the ctor. llvm-svn: 361789
* Remove elf::createSharedFile and move its code to SharedFile's ctor. NFC.Rui Ueyama2019-05-273-54/+49
| | | | llvm-svn: 361747
* [WebAssembly] Relax signature checking for undefined functions that are not ↵Sam Clegg2019-05-247-21/+65
| | | | | | | | | | | | | | | | | | | | | | | | | called directly When function signatures don't match and the undefined function is not called directly (i.e. only has its address taken) we don't issue a warning or create a runtime thunk for the undefined function. Instead in this case we simply use the defined version of the function. This is possible since checking signatures of dynamic calls happens at runtime so any invalid usage will still result in a runtime error. This is needed to allow C++ programs to link without generating warnings. Its not uncommon in C++ for vtables to be populated by function address whee the signature of the function is not known in the compilation unit. In this case clang declares the method as void(void) and relies on the vtable caller casting the data back to the correct signature. Fixes: https://bugs.llvm.org/show_bug.cgi?id=40412 Differential Revision: https://reviews.llvm.org/D62153 llvm-svn: 361678
* [COFF] De-virtualize Chunk and SectionChunkReid Kleckner2019-05-244-71/+169
| | | | | | | | | | | | | | | | Shaves another pointer off of SectionChunk, reducing the size from 96 to 88 bytes, down from 144 before I started working on this. Combined with D62356, this reduced peak memory usage when linking chrome_child.dll from 713MB to 675MB, or 5%. Create NonSectionChunk to provide virtual dispatch to the rest of the chunk types. Reviewers: ruiu, aganea Differential Revision: https://reviews.llvm.org/D62362 llvm-svn: 361667
* [COFF] Replace OutputSection* with uint16_t index in ChunkReid Kleckner2019-05-245-23/+46
| | | | | | | | | | | | | | Shaves another 8 bytes off of SectionChunk, the most commonly allocated type in LLD. These indices are only valid after we've assigned chunks to output sections and removed empty sections, so do that in a new pass. Reviewers: ruiu, aganea Differential Revision: https://reviews.llvm.org/D62356 llvm-svn: 361657
* [WebAssebmly] Add support for --wrapSam Clegg2019-05-2411-11/+172
| | | | | | | | | | | The code for implementing this features is taken almost verbatim from the ELF backend. Fixes: https://bugs.llvm.org/show_bug.cgi?id=41681 Differential Revision: https://reviews.llvm.org/D62380 llvm-svn: 361639
* [lld] Trace all references with lld --trace-symbolSam Clegg2019-05-247-13/+40
| | | | | | | | | | | Previously undefined symbol references were only traced if they were seen before that definition. Fixes https://bugs.llvm.org/show_bug.cgi?id=41878 Differential Revision: https://reviews.llvm.org/D61929 llvm-svn: 361636
* [WebAssembly] Add support for -emit-relocsSam Clegg2019-05-246-6/+51
| | | | | | | | | | This can be useful for post-link tools and for testing. Sometimes it can be useful to produces a regular executable but with relocations preserved. Differential Revision: https://reviews.llvm.org/D62378 llvm-svn: 361635
* [LLD][COFF] Implement /filealign parameterRui Ueyama2019-05-245-6/+65
| | | | | | | | | | | | | | Patch by Stefan Schmidt. This adds the /filealign parameter to lld, which allows to specify the section alignment in the output file (as it does on Microsoft's link.exe). This is required to be able to load dynamically linked libraries on the original Xbox, where the debugger monitor expects the section alignment in the file to be the same as in memory. llvm-svn: 361634
* [llvm-readobj] Implement GNU-style output for dynamic tableSimon Atanasyan2019-05-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | GNU readelf tool prints slightly different dynamic table "header" and surrounds dynamic tag names by brackets. This patch implements the same formatting for GNU-style output of the `llvm-readobj`. LLVM ``` DynamicSection [ (13 entries) Tag Type Name/Value 0x00000006 SYMTAB 0x168 ... ] ``` GNU ``` Dynamic section at offset 0x1d0 contains 13 entries: Tag Type Name/Value 0x00000006 (SYMTAB) 0x168 ... ``` Differential Revision: https://reviews.llvm.org/D62256 llvm-svn: 361633
* [ELF] Fix a doc typo. NFCFangrui Song2019-05-241-1/+1
| | | | llvm-svn: 361617
* [ELF] Deleted unused forward declarations. NFCFangrui Song2019-05-242-9/+0
| | | | llvm-svn: 361614
* [COFF] Remove finalizeContents virtual method from Chunk, NFCReid Kleckner2019-05-243-15/+20
| | | | | | | | | This only needs to be done for MergeChunks, so just do that in a separate pass in the Writer. This is one small step towards eliminating the vtable in Chunk. llvm-svn: 361573
* ELF: Remove a comparison against In.EhFrame. NFCI.Peter Collingbourne2019-05-232-4/+9
| | | | | | | | This won't work once we have multiple .eh_frame sections. Differential Revision: https://reviews.llvm.org/D62280 llvm-svn: 361556
* [COFF] Move KeepUnique bit from Chunk to SectionChunk, NFCReid Kleckner2019-05-232-8/+6
| | | | | | | | The KeepUnique bit is used during ICF, which only operates on SectionChunks, so only SectionChunks need it. This frees up a byte in Chunk, which I plan to use in a follow-up change. llvm-svn: 361549
* lld-link, clang: Treat non-existent input files as possible spellos for ↵Nico Weber2019-05-238-23/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | option flags OptTable treats arguments starting with / that aren't a known option as filenames. This means lld-link's and clang-cl's typo correction for unknown flags didn't do spell checking for misspelled options that start with /. I first tried changing OptTable, but that got pretty messy, see PR41787 comments 2 and 3. Instead, let lld-link's and clang's (including clang-cl's) "file not found" diagnostic check if a non-existent file looks like it could be a mis-spelled option, and if so add a "did you mean" suggestion to the "file not found" diagnostic. While here, make formatting of a few diagnostics a bit more self-consistent. Fixes PR41787. Differential Revision: https://reviews.llvm.org/D62276 llvm-svn: 361518
* Simplify InputFile::fetch().Rui Ueyama2019-05-233-13/+12
| | | | | | | We don't have to return a value from the function. Instead, we can directly call parseFile from the functions. llvm-svn: 361478
* Remove LazyObjFile::AddedToLink.Rui Ueyama2019-05-233-14/+8
| | | | | | | Instead we can just clear a MemoryBuffer so that we cannot get the same buffer more than once. llvm-svn: 361477
* Reland: [WebAssembly] Add __start_/_stop_ symbols for data sectionsSam Clegg2019-05-235-8/+111
| | | | | | | | | | This is a reland of rL361235. Fixes https://bugs.llvm.org/show_bug.cgi?id=41565 Differential Revision: https://reviews.llvm.org/D61876 llvm-svn: 361476
* Move code for symbol resolution from SymbolTable.cpp to Symbols.cpp.Rui Ueyama2019-05-237-351/+364
| | | | | | | | | | | | | | | | My recent commits separated symbol resolution from the symbol table, so the functions to resolve symbols are now in a somewhat wrong file. This patch moves it to Symbols.cpp. The functions are now member functions of the symbol. This is code move change. I modified function names so that they are appropriate as member functions, though. No functionality change intended. Differential Revision: https://reviews.llvm.org/D62290 llvm-svn: 361474
* Speed up --start-lib and --end-lib.Rui Ueyama2019-05-233-59/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | --{start,end}-lib give files grouped by the options the archive file semantics. That is, each object file between them acts as if it were in an archive file whose sole member is the file. Therefore, files between --{start,end}-lib are linked to the final output only if they are needed to resolve some undefined symbols. Previously, the feature was implemented this way: 1. We read a symbol table and insert defined symbols to the symbol table as lazy symbols. 2. If an undefind symbol is resolved to a lazy symbol, that lazy symbol instantiate ObjFile class for that symbol, which re-insert all defined symbols to the symbol table. So, if an ObjFile is instantiated, defined symbols are inserted to the symbol table twice. Since inserting long symbol names is not cheap, there's a room to optimize here. This patch optimzies it. Now, LazyObjFile remembers symbol handles and passed them over to a new ObjFile instance, so that the ObjFile doesn't insert the same strings. Here is a quick benchmark to link clang. "Original" is the original lld with unmodified command line options. For "Case 1" and "Case 2", I extracted all files from archive files and replace .a's in a command line with .o's wrapped with --{start,end}-lib. I used the original lld for Case 1" and use this patch for Case 2. Original: 5.892 Case 1: 6.001 (+1.8%) Case 2: 5.701 (-3.2%) So, interestingly, --{start,end}-lib are now faster than the regular linking scheme with archive files. That's perhaps not too surprising, though, because for regular archive files, we look up the symbol table with the same string twice. Differential Revision: https://reviews.llvm.org/D62188 llvm-svn: 361473
* [LLD][ELF] - Improve diagnostic about unrecognized relocations.George Rimar2019-05-237-7/+7
| | | | | | | | | | | | | | | | | | | | | | This is a minor improvement inspired by https://bugs.llvm.org/show_bug.cgi?id=38303. A person reported that he observed message complaining about unsupported R_ARM_V4BX: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC But with -z notext he only saw a relocation number, what is not convenient: error: ../../gfx/cairo/libpixman/src/pixman-arm-neon-asm-bilinear.o:(.text+0x4F0): unrecognized reloc 40 Also, in the error messages we use relocation but not reloc. With this patch we start to print one of the following messages: error: file.o: unrecognized relocation Unknown(999) error: file.o: unrecognized relocation R_X_KNOWN_BY_LLVM_BUT_UNSUPPORTED_BY_LLD_NAME There is no way to write a test for that I believe. Differential revision: https://reviews.llvm.org/D62237 llvm-svn: 361472
* [WebAssembly] Seal imports section before counting importsSam Clegg2019-05-233-14/+33
| | | | | | | | | | | | | | | | | | | | | | | Summary: Before we can assign entries in the function of global index space we need to know the total number of function and global imports respectively. To avoid programmer error this change seals that imports section before assigned function and global index space. Any attempt to add an import after the section is sealed will assert. The lack this such as check caused https://reviews.llvm.org/D61876 to be reverted. I'm also trying to craft a test case the this failure. Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62240 llvm-svn: 361470
* Move SymbolTable::addCombinedLTOObject() to LinkerDriver.Rui Ueyama2019-05-234-34/+29
| | | | | | | | | | | | Also renames it LinkerDriver::compileBitcodeFiles. The function doesn't logically belong to SymbolTable. We added this function to the symbol table because symbol table used to be a container of input files. This is no longer the case. Differential Revision: https://reviews.llvm.org/D62291 llvm-svn: 361469
* Re-land r361206 "[COFF] Store alignment in log2 form, NFC"Reid Kleckner2019-05-228-32/+56
| | | | | | | | | The previous patch lost the call to PowerOf2Ceil, which causes LLD to crash when handling common symbols with a non-power-of-2 size. I tweaked the existing common.test to make the bsspad16 common symbol be 15 bytes to add coverage for this case. llvm-svn: 361426
* [mips] Use GNU-style output to make tests smaller. NFCSimon Atanasyan2019-05-225-277/+107
| | | | llvm-svn: 361394
* [mips] Replace multiple `-check-prefix` by single `-check-prefixes`. NFCSimon Atanasyan2019-05-221-4/+2
| | | | llvm-svn: 361393
* Copy symbol length when we replace a symbol.Rui Ueyama2019-05-221-0/+5
| | | | | | | | | Symbol's NameSize is computed lazily. Currently, when we replace a symbol, a cached length value can be discarded. This patch propagates that value. Differential Revision: https://reviews.llvm.org/D62234 llvm-svn: 361364
* [ELF] Improve error message for relocations to symbols defined in discarded ↵Fangrui Song2019-05-229-37/+144
| | | | | | | | | | | | | | | | | | | | | sections Rather than report "undefined symbol: ", give more informative message about the object file that defines the discarded section. In particular, PR41133, if the section is a discarded COMDAT, print the section group signature and the object file with the prevailing definition. This is useful to track down some ODR issues. We need to * add `uint32_t DiscardedSecIdx` to Undefined for this feature. * make ComdatGroups public and change its type to DenseMap<CachedHashStringRef, const InputFile *> Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D59649 llvm-svn: 361359
* Simplify the logic to instantiate Symbols. Should be NFC.Rui Ueyama2019-05-221-5/+3
| | | | llvm-svn: 361350
* [docs] Fix troff macro (.F1 -> .Fl) in ld.lld.1Fangrui Song2019-05-221-2/+2
| | | | llvm-svn: 361345
* Fix test to put its outputs into the temp directory.Richard Smith2019-05-211-2/+2
| | | | llvm-svn: 361297
* Revert "[WebAssembly] Add __start_/_stop_ symbols for data sections"Sam Clegg2019-05-215-113/+10
| | | | | | | | | This reverts commit 7804dbddccba412087a15cab8db4412939700952. This change broke a bunch of tests of the WebAssembly waterfall. Will hopefully reland with increased test coverage. llvm-svn: 361273
* [ELF] Deleted unused ComdatGroups member variable left by D61854Fangrui Song2019-05-211-5/+0
| | | | llvm-svn: 361266
* Fix test failure.Rui Ueyama2019-05-211-1/+1
| | | | | | I forgot to submit a last-minute change to the last patch. llvm-svn: 361249
OpenPOWER on IntegriCloud