1 // archive.h -- archive support for gold -*- C++ -*-
18 // This class represents an archive--generally a libNAME.a file.
19 // Archives have a symbol table and a list of objects.
24 Archive(const std::string& name, Input_file* input_file)
25 : name_(name), input_file_(input_file), armap_(), extended_names_()
28 // The length of the magic string at the start of an archive.
29 static const int sarmag = 8;
31 // The magic string at the start of an archive.
32 static const char armag[sarmag];
34 // The string expected at the end of an archive member header.
35 static const char arfmag[2];
37 // The name of the object.
40 { return this->name_; }
42 // Set up the archive: read the symbol map.
46 // Lock the underlying file.
49 { this->input_file_->file().lock(); }
51 // Unlock the underlying file.
54 { this->input_file_->file().unlock(); }
56 // Return whether the underlying file is locked.
59 { return this->input_file_->file().is_locked(); }
61 // Select members from the archive as needed and add them to the
64 add_symbols(Symbol_table*, Input_objects*);
67 Archive(const Archive&);
68 Archive& operator=(const Archive&);
70 struct Archive_header;
71 class Add_archive_symbols_locker;
73 // Get a view into the underlying file.
75 get_view(off_t start, off_t size);
77 // Read an archive member header at OFF. Return the size of the
78 // member, and set *PNAME to the name.
80 read_header(off_t off, std::string* pname);
82 // Include an archive member in the link.
84 include_member(Symbol_table*, Input_objects*, off_t off);
86 // An entry in the archive map of symbols to object files.
91 // The offset to the file.
95 // Name of object as printed to user.
97 // For reading the file.
98 Input_file* input_file_;
100 std::vector<Armap_entry> armap_;
101 // The extended name table.
102 std::string extended_names_;
105 // This class is used to read an archive and pick out the desired
106 // elements and add them to the link.
108 class Add_archive_symbols : public Task
111 Add_archive_symbols(Symbol_table* symtab, Input_objects* input_objects,
112 Archive* archive, Task_token* this_blocker,
113 Task_token* next_blocker)
114 : symtab_(symtab), input_objects_(input_objects), archive_(archive),
115 this_blocker_(this_blocker), next_blocker_(next_blocker)
118 ~Add_archive_symbols();
120 // The standard Task methods.
123 is_runnable(Workqueue*);
132 class Add_archive_symbols_locker;
134 Symbol_table* symtab_;
135 Input_objects* input_objects_;
137 Task_token* this_blocker_;
138 Task_token* next_blocker_;
141 } // End namespace gold.
143 #endif // !defined(GOLD_ARCHIVE_H)