summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/COFF/Object.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-objcopy/COFF/Object.h')
-rw-r--r--llvm/tools/llvm-objcopy/COFF/Object.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/llvm/tools/llvm-objcopy/COFF/Object.h b/llvm/tools/llvm-objcopy/COFF/Object.h
index e6147c40b7c..a73e93620d3 100644
--- a/llvm/tools/llvm-objcopy/COFF/Object.h
+++ b/llvm/tools/llvm-objcopy/COFF/Object.h
@@ -37,12 +37,16 @@ struct Section {
ArrayRef<uint8_t> Contents;
std::vector<Relocation> Relocs;
StringRef Name;
+ ssize_t UniqueId;
+ size_t Index;
};
struct Symbol {
object::coff_symbol32 Sym;
StringRef Name;
- ArrayRef<uint8_t> AuxData;
+ std::vector<uint8_t> AuxData;
+ ssize_t TargetSectionId;
+ ssize_t AssociativeComdatTargetSectionId = 0;
size_t UniqueId;
size_t RawIndex;
bool Referenced;
@@ -61,7 +65,6 @@ struct Object {
uint32_t BaseOfData = 0; // pe32plus_header lacks this field.
std::vector<object::data_directory> DataDirectories;
- std::vector<Section> Sections;
ArrayRef<Symbol> getSymbols() const { return Symbols; }
// This allows mutating individual Symbols, but not mutating the list
@@ -79,14 +82,34 @@ struct Object {
// all sections.
Error markSymbols();
+ ArrayRef<Section> getSections() const { return Sections; }
+ // This allows mutating individual Sections, but not mutating the list
+ // of symbols itself.
+ iterator_range<std::vector<Section>::iterator> getMutableSections() {
+ return make_range(Sections.begin(), Sections.end());
+ }
+
+ const Section *findSection(ssize_t UniqueId) const;
+
+ void addSections(ArrayRef<Section> NewSections);
+ void removeSections(function_ref<bool(const Section &)> ToRemove);
+
private:
std::vector<Symbol> Symbols;
DenseMap<size_t, Symbol *> SymbolMap;
size_t NextSymbolUniqueId = 0;
+ std::vector<Section> Sections;
+ DenseMap<ssize_t, Section *> SectionMap;
+
+ ssize_t NextSectionUniqueId = 1; // Allow a UniqueId 0 to mean undefined.
+
// Update SymbolMap and RawIndex in each Symbol.
void updateSymbols();
+
+ // Update SectionMap and Index in each Section.
+ void updateSections();
};
// Copy between coff_symbol16 and coff_symbol32.
OpenPOWER on IntegriCloud