Revert "[llvm-objcopy] Add --strip-unneeded option"

There is a use after free I didn't see. Need to investigate.

This reverts commit f7624abeb1f0d012309baf2e78cf2499fbfe5e5f.

llvm-svn: 332925
diff --git a/llvm/tools/llvm-objcopy/Object.h b/llvm/tools/llvm-objcopy/Object.h
index 74ef5a7..ac384c1 100644
--- a/llvm/tools/llvm-objcopy/Object.h
+++ b/llvm/tools/llvm-objcopy/Object.h
@@ -344,7 +344,6 @@
   uint8_t Type;
   uint64_t Value;
   uint8_t Visibility;
-  uint32_t ReferenceCount;
 
   uint16_t getShndx() const;
 };
@@ -368,7 +367,6 @@
   void addSymbolNames();
   const SectionBase *getStrTab() const { return SymbolNames; }
   const Symbol *getSymbolByIndex(uint32_t Index) const;
-  Symbol *getSymbolByIndex(uint32_t Index);
   void updateSymbols(function_ref<void(Symbol &)> Callable);
 
   void removeSectionReferences(const SectionBase *Sec) override;
@@ -383,7 +381,7 @@
 };
 
 struct Relocation {
-  Symbol *RelocSymbol = nullptr;
+  const Symbol *RelocSymbol = nullptr;
   uint64_t Offset;
   uint64_t Addend;
   uint32_t Type;
@@ -434,7 +432,6 @@
   std::vector<Relocation> Relocations;
 
 public:
-  ~RelocationSection();
   void addRelocation(Relocation Rel) { Relocations.push_back(Rel); }
   void accept(SectionVisitor &Visitor) const override;
   void removeSymbols(function_ref<bool(const Symbol &)> ToRemove) override;
@@ -452,7 +449,7 @@
 class GroupSection : public SectionBase {
   MAKE_SEC_WRITER_FRIEND
   const SymbolTableSection *SymTab = nullptr;
-  Symbol *Sym = nullptr;
+  const Symbol *Sym = nullptr;
   ELF::Elf32_Word FlagWord;
   SmallVector<SectionBase *, 3> GroupMembers;
 
@@ -462,16 +459,9 @@
   ArrayRef<uint8_t> Contents;
 
   explicit GroupSection(ArrayRef<uint8_t> Data) : Contents(Data) {}
-  ~GroupSection() {
-    if (Sym)
-      --Sym->ReferenceCount;
-  }
 
   void setSymTab(const SymbolTableSection *SymTabSec) { SymTab = SymTabSec; }
-  void setSymbol(Symbol *S) {
-    Sym = S;
-    ++Sym->ReferenceCount;
-  }
+  void setSymbol(const Symbol *S) { Sym = S; }
   void setFlagWord(ELF::Elf32_Word W) { FlagWord = W; }
   void addMember(SectionBase *Sec) { GroupMembers.push_back(Sec); }