1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-21 18:08:01 +03:00
This commit is contained in:
Rui Ueyama 2021-04-06 17:21:19 +09:00
parent bc156aa03e
commit bbca727170
2 changed files with 10 additions and 1 deletions

3
mold.h
View File

@ -1289,6 +1289,9 @@ struct Context {
ConcurrentMap<ComdatGroup> comdat_groups;
FileCache<E, ObjectFile<E>> obj_cache;
FileCache<E, SharedFile<E>> dso_cache;
std::mutex mu;
std::vector<std::unique_ptr<ObjectFile<E>>> owning_objs;
std::vector<std::unique_ptr<ObjectFile<E>>> owning_dsos;
// Symbol auxiliary data
std::vector<SymbolAux> symbol_aux;

View File

@ -124,7 +124,10 @@ template <typename E>
ObjectFile<E> *
ObjectFile<E>::create(Context<E> &ctx, MemoryMappedFile<E> *mb,
std::string archive_name, bool is_in_lib) {
return new ObjectFile<E>(ctx, mb, archive_name, is_in_lib);
ObjectFile<E> *obj = new ObjectFile<E>(ctx, mb, archive_name, is_in_lib);
std::lock_guard lock(ctx.mu);
ctx.owning_objs.push_back(std::unique_ptr<ObjectFile<E>>(obj));
return obj;
}
template <typename E>
@ -1082,6 +1085,9 @@ ObjectFile<E>::create_internal_file(Context<E> &ctx) {
i64 num_globals = obj->elf_syms.size() - obj->first_global;
obj->symvers.resize(num_globals);
std::lock_guard lock(ctx.mu);
ctx.owning_objs.push_back(std::unique_ptr<ObjectFile<E>>(obj));
return obj;
}