summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/ELF/DefaultLayout.h
Commit message (Collapse)AuthorAgeFilesLines
* [ELF] Delete empty TargetLayout class and rename DefaultLayout to TargetLayoutSimon Atanasyan2015-04-031-998/+0
| | | | | | No functional changes. llvm-svn: 234052
* ELF: Move x86-64-only function from DefaultLayout to X86_64TargetLayout.Rui Ueyama2015-04-021-46/+0
| | | | | | | | Also removed some over-generalization added in r232866, such as making a function take two parameters and pass two equivalent arguments to the function. llvm-svn: 233882
* ELF: Make findAbsoluteAtom return AtomLayout* instead of an iterator.Rui Ueyama2015-03-311-2/+5
| | | | | | | | | | | All calls of findAbsoluteAtoms seem a bit awkward because of the type of the function. It semantically returns a pointer to an AtomLayout or nothing, so I made the function return AtomLayout*. In this patch, I also expanded some "auto"s because their actual type were not obvious in their contexts. llvm-svn: 233769
* Use cast instead of dyn_cast in combination with llvm_unreachable.Rui Ueyama2015-03-281-8/+7
| | | | llvm-svn: 233456
* Remove else after return.Rui Ueyama2015-03-271-4/+3
| | | | llvm-svn: 233453
* Use lambda instead of defining a class with operator().Rui Ueyama2015-03-271-9/+3
| | | | llvm-svn: 233452
* Rename ELFLinkingContext instances "ctx" intead of "context".Rui Ueyama2015-03-271-20/+19
| | | | llvm-svn: 233344
* [Mips] Support MIPS N64 relocation record formatSimon Atanasyan2015-03-241-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Remove extraneous semicolon in DefaultLayoutRafael Auler2015-03-231-1/+1
| | | | llvm-svn: 232985
* [ELF] OrderPass : Order atoms only by ordinals.Shankar Easwaran2015-03-201-0/+55
| | | | | | | | | | | | | | | | | | | | | | Move the init array/fini array sorting to the Output ELF writer. AFAIK, this is only needed by the X86_64/ARM ABI. This shaves time taken to self host lld by 0.2 seconds. Before patch ---------------- 4791.062059 task-clock # 1.634 CPUs utilized ( +- 0.28% ) 61,107 context-switches # 0.013 M/sec ( +- 0.56% ) 2.932902671 seconds time elapsed ( +- 0.84% ) After patch ------------- 4608.417248 task-clock # 1.669 CPUs utilized ( +- 0.30% ) 61,616 context-switches # 0.013 M/sec ( +- 0.63% ) 2.761012703 seconds time elapsed ( +- 0.63% ) llvm-svn: 232866
* [ELF] Use unordered_map for AdditionalSegmentsShankar Easwaran2015-03-201-3/+4
| | | | | | Fix a leftover class during implementation. llvm-svn: 232864
* Make it compile with MSVC 2013.Rui Ueyama2015-03-171-5/+6
| | | | | | | MSVC 2013 cannot compile this code because of C1001 "internal error". Stop using initializer list without type name. llvm-svn: 232448
* [LinkerScript] Implement semantics for simple sections mappingsRafael Auler2015-03-161-20/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert "[ELF] Change few static functions."Shankar Easwaran2015-03-141-1/+1
| | | | | | | | This reverts commit r232253. Fix comments from dblaikie. Since these functions dont access member state, its ok to be static. llvm-svn: 232271
* [ELF] Change few static functions.Shankar Easwaran2015-03-141-1/+1
| | | | | | Functions hasOutputSegment/maybeGetSOName doesnot need not be static. llvm-svn: 232253
* Use template aliases.Rui Ueyama2015-03-101-2/+2
| | | | | | We dropped Visual Studio 2012 support, so we can use template aliases. llvm-svn: 231756
* Remove "inline" from inlined functions.Rui Ueyama2015-03-041-14/+11
| | | | llvm-svn: 231271
* [ELF][Writer] Use llvm::StringMap insteadShankar Easwaran2015-02-231-1/+1
| | | | | | Cleanup. llvm-svn: 230219
* [ELF] Add section group/COMDAT support.Shankar Easwaran2015-02-231-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | 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][Writer] Use Path to create AtomSection.Shankar Easwaran2015-02-211-21/+21
| | | | | | | | | Now since the correct file path for atoms is available and not clobbered, commit r222309 which was reverted previously can be added back. No change in functionality. llvm-svn: 230138
* Remove unused parameters.Rui Ueyama2015-02-131-2/+2
| | | | llvm-svn: 229055
* Remove class that really does nothing.Rui Ueyama2015-02-131-10/+0
| | | | llvm-svn: 229030
* [ELF][Cleanup] Remove unused functionShankar Easwaran2015-02-121-4/+0
| | | | | | We can add this function when we really have a need. llvm-svn: 228907
* [ELF] Remove stray semicolonShankar Easwaran2015-02-061-1/+0
| | | | llvm-svn: 228378
* [ELF] Speedup creating program headers.Shankar Easwaran2015-02-061-4/+14
| | | | | | | | | | After the total number of program headers are determined, virtual addresses and file offsets need not be reassigned for sections whose virtual addresses and fileoffsets remained the same. This doesnot change any functionality. llvm-svn: 228377
* [ELF] Set order of ctors/dtors sectionShankar Easwaran2015-02-011-0/+2
| | | | llvm-svn: 227707
* [ELF] got/got.plt sections are handled as typeGOTShankar Easwaran2015-02-011-2/+0
| | | | | | | The .got and .got.plt sections are already handled as typeGOT. There is no need to handle these atoms whose contentType is typeData. llvm-svn: 227706
* [ELF] Adjust ELF header entry symbol value if this symbol is microMIPS encodedSimon Atanasyan2014-12-041-5/+5
| | | | | | | To find an AtomLayout object for the given symbol I replace the `Layout::findAtomAddrByName` method by `Layout::findAtomLayoutByName` method. llvm-svn: 223359
* [ELF] Fix layout of output sections.Shankar Easwaran2014-11-301-2/+6
| | | | | | | | | The AtomSections were improperly merging sections from various input files. This patch fixes the problem, with an updated test that was provided by Simon. Thanks to Simon Atanasyan for catching this issue. llvm-svn: 222982
* [ELF] Rename align2 to alignment.Shankar Easwaran2014-11-301-2/+2
| | | | | | No change in functionality. llvm-svn: 222975
* [ELF] Create input and output section namesShankar Easwaran2014-11-301-8/+24
| | | | | | No change in functionality. llvm-svn: 222973
* [ELF] Rename MergedSection to OutputSection.Shankar Easwaran2014-11-301-48/+44
| | | | | | No change in functionality. llvm-svn: 222972
* Revert "[ELF] Sectionkey should also contain path."Shankar Easwaran2014-11-191-18/+14
| | | | | | | | This reverts commit r222309. Reverting because of failures on darwin bot. llvm-svn: 222332
* Revert "[ELF] Rename MergedSection to OutputSection."Shankar Easwaran2014-11-191-44/+48
| | | | | | | | | 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
* Revert "[ELF] Create input and output section names"Shankar Easwaran2014-11-191-27/+8
| | | | | | | | This reverts commit r222311. Reverting because of failure in the darwin bot. llvm-svn: 222329
* [ELF] Handle ctors/dtors sectionsShankar Easwaran2014-11-191-4/+4
| | | | | | | | Move functionality from MIPS target to DefaultLayout. No change in functionality. llvm-svn: 222313
* [ELF] Create input and output section namesShankar Easwaran2014-11-191-8/+27
| | | | | | No change in functionality. llvm-svn: 222311
* [ELF] Rename MergedSection to OutputSection.Shankar Easwaran2014-11-191-48/+44
| | | | | | No change in functionality. llvm-svn: 222310
* [ELF] Sectionkey should also contain path.Shankar Easwaran2014-11-191-14/+18
| | | | | | No change in functionality. llvm-svn: 222309
* [ELF] Change order of section match.Shankar Easwaran2014-11-111-1/+1
| | | | | | Addressed comments from Sean silva. llvm-svn: 221650
* [ELF] Fix values of linker created dynamic variables.Shankar Easwaran2014-11-101-0/+3
| | | | | | | | The value of _DYNAMIC should be pointing at the start of the .dynamic segment. This was pointing to the end of the dynamic segment. Similarly the value of _GLOBAL_OFFSET_TABLE_ was not proper too. llvm-svn: 221587
* [ELF] Remove includes that are not usedShankar Easwaran2014-11-061-2/+0
| | | | llvm-svn: 221430
* [ELF] Use std::find_if insteadShankar Easwaran2014-11-061-2/+0
| | | | llvm-svn: 221426
* [ELF] Fix program headers.Shankar Easwaran2014-11-041-56/+20
| | | | | | | | | The ELF writer creates a invalid binary for few cases with large filesize and memory size for segments. This patch addresses the functionality and updates the test. This patch also cleans up parts of the ELF writer for future enhancements to support Linker scripts. llvm-svn: 221233
* [ELF] Add Readers for all the ELF subtargets.Shankar Easwaran2014-10-181-3/+0
| | | | | | | | | This would permit the ELF reader to check the architecture that is being selected by the linking process. This patch also sorts the include files according to LLVM conventions. llvm-svn: 220129
* Reapply [ELF] Only mark as DT_NEEDED libs that are strictly necessary (r219353)Rafael Auler2014-10-091-0/+11
| | | | | | | | | | | | | | | | | | | | When committed in r219353, this patch originally caused problems because it was not tested in debug build. In such scenarios, Driver.cpp adds two additional passes. These passes serialize all atoms via YAML and reads it back. Since the patch changed ObjectAtom to hold a new reference, the serialization was removing the extra data. This commit implements r219853 in another way, similar to the original MIPS way, by using a StringSet that holds the names of all copied atoms instead of directly holding a reference to the copied atom. In this way, this commit is simpler and eliminate the necessity of changing the DefinedAtom hierarchy to hold a new data. Reviewers: shankarke http://reviews.llvm.org/D5713 llvm-svn: 219449
* Revert "[ELF] Only mark as DT_NEEDED libs that are strictly necessary"Rui Ueyama2014-10-091-15/+1
| | | | | | This reverts commit r219353 because that seems to break buildbots. llvm-svn: 219369
* [ELF] Only mark as DT_NEEDED libs that are strictly necessaryRafael Auler2014-10-081-1/+15
| | | | | | | | | | | | | | | | | | | | | Enhances the creation of an ELF dynamic executable by avoiding recording unnecessary shared libraries as NEEDED to load a program. To do this, we must keep track of not only symbols that were referenced but also of COPY relocations, which steal the symbol from a shared library but does not store from which lib this symbol came from. To fix this, this commit changes ObjectSymbol to store the original library from which this symbol came. With this information, we are able to build a list of the exact shared libraries that must be marked as DT_NEEDED, instead of blindly marking all shared libraries as needed. This logic originally came from the MIPS backend with some adaptation. Reviewers: atanasyan, shankar.easwaran http://reviews.llvm.org/D5574 llvm-svn: 219353
* [ELF] Fix inclusion of weak symbols in the dynamic symbol tableRafael Auler2014-10-081-7/+22
| | | | | | | | | | | | | | | | | This commit implements in the X86_64 ELF lld backend yet another feature that was only available in the MIPS backend. However, this patch changes generic ELF classes to make it trivial for other ELF backends to use this logic too. When creating a dynamic executable that has dynamic relocations against weak undefined symbols, these symbols must be exported to the dynamic symbol table to seek a possible resolution at run time. A common use case is the __gmon_start__ weak glibc undefined symbol. Reviewer: shankarke http://reviews.llvm.org/D5571 llvm-svn: 219349
* [lld] [ELF] Support for general dynamic TLS relocations on X86_64Rafael Auler2014-09-291-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds support for the general dynamic TLS access model for X86_64 (see www.akkadia.org/drepper/tls.pdf). To properly support TLS, the patch also changes the __tls_get_addr atom to be a shared library atom instead of a regularly defined atom (the previous lld approach). This closely models the reality of a function that will be resolved at runtime by the dynamic linker and loader itself (ld.so). I was tempted to force LLD to link against ld.so itself to resolve these symbols, but since GNU ld does not need the ld.so library to resolve this symbol, I decided to mimic its behavior and keep hardwired a definition of __tls_get_addr in the lld code. This patch also moves some important logic that previously was only available to the MIPS lld backend to be used to all ELF backends. This logic, which now lives in the DefaultLayout class, will monitor which external (shared lib) symbols are really imported by the current module and will only populate the dynamic symbol table with used symbols, as opposed to the previous approach of dumping all shared lib symbols in the dynamic symbol table. This is important to this patch to avoid __tls_get_addr from getting injected into all dynamic symbol tables. By solving the previous problem of always adding __tls_get_addr, now the produced symbol tables are slightly smaller. But this impacted several tests that relied on hardwired/predefined sizes of the symbol table, requiring this patch to update such tests. Test Plan: Added a LIT test case that exercises a simple use case of TLS variable in a shared library. Reviewers: ruiu, rafael, Bigcheese, shankarke Reviewed By: Bigcheese, shankarke Subscribers: emaste, shankarke, joerg, kledzik, mcrosier, llvm-commits Projects: #lld Differential Revision: http://reviews.llvm.org/D5505 llvm-svn: 218633
OpenPOWER on IntegriCloud