diff options
| author | Georgii Rymar <grimar@accesssoftek.com> | 2019-10-28 13:47:44 +0300 |
|---|---|---|
| committer | Georgii Rymar <grimar@accesssoftek.com> | 2019-10-29 11:43:12 +0300 |
| commit | 3fe7f1dcf44ced0648fd0aef2b33056bbee37881 (patch) | |
| tree | 47b820fef886813a9e006d985ff0edd6f54deb6c /llvm/lib/ObjectYAML | |
| parent | 5b118a0471435751f39eeb92d56ecc3956053304 (diff) | |
| download | bcm5719-llvm-3fe7f1dcf44ced0648fd0aef2b33056bbee37881.tar.gz bcm5719-llvm-3fe7f1dcf44ced0648fd0aef2b33056bbee37881.zip | |
[yaml2obj] - Make .symtab to be not mandatory section for SHT_REL[A] section.
Before this change .symtab section was required for SHT_REL[A] section
declarations. yaml2obj automatically defined it in case when YAML document
did not have it.
With this change it is now possible to produce an object that
has a relocation section, but has no symbol table.
It simplifies the code and also it is inline with how we handle Link fields
for another special sections.
Differential revision: https://reviews.llvm.org/D69260
Diffstat (limited to 'llvm/lib/ObjectYAML')
| -rw-r--r-- | llvm/lib/ObjectYAML/ELFEmitter.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp index 6a4e00c6285..64b5cd4df5b 100644 --- a/llvm/lib/ObjectYAML/ELFEmitter.cpp +++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp @@ -205,17 +205,10 @@ template <class ELFT> ELFState<ELFT>::ELFState(ELFYAML::Object &D, yaml::ErrorHandler EH) : Doc(D), ErrHandler(EH) { StringSet<> DocSections; - for (std::unique_ptr<ELFYAML::Section> &D : Doc.Sections) { + for (std::unique_ptr<ELFYAML::Section> &D : Doc.Sections) if (!D->Name.empty()) DocSections.insert(D->Name); - // Some sections wants to link to .symtab by default. - // That means we want to create the symbol table for them. - if (D->Type == llvm::ELF::SHT_REL || D->Type == llvm::ELF::SHT_RELA) - if (!Doc.Symbols && D->Link.empty()) - Doc.Symbols.emplace(); - } - // Insert SHT_NULL section implicitly when it is not defined in YAML. if (Doc.Sections.empty() || Doc.Sections.front()->Type != ELF::SHT_NULL) Doc.Sections.insert( @@ -742,8 +735,9 @@ void ELFState<ELFT>::writeSectionContent( SHeader.sh_size = SHeader.sh_entsize * Section.Relocations.size(); // For relocation section set link to .symtab by default. - if (Section.Link.empty()) - SHeader.sh_link = SN2I.get(".symtab"); + unsigned Link = 0; + if (Section.Link.empty() && SN2I.lookup(".symtab", Link)) + SHeader.sh_link = Link; if (!Section.RelocatableSec.empty()) SHeader.sh_info = toSectionIndex(Section.RelocatableSec, Section.Name); |

