summaryrefslogtreecommitdiffstats
path: root/lld/ELF/MarkLive.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Remove useless accessor.Rui Ueyama2017-09-181-1/+1
| | | | llvm-svn: 313586
* Remove ResolvedReloc.Rui Ueyama2017-08-101-40/+36
| | | | | | | | | 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. llvm-svn: 310620
* Garbage-collect common symbols.Rui Ueyama2017-08-101-5/+17
| | | | | | | | | | | | 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 llvm-svn: 310617
* Fix the name of the section end symbol.Rafael Espindola2017-07-261-1/+1
| | | | | | It is __stop_<sec>, not __end_<sec>. llvm-svn: 309225
* Detemplate SymbolTable.Rafael Espindola2017-07-261-6/+6
| | | | | | NFC, just makes it easier to access from non templated code. llvm-svn: 309152
* ELF: Don't dereference Repl in MarkLive. NFCI.Peter Collingbourne2017-06-211-1/+1
| | | | | | | | This is unnecessary because --gc-sections runs before ICF. Differential Revision: https://reviews.llvm.org/D34465 llvm-svn: 305954
* [ELF] Mark symbols referenced from linker script as livePetr Hosek2017-06-151-0/+2
| | | | | | | | | 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 llvm-svn: 305452
* [ELF] - Do not crash when proccessing absolute symbols during GC.George Rimar2017-06-011-1/+2
| | | | | | | | This is PR33239, previously we segfault on given testcase. Differential revision: https://reviews.llvm.org/D33713 llvm-svn: 304392
* [ELF] - Combine LinkerScriptBase and LinkerScript<ELFT>George Rimar2017-03-201-1/+1
| | | | | | | | | | | | 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 llvm-svn: 298241
* Compute Config member function return values only once.Rui Ueyama2017-03-171-1/+1
| | | | | | | | | | | 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. llvm-svn: 298168
* [ELF] Restore GC handling of LINK_ORDER, C-named sections.Evgeniy Stepanov2017-03-171-3/+2
| | | | | | | | | | | | | __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 llvm-svn: 298154
* Remove DefinedSynthetic.Rafael Espindola2017-03-081-2/+2
| | | | | | | | | | | | | 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. llvm-svn: 297313
* Remove Config->Mips64EL and define Config->isMips64EL() instead.Rui Ueyama2017-03-071-1/+1
| | | | llvm-svn: 297107
* Detemplate EhInputSection. NFC.Rafael Espindola2017-03-061-6/+6
| | | | llvm-svn: 297077
* Detemplate merge (input and synthetic) sections. NFC.Rafael Espindola2017-03-061-1/+1
| | | | llvm-svn: 297061
* Fully precise gc handling of __start and __stop symbols.Rafael Espindola2017-03-061-22/+24
| | | | | | | | | | | | | | | 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. llvm-svn: 297049
* Pass a callback to resolveReloc. NFC.Rafael Espindola2017-03-021-13/+15
| | | | | | | This is consistent with rest of the file and opens the way for a relocation keeping multiple sections alive. llvm-svn: 296788
* Make gc a bit more aggressive.Rafael Espindola2017-03-021-8/+15
| | | | | | | | | | | 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. llvm-svn: 296723
* De-template DefinedRegular.Rui Ueyama2017-02-281-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D30348 llvm-svn: 296508
* De-template ResolvedReloc as it doesn't actually depends on ELFT.Rui Ueyama2017-02-271-12/+10
| | | | | | Pointed out by Bob Haarman. llvm-svn: 296377
* Move SymbolTable<ELFT>::Sections out of the class.Rui Ueyama2017-02-271-1/+1
| | | | | | | | | | The list of all input sections was defined in SymbolTable class for a historical reason. The list itself is not a template. However, because SymbolTable class is a template, we needed to pass around ELFT to access the list. This patch moves the list out of the class so that it doesn't need ELFT. llvm-svn: 296309
* Make InputSection a class. NFC.Rafael Espindola2017-02-231-5/+5
| | | | | | | | | With the current design an InputSection is basically anything that goes directly in a OutputSection. That includes plain input section but also synthetic sections, so this should probably not be a template. llvm-svn: 295993
* Convert InputSectionBase to a class.Rafael Espindola2017-02-231-19/+18
| | | | | | | Removing this template is not a big win by itself, but opens the way for removing more templates. llvm-svn: 295923
* [ELF] - Allow section to have multiple dependent sections.George Rimar2017-02-161-2/+2
| | | | | | | | | | | That fixes a case when section has more than one metadata section. Previously GC would collect one of such sections because we had implementation that stored only last one as dependent. Differential revision: https://reviews.llvm.org/D29981 llvm-svn: 295298
* Handle gcing user created metadata.Rafael Espindola2017-02-091-0/+3
| | | | | | In particular, this should allow us to gc unused asan metadata. llvm-svn: 294592
* Parse relocations only once.Rafael Espindola2016-11-101-14/+10
| | | | | | | | | | | | | | | | Relocations are the last thing that we wore storing a raw section pointer to and parsing on demand. With this patch we parse it only once and store a pointer to the actual data. The patch also changes where we store it. It is now in InputSectionBase. Not all sections have relocations, but most do and this simplifies the logic. It also means that we now only support one relocation section per section. Given that that constraint is maintained even with -r with gold bfd and lld, I think it is OK. llvm-svn: 286459
* Don't add null and discarded sections to the global list.Rafael Espindola2016-11-081-2/+0
| | | | | | Avoids having to skip them multiple times. llvm-svn: 286261
* Create a vector containing all input sections.Rui Ueyama2016-11-051-12/+10
| | | | | | | | | | | | | | | | Previously, we do this piece of code to iterate over all input sections. for (elf::ObjectFile<ELFT> *F : Symtab.getObjectFiles()) for (InputSectionBase<ELFT> *S : F->getSections()) It turned out that this mechanisms doesn't work well with synthetic input sections because synthetic input sections don't belong to any input file. This patch defines a vector that contains all input sections including synthetic ones. llvm-svn: 286051
* Now that the ELFFile constructor does nothing, create it when needed.Rafael Espindola2016-11-031-2/+2
| | | | | | This avoids duplicating the buffer in InputFile. llvm-svn: 285965
* Update for llvm change.Rafael Espindola2016-11-031-4/+4
| | | | llvm-svn: 285956
* Delete trivial getters. NFC.Rafael Espindola2016-10-261-4/+4
| | | | llvm-svn: 285190
* Delete getSectionHdr.Rafael Espindola2016-10-251-4/+4
| | | | | | | | | | | We were fairly inconsistent as to what information should be accessed with getSectionHdr and what information (like alignment) was stored elsewhere. Now all section info has a dedicated getter. The code is also a bit more compact. llvm-svn: 285079
* [ELF] - Applied clang format. NFC.George Rimar2016-10-201-2/+1
| | | | llvm-svn: 284705
* Allow linker-script-defined entry symbols.Rui Ueyama2016-10-201-2/+1
| | | | | | | | Previously, we were checking the existence of an entry symbol too early. It was done before the linker script processor creates symbols defined in scripts. Fixes bug 30743. llvm-svn: 284676
* Don't call markLiveAt for non alloc sections.Rafael Espindola2016-10-191-5/+6
| | | | | | We don't gc them anyway, so just use an early return in Enqueue. llvm-svn: 284663
* [ELF][ARM] Garbage collection support for .ARM.exidx sectionsPeter Smith2016-10-101-0/+2
| | | | | | | | | | | | | | | .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
* Early continue. NFC.Rui Ueyama2016-10-051-9/+9
| | | | llvm-svn: 283382
* Early return. NFC.Rui Ueyama2016-10-041-5/+6
| | | | llvm-svn: 283173
* Don't GC non-alloc mergeable section piecesEugene Leviant2016-09-291-8/+5
| | | | | | Differential revision: https://reviews.llvm.org/D25033 llvm-svn: 282708
* Read addend from the correct location.Rafael Espindola2016-09-291-1/+1
| | | | llvm-svn: 282663
* [ELF] - Fixed linkage error when using -g --gc-sections together.George Rimar2016-09-271-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r282444 introduced new issue, sample program below fails to link on assert(Piece.Live); int main() { return 0; } clang test.cpp -c -o out.o -g ld.lld -flavor gnu --gc-sections out.o -o out Problem is that .debug_info contains relocations to .debug_str: Section (7) .rela.debug_info { .. 0xC R_X86_64_32 .debug_str 0x0 0x12 R_X86_64_32 .debug_str 0x37 .. But we do not preserve .debug_str in a right way now. To fix this we should ignore relocations from non-allocatable sections to allocatable to allow GC work at full power, but still should proccess relocations from non-allocatable to non-allocatable sections as usual to mark some parts of debug sections alive to keep them so we do not end up with such assert when trying to access dead pieces. That looks like what gold/ld do, they do not strip .debug_str section from what I saw using sample provided. Thanks to Evgeny Leviant for suggestions about how to fix this. Differential revision: https://reviews.llvm.org/D24967 llvm-svn: 282495
* Non alloca sections should not keep other sections live.Rafael Espindola2016-09-261-1/+2
| | | | | | | This matches the gold behaviour and is important to prevent debug info from effectively disabling gc. llvm-svn: 282444
* Linkerscript: don't crash when GC .debug_lineEugene Leviant2016-09-261-8/+5
| | | | | | Differential revision: https://reviews.llvm.org/D24870 llvm-svn: 282393
* Linkerscript: do not GC non-allocated sectionsEugene Leviant2016-09-261-3/+5
| | | | | | Differential revision: https://reviews.llvm.org/D24733 llvm-svn: 282391
* [ELF/GC] Don't crash while processing Discarded sections.Davide Italiano2016-09-221-0/+7
| | | | | | | | | | The ELF spec doesn't allow relocations to point directly to a deduplicated COMDAT section but this unfortunately happens in practice. Bail out early instead of crashing. Differential Revision: https://reviews.llvm.org/D24750 llvm-svn: 282197
* Simplify InputFile ownership management.Rui Ueyama2016-09-141-3/+4
| | | | | | | | | | | | | | | | | | | | 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
* Inline small funciton.Rui Ueyama2016-09-131-14/+9
| | | | llvm-svn: 281381
* Store an ArrayRef for Data in InputSectionData.Rafael Espindola2016-09-121-1/+1
| | | | llvm-svn: 281210
* Compute section names only once.Rafael Espindola2016-09-081-1/+1
| | | | | | | | 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
OpenPOWER on IntegriCloud