summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/Object.h
diff options
context:
space:
mode:
authorPaul Semel <semelpaul@gmail.com>2018-05-21 22:50:32 +0000
committerPaul Semel <semelpaul@gmail.com>2018-05-21 22:50:32 +0000
commit040df77ed6fe27889467b1fea6c5f35612c1c0c2 (patch)
tree38e893c2ca0b7fcd24a81f0d296f2ff114cd6a30 /llvm/tools/llvm-objcopy/Object.h
parent99f701182934461d5f9b4ffef2d0bcfacd8bf88f (diff)
downloadbcm5719-llvm-040df77ed6fe27889467b1fea6c5f35612c1c0c2.tar.gz
bcm5719-llvm-040df77ed6fe27889467b1fea6c5f35612c1c0c2.zip
[llvm-objcopy] Add --strip-unneeded option
This option removes symbols that are not needed by relocations. Differential Revision: https://reviews.llvm.org/D46896 llvm-svn: 332915
Diffstat (limited to 'llvm/tools/llvm-objcopy/Object.h')
-rw-r--r--llvm/tools/llvm-objcopy/Object.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/llvm/tools/llvm-objcopy/Object.h b/llvm/tools/llvm-objcopy/Object.h
index ac384c1fdfe..74ef5a7ebcc 100644
--- a/llvm/tools/llvm-objcopy/Object.h
+++ b/llvm/tools/llvm-objcopy/Object.h
@@ -344,6 +344,7 @@ struct Symbol {
uint8_t Type;
uint64_t Value;
uint8_t Visibility;
+ uint32_t ReferenceCount;
uint16_t getShndx() const;
};
@@ -367,6 +368,7 @@ public:
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;
@@ -381,7 +383,7 @@ public:
};
struct Relocation {
- const Symbol *RelocSymbol = nullptr;
+ Symbol *RelocSymbol = nullptr;
uint64_t Offset;
uint64_t Addend;
uint32_t Type;
@@ -432,6 +434,7 @@ class RelocationSection
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;
@@ -449,7 +452,7 @@ public:
class GroupSection : public SectionBase {
MAKE_SEC_WRITER_FRIEND
const SymbolTableSection *SymTab = nullptr;
- const Symbol *Sym = nullptr;
+ Symbol *Sym = nullptr;
ELF::Elf32_Word FlagWord;
SmallVector<SectionBase *, 3> GroupMembers;
@@ -459,9 +462,16 @@ public:
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(const Symbol *S) { Sym = S; }
+ void setSymbol(Symbol *S) {
+ Sym = S;
+ ++Sym->ReferenceCount;
+ }
void setFlagWord(ELF::Elf32_Word W) { FlagWord = W; }
void addMember(SectionBase *Sec) { GroupMembers.push_back(Sec); }
OpenPOWER on IntegriCloud