summaryrefslogtreecommitdiff
path: root/lld/ELF/MarkLive.cpp
AgeCommit message (Collapse)Author
2018-06-16[ELF] Pass callables by function_refBenjamin Kramer
No need to create a heavyweight std::function if it's not stored. No functionality change intended.
2018-05-17[ELF] - Do not crash when do --gc-sections for non-allocatable metadata ↵George Rimar
sections. Currently, LLD marks all non-allocatable sections except SHF_REL[A] as Live when doing GC. This can be a reason of the crash when SHF_LINK_ORDER sections are involved, because their parents can be dead. We should do GC for them correctly. The patch implements it. Differential revision: https://reviews.llvm.org/D46880
2018-04-27Split .eh_frame sections in parellel.Rafael Espindola
We can now split them in the same spot we split merge sections.
2018-04-27Split merge sections early.Rafael Espindola
Now that getSectionPiece is fast (uses a hash) it is probably OK to split merge sections early. The reason I want to do this is to split eh_frame sections in the same place. This does mean that we have to decompress early. Given that the only compressed sections are debug info, I don't think we are missing much. It is a small improvement: 0.5% on the geometric mean.
2018-02-28Merge {COFF,ELF}/Strings.cpp to Common/Strings.cpp.Rui Ueyama
This should resolve the issue that lld build fails in some hosts that uses case-insensitive file system. Differential Revision: https://reviews.llvm.org/D43788
2018-02-20Consistent use of header file for ICF and MarkLiveSam Clegg
Previously wasm used a separate header to declare markLive and ELF used to declare ICF. This change makes each backend consistently declare these in their own headers. Differential Revision: https://reviews.llvm.org/D43529
2018-02-17Use toString to print out garbage-collected sections.Rui Ueyama
Currently, archive file name is missing in this message. In general, we should avoid constructing strings in an ad-hoc manner and instead use toString() to get consistent output strings. Differential Revision: https://reviews.llvm.org/D43420
2017-12-20Use dyn_cast instead of dyn_cast_or_null.Rafael Espindola
There should be no null sections in InputSections.
2017-12-20Use a reference for the shared symbol file.Rafael Espindola
Every shared symbol has a file, so we can use a reference.
2017-12-11ELF: Do not follow relocation edges to output sections during GC.Peter Collingbourne
This fixes an assertion error introduced by r320390. Differential Revision: https://reviews.llvm.org/D41095
2017-12-11Handle symbols pointing to output sections.Rafael Espindola
Now that gc sections runs after linker defined symbols are added it can see symbols that point to an OutputSection. Should fix a bot failure.
2017-11-30[ELF] - Handle EhInputSection Live bit in MarkLive.cppGeorge Rimar
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
2017-11-28Move Memory.{h,cpp} to Common.Rui Ueyama
Differential Revision: https://reviews.llvm.org/D40571
2017-11-28Bring back r319008.Rafael Espindola
This includes a fix to mark copy reloc aliases as used. Original message: [ELF] Do not keep symbols if they referenced only from discarded sections. This patch also ensures that in case of "--as-needed" is used, DT_NEEDED entries are not created if they are required only by these eliminated symbols.
2017-11-28Revert r319008, "[ELF] Do not keep symbols if they referenced only from ↵Igor Kudrin
discarded sections." and r319051, "Add a missing test." r319008 broke the LTO bots; r319051 depends on changes in r319008.
2017-11-27[ELF] Do not keep symbols if they referenced only from discarded sections.Igor Kudrin
This patch also ensures that in case of "--as-needed" is used, DT_NEEDED entries are not created if they are required only by these eliminated symbols. Differential Revision: https://reviews.llvm.org/D38790
2017-11-06ELF: Remove function Symbol::isInCurrentOutput().Peter Collingbourne
This function is now equivalent to isDefined().
2017-11-06ELF: Merge DefinedRegular and Defined.Peter Collingbourne
Now that DefinedRegular is the only remaining derived class of Defined, we can merge the two classes. Differential Revision: https://reviews.llvm.org/D39667
2017-11-03Rename SymbolBody -> SymbolRui Ueyama
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
2017-10-31Merge SymbolBody and Symbol into one class, SymbolBody.Rui Ueyama
SymbolBody and Symbol were separated classes due to a historical reason. Symbol used to be a pointer to a SymbolBody, and the relationship between Symbol and SymbolBody was n:1. r2681780 changed that. Since that patch, SymbolBody and Symbol are allocated next to each other to improve memory locality, and they have 1:1 relationship now. So, the separation of Symbol and SymbolBody no longer makes sense. This patch merges them into one class. In order to avoid updating too many places, I chose SymbolBody as a unified name. I'll rename it Symbol in a follow-up patch. Differential Revision: https://reviews.llvm.org/D39406
2017-10-27Rename isInCurrentDSO -> isInCurrentOutput.Rui Ueyama
DSO is short for dynamic shared object, so the function name was a little confusing because it sounded like it didn't work when we were a creating statically-linked executable or something. What we mean by "DSO" here is the current output file that we are creating. Thus the new name. Alternatively, we could call it the current ELF module, but "module" is a overloaded word, so I avoided that.
2017-10-27[ELF] - Simplify reporting of garbage collected sections.George Rimar
This moves reporting of garbage collected sections right after we do GC. That simplifies things. Differential revision: https://reviews.llvm.org/D39058
2017-10-24[ELF] - Do not collect SHT_REL[A] sections unconditionally when ↵George Rimar
--gc-sections and --emit-relocs used together. This is "Bug 34836 - --gc-sections remove relocations from --emit-relocs", When --emit-relocs is used, LLD currently always drops SHT_REL[A] sections from output if --gc-sections is present. Patch fixes the issue. Differential revision: https://reviews.llvm.org/D38724
2017-10-13Handle shared symbols in --gc-sections.Rafael Espindola
We don't want to gc a section if it is used via __start_*, but we were doing that if the same symbol was visible in a shared library.
2017-10-13Simplify. NFC.Rafael Espindola
2017-10-11Remove ScriptConfiguration class and move the members to LinkerScript class.Rui Ueyama
ScriptConfiguration was a class to contain parsed results of linker scripts. LinkerScript is a class to interpret it. That ditinction was needed because we haven't instantiated LinkerScript early (because, IIRC, LinkerScript class was a ELFT template function). So, when we parse linker scripts, we couldn't directly store the result to a LinkerScript instance. Now, that limitation is gone. We instantiate LinkerScript at the very beginning of our main function. We can directly store parse results to a LinkerScript instance.
2017-10-10Handle input section liveness only in MarkLive.cpp.Rui Ueyama
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.
2017-09-29[ELF] Simpler scheme for handling common symbolsBen Dunbobbin
Convert all common symbols to regular symbols after scan. This means that the downstream code does not to handle common symbols as a special case. Differential Revision: https://reviews.llvm.org/D38137
2017-09-20Revert rL313697, "Compact EhSectionPiece from 32 bytes to 16 bytes."NAKAMURA Takumi
It broke selfhosting. http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/4896
2017-09-19Compact EhSectionPiece from 32 bytes to 16 bytes.Rui Ueyama
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
2017-09-18Remove useless accessor.Rui Ueyama
2017-08-10Remove ResolvedReloc.Rui Ueyama
ResolvedReloc struct is always passed to a callback function and not stored anywhere. That is, in effect, we use the struct to pack multiple arguments to one argument, which doesn't make much sense. This patch removes the struct and passes the members to the callback directly.
2017-08-10Garbage-collect common symbols.Rui Ueyama
Liveness is usually a notion of input sections, but this patch adds "liveness" bit to common symbols because they don't belong to any input section. This patch is based on https://reviews.llvm.org/D36520 Differential Revision: https://reviews.llvm.org/D36546
2017-07-26Fix the name of the section end symbol.Rafael Espindola
It is __stop_<sec>, not __end_<sec>.
2017-07-26Detemplate SymbolTable.Rafael Espindola
NFC, just makes it easier to access from non templated code.
2017-06-21ELF: Don't dereference Repl in MarkLive. NFCI.Peter Collingbourne
This is unnecessary because --gc-sections runs before ICF. Differential Revision: https://reviews.llvm.org/D34465
2017-06-15[ELF] Mark symbols referenced from linker script as livePetr Hosek
This is necessary to ensure that sections containing symbols referenced from linker scripts (e.g. in data commands) don't get GC'd. Differential Revision: https://reviews.llvm.org/D34195
2017-06-01[ELF] - Do not crash when proccessing absolute symbols during GC.George Rimar
This is PR33239, previously we segfault on given testcase. Differential revision: https://reviews.llvm.org/D33713
2017-03-20[ELF] - Combine LinkerScriptBase and LinkerScript<ELFT>George Rimar
Patch removes templated linkerscript class. Unfortunately that required 2 additional static methods findSymbol() and addRegularSymbol() because code depends on Symtab<ELFT>::X Differential revision: https://reviews.llvm.org/D30982
2017-03-17Compute Config member function return values only once.Rui Ueyama
We had a few Config member functions that returns configuration values. For example, we had is64() which returns true if the target is 64-bit. The return values of these functions are constant and never change. This patch is to compute them only once to make it clear that they'll never change.
2017-03-17[ELF] Restore GC handling of LINK_ORDER, C-named sections.Evgeniy Stepanov
__start_xxx symbol keeps section xxx alive only if it is not SHF_LINK_ORDER. Such sections can be used for user metadata, when __start_xxx is used to iterate over section contents at runtime, and the liveness is determined solely by the linked (associated) section. This was earlier implemented in r294592, and broken in r296723. Differential Revision: https://reviews.llvm.org/D30964
2017-03-08Remove DefinedSynthetic.Rafael Espindola
With this we have a single section hierarchy. It is a bit less code, but the main advantage will be in a future patch being able to handle foo = symbol_in_obj; in a linker script. Currently that fails since we try to find the output section of symbol_in_obj. With this we should be able to just return an InputSection from the expression.
2017-03-07Remove Config->Mips64EL and define Config->isMips64EL() instead.Rui Ueyama
2017-03-06Detemplate EhInputSection. NFC.Rafael Espindola
2017-03-06Detemplate merge (input and synthetic) sections. NFC.Rafael Espindola
2017-03-06Fully precise gc handling of __start and __stop symbols.Rafael Espindola
This puts us at parity with bfd, which could already gc this case. I noticed the sections not being gced when linking a modified freebsd kernel. A section that was not gced and not mentioned in the linker script would end up breaking the expected layout. Since fixing the gc is relatively simple and an improvement, that seems better than trying to hack the orphan placement code. There are 173 input section in the entire link whose names are valid C identifiers, so this is probably not too performance critical.
2017-03-02Pass a callback to resolveReloc. NFC.Rafael Espindola
This is consistent with rest of the file and opens the way for a relocation keeping multiple sections alive.
2017-03-02Make gc a bit more aggressive.Rafael Espindola
We were not gcing any section whose name was a C identifier. Both gold and bfd only keep those if they are used. To avoid having to create the __start/__stop symbols early or doing string lookups in resolvedReloc, this patch just looks for undefined symbols __start/__stop to decide if a section is needed or not.
2017-02-28De-template DefinedRegular.Rui Ueyama
Differential Revision: https://reviews.llvm.org/D30348
2017-02-27De-template ResolvedReloc as it doesn't actually depends on ELFT.Rui Ueyama
Pointed out by Bob Haarman.