mirror of
https://github.com/rui314/mold.git
synced 2024-09-11 21:17:28 +03:00
Simplify
This commit is contained in:
parent
89612b7096
commit
c173f9c0ab
@ -74,7 +74,7 @@ ObjectFile<E> *
|
||||
ObjectFile<E>::create(Context<E> &ctx, MappedFile<Context<E>> *mf,
|
||||
std::string archive_name, bool is_in_lib) {
|
||||
ObjectFile<E> *obj = new ObjectFile<E>(ctx, mf, archive_name, is_in_lib);
|
||||
ctx.obj_pool.push_back(std::unique_ptr<ObjectFile<E>>(obj));
|
||||
ctx.obj_pool.emplace_back(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@ -1171,7 +1171,7 @@ template <typename E>
|
||||
SharedFile<E> *
|
||||
SharedFile<E>::create(Context<E> &ctx, MappedFile<Context<E>> *mf) {
|
||||
SharedFile<E> *obj = new SharedFile(ctx, mf);
|
||||
ctx.dso_pool.push_back(std::unique_ptr<SharedFile<E>>(obj));
|
||||
ctx.dso_pool.emplace_back(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ static PluginStatus add_input_file(const char *path) {
|
||||
MappedFile<Context<E>> *mf = MappedFile<Context<E>>::must_open(ctx, path);
|
||||
|
||||
ObjectFile<E> *file = ObjectFile<E>::create(ctx, mf, "", false);
|
||||
ctx.obj_pool.push_back(std::unique_ptr<ObjectFile<E>>(file));
|
||||
ctx.obj_pool.emplace_back(file);
|
||||
lto_objects<E>.push_back(file);
|
||||
|
||||
file->priority = file_priority++;
|
||||
@ -491,7 +491,7 @@ ObjectFile<E> *read_lto_object(Context<E> &ctx, MappedFile<Context<E>> *mf) {
|
||||
|
||||
// Create mold's object instance
|
||||
ObjectFile<E> *obj = new ObjectFile<E>;
|
||||
ctx.obj_pool.push_back(std::unique_ptr<ObjectFile<E>>(obj));
|
||||
ctx.obj_pool.emplace_back(obj);
|
||||
|
||||
obj->filename = mf->name;
|
||||
obj->symbols.push_back(new Symbol<E>);
|
||||
|
@ -812,7 +812,7 @@ OutputSection<E>::get_instance(Context<E> &ctx, std::string_view name,
|
||||
|
||||
OutputSection<E> *osec = new OutputSection(name, type, flags,
|
||||
ctx.output_sections.size());
|
||||
ctx.output_sections.push_back(std::unique_ptr<OutputSection<E>>(osec));
|
||||
ctx.output_sections.emplace_back(osec);
|
||||
return osec;
|
||||
}
|
||||
|
||||
@ -1408,8 +1408,8 @@ MergedSection<E>::get_instance(Context<E> &ctx, std::string_view name,
|
||||
if (MergedSection *osec = find())
|
||||
return osec;
|
||||
|
||||
auto *osec = new MergedSection(name, flags, type);
|
||||
ctx.merged_sections.push_back(std::unique_ptr<MergedSection>(osec));
|
||||
MergedSection *osec = new MergedSection(name, flags, type);
|
||||
ctx.merged_sections.emplace_back(osec);
|
||||
return osec;
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ static std::optional<u64> parse_defsym_addr(std::string_view s) {
|
||||
template <typename E>
|
||||
ObjectFile<E> *create_internal_file(Context<E> &ctx) {
|
||||
ObjectFile<E> *obj = new ObjectFile<E>;
|
||||
ctx.obj_pool.push_back(std::unique_ptr<ObjectFile<E>>(obj));
|
||||
ctx.obj_pool.emplace_back(obj);
|
||||
|
||||
// Create linker-synthesized symbols.
|
||||
auto *esyms = new std::vector<ElfSym<E>>(1);
|
||||
@ -884,7 +884,7 @@ void create_reloc_sections(Context<E> &ctx) {
|
||||
for (std::unique_ptr<OutputSection<E>> &osec : ctx.output_sections) {
|
||||
RelocSection<E> *r = new RelocSection<E>(ctx, *osec);
|
||||
ctx.chunks.push_back(r);
|
||||
ctx.output_chunks.push_back(std::unique_ptr<Chunk<E>>(r));
|
||||
ctx.output_chunks.emplace_back(r);
|
||||
}
|
||||
|
||||
// Create a table to map input symbol indices to output symbol indices
|
||||
@ -1377,7 +1377,7 @@ void compress_debug_sections(Context<E> &ctx) {
|
||||
comp = new GnuCompressedSection<E>(ctx, chunk);
|
||||
assert(comp);
|
||||
|
||||
ctx.output_chunks.push_back(std::unique_ptr<Chunk<E>>(comp));
|
||||
ctx.output_chunks.emplace_back(comp);
|
||||
ctx.chunks[i] = comp;
|
||||
});
|
||||
|
||||
|
@ -23,7 +23,7 @@ split_string(std::string_view str, char sep) {
|
||||
template <typename E>
|
||||
static void create_internal_file(Context<E> &ctx) {
|
||||
ObjectFile<E> *obj = new ObjectFile<E>;
|
||||
ctx.obj_pool.push_back(std::unique_ptr<ObjectFile<E>>(obj));
|
||||
ctx.obj_pool.emplace_back(obj);
|
||||
ctx.objs.push_back(obj);
|
||||
|
||||
auto add = [&](std::string_view name) {
|
||||
|
@ -21,7 +21,7 @@ ObjectFile<E>::create(Context<E> &ctx, MappedFile<Context<E>> *mf,
|
||||
obj->mf = mf;
|
||||
obj->archive_name = archive_name;
|
||||
obj->is_alive = archive_name.empty();
|
||||
ctx.obj_pool.push_back(std::unique_ptr<ObjectFile<E>>(obj));
|
||||
ctx.obj_pool.emplace_back(obj);
|
||||
return obj;
|
||||
};
|
||||
|
||||
@ -186,7 +186,7 @@ void ObjectFile<E>::split_subsections(Context<E> &ctx) {
|
||||
.input_addr = (u32)(isec.hdr.addr + r.offset),
|
||||
.p2align = (u8)isec.hdr.p2align,
|
||||
};
|
||||
subsections.push_back(std::unique_ptr<Subsection<E>>(subsec));
|
||||
subsections.emplace_back(subsec);
|
||||
}
|
||||
|
||||
if (r.symidx != -1)
|
||||
@ -482,7 +482,7 @@ void ObjectFile<E>::convert_common_symbols(Context<E> &ctx) {
|
||||
.p2align = (u8)msym.p2align,
|
||||
};
|
||||
|
||||
subsections.push_back(std::unique_ptr<Subsection<E>>(subsec));
|
||||
subsections.emplace_back(subsec);
|
||||
|
||||
sym.subsec = subsec;
|
||||
sym.value = 0;
|
||||
@ -514,7 +514,7 @@ InputSection<E> *ObjectFile<E>::get_common_sec(Context<E> &ctx) {
|
||||
hdr->type = S_ZEROFILL;
|
||||
|
||||
common_sec = new InputSection<E>(ctx, *this, *hdr);
|
||||
sections.push_back(std::unique_ptr<InputSection<E>>(common_sec));
|
||||
sections.emplace_back(common_sec);
|
||||
}
|
||||
return common_sec;
|
||||
}
|
||||
@ -523,7 +523,7 @@ template <typename E>
|
||||
DylibFile<E> *DylibFile<E>::create(Context<E> &ctx, MappedFile<Context<E>> *mf) {
|
||||
DylibFile<E> *dylib = new DylibFile<E>;
|
||||
dylib->mf = mf;
|
||||
ctx.dylib_pool.push_back(std::unique_ptr<DylibFile<E>>(dylib));
|
||||
ctx.dylib_pool.emplace_back(dylib);
|
||||
return dylib;
|
||||
};
|
||||
|
||||
|
@ -368,7 +368,7 @@ OutputSection<E>::get_instance(Context<E> &ctx, std::string_view segname,
|
||||
return osec;
|
||||
|
||||
OutputSection<E> *osec = new OutputSection<E>(ctx, segname, sectname);
|
||||
ctx.osec_pool.push_back(std::unique_ptr<OutputSection<E>>(osec));
|
||||
ctx.osec_pool.emplace_back(osec);
|
||||
return osec;
|
||||
}
|
||||
|
||||
@ -426,7 +426,7 @@ OutputSegment<E>::get_instance(Context<E> &ctx, std::string_view name) {
|
||||
return seg;
|
||||
|
||||
OutputSegment<E> *seg = new OutputSegment<E>(name);
|
||||
ctx.segments.push_back(std::unique_ptr<OutputSegment<E>>(seg));
|
||||
ctx.segments.emplace_back(seg);
|
||||
return seg;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user