summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/ELF/SectionChunks.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove the old ELF linker.Rafael Espindola2016-02-281-616/+0
| | | | | | I think it is clear by now that the new linker is viable. llvm-svn: 262158
* Fix Clang-tidy misc-use-override warnings, other minor fixes.Rui Ueyama2015-09-101-3/+3
| | | | | | Patch from Eugene Zelenko! llvm-svn: 247323
* [ELF] Apply segments from linker scriptsDenis Protivensky2015-07-231-0/+4
| | | | | | | | | | | | | | Put sections to segments according to linker scripts if available. Rework the code of TargetLayout::assignSectionsToSegments so it operates on the given list of segments, which can be either read from linker scripts or constructed as before. Handle NONE segments defined in linker scripts by putting corresponding sections to PT_NULL segment. Consider flags set for segments through linker scripts. Differential Revision: http://reviews.llvm.org/D10918 llvm-svn: 243002
* elf: Make error output from AtomSection<ELFT>::write() deterministic.Nico Weber2015-07-121-2/+2
| | | | | | | | | | | | | | | | The function uses parallel_for() and then writes error messages from the parallel loop's body. This produces nondetermistic error messages. Instead, copy error messages to a vector and sort it by the atom's file offsets before printing all error messages after the parallel_for(). This results in a few string copies, but only in the error case. (And passing tests seem more important than performance.) This makes tests elf/AArch64/rel-prel16-overflow.test and elf/AArch64/rel-prel32-overflow.test pass on Windows: Both tests check that atom error messages are emitted in a certain order, and on Windows they happened to be emitted in a different order before this patch. llvm-svn: 241988
* [ELF] Make OutputSection::memSize `const` member function. NFCSimon Atanasyan2015-07-011-1/+1
| | | | llvm-svn: 241194
* [ELF] Simplify dynamic table entry creation.Davide Italiano2015-05-211-1/+1
| | | | | | | Differential Revision: http://reviews.llvm.org/D9921 Reviewed by: atanasyan llvm-svn: 237973
* [ELF] Change return type of the OutputSection::flags() methodSimon Atanasyan2015-04-211-1/+1
| | | | | | | This method returns _flags field which has `uint64_t` type. Now the field's type and the method's return type are consistent. llvm-svn: 235393
* [ELF] Narrow down the type of OutputSection::_sections containerSimon Atanasyan2015-04-211-4/+4
| | | | | | | | | | The `OutputSection::appendSection()` method always gets a pointer to the `Section` class descendants. So it is not necessary to keep them in the vector of `Chunk` pointers. No functional changes. llvm-svn: 235392
* [Mips] Write .reginfo section into the separate PT_MIPS_REGINFO segmentSimon Atanasyan2015-04-211-1/+1
| | | | llvm-svn: 235391
* ELF: Remove redundant namespace qualifiers.Rui Ueyama2015-04-141-7/+6
| | | | llvm-svn: 234938
* ELF: Split SectionChunks.h to SectionChunks.{h,cpp}.Rui Ueyama2015-04-141-919/+52
| | | | | | The size of AArch64TargetHander.cpp.o is now 4.1MB. llvm-svn: 234931
* [ELF] Use type helper Elf_Word instead of plain uint32_t data typeSimon Atanasyan2015-04-141-6/+9
| | | | | | | | That helps to correctly write content of hash table if target and host endianness are not the same. Right now that commit does not affect any supported targets. llvm-svn: 234928
* [ELF] Write whole std::vector using a single `memcpy` callSimon Atanasyan2015-04-141-10/+3
| | | | | | | | | We do not need to iterate over `_buckets` and `_chains` vectors and write all elements one by one. No functional changes. llvm-svn: 234927
* [ELF] Remove redundant type cast to `char*` before passing array to memcpySimon Atanasyan2015-04-141-1/+1
| | | | | | No functional changes. llvm-svn: 234926
* Remove redundant virtual on member functions marked 'override'.David Blaikie2015-04-081-1/+1
| | | | llvm-svn: 234419
* ELF: Minimum alignment value is 1, not 0. NFC.Rui Ueyama2015-04-071-1/+1
| | | | | | | | Maybe we can interpret alignment 0 as "don't care", but for consistency, it's good to set 1 instead of 0 where we allow any alignments. llvm-svn: 234284
* Remove unused includes and forward declarations.Rui Ueyama2015-04-041-0/+1
| | | | llvm-svn: 234070
* [ELF] Merge Layout and TargetLayout classSimon Atanasyan2015-04-031-4/+8
| | | | | | It is enough to have single TargetLayout class. llvm-svn: 234065
* ELF: Remove TargetHandlerBase by merging it with TargetHandler.Rui Ueyama2015-04-011-1/+1
| | | | | | | | | | | | | | | | | | | In r233772, I removed an empty class, DefaultTargetHandler, from the class hierarchy by merging the class with TargetHandler. I then found that TargetHandler and its base class, TargetHandlerBase, are also almost the same. We need to go deeper. In this patch, I merged TargetHandlerBase with TargetHandler. The only difference between them is the existence (or absense) of a pure virtual function registerRelocationName(). I added that function to the (new) TargetHandler. One more thing is that TargetHandler was templated for no reason. I made it non-templated class. llvm-svn: 233773
* [ELF] Change type of `OutputSection::setType()` argument to int64_tSimon Atanasyan2015-03-301-1/+1
| | | | | | | | Type of `OutputSection::_type` field is int64_t. This change makes the field's and the argument's types consistent and allows to assign full range of values to the `OutputSection::_type` field. llvm-svn: 233617
* ELF: Use C++11 non-member initialization.Rui Ueyama2015-03-281-47/+35
| | | | | | | | Setting _alignment member varaible to 0 look suspicious since the minimum alignment value is 1. I'm not going to change that number in this patch, though. llvm-svn: 233472
* Use override keyword instead of virtual.Rui Ueyama2015-03-271-1/+1
| | | | llvm-svn: 233424
* Remove empty constructors.Rui Ueyama2015-03-271-3/+1
| | | | llvm-svn: 233423
* ELF: Remove blank doPreFlight and finalize member functions.Rui Ueyama2015-03-271-2/+0
| | | | | | Make these functions non-pure and define the default implementations. llvm-svn: 233405
* Rename ELFLinkingContext instances "ctx" intead of "context".Rui Ueyama2015-03-271-36/+33
| | | | llvm-svn: 233344
* Use alignment values everywhere instead of log2.Rui Ueyama2015-03-261-2/+2
| | | | | | | | This patch defines implicit conversion between integers and PowerOf2 instances, so uses of the classes is now implicit and look like regular integers. Now we are ready to remove the scaffolding. llvm-svn: 233245
* Remove implicit constructor and operator int from PowerOf2.Rui Ueyama2015-03-261-2/+2
| | | | | | | | | | This patch is to make instantiation and conversion to an integer explicit, so that we can mechanically replace all occurrences of the class with integer in the next step. Now get() returns an alignment value rather than its log2 value. llvm-svn: 233242
* [Mips] Support MIPS N64 relocation record formatSimon Atanasyan2015-03-241-36/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | N64 ABI relocation record r_info field in fact consists of five subfields: * r_sym - symbol index * r_ssym - special symbol * r_type3 - third relocation type * r_type2 - second relocation type * r_type - first relocation type Up to three these relocations applied one by one. The first relocation uses an addendum from the relocation record. Each subsequent relocation takes as its addend the result of the previous operation. Only the final operation actually modifies the location relocated. The first relocation uses as a reference symbol specified by the `r_sym` field. The third relocation assumes NULL symbol. The patch represents these data using LLD model and takes in account additional relocation types during a relocation calculation. Additional relocations do not introduce any new relations between two atoms and just specify operations need to be done during a relocation calculation. The first relocation type (`r_type`) stored in the `Reference::_kindValue`. The rest of relocations and `r_ssym` value are stored in the new `Reference::_tag` field "as-is". I decided to do not "decode" these data on the core LLD level to prevent pollution of the core LLD model by very target specific data. Also I have to override writing of relocation records in the `RelocationTable` class to convert MIPS N64 ABI relocation information from the `Reference` class back to the ELF relocation record. http://reviews.llvm.org/D8533 llvm-svn: 233057
* [ELF] Add missing override keywordSimon Atanasyan2015-03-231-16/+16
| | | | | | No functional changes. llvm-svn: 232938
* [ELF] Use parallel_for_each for writing.Shankar Easwaran2015-03-171-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes improves performance of lld, when self-hosting lld, when compared with the bfd linker. BFD linker on average takes 8 seconds in elapsed time. lld takes 3 seconds elapased time average. Without this change, lld takes ~5 seconds average. The runtime comparisons were done on a release build and measured by running linking thrice. lld self-host without the change ---------------------------------- real 0m3.196s user 0m4.580s sys 0m0.832s lld self-host with lld ----------------------- user 0m3.024s user 0m3.252s sys 0m0.796s time taken to build lld with bfd -------------------------------- real 0m8.419s user 0m7.748s sys 0m0.632s llvm-svn: 232460
* [ELF] Use pcrel format for eh_frame_ptr field encodingSimon Atanasyan2015-03-161-8/+12
| | | | | | | | | | | | | The `eh_frame_ptr` field in the `.eh_frame_hdr` section contains an address of the `.eh_frame` section. Using an absolute 32-bit format for encoding of this field does not work for 64-bit targets. It is better to use a relative format because it covers both 32-bit and 64-bit cases. Sure this work if a distance between `.eh_frame_hdr` and `.eh_frame` sections is less than 4 Gb but it is a rather correct assumption. http://reviews.llvm.org/D8352 llvm-svn: 232414
* [LinkerScript] Implement semantics for simple sections mappingsRafael Auler2015-03-161-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit implements the behaviour of the SECTIONS linker script directive, used to not only define a custom mapping between input and output sections, but also order input sections in the output file. To do this, we modify DefaultLayout with hooks at important places that allow us to re-order input sections according to a custom order. We also add a hook in SegmentChunk to allow us to calculate linker script expressions while assigning virtual addresses to the input sections that live in a segment. Not all SECTIONS constructs are currently supported, but only the ones that do not use special sort orders. It adds two LIT test as practical examples of which sections directives are currently supported. In terms of high-level changes, it creates a new class "script::Sema" that owns all linker script ASTs and the logic for linker script semantics as well. ELFLinkingContext owns a single copy of Sema, which will be used throughout the object file writing process (to layout sections as proposed by the linker script). Other high-level change is that the writer no longer uses a "const" copy of the linking context. This happens because linker script expressions must be calculated *while* calculating final virtual addresses, which is a very late step in object file writing. While calculating these expressions, we need to update the linker script symbol table (inside the semantics object), and, thus, we are "modifying our context" as we prepare to write the file. http://reviews.llvm.org/D8157 llvm-svn: 232402
* [Mips] Implement R_MIPS_TLS_xxx relocation handling in case of N64 ABISimon Atanasyan2015-03-161-2/+6
| | | | llvm-svn: 232361
* Use setVisibility() rather than assigning the value directly.Davide Italiano2015-03-141-2/+3
| | | | | | | We don't want to risk to override wrong st_other bits, and when we need to zero, we can do that explictly. llvm-svn: 232282
* [ELF] Fix DenseMapInfo for StringRefShankar Easwaran2015-03-141-1/+1
| | | | llvm-svn: 232251
* [ELF] Remove ambiguityShankar Easwaran2015-03-141-1/+1
| | | | | | Fix ambiguous finalize function. llvm-svn: 232250
* Remove "inline" from inlined functions.Rui Ueyama2015-03-041-39/+25
| | | | llvm-svn: 231271
* [ELF] Add section group/COMDAT support.Shankar Easwaran2015-02-231-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | SHF_GROUP: Group Member Sections ---------------------------------- A section which is part of a group, and is to be retained or discarded with the group as a whole, is identified by a new section header attribute: SHF_GROUP This section is a member (perhaps the only one) of a group of sections, and the linker should retain or discard all or none of the members. This section must be referenced in a SHT_GROUP section. This attribute flag may be set in any section header, and no other modification or indication is made in the grouped sections. All additional information is contained in the associated SHT_GROUP section. SHT_GROUP: Section Group Definition ------------------------------------- Represents a group section. The section group's sh_link field identifies a symbol table section, and its sh_info field the index of a symbol in that section. The name of that symbol is treated as the identifier of the section group. More information: https://mentorembedded.github.io/cxx-abi/abi/prop-72-comdat.html Added a lot of extensive tests, that tests functionality. llvm-svn: 230195
* [ELF] Add .gnu.linkonce support.Shankar Easwaran2015-02-231-0/+3
| | | | | | | | | | | | | When the GNU linker sees two input sections with the same name, and the name starts with ".gnu.linkonce.", the linker will only keep one copy and discard the other. Any section whose name starts with “.gnu.linkonce.” is a COMDAT section. Some architectures like Hexagon use this section to store floating point constants, that need be deduped. This patch adds gnu.linkonce functionality to the ELFReader. llvm-svn: 230194
* [ELF] Update for LLVM api changeSimon Atanasyan2015-01-251-2/+2
| | | | | | | | | The `Elf_Rel_Impl::setSymbolAndType` method now has the third argument `IsMips64EL` (like complement methods `getSymbol` and `getType`). While we do not support linking of MIPS64 ELF object file just pass `false` to the `setSymbolAndType`. llvm-svn: 227045
* ELF: Support detection of relocation errors during processingWill Newton2015-01-201-2/+36
| | | | | | | | | | | At the moment errors in relocation processing such as out of range values are not detected or at best trapped by asserts which will not be present in release builds. This patch adds support for checking error return values from applyRelocation() calls and printing an appropriate error message. It also adds support for printing multiple errors rather than just the first one. llvm-svn: 226557
* [ELF] Make `TargetRelocationHandler` a regular non-template classSimon Atanasyan2015-01-161-1/+1
| | | | | | | This class defines a relocation handler interface. The interface does not depend on the template argument so the argument is redundant. llvm-svn: 226259
* [ELF] Allow target to adjust a symbol's value for using in a dynamic tagSimon Atanasyan2014-12-101-2/+10
| | | | | | | | | Some targets like microMIPS and ARM Thumb use the last bit of a symbol's value to mark 'compressed' code. This patch adds new virtual function `DynamicTable::getAtomVirtualAddress` which allows to adjust a symbol's value before using it in a dynamic table tags like DT_INIT / DT_FINI. llvm-svn: 223963
* [ELF] Make -init/-fini options compatible with the gnu linkerSimon Atanasyan2014-12-101-0/+28
| | | | | | | | | | | | | | The LLD linker searches initializer and finalizer function names and emits DT_INIT/DT_FINI dynamic table tags to point to these symbols. The -init/-fini command line options override initializer ("_init") and finalizer ("_fini") function names used by default. Now the -init/-fini options do not affect .init_array/.fini_array sections. The corresponding code has been removed. Differential Revision: http://reviews.llvm.org/D6578 llvm-svn: 223917
* Fix a bunch of -Winconsistent-missing-override warnings.Eric Christopher2014-12-041-7/+7
| | | | llvm-svn: 223400
* [ELF] Adjust ELF header entry symbol value if this symbol is microMIPS encodedSimon Atanasyan2014-12-041-9/+8
| | | | | | | To find an AtomLayout object for the given symbol I replace the `Layout::findAtomAddrByName` method by `Layout::findAtomLayoutByName` method. llvm-svn: 223359
* [ELF] Rename align2 to alignment.Shankar Easwaran2014-11-301-21/+21
| | | | | | No change in functionality. llvm-svn: 222975
* [ELF] Create input and output section namesShankar Easwaran2014-11-301-12/+27
| | | | | | No change in functionality. llvm-svn: 222973
* [ELF] Rename MergedSection to OutputSection.Shankar Easwaran2014-11-301-40/+38
| | | | | | No change in functionality. llvm-svn: 222972
* Revert "[ELF] Rename MergedSection to OutputSection."Shankar Easwaran2014-11-191-38/+40
| | | | | | | | | This reverts commit r222310. Not sure which commit is the cause of the failure on the darwin bot. Will need to revert my changes and commit one change at a time. llvm-svn: 222330
OpenPOWER on IntegriCloud