summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputFiles.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add support for ThinLTO plugin option thinlto-object-suffix-replaceRumeet Dhindsa2018-05-161-1/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D46608 llvm-svn: 332527
* [ELF] - Simplify. NFC.George Rimar2018-05-141-1/+1
| | | | llvm-svn: 332242
* [ELF] Rework debug line parsing to use llvm::Error and callbacks (LLD-side)James Henderson2018-05-101-1/+8
| | | | | | | | | | | | | | Reviewed by: ruiu, grimar, espindola Differential Revision: https://reviews.llvm.org/D44562 Summary: r331971 changes the debug line parser interface to report LLVM errors in an interface that different executables can use, rather than always being printed directly as warnings to stderr. This change allows LLD to make use of the new interface and call its own warning methods to report problems. llvm-svn: 331972
* Added support for ThinLTO plugin options : thinlto-index-only and ↵Rumeet Dhindsa2018-05-021-10/+7
| | | | | | | | thinlto-prefix-replace Differential Revision: https://reviews.llvm.org/D46034 llvm-svn: 331405
* Do not set RequiresNullTerminator. NFC.Rui Ueyama2018-04-271-1/+1
| | | | | | When reading object files, we don't need '\0' at end of each file. llvm-svn: 331045
* Add --warn-backrefs to maintain compatibility with other linkersRui Ueyama2018-04-091-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm proposing a new command line flag, --warn-backrefs in this patch. The flag and the feature proposed below don't exist in GNU linkers nor the current lld. --warn-backrefs is an option to detect reverse or cyclic dependencies between static archives, and it can be used to keep your program compatible with GNU linkers after you switch to lld. I'll explain the feature and why you may find it useful below. lld's symbol resolution semantics is more relaxed than traditional Unix linkers. Therefore, ld.lld foo.a bar.o succeeds even if bar.o contains an undefined symbol that have to be resolved by some object file in foo.a. Traditional Unix linkers don't allow this kind of backward reference, as they visit each file only once from left to right in the command line while resolving all undefined symbol at the moment of visiting. In the above case, since there's no undefined symbol when a linker visits foo.a, no files are pulled out from foo.a, and because the linker forgets about foo.a after visiting, it can't resolve undefined symbols that could have been resolved otherwise. That lld accepts more relaxed form means (besides it makes more sense) that you can accidentally write a command line or a build file that works only with lld, even if you have a plan to distribute it to wider users who may be using GNU linkers. With --check-library-dependency, you can detect a library order that doesn't work with other Unix linkers. The option is also useful to detect cyclic dependencies between static archives. Again, lld accepts ld.lld foo.a bar.a even if foo.a and bar.a depend on each other. With --warn-backrefs it is handled as an error. Here is how the option works. We assign a group ID to each file. A file with a smaller group ID can pull out object files from an archive file with an equal or greater group ID. Otherwise, it is a reverse dependency and an error. A file outside --{start,end}-group gets a fresh ID when instantiated. All files within the same --{start,end}-group get the same group ID. E.g. ld.lld A B --start-group C D --end-group E A and B form group 0, C, D and their member object files form group 1, and E forms group 2. I think that you can see how this group assignment rule simulates the traditional linker's semantics. Differential Revision: https://reviews.llvm.org/D45195 llvm-svn: 329636
* Avoid some temporary allocations.Rafael Espindola2018-04-061-2/+8
| | | | | | | Some system libraries have a lot of versioned symbols. When linking scylla this brings the number of malloc calls from 49154 to 37944. llvm-svn: 329453
* Merge LazyArchive::fetch() and ArchiveFile::getMember(). NFC.Rui Ueyama2018-04-031-13/+12
| | | | | | | | They are to pull out an object file for a symbol, but for a historical reason the code is written in two separate functions. This patch merges them. llvm-svn: 329039
* Re-implement --just-symbols as a regular object file.Rui Ueyama2018-03-301-42/+28
| | | | | | | | | | | | I tried a few different designs to find a way to implement it without too much hassle and settled down with this. Unlike before, object files given as arguments for --just-symbols are handled as object files, with an exception that their section tables are handled as if they were all null. Differential Revision: https://reviews.llvm.org/D42025 llvm-svn: 328852
* Rename NonLocal -> Global.Rui Ueyama2018-03-281-11/+11
| | | | | | | | NonLocal is technically more accurate, but we already use the term "Global" to specify the non-local part of the symbol table, and Local <-> Global is easier to digest. llvm-svn: 328740
* Strip @VER suffices from the LTO output.Rafael Espindola2018-03-281-0/+4
| | | | | | | | | | | | | | | This fixes pr36623. The problem is that we have to parse versions out of names before LTO so that LTO can use that information. When we get the LTO produced .o files, we replace the previous symbols with the LTO produced ones, but they still have @ in their names. We could just trim the name directly, but calling parseSymbolVersion to do it is simpler. llvm-svn: 328738
* Force SHF_MERGE optimizations with -r.Rafael Espindola2018-03-271-3/+13
| | | | | | | | | | | | | | Some tools (dwarfdump for example) get confused by the current -O0 -r output since it has multiple copies of .debug_str. We cannot just merge sections with the same name as they can have different sh_entsize. We could have duplicated logic for merging sections based on name and sh_entsize, but it seems better to just use the existing logic by enabling optimizations. llvm-svn: 328640
* Remove extraneous local variable. NFC.Rui Ueyama2018-03-271-5/+3
| | | | llvm-svn: 328605
* Update comments.Rui Ueyama2018-03-271-11/+10
| | | | llvm-svn: 328604
* Refactor SharedFile::parseRest. NFC.Rui Ueyama2018-03-261-56/+77
| | | | | | | | | SharedFile::parseRest function grew organically and got a bit hard to understand. This patch refactor it. This patch also adds comments. Differential Revision: https://reviews.llvm.org/D44860 llvm-svn: 328579
* Do not add a dummy entry to SharedFile::Verdefs. NFC.Rui Ueyama2018-03-241-8/+4
| | | | | | | | Previously, we used 0 as an alias for VER_NDX_GLOBAL and had a dummy entry in SharedFile::Verdefs so that the access to the array is within its boundary. But that's not straightforwad. We can just stop doing both. llvm-svn: 328401
* Remove "FIXME" from a comment.Rui Ueyama2018-03-231-7/+6
| | | | | | A bug in BFD linker is not our FIXME item. llvm-svn: 328381
* Fix the MSVC build.Rafael Espindola2018-03-231-1/+1
| | | | llvm-svn: 328285
* Fix PR36793.Rafael Espindola2018-03-231-53/+38
| | | | | | | With this patch lld will iterate over compile units to find the line tables instead of assuming there is only one at offset 0. llvm-svn: 328284
* Replace a std::pair with a struct.Rafael Espindola2018-03-211-2/+2
| | | | | | This is more readable and should reduce the noise in a followup patch. llvm-svn: 328164
* Add a comment about ELF spec and the symbol table's sh_info.Rui Ueyama2018-03-151-0/+4
| | | | llvm-svn: 327645
* [ELF] - Formatted comment, fixed mistype. NFC.George Rimar2018-03-121-3/+2
| | | | llvm-svn: 327280
* [ELF] - Fix crash relative to SHF_LINK_ORDER sections.George Rimar2018-03-081-2/+9
| | | | | | | | | | | | | | | | | Our code assumes all input sections in an output SHF_LINK_ORDER section has SHF_LINK_ORDER flag. We do not check that and that can cause a crash. That happens because we call std::stable_sort(Sections.begin(), Sections.end(), compareByFilePosition);, where compareByFilePosition predicate does not expect to see null when calls getLinkOrderDep. The same might happen when sections refer to non-regular sections. Test cases demonstrate the issues, patch fixes them. Differential revision: https://reviews.llvm.org/D44193 llvm-svn: 327006
* Return early. NFC.Rui Ueyama2018-03-081-0/+1
| | | | | | | | We don't need to handle an object file having more than one symbol table, so as soon as we find the first one, we can process it and then return from the function. llvm-svn: 326977
* Simplify LazyobjFile and readElfSymbols.Rui Ueyama2018-03-081-45/+34
| | | | | | | | | | addElfSymbols and readJustSymbolsFile still has duplicate code, but I didn't come up with a good idea to eliminate them. Since this patch is an improvement, I'm sending this for review. Differential Revision: https://reviews.llvm.org/D44187 llvm-svn: 326972
* [ELF] Prevent crash when reporting errors if debug line cannot be parsedJames Henderson2018-03-071-0/+2
| | | | | | | | | | | | | LLD uses the debug info and debug line sections to determine the location of e.g. references to undefined symbols, when producing error messages. In the event that debug info was present, but debug line parsing failed for some reason, then a nullptr would end up being dereferenced by the location-lookup code. Differential Revision: https://reviews.llvm.org/D44205 Reviewers: grimar llvm-svn: 326899
* Implement --just-symbols.Rui Ueyama2018-03-061-0/+41
| | | | | | Differential Revision: https://reviews.llvm.org/D39348 llvm-svn: 326835
* Put undefined symbols from shared libraries in the symbol table.Rafael Espindola2018-02-271-1/+4
| | | | | | | With the recent fixes these symbols have more in common than not with regular undefined symbols. llvm-svn: 326242
* [ELF] Create and export symbols provided by a linker script if they ↵Igor Kudrin2018-02-271-1/+1
| | | | | | | | | | | referenced by DSOs. It should be possible to resolve undefined symbols in dynamic libraries using symbols defined in a linker script. Differential Revision: https://reviews.llvm.org/D43011 llvm-svn: 326176
* ELF: Stop collecting a list of symbols in ArchiveFile.Peter Collingbourne2018-02-161-2/+1
| | | | | | | | | | | | There seems to be no reason to collect this list of symbols. Also fix a bug where --exclude-libs would apply to all symbols that appear in an archive's symbol table, even if the relevant archive member was not added to the link. Differential Revision: https://reviews.llvm.org/D43369 llvm-svn: 325380
* [ELF][MIPS] Ignore incorrect version definition index for _gp_disp symbolSimon Atanasyan2018-02-071-0/+8
| | | | | | | | | | | | MIPS BFD linker puts _gp_disp symbol into DSO files and assigns zero version definition index to it. This value means 'unversioned local symbol' while _gp_disp is a section global symbol. We have to handle this bug in the LLD because BFD linker is used for building MIPS toolchain libraries. Differential revision: https://reviews.llvm.org/D42486 llvm-svn: 324467
* [ELF] - Report valid binary filename when reporting error.George Rimar2018-02-051-2/+2
| | | | | | | | | | We did not report valid filename for duplicate symbol error when symbol came from binary input file. Patch fixes it. Differential revision: https://reviews.llvm.org/D42635 llvm-svn: 324217
* Strip .note.gnu.build-id sections if --build-id is given.Rui Ueyama2018-02-021-0/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D42823 llvm-svn: 324146
* [DWARFv5] Re-enable dumping a line table with no CU.Paul Robinson2018-01-291-3/+1
| | | | | | | | | | | r323476 added support for DW_FORM_line_strp, and incorrectly made that depend on having a DWARFUnit available. We shouldn't be tracking .debug_line_str in DWARFUnit after all. After this patch, I can do an NFC follow up and undo a bunch of the "plumbing" part of r323476. Differential Revision: https://reviews.llvm.org/D42609 llvm-svn: 323691
* Detemplate reportDuplicate.Rafael Espindola2017-12-231-14/+54
| | | | | | | | | | We normally avoid "switch (Config->EKind)", but in this case I think it is worth it. It is only executed when there is an error and it allows detemplating a lot of code. llvm-svn: 321404
* Pass an InputFile to the InputSection constructor.Rafael Espindola2017-12-211-7/+5
| | | | | | | This simplifies toRegularSection and reduces the noise in a followup patch. llvm-svn: 321240
* Convert a few more InputFiles to references.Rafael Espindola2017-12-211-6/+6
| | | | | | | We use null files in sections to represent linker created sections, so ObjFile<ELFT> is never null. llvm-svn: 321238
* clang-format. NFC.Rafael Espindola2017-12-201-5/+5
| | | | llvm-svn: 321216
* Use a reference in addLazyArchive. NFC.Rafael Espindola2017-12-201-1/+1
| | | | llvm-svn: 321194
* Use a reference for the shared symbol file.Rafael Espindola2017-12-201-2/+2
| | | | | | Every shared symbol has a file, so we can use a reference. llvm-svn: 321187
* Use a reference for a value that is never null. NFC.Rafael Espindola2017-12-201-2/+2
| | | | llvm-svn: 321186
* Use a reference for a value that is never null. NFC.Rafael Espindola2017-12-201-5/+5
| | | | llvm-svn: 321185
* Handle a VersymIndex of 0 as an error.Rafael Espindola2017-12-151-5/+2
| | | | | | | | | I noticed that the continue this patch deletes was not tested. Trying to add a test I realized that we never put a VER_NDX_LOCAL symbol in the dynamic symbol table. There doesn't seem to be any reason for a linker to use VER_NDX_LOCAL for a defined shared symbol. llvm-svn: 320817
* Fix error messages.Rui Ueyama2017-12-151-1/+1
| | | | llvm-svn: 320772
* Use warn() instead of error() to report a bad symbol in a DSO.Rui Ueyama2017-12-151-0/+6
| | | | | | | | | | Specifically, libwidevinecdm.so in Chrome has such bad symbol. It seems the BFD linker handles them as local symbols, so instead of inserting them to the symbol table, we should skip them too. Differential Revision: https://reviews.llvm.org/D41257 llvm-svn: 320770
* Inline a small function.Rui Ueyama2017-12-131-10/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D41204 llvm-svn: 320652
* Remove unnecessary use of Repl.Rafael Espindola2017-12-131-4/+1
| | | | | | This runs before ICF, so Sec->Repl == Sec. llvm-svn: 320543
* Compact symbols from 96 to 88 bytes.Rafael Espindola2017-12-121-3/+5
| | | | | | | | | | | | By using an index instead of a pointer for verdef we can put the index next to the alignment field. This uses the otherwise wasted area and reduces the shared symbol size. By itself the performance change of this is in the noise, but I have a followup patch to remove another 8 bytes that improves performance when combined with this. llvm-svn: 320449
* Remove checkToString functions and use toString instead.Rui Ueyama2017-12-071-40/+30
| | | | | | Differential Revision: https://reviews.llvm.org/D40928 llvm-svn: 320005
* Always evaluate the second argument for CHECK() lazily.Rui Ueyama2017-12-061-41/+36
| | | | | | | | | This patch is to rename check CHECK and make it a C macro, so that we can evaluate the second argument lazily. Differential Revision: https://reviews.llvm.org/D40915 llvm-svn: 319974
OpenPOWER on IntegriCloud