1 // archive.h -- archive support for gold -*- C++ -*-
19 // This class represents an archive--generally a libNAME.a file.
20 // Archives have a symbol table and a list of objects.
25 Archive(const std::string
& name
, Input_file
* input_file
)
26 : name_(name
), input_file_(input_file
), armap_(), extended_names_()
29 // The length of the magic string at the start of an archive.
30 static const int sarmag
= 8;
32 // The magic string at the start of an archive.
33 static const char armag
[sarmag
];
35 // The string expected at the end of an archive member header.
36 static const char arfmag
[2];
38 // The name of the object.
41 { return this->name_
; }
43 // Set up the archive: read the symbol map.
47 // Lock the underlying file.
50 { this->input_file_
->file().lock(); }
52 // Unlock the underlying file.
55 { this->input_file_
->file().unlock(); }
57 // Return whether the underlying file is locked.
60 { return this->input_file_
->file().is_locked(); }
62 // Select members from the archive as needed and add them to the
65 add_symbols(Symbol_table
*, Layout
*, Input_objects
*);
68 Archive(const Archive
&);
69 Archive
& operator=(const Archive
&);
71 struct Archive_header
;
72 class Add_archive_symbols_locker
;
74 // Get a view into the underlying file.
76 get_view(off_t start
, off_t size
);
78 // Read an archive member header at OFF. Return the size of the
79 // member, and set *PNAME to the name.
81 read_header(off_t off
, std::string
* pname
);
83 // Include an archive member in the link.
85 include_member(Symbol_table
*, Layout
*, Input_objects
*, off_t off
);
87 // An entry in the archive map of symbols to object files.
92 // The offset to the file.
96 // Name of object as printed to user.
98 // For reading the file.
99 Input_file
* input_file_
;
101 std::vector
<Armap_entry
> armap_
;
102 // The extended name table.
103 std::string extended_names_
;
106 // This class is used to read an archive and pick out the desired
107 // elements and add them to the link.
109 class Add_archive_symbols
: public Task
112 Add_archive_symbols(Symbol_table
* symtab
, Layout
* layout
,
113 Input_objects
* input_objects
,
114 Archive
* archive
, Task_token
* this_blocker
,
115 Task_token
* next_blocker
)
116 : symtab_(symtab
), layout_(layout
), input_objects_(input_objects
),
117 archive_(archive
), this_blocker_(this_blocker
),
118 next_blocker_(next_blocker
)
121 ~Add_archive_symbols();
123 // The standard Task methods.
126 is_runnable(Workqueue
*);
135 class Add_archive_symbols_locker
;
137 Symbol_table
* symtab_
;
139 Input_objects
* input_objects_
;
141 Task_token
* this_blocker_
;
142 Task_token
* next_blocker_
;
145 } // End namespace gold.
147 #endif // !defined(GOLD_ARCHIVE_H)