summaryrefslogtreecommitdiffstats
path: root/lld/ELF/SyntheticSections.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix off-by-one error.Rui Ueyama2017-09-251-1/+1
| | | | llvm-svn: 314093
* Do not use StringTableBuilder to build symbol table for .gdb_index.Rui Ueyama2017-09-251-11/+20
| | | | | | | | | | | | | | | | Previously, we had two levels of hash table lookup. The first hash lookup uses CachedHashStringRefs as keys and returns offsets in string table. Then, we did the second hash table lookup to obtain GdbSymbol pointers. But we can directly map strings to GDbSymbols. One test file is updated in this patch because we no longer have a '\0' byte at the start of the string pool, which was automatically inserted by StringTableBuilder. This patch speeds up Clang debug build (with -gdb-index) link time by 0.3 seconds. llvm-svn: 314092
* Compute string hashes early and cache them.Rui Ueyama2017-09-251-6/+7
| | | | | | | | This change alone speeds up linking of Clang debug build with -gdb-index by 1.2 seconds, from 12.5 seconds to 11.3 seconds. (Without -gdb-index, lld takes 8.5 seconds to link the same input files.) llvm-svn: 314090
* Refactor GdbIndexSection. NFC.Rui Ueyama2017-09-241-89/+105
| | | | | | | | | | | | | | | | | | | This patch rewrites a part of GdbIndexSection to address the following issues in the previous implementation: - Previously, some struct declarations were in GdbIndex.h while they were not used in GdbIndex.cpp. Such structs are moved to SyntheticSection.h. - The actual implementation were split into GdbIndexSection and GdbHash section, but that separation didn't make much sense. They are now unified as GdbIndexSection. In addition to the above changes, this patch splits functions, rename variables and remove redundant functions/variables to generally improve code quality. llvm-svn: 314084
* [ELF] - Fix segfault when processing .eh_frame.George Rimar2017-09-201-2/+3
| | | | | | | | | | | | Its a PR34648 which was a segfault that happened because we stored pointers to elements in DenseMap. When DenseMap grows such pointers are invalidated. Solution implemented is to keep elements by pointer and not by value. Differential revision: https://reviews.llvm.org/D38034 llvm-svn: 313741
* Revert rL313697, "Compact EhSectionPiece from 32 bytes to 16 bytes."NAKAMURA Takumi2017-09-201-13/+13
| | | | | | | 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-13/+13
| | | | | | | | | | | | | | 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
* Rename CieRecord instance variables.Rui Ueyama2017-09-191-26/+26
| | | | | | | | CieRecord is a struct containing a CIE and FDEs, but oftentimes the struct itself is named `Cie` which caused some confusion. This patch renames them `CieRecords` or `Rec`. llvm-svn: 313681
* Simplify. NFC.Rui Ueyama2017-09-191-8/+6
| | | | llvm-svn: 313667
* [ELF] - Introduce std::vector<InputFile *> global arrays.George Rimar2017-09-191-1/+3
| | | | | | | | | | | | 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
* Rename EhSectionPiece::ID -> EhSectionPiece::Sec.Rui Ueyama2017-09-181-2/+2
| | | | | | ID sounds like an identifier, but this is actually a pointer to a section. llvm-svn: 313588
* Do not use inheritance for EhSectionPiece.Rui Ueyama2017-09-181-1/+1
| | | | | | | | EhSectionPiece inherited from SectionPiece, but we did not actually use EhSectionPiece objects as SectionPiece ojbects. They were handled as distinct types. So it didn't make much sense to use inheritance. llvm-svn: 313587
* Remove useless accessor.Rui Ueyama2017-09-181-3/+3
| | | | llvm-svn: 313586
* Remove redundant cast<> and null check.Rui Ueyama2017-09-181-6/+4
| | | | | | | | "Repl" member is guranteed to have a non-null pointer. If an input section is not merged by ICF, "Repl" points to "this". Otherwise, it points to some other section. It must not be NULL. llvm-svn: 313556
* Add a comment about a workaround for ld.gold -r.Rui Ueyama2017-09-121-0/+7
| | | | llvm-svn: 313095
* Remove Offset from Common.Rafael Espindola2017-09-121-1/+3
| | | | | | It is not needed since it is always 0. llvm-svn: 313076
* Currently lld creates a single section to collect all commons. There is no wayDmitry Mikulin2017-09-081-32/+13
| | | | | | | | | | | | | | | to separate commons based on file name patterns. The following linker script construct does not work because commons are allocated before section placement is done and the only synthesized BssSection that holds all commons has no file associated with it: SECTIONS { .common_0 : { *file0.o(COMMON) }} This patch changes the allocation of commons to create a section per common symbol and let the section logic do the layout. Differential revision: https://reviews.llvm.org/D37489 llvm-svn: 312796
* [LLD] Fix padding of .eh_frame when in executable segmentAndrew Ng2017-09-071-1/+6
| | | | | | | | | | | | | | | | | The default padding for an executable segment is the target trap instruction which for x86_64 is 0xCC. However, the .eh_frame section requires the padding to be zero. The code that writes the .eh_frame section assumes that its segment is zero initialized and does not explicitly write the zero padding. This does not work when the .eh_frame section is in the executable segment (for example when using -no-rosegment). This patch changes the .eh_frame writing code to explicitly write the zero padding. Differential Revision: https://reviews.llvm.org/D37462 llvm-svn: 312706
* [ELF] - Never call splitIntoPieces() twice. NFC.George Rimar2017-09-011-1/+0
| | | | | | | | Previously it was called twice for .comment synthetic section. That created 2 pieces of data, which was deduplicated anyways, but was not clean. llvm-svn: 312327
* Remove GdbIndexSection::finalizeContents.Rui Ueyama2017-08-151-25/+14
| | | | | | | | GdbIndexSection doesn't need lazy finalization because when an instance of the class is created, we already know all debug info sections. We can initialize the instnace in the ctor. llvm-svn: 310931
* Use ArrayRef instead of std::vector&.Rui Ueyama2017-08-151-4/+4
| | | | llvm-svn: 310930
* Update a comment and rename a function.Rui Ueyama2017-08-151-5/+3
| | | | llvm-svn: 310929
* Remove SymbolTable::findInCurrentDSO.Rui Ueyama2017-08-151-4/+6
| | | | | | | This function doesn't seem to add value to the symbol table as it is easy to write code without it. llvm-svn: 310925
* Garbage-collect common symbols.Rui Ueyama2017-08-101-1/+3
| | | | | | | | | | | | 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
* Move File from SymbolBody to Symbol.Rafael Espindola2017-08-041-2/+2
| | | | | | | | | | | | | With this Symbol has the same size as before, but DefinedRegular goes from 72 to 64 bytes. I also find this a bit easier to read. There are fewer places initializing File for example. This has a small but measurable speed improvement on all tests (1% max). llvm-svn: 310142
* [ELF] Explicitly write null bytes in string tablesJames Henderson2017-08-041-0/+1
| | | | | | | | | | | | | | Following r309829, if a string table appears in an executable segment, the strings will not be null terminated. This is a problem, for example, for the .dynstr section when using -no-rosegment. The strings end up being terminated with 0xcc because prior to this patch, LLD did not explicitly write the null terminators. This change fixes that by always writing the null terminators. Reviewers: rafael Differential Revision: https://reviews.llvm.org/D36267 llvm-svn: 310042
* [ELF] - Replace parallelForEach with ranged form.George Rimar2017-08-041-9/+8
| | | | | | | | Makes code a bit more convinent to write/read. Differential revision: https://reviews.llvm.org/D36089 llvm-svn: 310040
* [ELF] - Use multithreading for building .gdb_index.George Rimar2017-08-011-5/+6
| | | | | | | | Enables multithreaded .gdb_index building. Differential revision: https://reviews.llvm.org/D36090 llvm-svn: 309688
* Merge OutputSectionCommand and OutputSection.Rafael Espindola2017-07-271-1/+1
| | | | | | | | | | | | | This is a bit of a hack, but it is *so* convenient. Now that we create synthetic linker scripts when none is provided, we always have to handle paired OutputSection and OutputsectionCommand and keep a mapping from one to the other. This patch simplifies things by merging them and creating what used to be OutputSectionCommands really early. llvm-svn: 309311
* Rename ObjectFile -> ObjFile.Rui Ueyama2017-07-261-2/+2
| | | | | | | Rename it because it was too easy to conflict with llvm::object::ObjectFile which broke buildbots several times. llvm-svn: 309199
* Detemplate SymbolTable.Rafael Espindola2017-07-261-4/+4
| | | | | | NFC, just makes it easier to access from non templated code. llvm-svn: 309152
* Do not strip SHF_GROUP in elf::decompressAndMergeSections().Rui Ueyama2017-07-201-4/+3
| | | | | | | | SHF_GROUP flag should have been removed when the control reaches here because InputSectionBase turns the flag off. So this code should be redundant. llvm-svn: 308680
* Speed up gdb index creation.Rafael Espindola2017-07-191-14/+8
| | | | | | | | | | | With that in place we can use lld's own infrastructure for the low level detail of dwarf parsing. With this we don't decompress sections twice, we don't scan all realocations and even with this simplistic implementation linking clang with gdb index goes from 34.09 seconds to 20.80 seconds. llvm-svn: 308544
* [ELF] - Fix member name: alignment -> Alignment. NFC.George Rimar2017-07-181-1/+1
| | | | llvm-svn: 308300
* [ELF] - Apply clang-format. NFC.George Rimar2017-07-181-13/+5
| | | | llvm-svn: 308297
* [ELF] - Implement filter library support (-F / --filter)George Rimar2017-07-171-0/+2
| | | | | | | | | | | | | | | | | | This is PR33766. -F name --filter=name When creating an ELF shared object, set the internal DT_FILTER field to the specified name. This tells the dynamic linker that the symbol table of the shared object which is being created should be used as a filter on the symbol table of the shared object name. If you later link a program against this filter object, then, when you run the program, the dynamic linker will see the DT_FILTER field. The dynamic linker will resolve symbols according to the symbol table of the filter object as usual, but it will actually link to the definitions found in the shared object name. Thus the filter object can be used to select a subset of the symbols provided by the object name. (https://linux.die.net/man/1/ld). Shared Objects as Filters: https://docs.oracle.com/cd/E19683-01/817-3677/chapter4-31738/index.html Differential revision: https://reviews.llvm.org/D35352 llvm-svn: 308167
* [ELF] Fix writing the content of the .got section in a wrong place.Igor Kudrin2017-07-141-1/+6
| | | | | | | | | | In filling the .got sections, InputSection::OutSecOff was added twice when finding the position to apply a relocation: first time in InputSection::writeTo() and then in SectionBase::getOffset(). Differential revision: https://reviews.llvm.org/D34232 llvm-svn: 308003
* Refactor gdb index creation.Rafael Espindola2017-07-121-27/+33
| | | | | | | | | | | | | | I have a patch to let DwarfContext defer to lld for getting section contents and relocations. That is a pretty big performance improvement. This is just a refactoring to make that easier to do. This change makes the *creation* of gdb index a dedicated step and makes that templated. That is so that we can uses Elf_Rel in the code. llvm-svn: 307867
* [ELF] - Fail the link if something happens on DWARF parsing stage of ↵George Rimar2017-07-071-1/+5
| | | | | | | | | | | | | | | | | | -gdb-index building This is relative to PR33173, Previously if something wrong happened on DWARF parsers side during parsing object for building gdb index (like was in PR: unsupported relocation) then LLD continued and finished the link. DWARF parsers sure showed error message on their side, but that is all. Patch changes behavior to fail the link in this case and show more detailed message. Differential revision: https://reviews.llvm.org/D34814 llvm-svn: 307370
* Use Entry::SecSize in a couple of cases.Rafael Espindola2017-07-051-4/+5
| | | | | | | This avoids having to compute relocation section sizes early, removing the last use of assignOffsets. llvm-svn: 307219
* Add basic 64-bit SPARC supportRui Ueyama2017-06-281-3/+17
| | | | | | | | | | | | | | | Add support for the most common SPARC relocations. Make DT_PLTGOT point to the PLT on SPARC. Mark the PLT as executable on SPARC. This adds a basic test that creates a SPARV9 executable that invokes the exit system call on OpenBSD. Patch by Mark Kettenis. Differential Revision: https://reviews.llvm.org/D34618 llvm-svn: 306565
* [ELF] - Do not set st_size field of SHT_UNDEF symbols.George Rimar2017-06-281-1/+8
| | | | | | | | | | | | | | | | | This fixes PR33598. Size field for undefined symbols is not significant. Setting it to fixed value, like zero, may be useful though. For example when we have 2 DSO's, like in this PR, if lower level DSO may change slightly (in part of some symbol's st_size) and higher-level DSO is rebuilt, then tools that monitoring checksum of high level DSO file can notice it and trigger cascade of some other unnecessary actions. If we set st_size to zero, that can be avoided. Differential revision: https://reviews.llvm.org/D34673 llvm-svn: 306526
* ELF: Move section merging before ICF. NFCI.Peter Collingbourne2017-06-121-6/+57
| | | | | | Differential Revision: https://reviews.llvm.org/D34093 llvm-svn: 305176
* [ELF] - Fix build bot.George Rimar2017-06-091-1/+1
| | | | | | | | | | | | | SyntheticSections.cpp:1773:29: error: chosen constructor is explicit in copy-initialization CuVectors.push_back({}); ^~ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/set:428:14: note: constructor declared here explicit set(const value_compare& __comp = value_compare()) ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/vector:702:59: note: passing argument to parameter '__x' here _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x); llvm-svn: 305054
* [ELF] - Make implementation of .gdb index to be more natural for futher ↵George Rimar2017-06-071-50/+90
| | | | | | | | | | | | paralleling. This patch reimplements .gdb_index in more natural way, that makes proccess of switching to multithreaded index building to be trivial. Differential revision: https://reviews.llvm.org/D33552 llvm-svn: 304927
* Delete dead function.Rafael Espindola2017-06-071-11/+0
| | | | llvm-svn: 304914
* [ELF] - Simplify readAddressArea() implementation.George Rimar2017-06-071-17/+10
| | | | | | | | | | | | | | | | | Approach significantly simplifies LLD .gdb_index code and makes it much faster. Also it should resolve issues, like D33176 tries to address once and forever in a clean way. LLC binary linking without patch and without --gdb-index: 1,599241063 LLC binary linking without patch and with --gdb-index: 6,064316262 LLC binary linking with patch and with --gdb-index: 4,116792104 Time spent for building gdbindex changes from (6,064316262 - 1,599241063 == 4,465075199) to (4,116792104- 1,599241063 == 2,517551041). That is 2,517551041/4,465075199 = 0,564 or about 44% speedup. Differential revision: https://reviews.llvm.org/D33183 llvm-svn: 304895
* Move Object format code to lib/BinaryFormat.Zachary Turner2017-06-071-1/+1
| | | | | | | | | | | | This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 llvm-svn: 304864
* Store a single Parent pointer for InputSectionBase.Rafael Espindola2017-05-311-34/+34
| | | | | | | | | | | | | | | Before InputSectionBase had an OutputSection pointer, but that was not always valid. For example, if it was a merge section one actually had to look at MergeSec->OutSec. This was brittle and caused bugs like the one fixed by r304260. We now have a single Parent pointer that points to an OutputSection for InputSection, but to a SyntheticSection for merge sections and .eh_frame. This makes it impossible to accidentally access an invalid OutSec. llvm-svn: 304338
* Simplify. NFC.Rafael Espindola2017-05-311-4/+2
| | | | llvm-svn: 304330
OpenPOWER on IntegriCloud