summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputFiles.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Update for llvm change.Rafael Espindola2016-10-171-7/+7
| | | | llvm-svn: 284409
* [ELF] - Don't crash on multiple SHT_MIPS_REGINFO/SHT_MIPS_ABIFLAGS sections.George Rimar2016-10-171-0/+6
| | | | | | | | | | In continue of D25555, this patch fixes possible crash when we have multiple SHT_MIPS_REGINFO or SHT_MIPS_ABIFLAGS sections. yaml2obj was used to produce such objects. Differential revision: https://reviews.llvm.org/D25609 llvm-svn: 284376
* [ELF] - Do not crash when object has multiple SHT_MIPS_OPTIONSGeorge Rimar2016-10-141-0/+3
| | | | | | | | | | | | Issue was revealed by AFl and I was able to generate such object using yaml2obj. When object has more than one SHT_MIPS_OPTIONS, each except the last one is destroyed after placing into Sections array. Sections array contains dead pointers finally. LLD may crash then. Differential revision: https://reviews.llvm.org/D25555 llvm-svn: 284227
* [ThinLTO] Avoid archive member collisions.Davide Italiano2016-10-121-6/+21
| | | | | | | | This fixes PR30665. Differential Revision: https://reviews.llvm.org/D25495 llvm-svn: 284034
* Recommit r283733 "[ELF] - Do not crash if common symbol alignment set to ↵George Rimar2016-10-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | value greater than UINT32_MAX. With fix: commit changes from InputFiles.cpp too. Original commit message: We have following code in lld, that truncates the alignment value to 32 bit. Big alignment in this case may give result 0 and crash later. template <class ELFT> CommonInputSection<ELFT>::CommonInputSection(std::vector<DefinedCommon *> Syms) : InputSection<ELFT>(nullptr, &Hdr, "") { .... for (DefinedCommon *Sym : Syms) { this->Alignment = std::max<uintX_t>(this->Alignment, Sym->Alignment); ... } } Patch fixes the issue. Differential revision: https://reviews.llvm.org/D25235 llvm-svn: 283738
* [ELF][ARM] Fix formatting mistake, removed extra space before ) NFC.Peter Smith2016-10-101-1/+1
| | | | llvm-svn: 283735
* [ELF][ARM] Garbage collection support for .ARM.exidx sectionsPeter Smith2016-10-101-0/+20
| | | | | | | | | | | | | | | .ARM.exidx sections have a reverse dependency on the section they have a SHF_LINK_ORDER dependency on. In other words a .ARM.exidx section is live only if the executable section it describes is live. We implement this with a reverse dependency field in InputSection. Adding the dependency to InputSection is the simplest implementation but it could be moved out to a separate map if it were found to decrease performance for non ARM targets. Differential revision: https://reviews.llvm.org/D25234 llvm-svn: 283734
* [ELF] - Fixed assert fail when symbol table has zero sh_info value.George Rimar2016-10-071-1/+1
| | | | | | | | | | When sh_info of sumbol table value was set to zero, lld was asserting. Patch fixes the issue. Differential revision: https://reviews.llvm.org/D25016 llvm-svn: 283562
* [ELF] - Do not crash on invalid size of dynamic section.George Rimar2016-10-071-4/+4
| | | | | | | | | | | | Previously if sh_size of dynamic section was broken, lld may crash. Or even may not crash if used 32 bits host. (then value may be truncated to 32 bits when doing pointer arithmetic and could be just zero). Patch fixes the issue. Differential revision: https://reviews.llvm.org/D25327 llvm-svn: 283533
* [ELF] - Do not crash when unable to parse ELF object file.George Rimar2016-10-071-1/+1
| | | | | | | | | | | | | createELFObj() may call error(...), for example when file is too short. In that case header is not set and following line lead to crash: EMachine = ELFObj.getHeader()->e_machine; Patch fixes the issue. Differential revision: https://reviews.llvm.org/D25233 llvm-svn: 283532
* [ELF] - Make checks in ObjectFile<ELFT>::getSection() stricter.George Rimar2016-10-061-3/+8
| | | | | | | | | This patch makes the check for null section stricter, so it is only allowed for STT_SECTION symbols now. Differential revision: https://reviews.llvm.org/D25231 llvm-svn: 283426
* [ELF] Do not merge sections in case of relocatable object generationSimon Atanasyan2016-10-051-0/+9
| | | | | | | | | | | | | Do not merge sections if generating a relocatable object. It makes the code simpler because we do not need to update relocations addends to reflect changes introduced by merging. Instead of that we write such "merge" sections into separate OutputSections and keep SHF_MERGE / SHF_STRINGS flags and sh_entsize value to be able to perform merging later during a final linking. Differential Revision: http://reviews.llvm.org/D25066 llvm-svn: 283300
* Add a comment.Rui Ueyama2016-10-041-1/+4
| | | | llvm-svn: 283229
* [ELF] Don't discard excluded section if -r is usedEugene Leviant2016-10-041-1/+1
| | | | | | | This conforms to GNU ld/gold behavior and fixes crash in case excluded section also has associated relocation section llvm-svn: 283214
* [ELF] - Do not crash if common symbol has alignment 0.George Rimar2016-10-041-0/+3
| | | | | | | | | Testcase contains a common symbol with zero alignment, previously lld would crash, patch fixes that. Differential revision: https://reviews.llvm.org/D25085 llvm-svn: 283197
* [ELF] - Apply clang-format. NFC.George Rimar2016-10-031-13/+12
| | | | llvm-svn: 283101
* Remove an warning message that can be spammy.Rui Ueyama2016-09-301-7/+0
| | | | | | | | | | | | | | | | | | This was intended to warn on a usage error of an ar command. I was thinking that false positive would be rare because it has two guards: it warns only when an archive file has no symbols and contains at least one file. Turned out that false positive would probably be not that rare. You wouldn't intentionally create an object file that contains no exported symbols, but with conditional compile guards, you could create such file. If it is for a LTO build, you could create an archive file containing such file. That means there's no way to detect the usage error in a reliable manner. This patch simply removes the warning. llvm-svn: 282916
* Improve error check for an empty archive.Rui Ueyama2016-09-301-10/+8
| | | | | | | | | | | Previously, it warned on any archive file that has no symbol. It turned out that that is too noisy. With this patch, it warns on such archive file that contains no file. Differential Revision: https://reviews.llvm.org/D25111 llvm-svn: 282885
* Add comments.Rui Ueyama2016-09-291-7/+10
| | | | llvm-svn: 282807
* Rename warning -> warn.Rui Ueyama2016-09-291-4/+4
| | | | | | It's better because it's a verb. llvm-svn: 282763
* Use InputFile::Symbol instead of auto for consistency.Rui Ueyama2016-09-291-6/+4
| | | | llvm-svn: 282658
* [ELF/LTO] Switch to the new resolution-based API.Davide Italiano2016-09-291-80/+35
| | | | | | Differential Revision: https://reviews.llvm.org/D24492 llvm-svn: 282656
* Warn on empty archive files.Rui Ueyama2016-09-281-1/+10
| | | | | | Differential Revision: https://reviews.llvm.org/D25044 llvm-svn: 282633
* Sort headers. NFC.Rafael Espindola2016-09-281-1/+1
| | | | llvm-svn: 282603
* [ELF] Ignore sections flagged with SHF_EXCLUDEEugene Leviant2016-09-281-0/+5
| | | | | | Differential revision: https://reviews.llvm.org/D24966 llvm-svn: 282568
* Accept sh_entsize = 0.Rui Ueyama2016-09-211-4/+12
| | | | | | | | | | This surfaced again with Rust. As per bug 30435, rustc creates a mergeable section with a sh_entsize zero. It bit us before, too. I think we should relax the input check rather than being too picky. Differential Revision: https://reviews.llvm.org/D24789 llvm-svn: 282049
* Simplify InputFile ownership management.Rui Ueyama2016-09-141-20/+27
| | | | | | | | | | | | | | | | | | | | Previously, all input files were owned by the symbol table. Files were created at various places, such as the Driver, the lazy symbols, or the bitcode compiler, and the ownership of new files was transferred to the symbol table using std::unique_ptr. All input files were then free'd when the symbol table is freed which is on program exit. I think we don't have to transfer ownership just to free all instance at once on exit. In this patch, all instances are automatically collected to a vector and freed on exit. In this way, we no longer have to use std::unique_ptr. Differential Revision: https://reviews.llvm.org/D24493 llvm-svn: 281425
* Enable merging of SHF_MERGE sections with linker scripts.Rafael Espindola2016-09-131-8/+0
| | | | | | | | | This also fixes the related problem of non SHF_MERGE sections with different flags not being merged. Fixes pr30355. llvm-svn: 281338
* Add comments.Rui Ueyama2016-09-121-0/+2
| | | | llvm-svn: 281265
* [ELF] Add support for -b binaryMichael J. Spencer2016-09-091-0/+49
| | | | | | | | | | Implemented by building an ELF file in memory. elf, default, and binary match gold behavior. Differential Revision: https://reviews.llvm.org/D24060 llvm-svn: 281108
* Add comments.Rui Ueyama2016-09-091-0/+4
| | | | llvm-svn: 281098
* [ELF] Fix DT_NEEDED value.Davide Italiano2016-09-081-1/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D24363 llvm-svn: 280990
* Compute section names only once.Rafael Espindola2016-09-081-50/+46
| | | | | | | | This simplifies error handling as there is now only one place in the code that needs to consider the possibility that the name is corrupted. Before we would do it in every access. llvm-svn: 280937
* [LTO/InputFiles] Merge two ifs into one. NFCI.Davide Italiano2016-08-311-5/+3
| | | | llvm-svn: 280225
* [ELF] - Introduce StripPolicy instead of Config->StripAll/StripDebug flags.George Rimar2016-08-311-1/+1
| | | | | | | | | | This approach is not only consistent with UnresolvedPolicy, but also should help to solve a problem of options with opposing meanings, mentioned in PR28843 Differential revision: https://reviews.llvm.org/D23869 llvm-svn: 280206
* Pass Binding instead of IsWeak to addBitcode.Rafael Espindola2016-08-301-3/+2
| | | | | | We were computing the binding on both the caller and callee. llvm-svn: 280156
* [LTO] Fix the logic for dropping unnamed_addr.Davide Italiano2016-08-301-9/+18
| | | | | | Differential Revision: https://reviews.llvm.org/D24037 llvm-svn: 280144
* [ELF] - Do not use mergeable sections when LS is used.George Rimar2016-08-121-0/+9
| | | | | | | | | | | | | | | After latest changes we combine input sections with different attributes into single output section. Problem here is that regular output sections does not support adding mergeable input sections (and vise versa). Patch just temporarily disables merging for now at the same way we do for -O0 for example. This change helps for linking FreeBSD kernel. Differential revision: https://reviews.llvm.org/D23447 llvm-svn: 278555
* [ELF] - Fix for: error "invalid section index: xxx" when linking FreeBSD kernel.George Rimar2016-08-121-2/+7
| | | | | | | | | | | | We found that GNU assembler 2.17.50 [FreeBSD] 2007-07-03 could generate broken objects. STT_SECTION symbols can be associated with SHT_REL[A]/SHT_SYMTAB/SHT_STRTAB sections. This is PR28868, patch fixes handling of such files. Differential revision: https://reviews.llvm.org/D23201 llvm-svn: 278550
* [ELF][MIPS] Support .MIPS.abiflags sectionSimon Atanasyan2016-08-121-0/+4
| | | | | | | This section supersedes .reginfo and .MIPS.options sections. But for now we have to support all three sections for ABI transition period. llvm-svn: 278482
* Rename functions that handle bitcode files.Rui Ueyama2016-08-031-4/+4
| | | | | | | getELFKind was overloaded with bitcode files and regular object files, and I found that is a bit confusing. This patch renames them. llvm-svn: 277646
* Do not instantiate Triple twice.Rui Ueyama2016-08-031-11/+8
| | | | | | Also removes redundant variables. NFC. llvm-svn: 277644
* Add EM_IAMCU support.Rui Ueyama2016-08-031-1/+1
| | | | | | | | | This patch adds "-m elf_iamcu" to ldd for IAMCU psABI: https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI Patch by H.J Lu. llvm-svn: 277643
* Do not handle zero-sized mergeable section as mergeable.Rui Ueyama2016-08-031-0/+7
| | | | | | | | | | | | | | Mergeable sections with size zero are useless because they don't actually contain data, and therefore there's no merit ot merge them. However, in reality, there are object files in the wild containing such sections. Currently, LLD can't handle them proerply. This patch makes LLD to handle such sections as if they are non- mergeable to fix the issue. Fixes bug 28822. llvm-svn: 277568
* Move code for MIPS from createInputSection to initializeSections.Rui Ueyama2016-07-261-13/+8
| | | | | | | | | We already have code for ARM in initializeSections, so this is more consistent. Differential Revision: https://reviews.llvm.org/D22833 llvm-svn: 276811
* [ELF][MIPS] Use section type to recognize .reginfo and .MIPS.options sectionsSimon Atanasyan2016-07-261-3/+3
| | | | | | It is faster and more correct method than string comparision. llvm-svn: 276807
* Implement almost-zero-cost --trace-symbol.Rui Ueyama2016-07-171-5/+0
| | | | | | | | | | | | | | | | | | | | --trace-symbol is a command line option to watch a symbol. Previosly, we looked up a hash table for a new symbol if the option is given. Any code that looks up a hash table for each symbol is expensive because the linker handles a lot of symbols. In our design, we look up a hash table strictly only once for a symbol, so --trace-symbol was an exception. This patch improves efficiency of the option by merging the hash table into the symbol table. Instead of looking up a separate hash table with a string, this patch sets `Traced` flag to symbols specified by --trace-symbol. So, if you insert a symbol and get a symbol with `Traced` flag on, you know that you need to print out a log message for the symbol. This is nearly zero cost. llvm-svn: 275716
* Add a pointer to a source file to SymbolBody.Rui Ueyama2016-07-171-1/+1
| | | | | | | | | | | | Previously, each subclass of SymbolBody had a pointer to a source file from which it was created. So, there was no single way to get a source file for a symbol. We had getSourceFile<ELFT>(), but the function was a bit inconvenient as it's a template. This patch makes SymbolBody have a pointer to a source file. If a symbol is not created from a file, the pointer has a nullptr. llvm-svn: 275701
* Remove redundant namespace specifiers.Rui Ueyama2016-07-161-4/+4
| | | | llvm-svn: 275694
* ELF: Include filenames in error messages.Rui Ueyama2016-07-151-19/+26
| | | | llvm-svn: 275608
OpenPOWER on IntegriCloud