1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-27 10:23:41 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-12-13 22:31:50 +09:00
parent 93a15f5515
commit f4886d4dae
2 changed files with 10 additions and 15 deletions

20
main.cc
View File

@ -115,11 +115,8 @@ static void resolve_symbols() {
});
// Eliminate unused archive members and as-needed DSOs.
auto callback = [](InputFile *file){ return !file->is_alive; };
out::objs.erase(std::remove_if(out::objs.begin(), out::objs.end(), callback),
out::objs.end());
out::dsos.erase(std::remove_if(out::dsos.begin(), out::dsos.end(), callback),
out::dsos.end());
erase(out::objs, [](InputFile *file){ return !file->is_alive; });
erase(out::dsos, [](InputFile *file){ return !file->is_alive; });
}
static void eliminate_comdats() {
@ -405,10 +402,7 @@ static void fill_symbol_versions() {
// Create a list of versioned symbols and sort by file and version.
std::vector<Symbol *> syms = out::dynsym->symbols;
syms.erase(std::remove_if(syms.begin(), syms.end(),
[](Symbol *sym){ return sym->ver_idx < 2; }),
syms.end());
erase(syms, [](Symbol *sym){ return sym->ver_idx < 2; });
if (syms.empty())
return;
@ -975,9 +969,7 @@ int main(int argc, char **argv) {
if (osec->shdr.sh_size)
out::chunks.push_back(osec);
out::chunks.erase(std::remove_if(out::chunks.begin(), out::chunks.end(),
[](OutputChunk *c) { return !c; }),
out::chunks.end());
erase(out::chunks, [](OutputChunk *c) { return !c; });
// Sort the sections by section flags so that we'll have to create
// as few segments as possible.
@ -1040,9 +1032,7 @@ int main(int argc, char **argv) {
for (OutputChunk *chunk : out::chunks)
chunk->update_shdr();
out::chunks.erase(std::remove_if(out::chunks.begin(), out::chunks.end(),
[](OutputChunk *c) { return c->shdr.sh_size == 0; }),
out::chunks.end());
erase(out::chunks, [](OutputChunk *c) { return c->shdr.sh_size == 0; });
// Set section indices.
for (int i = 0, shndx = 1; i < out::chunks.size(); i++)

5
mold.h
View File

@ -1257,3 +1257,8 @@ inline std::vector<T> flatten(std::vector<std::vector<T>> &vec) {
ret.insert(ret.end(), v.begin(), v.end());
return ret;
}
template <typename T, typename U>
inline void erase(std::vector<T> &vec, U pred) {
vec.erase(std::remove_if(vec.begin(), vec.end(), pred), vec.end());
}