diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-11-17 23:16:39 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-11-17 23:16:39 +0000 |
| commit | 933fcab2ad476809967695b9b11087c6b96d6b64 (patch) | |
| tree | c41808a4d9dae57dd7e7975d7eff47777c53488a /lld/ELF/OutputSections.cpp | |
| parent | b379d7df12b50199303f56df60b21663c2c2144e (diff) | |
| download | bcm5719-llvm-933fcab2ad476809967695b9b11087c6b96d6b64.tar.gz bcm5719-llvm-933fcab2ad476809967695b9b11087c6b96d6b64.zip | |
Always compute sh_link for SHF_LINK_ORDER sections.
Since the output has a section table too, it is meaningful to compute
the sh_link. In a more practical note, the binutils' strip crashes if
sh_link is not set for SHT_ARM_EXIDX.
llvm-svn: 287280
Diffstat (limited to 'lld/ELF/OutputSections.cpp')
| -rw-r--r-- | lld/ELF/OutputSections.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index f0b1ecef932..4bf95294a04 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -400,25 +400,19 @@ OutputSection<ELFT>::OutputSection(StringRef Name, uint32_t Type, uintX_t Flags) } template <class ELFT> void OutputSection<ELFT>::finalize() { - if (!Config->Relocatable) { - // SHF_LINK_ORDER only has meaning in relocatable objects - this->Flags &= ~SHF_LINK_ORDER; - return; - } - - uint32_t Type = this->Type; if ((this->Flags & SHF_LINK_ORDER) && !this->Sections.empty()) { - // When doing a relocatable link we must preserve the link order - // dependency of sections with the SHF_LINK_ORDER flag. The dependency - // is indicated by the sh_link field. We need to translate the - // InputSection sh_link to the OutputSection sh_link, all InputSections - // in the OutputSection have the same dependency. + // We must preserve the link order dependency of sections with the + // SHF_LINK_ORDER flag. The dependency is indicated by the sh_link field. We + // need to translate the InputSection sh_link to the OutputSection sh_link, + // all InputSections in the OutputSection have the same dependency. if (auto *D = this->Sections.front()->getLinkOrderDep()) this->Link = D->OutSec->SectionIndex; } - if (Type != SHT_RELA && Type != SHT_REL) + uint32_t Type = this->Type; + if (!Config->Relocatable || (Type != SHT_RELA && Type != SHT_REL)) return; + this->Link = In<ELFT>::SymTab->OutSec->SectionIndex; // sh_info for SHT_REL[A] sections should contain the section header index of // the section to which the relocation applies. |

