This reverts commit r241350 and r241352.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 3 Jul 2015 14:54:02 +0000 (14:54 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 3 Jul 2015 14:54:02 +0000 (14:54 +0000)
r241350 broke lld tests.
r241352 depends on r241350.

Original messages:
"[ELFYAML] Fix handling SHT_NOBITS sections by obj2yaml/yaml2obj tools"
"[ELFYAML] Make the Size field for .bss section optional"

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241354 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/ELFYAML.h
lib/Object/ELFYAML.cpp
test/Object/obj2yaml.test
test/Object/yaml2obj-elf-rel-noref.yaml
tools/obj2yaml/elf2yaml.cpp
tools/yaml2obj/yaml2elf.cpp

index df0aa500c8a29d6b552a3432a02ad2a9335a0722..b45507920a9c61af52fd32f2bbb8c923f5f679f7 100644 (file)
@@ -85,13 +85,7 @@ struct SectionOrType {
 };
 
 struct Section {
-  enum class SectionKind {
-    Group,
-    RawContent,
-    Relocation,
-    NoBits,
-    MipsABIFlags
-  };
+  enum class SectionKind { Group, RawContent, Relocation, MipsABIFlags };
   SectionKind Kind;
   StringRef Name;
   ELF_SHT Type;
@@ -112,14 +106,6 @@ struct RawContentSection : Section {
   }
 };
 
-struct NoBitsSection : Section {
-  llvm::yaml::Hex64 Size;
-  NoBitsSection() : Section(SectionKind::NoBits) {}
-  static bool classof(const Section *S) {
-    return S->Kind == SectionKind::NoBits;
-  }
-};
-
 struct Group : Section {
   // Members of a group contain a flag and a list of section indices
   // that are part of the group.
index 72c232c3287065c83c77e913eddbf2564c665a95..ecdd468305bebf9f4772f92fde6ae39959f980e4 100644 (file)
@@ -627,11 +627,6 @@ static void sectionMapping(IO &IO, ELFYAML::RawContentSection &Section) {
   IO.mapOptional("Size", Section.Size, Hex64(Section.Content.binary_size()));
 }
 
-static void sectionMapping(IO &IO, ELFYAML::NoBitsSection &Section) {
-  commonSectionMapping(IO, Section);
-  IO.mapOptional("Size", Section.Size, Hex64(0));
-}
-
 static void sectionMapping(IO &IO, ELFYAML::RelocationSection &Section) {
   commonSectionMapping(IO, Section);
   IO.mapOptional("Relocations", Section.Relocations);
@@ -687,11 +682,6 @@ void MappingTraits<std::unique_ptr<ELFYAML::Section>>::mapping(
       Section.reset(new ELFYAML::Group());
     groupSectionMapping(IO, *cast<ELFYAML::Group>(Section.get()));
     break;
-  case ELF::SHT_NOBITS:
-    if (!IO.outputting())
-      Section.reset(new ELFYAML::NoBitsSection());
-    sectionMapping(IO, *cast<ELFYAML::NoBitsSection>(Section.get()));
-    break;
   case ELF::SHT_MIPS_ABIFLAGS:
     if (!IO.outputting())
       Section.reset(new ELFYAML::MipsABIFlags());
index 8054b23eb560bee2c5917370d36c899bc99f6fe2..08000f66581bd3c5278b6c9cc70ca9b77159c3ae 100644 (file)
@@ -234,7 +234,7 @@ ELF-MIPSEL-NEXT:   - Name:            .bss
 ELF-MIPSEL-NEXT:     Type:            SHT_NOBITS
 ELF-MIPSEL-NEXT:     Flags:           [ SHF_WRITE, SHF_ALLOC ]
 ELF-MIPSEL-NEXT:     AddressAlign:    0x0000000000000004
-ELF-MIPSEL-NEXT:     Size:            0x0000000000000004
+ELF-MIPSEL-NEXT:     Content:         48656C6C
 ELF-MIPSEL-NEXT:   - Name:            .mdebug.abi32
 ELF-MIPSEL-NEXT:     Type:            SHT_PROGBITS
 ELF-MIPSEL-NEXT:     AddressAlign:    0x0000000000000001
@@ -324,6 +324,7 @@ ELF-MIPS64EL-NEXT:   - Name:            .bss
 ELF-MIPS64EL-NEXT:     Type:            SHT_NOBITS
 ELF-MIPS64EL-NEXT:     Flags:           [ SHF_WRITE, SHF_ALLOC ]
 ELF-MIPS64EL-NEXT:     AddressAlign:    0x0000000000000010
+ELF-MIPS64EL-NEXT:     Content:         ''
 ELF-MIPS64EL-NEXT:   - Name:            .MIPS.options
 ELF-MIPS64EL-NEXT:     Type:            SHT_MIPS_OPTIONS
 ELF-MIPS64EL-NEXT:     Flags:           [ SHF_ALLOC ]
index 4a13acd1fd382638c48127dcbe34f9ad91f89aec..69fcf08544343728aa74dc31afd3ca510f057332 100644 (file)
@@ -32,7 +32,7 @@ Sections:
     Type:            SHT_NOBITS
     Flags:           [ SHF_WRITE, SHF_ALLOC ]
     AddressAlign:    0x0000000000000001
-    Size:            0
+    Content:         ''
   - Name:            .ARM.attributes
     Type:            SHT_ARM_ATTRIBUTES
     AddressAlign:    0x0000000000000001
index f117a10d382227a4ad09fe4aac1a1547efac2b69..9afcedef63982e8fce6eeb366b0f8b27b497033c 100644 (file)
@@ -40,7 +40,6 @@ class ELFDumper {
   ErrorOr<ELFYAML::RelocationSection *> dumpRelaSection(const Elf_Shdr *Shdr);
   ErrorOr<ELFYAML::RawContentSection *>
   dumpContentSection(const Elf_Shdr *Shdr);
-  ErrorOr<ELFYAML::NoBitsSection *> dumpNoBitsSection(const Elf_Shdr *Shdr);
   ErrorOr<ELFYAML::Group *> dumpGroup(const Elf_Shdr *Shdr);
   ErrorOr<ELFYAML::MipsABIFlags *> dumpMipsABIFlags(const Elf_Shdr *Shdr);
 
@@ -105,13 +104,6 @@ ErrorOr<ELFYAML::Object *> ELFDumper<ELFT>::dump() {
       Y->Sections.push_back(std::unique_ptr<ELFYAML::Section>(G.get()));
       break;
     }
-    case ELF::SHT_NOBITS: {
-      ErrorOr<ELFYAML::NoBitsSection *> S = dumpNoBitsSection(&Sec);
-      if (std::error_code EC = S.getError())
-        return EC;
-      Y->Sections.push_back(std::unique_ptr<ELFYAML::Section>(S.get()));
-      break;
-    }
     default: {
       ErrorOr<ELFYAML::RawContentSection *> S = dumpContentSection(&Sec);
       if (std::error_code EC = S.getError())
@@ -312,18 +304,6 @@ ELFDumper<ELFT>::dumpContentSection(const Elf_Shdr *Shdr) {
   return S.release();
 }
 
-template <class ELFT>
-ErrorOr<ELFYAML::NoBitsSection *>
-ELFDumper<ELFT>::dumpNoBitsSection(const Elf_Shdr *Shdr) {
-  auto S = make_unique<ELFYAML::NoBitsSection>();
-
-  if (std::error_code EC = dumpCommonSection(Shdr, *S))
-    return EC;
-  S->Size = Shdr->sh_size;
-
-  return S.release();
-}
-
 template <class ELFT>
 ErrorOr<ELFYAML::Group *> ELFDumper<ELFT>::dumpGroup(const Elf_Shdr *Shdr) {
   auto S = make_unique<ELFYAML::Group>();
index 795d54262917c6d9341079e90584d70335c73560..772b5b918ecab9cbe4989e59fb60ee7a77417555 100644 (file)
@@ -241,8 +241,6 @@ bool ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
     } else if (auto S = dyn_cast<ELFYAML::MipsABIFlags>(Sec.get())) {
       if (!writeSectionContent(SHeader, *S, CBA))
         return false;
-    } else if (isa<ELFYAML::NoBitsSection>(Sec.get())) {
-      // SHT_NOBITS section does not have content so nothing to do here.
     } else
       llvm_unreachable("Unknown section type");