1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-28 19:04:27 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-12-21 18:42:14 +09:00
parent 23e9d8c36f
commit 92afbacf44
5 changed files with 19 additions and 24 deletions

18
main.cc
View File

@ -421,11 +421,9 @@ static void fill_symbol_versions() {
if (syms.empty()) if (syms.empty())
return; return;
std::stable_sort(syms.begin(), syms.end(), [](Symbol *a, Symbol *b) { sort(syms, [](Symbol *a, Symbol *b) {
SharedFile *x = (SharedFile *)a->file; return std::make_tuple(((SharedFile *)a->file)->soname, a->ver_idx) <
SharedFile *y = (SharedFile *)b->file; std::make_tuple(((SharedFile *)b->file)->soname, b->ver_idx);
return std::make_tuple(x->soname, a->ver_idx) <
std::make_tuple(y->soname, b->ver_idx);
}); });
// Compute sizes of .gnu.version and .gnu.version_r sections. // Compute sizes of .gnu.version and .gnu.version_r sections.
@ -1014,7 +1012,6 @@ static void show_stats() {
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
// Main
Timer t_all("all"); Timer t_all("all");
// Parse non-positional command line options // Parse non-positional command line options
@ -1168,10 +1165,8 @@ int main(int argc, char **argv) {
std::make_tuple(y->name, (u32)y->shdr.sh_type, (u64)y->shdr.sh_flags); std::make_tuple(y->name, (u32)y->shdr.sh_type, (u64)y->shdr.sh_flags);
}; };
std::stable_sort(OutputSection::instances.begin(), OutputSection::instances.end(), sort(OutputSection::instances, section_compare);
section_compare); sort(MergedSection::instances, section_compare);
std::stable_sort(MergedSection::instances.begin(), MergedSection::instances.end(),
section_compare);
// Add sections to the section lists // Add sections to the section lists
for (OutputSection *osec : OutputSection::instances) for (OutputSection *osec : OutputSection::instances)
@ -1185,8 +1180,7 @@ int main(int argc, char **argv) {
// Sort the sections by section flags so that we'll have to create // Sort the sections by section flags so that we'll have to create
// as few segments as possible. // as few segments as possible.
std::stable_sort(out::chunks.begin(), out::chunks.end(), sort(out::chunks, [](OutputChunk *a, OutputChunk *b) {
[](OutputChunk *a, OutputChunk *b) {
return get_section_rank(a->shdr) < get_section_rank(b->shdr); return get_section_rank(a->shdr) < get_section_rank(b->shdr);
}); });

View File

@ -14,8 +14,7 @@ void print_map() {
for (auto &pair : map) { for (auto &pair : map) {
std::vector<Symbol *> &vec = pair.second; std::vector<Symbol *> &vec = pair.second;
std::stable_sort(vec.begin(), vec.end(), sort(vec, [](Symbol *a, Symbol *b) { return a->value < b->value; });
[](Symbol *a, Symbol *b) { return a->value < b->value; });
} }
std::cout << " VMA Size Align Out In Symbol\n"; std::cout << " VMA Size Align Out In Symbol\n";

5
mold.h
View File

@ -1009,3 +1009,8 @@ template <typename T, typename U>
inline void erase(std::vector<T> &vec, U pred) { inline void erase(std::vector<T> &vec, U pred) {
vec.erase(std::remove_if(vec.begin(), vec.end(), pred), vec.end()); vec.erase(std::remove_if(vec.begin(), vec.end(), pred), vec.end());
} }
template <typename T, typename U>
inline void sort(T &vec, U less) {
std::stable_sort(vec.begin(), vec.end(), less);
}

View File

@ -713,8 +713,7 @@ void SharedFile::parse() {
// Sort symbols by value for find_aliases(), as find_aliases() does // Sort symbols by value for find_aliases(), as find_aliases() does
// binary search on symbols. // binary search on symbols.
std::stable_sort(pairs.begin(), pairs.end(), sort(pairs, [](const std::pair<const ElfSym *, u16> &a,
[](const std::pair<const ElfSym *, u16> &a,
const std::pair<const ElfSym *, u16> &b) { const std::pair<const ElfSym *, u16> &b) {
return a.first->st_value < b.first->st_value; return a.first->st_value < b.first->st_value;
}); });

View File

@ -15,9 +15,7 @@ void Counter::print() {
return; return;
std::vector<Counter *> vec = instances; std::vector<Counter *> vec = instances;
std::stable_sort(vec.begin(), vec.end(), [](Counter *a, Counter *b) { sort(vec, [](Counter *a, Counter *b) { return a->value > b->value; });
return a->value > b->value;
});
for (Counter *c : vec) for (Counter *c : vec)
std::cout << std::setw(20) << std::right << c->name << "=" << c->value << "\n"; std::cout << std::setw(20) << std::right << c->name << "=" << c->value << "\n";