summaryrefslogtreecommitdiffstats
path: root/lld/ELF/OutputSections.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] - Simplify reporting of garbage collected sections.George Rimar2017-10-271-16/+0
| | | | | | | | | This moves reporting of garbage collected sections right after we do GC. That simplifies things. Differential revision: https://reviews.llvm.org/D39058 llvm-svn: 316759
* [lld] Move Threads to CommonBob Haarman2017-10-131-1/+1
| | | | | | | | | | | | | | | | Summary: This will allow using the functionality from other linkers. It is also a prerequisite for sharing the error logging code. Reviewers: ruiu Reviewed By: ruiu Subscribers: emaste, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D38822 llvm-svn: 315725
* Do not copy Sections vector.Rui Ueyama2017-10-111-1/+1
| | | | llvm-svn: 315436
* Rename BytesDataCommand -> ByteCommand.Rui Ueyama2017-10-111-1/+1
| | | | llvm-svn: 315431
* Rename Commands -> SectionCommands.Rui Ueyama2017-10-111-10/+12
| | | | | | | | | | "Commands" was ambiguous because in the linker script, everything is a command. We used to handle only SECTIONS commands, and at the time, it might make sense to call them the commands, but it is no longer the case. We handle not only SECTIONS but also MEMORY, PHDRS, VERSION, etc., and they are all commands. llvm-svn: 315409
* Remove OutputSection::updateAlignment.Rui Ueyama2017-10-071-1/+1
| | | | | | I feel it is easier to understand without this function. llvm-svn: 315140
* Clarify code by adding a comment.Rui Ueyama2017-10-071-4/+7
| | | | llvm-svn: 315139
* Merge addInputSec with OutputSection::addSection.Rui Ueyama2017-10-071-62/+48
| | | | | | | | | | Previously, when we added an input section to an output section, we called `OutputSectionFactory::addInputSec`. This isn't a good design because, a factory class is intended to create a new object and return it, but in this use case, it will never create a new object. This patch fixes the design flaw. llvm-svn: 315138
* Return early. NFC.Rui Ueyama2017-10-071-10/+11
| | | | llvm-svn: 315137
* Remove unused parameters.Rui Ueyama2017-10-071-6/+4
| | | | llvm-svn: 315133
* Do not mutate Script->Opt.Commands from a leaf helper function.Rui Ueyama2017-10-061-20/+23
| | | | | | | | Factory::addInputSec added an output section to Script->Opt.Commands, but that is too subtle. This patch makes it explicit so that it is easy to see when a new element is added to Script->Opt.Commands. llvm-svn: 315129
* Split addSection into two small functions. NFCI.Rui Ueyama2017-10-061-14/+26
| | | | | | | | | addSection function was hard to read because it behaves differently depending on its arguments but what exactly it does is not clear. Now it should be better. Still, it is not clear (not what but) why it does what it does, but I'll take a look at it later. llvm-svn: 315124
* Inline a small function.Rui Ueyama2017-10-061-8/+3
| | | | llvm-svn: 315113
* [EFL] - Fix incorrect code style. NFC.George Rimar2017-09-281-2/+4
| | | | llvm-svn: 314394
* [ELF] - Do not merge sections from SHT_GROUP when -relocatableGeorge Rimar2017-09-191-6/+8
| | | | | | | | | | | | | | | | | | | This is PR34506. Imagine we have 2 sections the same name but different COMDAT groups: .section .foo,"axG",@progbits,bar,comdat .section .foo,"axG",@progbits,zed,comdat When linking relocatable we do not merge SHT_GROUP sections. But still would merge both input sections .foo into single output section .foo. As a result we will have 2 different SHT_GROUPs containing the same section, what is wrong. Patch fixes the issue, preventing merging SHF_GROUP sections with any others. Differential revision: https://reviews.llvm.org/D37574 llvm-svn: 313621
* [ELF] - Fix comment. NFC.George Rimar2017-09-181-1/+1
| | | | llvm-svn: 313523
* Remove redundant parentheses.Rui Ueyama2017-09-151-1/+1
| | | | llvm-svn: 313408
* [ELF] - Remove one of OutputSectionFactory::addInputSec().George Rimar2017-09-151-40/+46
| | | | | | | | | | Patch removes one of OutputSectionFactory::addInputSec methods. That allows to simplify reporting of discarded sections and should help to D37561. Differential revision: https://reviews.llvm.org/D37735 llvm-svn: 313361
* [ELF] - Move getSymbols() methods to InputFile.George Rimar2017-08-041-1/+1
| | | | | | | | It can help to detemplate code. Differential revision: https://reviews.llvm.org/D35936 llvm-svn: 310049
* [ELF] - Fix "--symbol-ordering-file doesn't work with linker scripts"George Rimar2017-08-041-11/+15
| | | | | | | | | | | | | | | This is PR33889, Patch adds support of combination of linkerscript and -symbol-ordering-file option. If no sorting commands are present in script inside section declaration and no --sort-section option specified, code uses sorting from ordering file if any exist. Differential revision: https://reviews.llvm.org/D35843 llvm-svn: 310045
* Fix the order of section that are not on an order file.Rafael Espindola2017-07-281-1/+1
| | | | | | They were being placed before sections that were listed. llvm-svn: 309391
* Merge OutputSectionCommand and OutputSection.Rafael Espindola2017-07-271-7/+322
| | | | | | | | | | | | | 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
* [ELF] - Apply clang-format. NFC.George Rimar2017-07-181-4/+4
| | | | llvm-svn: 308297
* Remove redundant argument. NFC.Rafael Espindola2017-07-061-3/+1
| | | | llvm-svn: 307279
* Move fabricateDefaultCommands earlier.Rafael Espindola2017-07-051-82/+0
| | | | | | | It is now just after the OutputSections are created, which is as early as it can possibly go. llvm-svn: 307225
* Use Entry::SecSize in a couple of cases.Rafael Espindola2017-07-051-12/+0
| | | | | | | This avoids having to compute relocation section sizes early, removing the last use of assignOffsets. llvm-svn: 307219
* Remove confusing `return`.Rui Ueyama2017-06-261-1/+1
| | | | | | | `addInputSec` returns void. Even though it is syntactically correct, the use of `return` here is just confusing. llvm-svn: 306307
* [ELF] Add an apostrophe after a file name when reporting discarded sections.Igor Kudrin2017-06-221-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D34442 llvm-svn: 305983
* Make OutputSections and OutputSectionCommands globals.Rafael Espindola2017-06-131-0/+3
| | | | | | | This is similar to what we do for InputSections and makes them easier to access. llvm-svn: 305337
* [ICF] Ignore SHF_GROUP flag when comparing two sections.Rui Ueyama2017-06-101-6/+2
| | | | | | | | | | | | | | | | | | | | SHF_GROUP bit doesn't make sense in executables or DSOs, so linkers are expected to remove that bit from section flags. We did that when we create output sections. This patch is to do that earlier than before. Now the flag is dropped when we instantiate input section objects. This change improves ICF. Previously, two sections that differ only in SHF_GROUP flag were not merged, because when the control reached ICF, the flag was still there. Now the flag is dropped before reaching to ICF, so the difference is ignored naturally. This issue was found by pcc. Differential Revision: https://reviews.llvm.org/D34074 llvm-svn: 305134
* Use OutputSectionCommands in assignOffsets.Rafael Espindola2017-06-071-2/+5
| | | | | | This allows moving clearOutputSections earlier. llvm-svn: 304952
* [ELF] - Do not merge relocation sections by name when using --emit-relocs.George Rimar2017-06-071-0/+14
| | | | | | | | | | | | Previously we would merge relocation sections by name. That did not work in some cases, like testcase shows. Patch implements logic to merge relocation sections if their target sections were merged into the same output section. Differential revision: https://reviews.llvm.org/D33824 llvm-svn: 304886
* 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
* Move finalize to OutputSectionCommands. NFC.Rafael Espindola2017-06-061-78/+0
| | | | | | | This removes a mapping from OutputSection to OutputSectionCommand and is another step in moving clearOutputSections earlier. llvm-svn: 304821
* [ELF] - Allow multiple comdats when producing relocatable output.George Rimar2017-06-061-0/+11
| | | | | | | | | | | | Previously LLD would fail for case when there are multiple comdats and -r. That happened because it merged all ".group" (SHT_GROUP) sections into single output, producing broken result. Such sections may have similar name, alignment and flags and other properties. We need to produce separate output section for each such input one. Differential revision: https://reviews.llvm.org/D33643 llvm-svn: 304769
* [ELF] SHF_LINK_ORDER should sort based on InputSectionDescriptionsPeter Smith2017-06-051-1/+13
| | | | | | | | | | This change alters the sorting for OutputSections with the SHF_LINK_ORDER flag in OutputSection::finalize() to use the InputSectionDescription representation and not the OutputSection::Sections representation. Differential revision: https://reviews.llvm.org/D33772 llvm-svn: 304700
* [ELF] - Assign SHF_INFO_LINK flag to REL[A] sections.George Rimar2017-06-021-0/+1
| | | | | | | | | | | | | | | | | | | | Spec says: (http://www.sco.com/developers/gabi/latest/ch4.sheader.html) sh_info This member holds extra information, whose interpretation depends on the section type. If the sh_flags field for this section header includes the attribute SHF_INFO_LINK, then this member represents a section header table index. SHF_INFO_LINK The sh_info field of this section header holds a section header table index. Since sh_info for SHT_REL[A] sections should contain the section header index of the section to which the relocation applies, this is consistent with spec to put this flag. Behavior matches both bfd and gold as well. Differential revision: https://reviews.llvm.org/D33763 llvm-svn: 304531
* Move maybeCompress to OutputSectionCommand.Rafael Espindola2017-06-011-33/+0
| | | | | | | This removes a call to getCmd and allows us to move clearOutputSections earlier. llvm-svn: 304439
* Store a single Parent pointer for InputSectionBase.Rafael Espindola2017-05-311-7/+7
| | | | | | | | | | | | | | | 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
* Fix a crash.Rafael Espindola2017-05-311-2/+2
| | | | | | | | We would crash if a SHF_LINK_ORDER section pointed to a non InputSection section. Since those sections are not merged in order, SHF_LINK_ORDER is pretty meaningless and we can error on that case. llvm-svn: 304327
* Check Live instead of the section type.Rafael Espindola2017-05-301-1/+1
| | | | | | | By the time we get here all live sections should have been combined into InputSections. llvm-svn: 304243
* [ELF] - Fix comment. NFC.George Rimar2017-05-301-1/+1
| | | | llvm-svn: 304197
* [ELF] - Do not allow -r to eat comdats.George Rimar2017-05-291-1/+22
| | | | | | | | | | | | | This is PR33052, "Bug 33052 - -r eats comdats ". To fix it I stop removing group section from out when -r is given and fixing SHT_GROUP content when writing it just like we do some other fixup, e.g. for Rel[a]. (it needs fix for section indices that are in group). Differential revision: https://reviews.llvm.org/D33485 llvm-svn: 304140
* When uncompressing sections, remove SHF_COMPRESSED bits. NFC.Rui Ueyama2017-05-251-5/+1
| | | | | | | In this way, the content and the flag is always consistent, which I think better than removing the bit when input sections reaches the Writer. llvm-svn: 303926
* Move writeTo to OutputSectionCommand.Rafael Espindola2017-05-241-65/+1
| | | | | | | | | | | | This reduces how many times we have to map from OutputSection to OutputSectionCommand. It is a required step to moving clearOutputSections earlier. In order to always use writeTo in OutputSectionCommand we have to call fabricateDefaultCommands for -r links and move section compression after it. llvm-svn: 303784
* [ELF] - Detemplate access to SymTab, DynSymTab, GnuHashTab. NFC.George Rimar2017-05-161-1/+1
| | | | | | Follow up for r303150. llvm-svn: 303153
* Rename parallelFor -> parallelForEachN.Rui Ueyama2017-05-101-1/+1
| | | | | | So that it is clear that the function is a wrapper for for_each_n. llvm-svn: 302718
* [ELF] Improve error message for incompatible section typesRui Ueyama2017-05-101-2/+5
| | | | | | | | | | | | | | | | | Previously we were not printing out the type of the incompatible section which made it difficult to determine what the problem was. The error message format has been change to the following: error: section type mismatch for .shstrtab >>> <internal>:(.shstrtab): SHT_STRTAB >>> output section .shstrtab: Unknown Patch by Alexander Richardson. Differential Revision: https://reviews.llvm.org/D32488 llvm-svn: 302694
* Don't use section names in getFiller. NFC.Rafael Espindola2017-05-101-1/+1
| | | | | | This is just faster and avoids using names. llvm-svn: 302661
* [ELF] - Linkerscript: support combination of linkerscript and ↵George Rimar2017-05-081-5/+14
| | | | | | | | | | | | --compress-debug-sections. Previously it was impossible to use linkerscript with --compress-debug-sections because of assert failture: Assertion failed: isFinalized(), file C:\llvm\lib\MC\StringTableBuilder.cpp, line 64 Patch fixes the issue llvm-svn: 302413
OpenPOWER on IntegriCloud