summaryrefslogtreecommitdiffstats
path: root/lld/ELF/SyntheticSections.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add a reference to a Ulrich Drepper's paper.Rui Ueyama2017-03-011-1/+8
| | | | llvm-svn: 296650
* Instead of passing an empty ArrayRef as contents, pass actual contents. NFC.Rui Ueyama2017-03-011-6/+6
| | | | llvm-svn: 296586
* Set output section's st_entsize based on input section's st_entsize.Rui Ueyama2017-03-011-10/+13
| | | | | | | Each input section knows its sh_entsize value, so we can set output section's sh_entsize based on input sections values. llvm-svn: 296577
* Partially rewrite .gnu.hash synthetic section and add comments.Rui Ueyama2017-03-011-89/+72
| | | | | | | | This implementation is probably slightly inefficient than before, but that should be negligible because this is not a performance- critical pass. llvm-svn: 296570
* Add comments about .hash and .gnu.hash.Rui Ueyama2017-02-281-0/+31
| | | | llvm-svn: 296529
* De-template DefinedRegular.Rui Ueyama2017-02-281-12/+11
| | | | | | Differential Revision: https://reviews.llvm.org/D30348 llvm-svn: 296508
* Make it obvious that st_value for common symbols has a different meaning.Rui Ueyama2017-02-281-5/+13
| | | | llvm-svn: 296507
* Fix wrong TLS symbol values.Rui Ueyama2017-02-281-8/+0
| | | | | | | | | | I do not fully understand why we had these values in the tests, but the new value matches what ld.bfd and ld.gold set, so I guess that was just a mistake. Differential Revision: https://reviews.llvm.org/D30441 llvm-svn: 296505
* Revert "Add terminator to .eh_frame sections"Rafael Espindola2017-02-281-8/+1
| | | | | | | | | | | | | | This reverts commit r296378. I am pretty sure this is incorrect. In particular, for just .cfi_startproc nop .cfi_endproc We now add an extra 4 zeros that neither bfd nor gold add. llvm-svn: 296503
* [ELF] - Do not set flags for CopyRelSection. NFC.George Rimar2017-02-281-4/+1
| | | | | | | It does not make sense. Them added either to Out::BssRelRo or Out::Bss, which are always RW. llvm-svn: 296475
* Refactor {Gnu,}HashTableSection classes.Rui Ueyama2017-02-281-20/+29
| | | | | | | | | | | In other places in LLD, we use write32<E> instead of Elf_Word. This patch uses the same technique in the hash table classes. The hash table classes needs improving as they have almost no comments. We at least need to describe the hash table structure and why we have to support two different on-disk hash tables for the same purpose. I'll do that later. llvm-svn: 296439
* Remove useless assignments.Rui Ueyama2017-02-281-10/+7
| | | | | | These assignments seem meaningful, but actually all tests pass without them. llvm-svn: 296436
* Merge SymbolTableSection::add{Global,Local} into one function.Rui Ueyama2017-02-281-7/+6
| | | | | | | | Previously, these two functions put their symbols in different queues. Now that the queues have been merged. So there's no point to keep two separate functions. llvm-svn: 296435
* Return early. NFC.Rui Ueyama2017-02-281-0/+1
| | | | llvm-svn: 296434
* Move SymbolTableSection::getOutputSection to SymbolBody::getOutputSection.Rui Ueyama2017-02-281-31/+1
| | | | | | | | | That function doesn't use any member of SymbolTableSection, so I couldn't see a reason to make it a member of that class. The function takes a SymbolBody, so it is more natural to make it a member of SymbolBody. llvm-svn: 296433
* Simplify SymbolTableSection<ELFT>::finalizeContents().Rui Ueyama2017-02-281-26/+27
| | | | | | | | | Previously, there were three conditions: .symtab, .dynsym or we are producing a relocatable output. Turned out that the third condition is the same as the first one. This patch removes that third condition and simplify code. llvm-svn: 296431
* Improve SymbolTableSection synthetic section.Rui Ueyama2017-02-281-68/+46
| | | | | | | | | | | | | | | | | The previous code was a bit hard to understand because it unnecessarily distinguished local and non-local symbols. It had NumLocals member variable, but that variable didn't have a number of local symbols but had some value that I cannot describe easily. This patch rewrites SynbolTableSection::finalizeContents and SymbolTableSection::writeTo to make it easy to understand. NumLocals member variable has been removed, and writeGlobalSymbols and writeLocalSymbols have been merged into one function. There's still a piece of code that I think unnecessary. I'm not removing that code in this patch, but will do in a follow-up patch. llvm-svn: 296423
* Refactor write{Global,Local}Symbols.Rui Ueyama2017-02-271-19/+15
| | | | | | | | This part of code is hard to understand because NumLocals does not actually mean the number of local symbols but something else (!). We need to rewrite. But before that we need to clean it up. llvm-svn: 296400
* Add terminator to .eh_frame sectionsRui Ueyama2017-02-271-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by Mark Kettenis. Currenlty ld.lld does not add a terminator (a CIE with its length field set to zero) to the .eh_frame sections it generates. While the relevant standards (the AMD64 SysV ABI and the Linux LSB) are not explicit about this, such a terminator is expected by some unwinder implementations and seems to be always emitted by ld.bfd. In addition to that, the Linux LSB https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html#EHFRAME explicitly says that The .eh_frame section shall contain 1 or more Call Frame Information (CFI) records. Currently, if the .eh_frame sections of the input files only contain terminators, ld.lld emits a zero=sized .eh_frame section which clearly doesn't meet that requirement. The diff makes sure a terminator gets added to each .eh_frame section and adjusts all the relevant tests to account for that. An additional test isn't needed as these adjustments mean that the existence of the terminator is tested for by several tests already. Differential Revision: https://reviews.llvm.org/D30335 llvm-svn: 296378
* Simplify sortMipsSymbols function a bit.Rui Ueyama2017-02-271-10/+7
| | | | llvm-svn: 296319
* Add comments to SymbolTableSection.Rui Ueyama2017-02-271-2/+8
| | | | llvm-svn: 296318
* Rename SyntheticSection::finalize -> finalizeContents.Rui Ueyama2017-02-271-15/+15
| | | | | | | In LLD source code, too many functions are called "finalize", although what they do are different. This patch gives it a better name. llvm-svn: 296314
* De-template SyntheticSection.Rui Ueyama2017-02-271-47/+49
| | | | | | This class didn't use ELFT. llvm-svn: 296313
* De-template InterpSection because it doesn't use ELFT.Rui Ueyama2017-02-271-6/+1
| | | | llvm-svn: 296311
* Move SymbolTable<ELFT>::Sections out of the class.Rui Ueyama2017-02-271-4/+4
| | | | | | | | | | 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
* Remove useless template so that Out<ELFT> becomes just Out.Rui Ueyama2017-02-271-10/+10
| | | | llvm-svn: 296307
* De-template SharedSymbol.Rui Ueyama2017-02-261-9/+12
| | | | | | Differential Revision: https://reviews.llvm.org/D30351 llvm-svn: 296303
* Merge OutputSectionBase and OutputSection. NFC.Rafael Espindola2017-02-241-8/+8
| | | | | | | Now that all special sections are SyntheticSections, we only need one OutputSection class. llvm-svn: 296127
* Convert EhOutputSection to be a synthetic section.Rafael Espindola2017-02-231-3/+212
| | | | | | | | With this we complete the transition out of special output sections, and with the previous patches it should be possible to merge OutputSectionBase and OuputSection. llvm-svn: 296023
* Make InputSection a class. NFC.Rafael Espindola2017-02-231-21/+19
| | | | | | | | | 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
* Use uint64_t instead of ELFT*::uint.Rui Ueyama2017-02-231-11/+6
| | | | | | This shouldn't change the meaning of the code. llvm-svn: 295927
* Convert InputSectionBase to a class.Rafael Espindola2017-02-231-36/+46
| | | | | | | Removing this template is not a big win by itself, but opens the way for removing more templates. llvm-svn: 295923
* [ELF] Allow local symbols to be added after global symbolsPeter Smith2017-02-201-2/+9
| | | | | | | | | | | | This change moves the SymbolBodies with isLocal() == true before the global symbols then calculating NumLocals rather than assuming all locals are added before globals and the first NumLocals have isLocal() == true. This permits Thunks to be moved after the pass that adds global symbols from synthetics to the symbol table. Differential revision: https://reviews.llvm.org/D30085 llvm-svn: 295650
* Removes a trivial accessor.Rui Ueyama2017-02-161-1/+1
| | | | llvm-svn: 295288
* Do not overload a one-bit variable, NeedsCopyOrPltAddr.Rui Ueyama2017-02-161-2/+2
| | | | | | | | | This patch removes NeedsCopyOrPltAddr and instead add two variables, NeedsCopy and NeedsPltAddr. This uses one more bit in Symbol class, but the actual size doesn't increase because we had unused bits. This should improve code readability. llvm-svn: 295287
* Addends should always be signed.Rafael Espindola2017-02-161-5/+4
| | | | | | | | | | In the target dependent code we already always return a int64_t. In the target independent code we carefully use uintX_t, which has the same result given 2 complement rules. This just simplifies the code to use int64_t everywhere. llvm-svn: 295263
* Fix the st_name of section symbols.Rafael Espindola2017-02-151-3/+4
| | | | | | | If it is non-zero then objdump will print an empty name when printing relocations against the section. llvm-svn: 295129
* [ELF][MIPS] Use `InputSectionBase::getOutputSection()` to access output ↵Simon Atanasyan2017-02-141-2/+3
| | | | | | | | | sections from the `MipsGotSection` Follow-up to r294005. This patch restores handling of MISP GOT relocations against merge sections. llvm-svn: 295040
* Do not store a computable attributes to Config.Rui Ueyama2017-02-141-1/+1
| | | | llvm-svn: 295031
* Create only one section symbol per section.Rafael Espindola2017-02-111-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Unfortunately some consumers of our .o files produced with -r expect only one section symbol per section. That is true of at least of go's own linker. Combining them is a somewhat convoluted process. We have to create a symbol for every section since we don't know which ones will be needed. The relocation sections also have to be written first to handle the Elf_Rel addend. I did consider a completely different approach: We could remove the -r special case of relocation sections when reading. We would instead have a copyRelocs function that is used instead of scanRelocs. It would create a DynamicReloc for each relocation and a RelocationSection for each input relocation section. A complication of such change is that DynamicReloc would have to take a section index and a input section instead of a symbol since with -emit-relocs some DynamicReloc would hold relocations referring to the dynamic symbol table and other to the static symbol table. That would be a pretty big change, and if we do it it is probably better to do it as a refactoring. llvm-svn: 294816
* [ELF] Refactor PltSection and IPltSection into PltSection [NFC]Peter Smith2017-02-091-52/+24
| | | | | | | | | | | | Much of the code in PltSection and IPltSection is similar, we identify the IPlt by a HeaderSize of 0 and alter our behaviour in the member functions appropriately: -Iplt does not have a header -Iplt always follows after the Plt Differential Revision: https://reviews.llvm.org/D29664 llvm-svn: 294579
* [ELF] Use synthetic section to hold copy relocationPeter Smith2017-02-091-3/+15
| | | | | | | | | | | | | | When we need a copy relocation we create a synthetic SHT_NOBITS section that contains the right amount of ZI and assign it to either .bss or .rel.ro.bss as appropriate. This allows the dynamic relocation to be placed on the InputSection, removing the last case where a dynamic relocation is stored as an offset from the OutputSection. This has the side effect that we can run assignOffsets() after scanRelocs() without losing the additional ZI needed for the copy relocations. Differential Revision: https://reviews.llvm.org/D29637 llvm-svn: 294577
* Stop propagating Entsize.Rafael Espindola2017-02-031-4/+1
| | | | | | | Now that we combine multiple synthetic merge section into one output section there is no point in trying to propagate a value. llvm-svn: 294048
* Replace MergeOutputSection with a synthetic section.Rafael Espindola2017-02-031-2/+82
| | | | | | | | | | | | | | With a synthetic merge section we can have, for example, a single .rodata section with stings, fixed sized constants and non merge constants. I can be simplified further by not setting Entsize, but that is probably better done is a followup patch. This should allow some cleanup in the linker script code now that every output section command maps to just one output section. llvm-svn: 294005
* [ELF] Use SyntheticSections for ThunksPeter Smith2017-02-011-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | Thunks are now implemented by redirecting the relocation to the symbol S, to a symbol TS in a Thunk. The Thunk will transfer control to S. This has the following implications: - All the side-effects of Thunks happen within createThunks() - Thunks are no longer stored in InputSections and Symbols no longer need to hold a pointer to a Thunk - The synthetic Thunk sections need to be merged into OutputSections This implementation is almost a direct conversion of the existing Thunks with the following exceptions: - Mips LA25 Thunks are placed before the InputSection that defines the symbol that needs a Thunk. - All ARM Thunks are placed at the end of the OutputSection of the first caller to the Thunk. Range extension Thunks are not supported yet so it is optimistically assumed that all Thunks can be reused. This is a recommit of r293283 with a fixed comparison predicate as std::merge requires a strict weak ordering. Differential revision: https://reviews.llvm.org/D29327 llvm-svn: 293757
* Revert "[ELF][ARM] Use SyntheticSections for Thunks"Rui Ueyama2017-01-281-26/+0
| | | | | | This reverts commit r293283 because it broke MSVC build. llvm-svn: 293352
* [ELF][ARM] Use SyntheticSections for ThunksPeter Smith2017-01-271-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | Thunks are now implemented by redirecting the relocation to the symbol S, to a symbol TS in a Thunk. The Thunk will transfer control to S. This has the following implications: - All the side-effects of Thunks happen within createThunks() - Thunks are no longer stored in InputSections and Symbols no longer need to hold a pointer to a Thunk - The synthetic Thunk sections need to be merged into OutputSections This implementation is almost a direct conversion of the existing Thunks with the following exceptions: - Mips LA25 Thunks are placed before the InputSection that defines the symbol that needs a Thunk. - All ARM Thunks are placed at the end of the OutputSection of the first caller to the Thunk. Range extension Thunks are not supported yet so it is optimistically assumed that all Thunks can be reused. Differential Revision: https://reviews.llvm.org/D29129 llvm-svn: 293283
* Fix -r when the input has a relocation with no symbol.Rafael Espindola2017-01-261-0/+2
| | | | | | Should fix a few freebsd packages with dtrace. llvm-svn: 293177
* [ELF] Add local mapping symbols to ARM PLT entriesPeter Smith2017-01-251-0/+44
| | | | | | | | | | | | | Mapping symbols allow a mapping symbol aware disassembler to correctly disassemble the PLT when the code immediately prior to the PLT is Thumb. To implement this we add a function to add symbols with local binding to be defined in SyntheticSymbols. Differential Revision: https://reviews.llvm.org/D28956 llvm-svn: 293044
* [ELF] - Fixed crash after incrementing end iterator.George Rimar2017-01-241-1/+1
| | | | | | | | | | | | | | | | | | | | Next code crashed under MSVS2015 for me: this->OutSec->Info = this->Info = 1 + It - Symbols.begin(); Because It was end() and addition of 1 is not allowed. vector implementation catched and failed that inside: _Myiter& operator+=(difference_type _Off) { // increment by integer #if _ITERATOR_DEBUG_LEVEL == 2 if (this->_Getcont() == 0 || this->_Ptr + _Off < ((_Myvec *)this->_Getcont())->_Myfirst || ((_Myvec *)this->_Getcont())->_Mylast < this->_Ptr + _Off) { // report error _DEBUG_ERROR("vector iterator + offset out of range"); _SCL_SECURE_OUT_OF_RANGE; llvm-svn: 292940
OpenPOWER on IntegriCloud