summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputFiles.h
Commit message (Collapse)AuthorAgeFilesLines
...
* Add a helper function to define symbols.Rui Ueyama2016-10-201-2/+0
| | | | | | | Also replace std::copy with memcpy because in other places we are using memcpy. llvm-svn: 284700
* [ThinLTO] Avoid archive member collisions.Davide Italiano2016-10-121-3/+11
| | | | | | | | This fixes PR30665. Differential Revision: https://reviews.llvm.org/D25495 llvm-svn: 284034
* [ELF][ARM] Garbage collection support for .ARM.exidx sectionsPeter Smith2016-10-101-0/+1
| | | | | | | | | | | | | | | .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] - Do not crash on invalid symbol index.George Rimar2016-10-041-0/+2
| | | | | | | | | | | | | | Relative to PR30540. If .symtab has invalid type in elf, no bodies are created and any relocation that tries to access them will fail. The same can happen if symbol index is just incorrect. This was revealed by "id_000005,sig_11,src_000000,op_flip2,pos_420" Differential revision: https://reviews.llvm.org/D25025 llvm-svn: 283201
* [ELF/LTO] Switch to the new resolution-based API.Davide Italiano2016-09-291-6/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D24492 llvm-svn: 282656
* Simplify InputFile ownership management.Rui Ueyama2016-09-141-5/+14
| | | | | | | | | | | | | | | | | | | | 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
* [ELF] Add support for -b binaryMichael J. Spencer2016-09-091-0/+13
| | | | | | | | | | 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
* [ELF][MIPS] Support .MIPS.abiflags sectionSimon Atanasyan2016-08-121-0/+2
| | | | | | | 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
* COFF: Implement /linkrepro flag.Peter Collingbourne2016-07-261-0/+1
| | | | | | | | | | | | | | | | This flag is implemented similarly to --reproduce in the ELF linker. This patch implements /linkrepro by moving the cpio writer and associated utility functions to lldCore, and using that implementation in both linkers. One COFF-specific detail is that we store the object file from which the resource files were created in our reproducer, rather than the resource files themselves. This allows the reproducer to be used on non-Windows systems for example. Differential Revision: https://reviews.llvm.org/D22418 llvm-svn: 276719
* ELF: Include filenames in error messages.Rui Ueyama2016-07-151-1/+2
| | | | llvm-svn: 275608
* Inline traceUndefined function.Rui Ueyama2016-07-151-2/+0
| | | | llvm-svn: 275531
* Fix memory leak.Rui Ueyama2016-07-081-1/+4
| | | | | | | | | | Symbol's dtors are not called because they are allocated using BumpPtrAllocators. So, members of std::unique_ptr type are not freed when symbols are deallocated. This patch is to allocate Thunks using BumpPtrAllocators. llvm-svn: 274896
* Refactor ELF type inference functions.Rui Ueyama2016-06-291-2/+5
| | | | | | | | | | | | | Previously, we initialized Config->EKind and Config->EMachine when we instantiate ELF objects. That was not an ideal location to do that because the logic was buried too deep inside a concrete logic. This patch moves the code to the driver so that the initialization becomes explicit. Differential Revision: http://reviews.llvm.org/D21784 llvm-svn: 274089
* Implement --trace-symbol=symbol option.Rui Ueyama2016-06-231-0/+2
| | | | | | | | | | | | | | | Patch by Shridhar Joshi. This option provides names of all the link time modules which define and reference symbols requested by user. This helps to speed up application development by detecting references causing undefined symbols. It also helps in detecting symbols being resolved to wrong (unintended) definitions in case of applications containing multiple definitions for same symbols with different types, bindings. Implements PR28226. llvm-svn: 273536
* Don't include --start-lib/--end-lib files twice.Rafael Espindola2016-06-141-0/+2
| | | | | | | | | This should never happen with correct programs, but it is trivial write a testcase where lld would crash or report duplicated symbols. We now behave like when an archive is used and include the file only once. llvm-svn: 272724
* Rename EHInputSection -> EhInputSection.Rui Ueyama2016-05-241-1/+1
| | | | llvm-svn: 270532
* Print member name in undefined symbol error.Rafael Espindola2016-05-091-0/+3
| | | | llvm-svn: 268976
* [ELF][MIPS] Read/write .MIPS.options sectionSimon Atanasyan2016-05-041-0/+2
| | | | | | | | | MIPS N64 ABI introduces .MIPS.options section which specifies miscellaneous options to be applied to an object/shared/executable file. LLVM as well as modern versions of GNU tools read and write the only type of the options - ODK_REGINFO. It is exact copy of .reginfo section used by O32 ABI. llvm-svn: 268485
* ELF: New symbol table design.Peter Collingbourne2016-05-011-27/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements a new design for the symbol table that stores SymbolBodies within a memory region of the Symbol object. Symbols are mutated by constructing SymbolBodies in place over existing SymbolBodies, rather than by mutating pointers. As mentioned in the initial proposal [1], this memory layout helps reduce the cache miss rate by improving memory locality. Performance numbers: old(s) new(s) Without debug info: chrome 7.178 6.432 (-11.5%) LLVMgold.so 0.505 0.502 (-0.5%) clang 0.954 0.827 (-15.4%) llvm-as 0.052 0.045 (-15.5%) With debug info: scylla 5.695 5.613 (-1.5%) clang 14.396 14.143 (-1.8%) Performance counter results show that the fewer required indirections is indeed the cause of the improved performance. For example, when linking chrome, stalled cycles decreases from 14,556,444,002 to 12,959,238,310, and instructions per cycle increases from 0.78 to 0.83. We are also executing many fewer instructions (15,516,401,933 down to 15,002,434,310), probably because we spend less time allocating SymbolBodies. The new mechanism by which symbols are added to the symbol table is by calling add* functions on the SymbolTable. In this patch, I handle local symbols by storing them inside "unparented" SymbolBodies. This is suboptimal, but if we do want to try to avoid allocating these SymbolBodies, we can probably do that separately. I also removed a few members from the SymbolBody class that were only being used to pass information from the input file to the symbol table. This patch implements the new design for the ELF linker only. I intend to prepare a similar patch for the COFF linker. [1] http://lists.llvm.org/pipermail/llvm-dev/2016-April/098832.html Differential Revision: http://reviews.llvm.org/D19752 llvm-svn: 268178
* Use a single context for lto.Rafael Espindola2016-04-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using multiple context used to be a really big memory saving because we could free memory from each file while the linker proceeded with the symbol resolution. We are getting lazier about reading data from the bitcode, so I was curious if this was still a good tradeoff. One thing that is a bit annoying is that we still have to copy the symbol names. The problem is that the names are stored in the Module and get freed when we move the module bits during linking. Long term I think the solution is to add a symbol table to the bitcode. That way IRObject file will not need to use a Module or a Context and we can drop it while still keeping a StringRef to the names. This patch is still be an interesting medium term improvement. When linking llvm-as without debug info this patch is a small speedup: master: 29.861877513 seconds patch: 29.814533787 seconds With debug info the numbers are master: 34.765181469 seconds patch: 34.563351584 seconds The peak memory usage when linking llvm-as with debug info was master: 599.10MB patch: 600.13MB llvm-svn: 267921
* ELF: Create .gnu.version and .gnu.version_r sections when linking against ↵Peter Collingbourne2016-04-271-0/+19
| | | | | | | | versioned DSOs. Differential Revision: http://reviews.llvm.org/D19464 llvm-svn: 267775
* ELF: Move code to where it is used, and related cleanups. NFC.Peter Collingbourne2016-04-261-0/+5
| | | | | | Differential Revision: http://reviews.llvm.org/D19490 llvm-svn: 267637
* Call repl in getSymbolBody. NFC.Rafael Espindola2016-04-261-1/+1
| | | | | | Every caller was doing it. llvm-svn: 267603
* [LTO] Create Undefined Bitcode symbol when we drop a comdat member.Davide Italiano2016-04-221-0/+5
| | | | | | Differential Revision: http://reviews.llvm.org/D19389 llvm-svn: 267181
* This reverts commit r267154 and r267161.Rafael Espindola2016-04-221-6/+0
| | | | | | | | | | | | | | | | It turns out that this will read data from the section to properly handle Elf_Rel implicit addends. Sorry for the noise. Original messages: Try to fix Windows lld build. Move getRelocTarget to ObjectFile. It doesn't use anything from the InputSection. llvm-svn: 267163
* Move getRelocTarget to ObjectFile.Rafael Espindola2016-04-221-0/+6
| | | | | | It doesn't use anything from the InputSection. llvm-svn: 267154
* ELF: Implement --start-lib and --end-libRui Ueyama2016-04-071-3/+40
| | | | | | | | | | | | | | | | start-lib and end-lib are options to link object files in the same semantics as archive files. If an object is in start-lib and end-lib, the object is linked only when the file is needed to resolve undefined symbols. That means, if an object is in start-lib and end-lib, it behaves as if it were in an archive file. In this patch, I introduced a new notion, LazyObjectFile. That is analogous to Archive file type, but that works for a single object file instead of for an archive file. http://reviews.llvm.org/D18814 llvm-svn: 265710
* Do not allocate MipsReginfo using BumpPtrAllocator.Rui Ueyama2016-04-061-1/+1
| | | | | | So that MipsReginfo's destructor will be called. llvm-svn: 265512
* Fix a memory leak found by check-lld asan tests.Ivan Krasin2016-04-061-0/+1
| | | | | | | | | | | | | | | | | | Summary: This bug was introduced by http://reviews.llvm.org/rL265059, where InputSectionBase got Thunks field, which can do memory allocations. Since InputSectionBase destructors were never called (I count it as another bug), that caused a memory leak when 2 or more thunks are added to a section. The fix to is properly call InputSectionBase destructors from ~ObjectFile. Reviewers: atanasyan, ruiu, rafael Subscribers: rafael, krasin, pcc Differential Revision: http://reviews.llvm.org/D18809 llvm-svn: 265497
* Don't store an Elf_Sym for most symbols.Rafael Espindola2016-04-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Our symbol representation was redundant, and some times would get out of sync. It had an Elf_Sym, but some fields were copied to SymbolBody. Different parts of the code were checking the bits in SymbolBody and others were checking Elf_Sym. There are two general approaches to fix this: * Copy the required information and don't store and Elf_Sym. * Don't copy the information and always use the Elf_Smy. The second way sounds tempting, but has a big problem: we would have to template SymbolBody. I started doing it, but it requires templeting *everything* and creates a bit chicken and egg problem at the driver where we have to find ELFT before we can create an ArchiveFile for example. As much as possible I compared the test differences with what gold and bfd produce to make sure they are still valid. In most cases we are just adding hidden visibility to a local symbol, which is harmless. In most tests this is a small speedup. The only slowdown was scylla (1.006X). The largest speedup was clang with no --build-id, -O3 or --gc-sections (i.e.: focus on the relocations): 1.019X. llvm-svn: 265293
* Use ELFT instead of ELFFile<ELFT>.Rui Ueyama2016-03-141-13/+13
| | | | llvm-svn: 263510
* Remove uint32_X type.Rui Ueyama2016-03-131-6/+1
| | | | | | This type is equivalent to Elf_Word type. llvm-svn: 263397
* ELF: Split initializeSections and add comments.Rui Ueyama2016-03-131-0/+1
| | | | llvm-svn: 263395
* Revert r263252: "[ELF] - Change all messages to lowercase to be consistent."Rui Ueyama2016-03-111-8/+7
| | | | | | This reverts commit r263252 because the change contained unrelated changes. llvm-svn: 263272
* [ELF] - Change all messages to lowercase to be consistent.George Rimar2016-03-111-7/+8
| | | | | | | | | | | | | | That is directly opposite to http://reviews.llvm.org/D18045, which was reverted. This patch changes all messages to start from lowercase letter if they were not before. That is done to be consistent with clang. Differential revision: http://reviews.llvm.org/D18085 llvm-svn: 263252
* Avoid calling getNamedValue.Rafael Espindola2016-03-111-8/+7
| | | | | | | In lld we usually avoid hash lookups. In addition to that, IR names are not fully mangled, so it is best to avoid using them whenever possible. llvm-svn: 263248
* Create a SymbolBody for locals.Rafael Espindola2016-03-111-11/+6
| | | | | | pr26878 shows a case where locals have to be in the got. llvm-svn: 263222
* [lto] Make sure that ctors are added to the combined module.Sean Silva2016-03-111-0/+8
| | | | | | | | | | | | | | Summary: More generally, appending linkage is a special case that we don't want to create a SymbolBody for. Reviewers: rafael, ruiu Subscribers: Bigcheese, llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D18012 llvm-svn: 263179
* Handle comdat in LTO.Rafael Espindola2016-03-021-1/+1
| | | | llvm-svn: 262489
* Rename elf2 to elf.Rafael Espindola2016-02-281-2/+2
| | | | llvm-svn: 262159
* Make SymbolBodies private.Rafael Espindola2016-02-261-2/+2
| | | | | | | | | This makes BitcodeFile a bit closer to ObjectFile. If anyone prefers I can go the other way and delete getSymbols from ObjectFile. llvm-svn: 262072
* Add initial LTO support.Rafael Espindola2016-02-121-2/+16
| | | | llvm-svn: 260726
* ELF: Use StringRef instead of std::string.Rui Ueyama2016-02-021-1/+1
| | | | | | | | All MemoryBuffers for archive files are guaranteed to exist as long as their children are used in the linker. So we don't need to copy strings here. Thanks to Sean Silva for pointing this out. llvm-svn: 259554
* ELF: Include archive names in error messages.Rui Ueyama2016-02-021-1/+7
| | | | | | | | If object files are drawn from archive files, the error message should be something like "conflict symbols in foo.a(bar.o) and baz.o" instead of "conflict symbols in bar.o and baz.o". This patch implements that. llvm-svn: 259475
* Merge identical strings.Rafael Espindola2016-01-291-1/+3
| | | | | | | | | | | This avoids the need to have reserve and addString in sync. We avoid hashing the global symbols again. This means that we don't merge a global symbol that has the same name as some other string, but that doesn't seem very common. The string table size is the same in clang an scylladb with or without hashing global symbols again. llvm-svn: 259136
* Remove another case of almost duplicated code.Rafael Espindola2016-01-271-0/+2
| | | | | | | Were had very similar code for deciding to keep a local symbol and for actually writing it. llvm-svn: 258958
* Simplify function signature. NFC.Rui Ueyama2016-01-211-1/+1
| | | | | | StringTable is a member variable, so we don't need to pass it around. llvm-svn: 258382
* Rename GroupEntryType -> uint32_X.Rui Ueyama2016-01-061-2/+5
| | | | | | | GroupEntryType was a 32-bit integral type but that was not obvious from its name. llvm-svn: 256971
* Rename Comdats -> ComdatGroups.Rui Ueyama2016-01-061-2/+2
| | | | | | | I usually prefer short names, but in this case the new descriptive name should improve readability a bit. llvm-svn: 256899
* Rename SharedFile::parse -> SharedFile::parseRest.Rui Ueyama2016-01-061-1/+1
| | | | | | | | | | | | Unlike ObjectFile or ArchiveFile, SharedFile had two parse functions, parseSoName() and parse(). parse must have been called after parseSoName, but that requirement was not obvious from their names. (So it looked like you could call parse() on a shared object file right away.) This patch rename parseRest. It is now obvious that there's no single parse function for the shared object file. llvm-svn: 256898
OpenPOWER on IntegriCloud