summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputSection.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove unnecessary this->. NFC.Rafael Espindola2017-12-191-32/+29
| | | | llvm-svn: 321081
* Move Repl to SectionBase.Rafael Espindola2017-12-131-1/+1
| | | | | | | | | | | | | | | | It is currently in InputSectionBase. Only InputSections are used in ICF, so Repl should be move to InputSection to clear the class hierarchy or, like this patch does, to SectionBase for convenience. The convenience of having it on the base class is that we can just access the replacement without having to first check if it is an InputSection. It is a bit less code and a bit faster as some of this code is very hot. I got up to 1.77% improvement in clang-gdb-index and no regressions according to lnt. llvm-svn: 320654
* Move Repl check to a symbol method.Rafael Espindola2017-12-131-1/+1
| | | | | | | | | | | | Having a SectionBase method check Repl is inconsistent with how we handle other section information. For example, if a section is replaced, Sec->Live is false and it is natural for Sec->getOutputSection() to be null. It is the symbol that is moved to the replacement section. llvm-svn: 320599
* Fix the type of the Discared section.Rafael Espindola2017-12-131-1/+1
| | | | | | | It is constructed with a kind of Regular and will dyn_cast to InputSection, but is declared to be an InputSectionBase. llvm-svn: 320539
* Remove some includes from InputFiles.h.Rafael Espindola2017-12-091-0/+1
| | | | | | | They were not used in InputFiles.h and it was getting too easy to add circular includes. llvm-svn: 320256
* [ELF] - Handle EhInputSection Live bit in MarkLive.cppGeorge Rimar2017-11-301-6/+1
| | | | | | | | | | Since MarkLive.cpp is the place where we set Live flags for other sections, it looks correct to do that there. Benefit is that we stop spreading GC logic outsize of MarkLive.cpp. Differential revision: https://reviews.llvm.org/D40454 llvm-svn: 319435
* Don't crash on invalid.Rafael Espindola2017-11-301-1/+6
| | | | llvm-svn: 319404
* Delete dead code.Rafael Espindola2017-11-301-4/+0
| | | | llvm-svn: 319403
* Move Memory.{h,cpp} to Common.Rui Ueyama2017-11-281-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D40571 llvm-svn: 319221
* Consistent use of <internal> when displaying internal symbol namesSam Clegg2017-11-271-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D40510 llvm-svn: 319108
* [ELF] - Don't emit broken relocations for SHF_MERGE sections when ↵George Rimar2017-11-161-1/+2
| | | | | | | | | | | | --emit-relocs is used. Previously our relocations we rewrote were broken for that case. We emited incorrect addend and broken relocation info field because did not produce section symbol for mergeable synthetic sections. Differential revision: https://reviews.llvm.org/D40070 llvm-svn: 318394
* [MIPS] Fix calculation of the R_MICROMIPS_LO16 / HI16 relocationsSimon Atanasyan2017-11-091-0/+5
| | | | llvm-svn: 317781
* ELF: Merge DefinedRegular and Defined.Peter Collingbourne2017-11-061-5/+5
| | | | | | | | | Now that DefinedRegular is the only remaining derived class of Defined, we can merge the two classes. Differential Revision: https://reviews.llvm.org/D39667 llvm-svn: 317448
* Rename Body -> Sym.Rui Ueyama2017-11-041-44/+44
| | | | | | | | | | This patch is mechanically created by sed -i -e s/Body/Sym/g lld/ELF/*.{cpp,h} and clang-format-diff. llvm-svn: 317392
* Rename SymbolBody -> SymbolRui Ueyama2017-11-031-13/+12
| | | | | | | | | | | | | Now that we have only SymbolBody as the symbol class. So, "SymbolBody" is a bit strange name now. This is a mechanical change generated by perl -i -pe s/SymbolBody/Symbol/g $(git grep -l SymbolBody lld/ELF lld/COFF) nd clang-format-diff. Differential Revision: https://reviews.llvm.org/D39459 llvm-svn: 317370
* [ELF] - Remove excessive field initialization. NFC.George Rimar2017-11-031-1/+0
| | | | | | It is already initialized in header file to same value. llvm-svn: 317320
* [ELF] - Teach LLD to report line numbers for data symbols.George Rimar2017-11-011-19/+33
| | | | | | | | | | | | | | | | | | | This is PR34826. Currently LLD is unable to report line number when reporting duplicate declaration of some variable. That happens because for extracting line information we always use .debug_line section content which describes mapping from machine instructions to source file locations, what does not help for variables as does not describe them. In this patch I am taking the approproate information about variables locations from the .debug_info section. Differential revision: https://reviews.llvm.org/D38721 llvm-svn: 317080
* Revert r316305: Remove a fast lookup table from MergeInputSection.Rui Ueyama2017-10-311-1/+16
| | | | | | This reverts commit r316305 because performance regression was observed. llvm-svn: 317026
* [ELF] - Ignore non-absolute R_386_GOTPC relocation in debug sections.George Rimar2017-10-271-0/+7
| | | | | | | | | | | | | | This is for PR34852. GCC 8.0 or earlier have a bug that it emits R_386_GOTPC relocations against _GLOBAL_OFFSET_TABLE for .debug_info. The bug seems to have been fixed in 2017: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82630, but we do not want LLD to report errors for such inputs. In this patch we ignore such relocations. Differential revision: https://reviews.llvm.org/D38625 llvm-svn: 316761
* Do not use InputSection::getFile<ELFT>() if InputSection::File suffices. NFC.Rui Ueyama2017-10-271-1/+1
| | | | llvm-svn: 316735
* De-template EhReader. NFC.Rui Ueyama2017-10-271-1/+1
| | | | llvm-svn: 316733
* De-template elf::getObjMsg. NFC.Rui Ueyama2017-10-271-8/+2
| | | | llvm-svn: 316732
* [lld] unified COFF and ELF error handling on new Common/ErrorHandlerBob Haarman2017-10-251-1/+1
| | | | | | | | | | | | | | | | | | | Summary: The COFF linker and the ELF linker have long had similar but separate Error.h and Error.cpp files to implement error handling. This change introduces new error handling code in Common/ErrorHandler.h, changes the COFF and ELF linkers to use it, and removes the old, separate implementations. Reviewers: ruiu Reviewed By: ruiu Subscribers: smeenai, jyknight, emaste, sdardis, nemanjai, nhaehnle, mgorny, javed.absar, kbarton, fedor.sergeev, llvm-commits Differential Revision: https://reviews.llvm.org/D39259 llvm-svn: 316624
* Simplify.Rui Ueyama2017-10-251-8/+4
| | | | | | | ArrayRef<T>() equals to ArrayRef<T>(nullptr, 0), so it looks like we don't need to handle size 0 as a special case. llvm-svn: 316600
* Remove a fast lookup table from MergeInputSection.Rui Ueyama2017-10-221-17/+2
| | | | | | | | | | | | | | We used to have a map from section piece offsets to section pieces as a cache for binary search. But I found that the map took quite a large amount of memory and didn't make linking faster. So, in this patch, I removed the map. This patch saves 566 MiB of RAM (2.019 GiB -> 1.453 GiB) when linking clang with debug info, and the link time is 4% faster in that test case. Thanks for Sean Silva for pointing this out. llvm-svn: 316305
* Simplify.Rui Ueyama2017-10-221-11/+9
| | | | llvm-svn: 316281
* Assume that mergeable input sections are smaller than 4 GiB.Rui Ueyama2017-10-211-15/+22
| | | | | | | | | | | | | | | By assuming that mergeable input sections are smaller than 4 GiB, lld's memory usage when linking clang with debug info drops from 2.788 GiB to 2.019 GiB (measured by valgrind, and that does not include memory space for mmap'ed files). I think that's a reasonable assumption given such a large RAM savings, so this patch. According to valgrind, gold needs 3.54 GiB of RAM to do the same thing. NB: This patch does not introduce a limitation on the size of output sections. You can still create sections larger than 4 GiB. llvm-svn: 316280
* Don't call buildSectionOrder multiple times.Rafael Espindola2017-10-211-1/+4
| | | | | | This takes linking the linux kernel from 1.52s to 0.58s. llvm-svn: 316251
* Use existing helper. NFC.Rafael Espindola2017-10-131-2/+1
| | | | llvm-svn: 315654
* Remove one parameter from Target::getRelExpr.Rui Ueyama2017-10-121-1/+3
| | | | | | | | A section was passed to getRelExpr just to create an error message. But if there's an invalid relocation, we would eventually report it in relocateOne. So we don't have to pass a section to getRelExpr. llvm-svn: 315552
* Define RelType to represent relocation types.Rui Ueyama2017-10-111-5/+5
| | | | | | | | | | | | | | | | | | We were using uint32_t as the type of relocation kind. It has a readability issue because what Type really means in `uint32_t Type` is not obvious. It could be a section type, a symbol type or a relocation type. Since we do not do any arithemetic operations on relocation types (e.g. adding one to R_X86_64_PC32 doesn't make sense), it would be more natural if they are represented as enums. Unfortunately, that is not doable because relocation type definitions are spread into multiple header files. So I decided to use typedef. This still should be better than the plain uint32_t because the intended type is now obvious. llvm-svn: 315525
* Split decompressAndMergeSection into two separate functions.Rui Ueyama2017-10-111-4/+1
| | | | | | | Even though they are called sequentially, they are separate operations, so it is better to split it. llvm-svn: 315422
* Handle input section liveness only in MarkLive.cpp.Rui Ueyama2017-10-101-17/+0
| | | | | | | | | | | | The condition whether a section is alive or not by default is becoming increasingly complex, so the decision of garbage collection is spreading over InputSection.h and MarkLive.cpp, which is not a good state. This moves the code to MarkLive.cpp, to keep the file the central place to make decisions about garbage collection. llvm-svn: 315384
* [ELF] - Improve "has non-ABS reloc" error.George Rimar2017-10-101-1/+2
| | | | | | | | It did not contain information about relocation type and symbol. Differential revision: https://reviews.llvm.org/D38623 llvm-svn: 315280
* Make a local variable name shorter. NFC.Rui Ueyama2017-10-101-7/+7
| | | | llvm-svn: 315271
* Simplify.Rui Ueyama2017-10-101-6/+6
| | | | llvm-svn: 315270
* Add comment to InputSectionBase::File.Rui Ueyama2017-10-101-9/+0
| | | | | | | This patch also moves declarations so that related declarations next to each other. llvm-svn: 315266
* Inline a small function. NFC.Rui Ueyama2017-10-061-14/+8
| | | | llvm-svn: 315096
* [ELF] Decompress debug info sections earlyShoaib Meenai2017-10-041-3/+9
| | | | | | | | | | | | | | | | | | When reporting a symbol conflict, LLD parses the debug info to report source location information. Sections have not been decompressed at this point, so if an object file contains zlib compressed debug info, LLD ends up passing this compressed debug info to the DWARF parser, which causes debug info parsing failures and can trigger assertions in the parser (as the test case demonstrates). Decompress debug sections when constructing the LLDDwarfObj to avoid this issue. This doesn't handle GNU-style compressed debug info sections (.zdebug_*), which at present are simply ignored by LLDDwarfObj; those can be done in a follow-up. Differential Revision: https://reviews.llvm.org/D38491 llvm-svn: 314866
* Inline hot functions.Rui Ueyama2017-10-011-12/+0
| | | | llvm-svn: 314637
* Fix 32-bit buildbots.Rui Ueyama2017-09-301-2/+3
| | | | | | | | | | | The result of hash_value(StringRef) depends on sizeof(size_t). That causes lld to create different mergeable table contents on 32-bit machines. This patch is to use xxHash64 so that we get the same hash values on 32-bit machines. llvm-svn: 314603
* [ELF] - Change error message text. NFC.George Rimar2017-09-281-3/+3
| | | | | | As suggested in review comments of D38170. llvm-svn: 314392
* [ELF] - Speedup -r and --emit-relocsGeorge Rimar2017-09-271-5/+0
| | | | | | | | | | | | | | | | This is "Bug 34688 - lld much slower than bfd when linking the linux kernel" Inside copyRelocations() we have O(N*M) algorithm, where N - amount of relocations and M - amount of symbols in symbol table. It isincredibly slow for linking linux kernel. Patch creates local search tables to speedup. With this fix link time goes for me from 12.95s to 0.55s what is almost 23x faster. (used release LLD). Differential revision: https://reviews.llvm.org/D38129 llvm-svn: 314282
* [AArch64] Implement R_AARCH64_ LD_PREL_LO19.Davide Italiano2017-09-201-0/+1
| | | | | | | | Fixes PR34660. Differential Revision: https://reviews.llvm.org/D38053 llvm-svn: 313841
* Revert rL313697, "Compact EhSectionPiece from 32 bytes to 16 bytes."NAKAMURA Takumi2017-09-201-1/+1
| | | | | | | It broke selfhosting. http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/4896 llvm-svn: 313731
* Compact EhSectionPiece from 32 bytes to 16 bytes.Rui Ueyama2017-09-191-1/+1
| | | | | | | | | | | | | | EhSectionPiece used to have a pointer to a section, but that pointer was mostly redundant because we almost always know what the section is without using that pointer. This patch removes the pointer from the struct. This patch also use uint32_t/int32_t instead of size_t to represent offsets that are hardly be larger than 4 GiB. At the moment, I think it is OK even if we cannot handle .eh_frame sections larger than 4 GiB. Differential Revision: https://reviews.llvm.org/D38012 llvm-svn: 313697
* [ELF] - Don't crash when --emit-relocs is used with --gc-sectionsGeorge Rimar2017-09-191-1/+17
| | | | | | | | | We crashed when --emit-relocs was used and relocated section was collected by GC. Differential revision: https://reviews.llvm.org/D37561 llvm-svn: 313620
* [ELF] - Introduce std::vector<InputFile *> global arrays.George Rimar2017-09-191-7/+2
| | | | | | | | | | | | This patch removes lot of static Instances arrays from different input file classes and introduces global arrays for access instead. Similar to arrays we have for InputSections/OutputSectionCommands. It allows to iterate over input files in a non-templated code. Differential revision: https://reviews.llvm.org/D35987 llvm-svn: 313619
* Add a helper for checking for weak undef. NFC.Rafael Espindola2017-09-131-2/+2
| | | | llvm-svn: 313188
* [MIPS] Initial support of microMIPS code linkingSimon Atanasyan2017-09-121-1/+1
| | | | | | | | | | | | | | | | The patch implements initial support of microMIPS code linking: - Handle microMIPS specific relocations. - Emit both R1-R5 and R6 microMIPS PLT records. For now linking mixed set of regular and microMIPS object files is not supported. Also the patch does not handle (setup and clear) the least-significant bit of an address which is utilized as the ISA mode bit and allows to make jump between regular and microMIPS code without any thunks. Differential revision: https://reviews.llvm.org/D37335 llvm-svn: 313028
OpenPOWER on IntegriCloud