diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-11-15 17:35:22 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-11-15 17:35:22 +0000 |
| commit | 8bc2a19ef833217219e563f934d4a9623ab93e91 (patch) | |
| tree | 74a9c417b69039e150334d9d07ec37125bf951ab /lld/ELF/OutputSections.cpp | |
| parent | 3f0b575363213ba350dd35c53b3f47b0135c18f3 (diff) | |
| download | bcm5719-llvm-8bc2a19ef833217219e563f934d4a9623ab93e91.tar.gz bcm5719-llvm-8bc2a19ef833217219e563f934d4a9623ab93e91.zip | |
Drop conflicting sh_entsize values.
An output section can include elements from two input sections with
different sh_entsize. When that happens the output section itself
should not have a sh_entsize.
llvm-svn: 318311
Diffstat (limited to 'lld/ELF/OutputSections.cpp')
| -rw-r--r-- | lld/ELF/OutputSections.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 357affe9e22..bc67a000e88 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -91,9 +91,10 @@ static bool canMergeToProgbits(unsigned Type) { void OutputSection::addSection(InputSection *IS) { if (!Live) { // If IS is the first section to be added to this section, - // initialize Type by IS->Type. + // initialize Type and Entsize from IS. Live = true; Type = IS->Type; + Entsize = IS->Entsize; } else { // Otherwise, check if new type or flags are compatible with existing ones. if ((Flags & (SHF_ALLOC | SHF_TLS)) != (IS->Flags & (SHF_ALLOC | SHF_TLS))) @@ -124,13 +125,10 @@ void OutputSection::addSection(InputSection *IS) { this->Size = IS->OutSecOff + IS->getSize(); // If this section contains a table of fixed-size entries, sh_entsize - // holds the element size. Consequently, if this contains two or more - // input sections, all of them must have the same sh_entsize. However, - // you can put different types of input sections into one output - // section by using linker scripts. I don't know what to do here. - // Probably we sholuld handle that as an error. But for now we just - // pick the largest sh_entsize. - this->Entsize = std::max(this->Entsize, IS->Entsize); + // holds the element size. If it contains elements of different size we + // set sh_entsize to 0. + if (Entsize != IS->Entsize) + Entsize = 0; if (!IS->Assigned) { IS->Assigned = true; |

