forked from OSchip/llvm-project
				
			Revert "[WebAssembly] Merge producers section"
This reverts commit 71eaf61c6c121c8c3bcaf3490557e92cf81599cb. One of the lld tests was breaking, so revert this change until it is fixed. llvm-svn: 351409
This commit is contained in:
		
							parent
							
								
									015585abb2
								
							
						
					
					
						commit
						d24ae47db6
					
				| 
						 | 
					@ -240,8 +240,6 @@ void ObjFile::parse() {
 | 
				
			||||||
      CustomSections.emplace_back(make<InputSection>(Section, this));
 | 
					      CustomSections.emplace_back(make<InputSection>(Section, this));
 | 
				
			||||||
      CustomSections.back()->setRelocations(Section.Relocations);
 | 
					      CustomSections.back()->setRelocations(Section.Relocations);
 | 
				
			||||||
      CustomSectionsByIndex[SectionIndex] = CustomSections.back();
 | 
					      CustomSectionsByIndex[SectionIndex] = CustomSections.back();
 | 
				
			||||||
      if (Section.Name == "producers")
 | 
					 | 
				
			||||||
        ProducersSection = &Section;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    SectionIndex++;
 | 
					    SectionIndex++;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -99,7 +99,6 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const WasmSection *CodeSection = nullptr;
 | 
					  const WasmSection *CodeSection = nullptr;
 | 
				
			||||||
  const WasmSection *DataSection = nullptr;
 | 
					  const WasmSection *DataSection = nullptr;
 | 
				
			||||||
  const WasmSection *ProducersSection = nullptr;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Maps input type indices to output type indices
 | 
					  // Maps input type indices to output type indices
 | 
				
			||||||
  std::vector<uint32_t> TypeMap;
 | 
					  std::vector<uint32_t> TypeMap;
 | 
				
			||||||
| 
						 | 
					@ -140,7 +139,7 @@ public:
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Will report a fatal() error if the input buffer is not a valid bitcode
 | 
					// Will report a fatal() error if the input buffer is not a valid bitcode
 | 
				
			||||||
// or wasm object file.
 | 
					// or was object file.
 | 
				
			||||||
InputFile *createObjectFile(MemoryBufferRef MB);
 | 
					InputFile *createObjectFile(MemoryBufferRef MB);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Opens a given file.
 | 
					// Opens a given file.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,8 +21,6 @@
 | 
				
			||||||
#include "lld/Common/Strings.h"
 | 
					#include "lld/Common/Strings.h"
 | 
				
			||||||
#include "lld/Common/Threads.h"
 | 
					#include "lld/Common/Threads.h"
 | 
				
			||||||
#include "llvm/ADT/DenseSet.h"
 | 
					#include "llvm/ADT/DenseSet.h"
 | 
				
			||||||
#include "llvm/ADT/SmallSet.h"
 | 
					 | 
				
			||||||
#include "llvm/ADT/SmallVector.h"
 | 
					 | 
				
			||||||
#include "llvm/ADT/StringMap.h"
 | 
					#include "llvm/ADT/StringMap.h"
 | 
				
			||||||
#include "llvm/BinaryFormat/Wasm.h"
 | 
					#include "llvm/BinaryFormat/Wasm.h"
 | 
				
			||||||
#include "llvm/Object/WasmTraits.h"
 | 
					#include "llvm/Object/WasmTraits.h"
 | 
				
			||||||
| 
						 | 
					@ -97,7 +95,6 @@ private:
 | 
				
			||||||
  void createRelocSections();
 | 
					  void createRelocSections();
 | 
				
			||||||
  void createLinkingSection();
 | 
					  void createLinkingSection();
 | 
				
			||||||
  void createNameSection();
 | 
					  void createNameSection();
 | 
				
			||||||
  void createProducersSection();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void writeHeader();
 | 
					  void writeHeader();
 | 
				
			||||||
  void writeSections();
 | 
					  void writeSections();
 | 
				
			||||||
| 
						 | 
					@ -330,8 +327,7 @@ void Writer::calculateCustomSections() {
 | 
				
			||||||
      StringRef Name = Section->getName();
 | 
					      StringRef Name = Section->getName();
 | 
				
			||||||
      // These custom sections are known the linker and synthesized rather than
 | 
					      // These custom sections are known the linker and synthesized rather than
 | 
				
			||||||
      // blindly copied
 | 
					      // blindly copied
 | 
				
			||||||
      if (Name == "linking" || Name == "name" || Name == "producers" ||
 | 
					      if (Name == "linking" || Name == "name" || Name.startswith("reloc."))
 | 
				
			||||||
          Name.startswith("reloc."))
 | 
					 | 
				
			||||||
        continue;
 | 
					        continue;
 | 
				
			||||||
      // .. or it is a debug section
 | 
					      // .. or it is a debug section
 | 
				
			||||||
      if (StripDebug && Name.startswith(".debug_"))
 | 
					      if (StripDebug && Name.startswith(".debug_"))
 | 
				
			||||||
| 
						 | 
					@ -637,43 +633,6 @@ void Writer::createNameSection() {
 | 
				
			||||||
  Sub.writeTo(Section->getStream());
 | 
					  Sub.writeTo(Section->getStream());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Writer::createProducersSection() {
 | 
					 | 
				
			||||||
  SmallVector<std::pair<std::string, std::string>, 8> Languages;
 | 
					 | 
				
			||||||
  SmallVector<std::pair<std::string, std::string>, 8> Tools;
 | 
					 | 
				
			||||||
  SmallVector<std::pair<std::string, std::string>, 8> SDKs;
 | 
					 | 
				
			||||||
  for (ObjFile *File : Symtab->ObjectFiles) {
 | 
					 | 
				
			||||||
    const WasmProducerInfo &Info = File->getWasmObj()->getProducerInfo();
 | 
					 | 
				
			||||||
    for (auto &Producers : {std::make_pair(&Info.Languages, &Languages),
 | 
					 | 
				
			||||||
                            std::make_pair(&Info.Tools, &Tools),
 | 
					 | 
				
			||||||
                            std::make_pair(&Info.SDKs, &SDKs)}) {
 | 
					 | 
				
			||||||
      llvm::SmallSet<StringRef, 8> SeenProducers;
 | 
					 | 
				
			||||||
      for (auto &Producer : *Producers.first)
 | 
					 | 
				
			||||||
        if (SeenProducers.insert(Producer.first).second)
 | 
					 | 
				
			||||||
          Producers.second->push_back(Producer);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  int FieldCount =
 | 
					 | 
				
			||||||
      int(!Languages.empty()) + int(!Tools.empty()) + int(!SDKs.empty());
 | 
					 | 
				
			||||||
  if (FieldCount == 0)
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
  SyntheticSection *Section =
 | 
					 | 
				
			||||||
      createSyntheticSection(WASM_SEC_CUSTOM, "producers");
 | 
					 | 
				
			||||||
  auto &OS = Section->getStream();
 | 
					 | 
				
			||||||
  writeUleb128(OS, FieldCount, "field count");
 | 
					 | 
				
			||||||
  for (auto &Field : {std::make_pair(StringRef("language"), Languages),
 | 
					 | 
				
			||||||
                      std::make_pair(StringRef("processed-by"), Tools),
 | 
					 | 
				
			||||||
                      std::make_pair(StringRef("sdk"), SDKs)}) {
 | 
					 | 
				
			||||||
    if (Field.second.empty())
 | 
					 | 
				
			||||||
      continue;
 | 
					 | 
				
			||||||
    writeStr(OS, Field.first, "field name");
 | 
					 | 
				
			||||||
    writeUleb128(OS, Field.second.size(), "number of entries");
 | 
					 | 
				
			||||||
    for (auto &Entry : Field.second) {
 | 
					 | 
				
			||||||
      writeStr(OS, Entry.first, "producer name");
 | 
					 | 
				
			||||||
      writeStr(OS, Entry.second, "producer version");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void Writer::writeHeader() {
 | 
					void Writer::writeHeader() {
 | 
				
			||||||
  memcpy(Buffer->getBufferStart(), Header.data(), Header.size());
 | 
					  memcpy(Buffer->getBufferStart(), Header.data(), Header.size());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -813,13 +772,9 @@ void Writer::createSections() {
 | 
				
			||||||
    createLinkingSection();
 | 
					    createLinkingSection();
 | 
				
			||||||
    createRelocSections();
 | 
					    createRelocSections();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (!Config->StripDebug && !Config->StripAll)
 | 
					  if (!Config->StripDebug && !Config->StripAll)
 | 
				
			||||||
    createNameSection();
 | 
					    createNameSection();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!Config->StripAll)
 | 
					 | 
				
			||||||
    createProducersSection();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for (OutputSection *S : OutputSections) {
 | 
					  for (OutputSection *S : OutputSections) {
 | 
				
			||||||
    S->setOffset(FileSize);
 | 
					    S->setOffset(FileSize);
 | 
				
			||||||
    S->finalizeContents();
 | 
					    S->finalizeContents();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue