diff options
| author | George Rimar <grimar@accesssoftek.com> | 2019-09-25 12:09:30 +0000 |
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2019-09-25 12:09:30 +0000 |
| commit | cfc2bccfd87e19e99dc9ad177d00f2728fb2e7e1 (patch) | |
| tree | cd56d657885b544b713d93d22d0bb340bec36886 /llvm/lib/ObjectYAML | |
| parent | c4046ff04ddc040757ae3d03e3e73304e5f8ba82 (diff) | |
| download | bcm5719-llvm-cfc2bccfd87e19e99dc9ad177d00f2728fb2e7e1.tar.gz bcm5719-llvm-cfc2bccfd87e19e99dc9ad177d00f2728fb2e7e1.zip | |
[yaml2elf] - Support describing .stack_sizes sections using unique suffixes.
Currently we can't use unique suffixes in section names to describe
stack sizes sections. E.g. '.stack_sizes [1]' will be treated as a regular section.
This happens because we recognize stack sizes section by name and
do not yet drop the suffix before the check.
The patch fixes it.
Differential revision: https://reviews.llvm.org/D68018
llvm-svn: 372853
Diffstat (limited to 'llvm/lib/ObjectYAML')
| -rw-r--r-- | llvm/lib/ObjectYAML/ELFEmitter.cpp | 13 | ||||
| -rw-r--r-- | llvm/lib/ObjectYAML/ELFYAML.cpp | 1 |
2 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp index 0139c2d1144..6edc3c8e763 100644 --- a/llvm/lib/ObjectYAML/ELFEmitter.cpp +++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp @@ -340,7 +340,7 @@ bool ELFState<ELFT>::initImplicitHeader(ContiguousBlobAccumulator &CBA, return true; } -static StringRef dropUniqueSuffix(StringRef S) { +StringRef llvm::ELFYAML::dropUniqueSuffix(StringRef S) { size_t SuffixPos = S.rfind(" ["); if (SuffixPos == StringRef::npos) return S; @@ -371,7 +371,8 @@ void ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders, assert(Sec && "It can't be null unless it is an implicit section. But all " "implicit sections should already have been handled above."); - SHeader.sh_name = DotShStrtab.getOffset(dropUniqueSuffix(Sec->Name)); + SHeader.sh_name = + DotShStrtab.getOffset(ELFYAML::dropUniqueSuffix(Sec->Name)); SHeader.sh_type = Sec->Type; if (Sec->Flags) SHeader.sh_flags = *Sec->Flags; @@ -473,7 +474,7 @@ ELFState<ELFT>::toELFSymbols(ArrayRef<ELFYAML::Symbol> Symbols, if (Sym.NameIndex) Symbol.st_name = *Sym.NameIndex; else if (!Sym.Name.empty()) - Symbol.st_name = Strtab.getOffset(dropUniqueSuffix(Sym.Name)); + Symbol.st_name = Strtab.getOffset(ELFYAML::dropUniqueSuffix(Sym.Name)); Symbol.setBindingAndType(Sym.Binding, Sym.Type); if (!Sym.Section.empty()) @@ -962,7 +963,7 @@ template <class ELFT> void ELFState<ELFT>::buildSectionIndex() { if (Name.empty()) continue; - DotShStrtab.add(dropUniqueSuffix(Name)); + DotShStrtab.add(ELFYAML::dropUniqueSuffix(Name)); if (!SN2I.addName(Name, I)) reportError("repeated section name: '" + Name + "' at YAML section number " + Twine(I)); @@ -987,12 +988,12 @@ template <class ELFT> void ELFState<ELFT>::buildSymbolIndexes() { template <class ELFT> void ELFState<ELFT>::finalizeStrings() { // Add the regular symbol names to .strtab section. for (const ELFYAML::Symbol &Sym : Doc.Symbols) - DotStrtab.add(dropUniqueSuffix(Sym.Name)); + DotStrtab.add(ELFYAML::dropUniqueSuffix(Sym.Name)); DotStrtab.finalize(); // Add the dynamic symbol names to .dynstr section. for (const ELFYAML::Symbol &Sym : Doc.DynamicSymbols) - DotDynstr.add(dropUniqueSuffix(Sym.Name)); + DotDynstr.add(ELFYAML::dropUniqueSuffix(Sym.Name)); // SHT_GNU_verdef and SHT_GNU_verneed sections might also // add strings to .dynstr section. diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp index d369f14be4b..94b1df10439 100644 --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -1152,6 +1152,7 @@ void MappingTraits<std::unique_ptr<ELFYAML::Section>>::mapping( if (!IO.outputting()) { StringRef Name; IO.mapOptional("Name", Name, StringRef()); + Name = ELFYAML::dropUniqueSuffix(Name); if (ELFYAML::StackSizesSection::nameMatches(Name)) Section = std::make_unique<ELFYAML::StackSizesSection>(); |

