From aba62e9c00e5ada889438aa19dfb4b13e9870044 Mon Sep 17 00:00:00 2001 From: Vlad Tsyrklevich Date: Wed, 28 Aug 2019 13:15:08 +0000 Subject: Revert "[yaml2obj] - Don't allow setting StOther and Other/Visibility at the same time." This reverts commit r370032, it was causing check-llvm failures on sanitizer-x86_64-linux-bootstrap-msan llvm-svn: 370198 --- llvm/lib/ObjectYAML/ELFEmitter.cpp | 7 +----- llvm/lib/ObjectYAML/ELFYAML.cpp | 50 ++++++++++++++------------------------ 2 files changed, 19 insertions(+), 38 deletions(-) (limited to 'llvm/lib/ObjectYAML') diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp index 96b13e4e530..6a2d28e16e2 100644 --- a/llvm/lib/ObjectYAML/ELFEmitter.cpp +++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp @@ -464,12 +464,7 @@ toELFSymbols(NameToIdxMap &SN2I, ArrayRef Symbols, } // else Symbol.st_shndex == SHN_UNDEF (== 0), since it was zero'd earlier. Symbol.st_value = Sym.Value; - - if (Sym.Other) - Symbol.st_other = *Sym.Other; - else if (Sym.StOther) - Symbol.st_other = *Sym.StOther; - + Symbol.st_other = Sym.Other; Symbol.st_size = Sym.Size; } diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp index fe6be47d8fd..e7db190eb0a 100644 --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -866,28 +866,15 @@ void MappingTraits::mapping( namespace { struct NormalizedOther { - NormalizedOther(IO &) {} - NormalizedOther(IO &, Optional Original) { - if (uint8_t Val = *Original & 0x3) - Visibility = Val; - if (uint8_t Val = *Original & ~0x3) - Other = Val; - } - - Optional denormalize(IO &) { - if (!Visibility && !Other) - return None; + NormalizedOther(IO &) + : Visibility(ELFYAML::ELF_STV(0)), Other(ELFYAML::ELF_STO(0)) {} + NormalizedOther(IO &, uint8_t Original) + : Visibility(Original & 0x3), Other(Original & ~0x3) {} - uint8_t Ret = 0; - if (Visibility) - Ret |= *Visibility; - if (Other) - Ret |= *Other; - return Ret; - } + uint8_t denormalize(IO &) { return Visibility | Other; } - Optional Visibility; - Optional Other; + ELFYAML::ELF_STV Visibility; + ELFYAML::ELF_STO Other; }; } // end anonymous namespace @@ -909,16 +896,17 @@ void MappingTraits::mapping(IO &IO, ELFYAML::Symbol &Symbol) { // targets (e.g. MIPS) may use it to specify the named bits to set (e.g. // STO_MIPS_OPTIONAL). For producing broken objects we want to allow writing // any value to st_other. To do this we allow one more field called "StOther". - // If it is present in a YAML document, we set st_other to its integer value - // whatever it is. - // obj2yaml should not print 'StOther', it should print 'Visibility' and - // 'Other' fields instead. - assert(!IO.outputting() || !Symbol.StOther.hasValue()); - IO.mapOptional("StOther", Symbol.StOther); - MappingNormalization> Keys(IO, - Symbol.Other); - IO.mapOptional("Visibility", Keys->Visibility); - IO.mapOptional("Other", Keys->Other); + // If it is present in a YAML document, we set st_other to that integer, + // ignoring the other fields. + Optional Other; + IO.mapOptional("StOther", Other); + if (Other) { + Symbol.Other = *Other; + } else { + MappingNormalization Keys(IO, Symbol.Other); + IO.mapOptional("Visibility", Keys->Visibility, ELFYAML::ELF_STV(0)); + IO.mapOptional("Other", Keys->Other, ELFYAML::ELF_STO(0)); + } } StringRef MappingTraits::validate(IO &IO, @@ -927,8 +915,6 @@ StringRef MappingTraits::validate(IO &IO, return "Index and Section cannot both be specified for Symbol"; if (Symbol.NameIndex && !Symbol.Name.empty()) return "Name and NameIndex cannot both be specified for Symbol"; - if (Symbol.StOther && Symbol.Other) - return "StOther cannot be specified for Symbol with either Visibility or Other"; return StringRef(); } -- cgit v1.2.3