mirror of
https://github.com/rui314/mold.git
synced 2024-10-05 00:57:08 +03:00
Refactor
This commit is contained in:
parent
bba506d6b4
commit
2ee2243c63
@ -47,6 +47,24 @@ ElfShdr<E> *InputFile<E>::find_section(i64 type) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename E>
|
||||
void InputFile<E>::clear_symbols(Context<E> &ctx) {
|
||||
assert(!is_alive);
|
||||
|
||||
for (Symbol<E> *sym : get_global_syms()) {
|
||||
if (sym->file == this) {
|
||||
sym->file = nullptr;
|
||||
sym->input_section = nullptr;
|
||||
sym->value = -1;
|
||||
sym->sym_idx = -1;
|
||||
sym->ver_idx = 0;
|
||||
sym->is_weak = false;
|
||||
sym->is_imported = false;
|
||||
sym->is_exported = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename E>
|
||||
ObjectFile<E>::ObjectFile(Context<E> &ctx, MappedFile<Context<E>> *mf,
|
||||
std::string archive_name, bool is_in_lib)
|
||||
|
@ -889,6 +889,7 @@ public:
|
||||
ElfShdr<E> *find_section(i64 type);
|
||||
|
||||
virtual void resolve_symbols(Context<E> &ctx) = 0;
|
||||
virtual void clear_symbols(Context<E> &ctx);
|
||||
|
||||
virtual void
|
||||
mark_live_objects(Context<E> &ctx,
|
||||
|
@ -112,9 +112,7 @@ void resolve_symbols(Context<E> &ctx) {
|
||||
// Remove symbols of eliminated files.
|
||||
tbb::parallel_for_each(files, [&](InputFile<E> *file) {
|
||||
if (!file->is_alive)
|
||||
for (Symbol<E> *sym : file->get_global_syms())
|
||||
if (sym->file == file)
|
||||
new (sym) Symbol<E>(sym->name());
|
||||
file->clear_symbols(ctx);
|
||||
});
|
||||
|
||||
// Since we have turned on object files live bits, their symbols
|
||||
|
Loading…
Reference in New Issue
Block a user