diff options
author | Petr Hosek <phosek@chromium.org> | 2017-09-07 23:02:50 +0000 |
---|---|---|
committer | Petr Hosek <phosek@chromium.org> | 2017-09-07 23:02:50 +0000 |
commit | ec2b3fce1bd3a494c5dd94ea78863d13ad41a0cf (patch) | |
tree | befd299b2e23a4a6511d2072f598ca2522db64ce /llvm/tools/llvm-objcopy/Object.h | |
parent | b79e7a6897c4d806c8272aee5d390c4cf86f22ce (diff) | |
download | bcm5719-llvm-ec2b3fce1bd3a494c5dd94ea78863d13ad41a0cf.tar.gz bcm5719-llvm-ec2b3fce1bd3a494c5dd94ea78863d13ad41a0cf.zip |
[llvm-objcopy] Add support for special section indexes in symbol table greater than SHN_LORESERVE
As is indexes above SHN_LORESERVE will not be handled correctly because
they'll be treated as indexes of sections rather than special values
that should just be copied. This change adds support to copy them
though.
Patch by Jake Ehrlich
Differential Revision: https://reviews.llvm.org/D37393
llvm-svn: 312756
Diffstat (limited to 'llvm/tools/llvm-objcopy/Object.h')
-rw-r--r-- | llvm/tools/llvm-objcopy/Object.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/llvm/tools/llvm-objcopy/Object.h b/llvm/tools/llvm-objcopy/Object.h index 61d5f80c051..dff3fc40893 100644 --- a/llvm/tools/llvm-objcopy/Object.h +++ b/llvm/tools/llvm-objcopy/Object.h @@ -113,15 +113,32 @@ public: } }; +// Symbols have a st_shndx field that normally stores an index but occasionally +// stores a different special value. This enum keeps track of what the st_shndx +// field means. Most of the values are just copies of the special SHN_* values. +// SYMBOL_SIMPLE_INDEX means that the st_shndx is just an index of a section. +enum SymbolShndxType { + SYMBOL_SIMPLE_INDEX = 0, + SYMBOL_ABS = llvm::ELF::SHN_ABS, + SYMBOL_COMMON = llvm::ELF::SHN_COMMON, + SYMBOL_HEXAGON_SCOMMON = llvm::ELF::SHN_HEXAGON_SCOMMON, + SYMBOL_HEXAGON_SCOMMON_2 = llvm::ELF::SHN_HEXAGON_SCOMMON_2, + SYMBOL_HEXAGON_SCOMMON_4 = llvm::ELF::SHN_HEXAGON_SCOMMON_4, + SYMBOL_HEXAGON_SCOMMON_8 = llvm::ELF::SHN_HEXAGON_SCOMMON_8, +}; + struct Symbol { uint8_t Binding; SectionBase *DefinedIn; + SymbolShndxType ShndxType; uint32_t Index; llvm::StringRef Name; uint32_t NameIndex; uint64_t Size; uint8_t Type; uint64_t Value; + + uint16_t getShndx() const; }; class SymbolTableSection : public SectionBase { @@ -132,7 +149,8 @@ protected: public: void setStrTab(StringTableSection *StrTab) { SymbolNames = StrTab; } void addSymbol(llvm::StringRef Name, uint8_t Bind, uint8_t Type, - SectionBase *DefinedIn, uint64_t Value, uint64_t Sz); + SectionBase *DefinedIn, uint64_t Value, uint16_t Shndx, + uint64_t Sz); void addSymbolNames(); const Symbol *getSymbolByIndex(uint32_t Index) const; void finalize() override; |