1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-13 09:39:13 +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

22
main.cc
View File

@ -421,11 +421,9 @@ static void fill_symbol_versions() {
if (syms.empty())
return;
std::stable_sort(syms.begin(), syms.end(), [](Symbol *a, Symbol *b) {
SharedFile *x = (SharedFile *)a->file;
SharedFile *y = (SharedFile *)b->file;
return std::make_tuple(x->soname, a->ver_idx) <
std::make_tuple(y->soname, b->ver_idx);
sort(syms, [](Symbol *a, Symbol *b) {
return std::make_tuple(((SharedFile *)a->file)->soname, a->ver_idx) <
std::make_tuple(((SharedFile *)b->file)->soname, b->ver_idx);
});
// Compute sizes of .gnu.version and .gnu.version_r sections.
@ -1014,7 +1012,6 @@ static void show_stats() {
}
int main(int argc, char **argv) {
// Main
Timer t_all("all");
// 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::stable_sort(OutputSection::instances.begin(), OutputSection::instances.end(),
section_compare);
std::stable_sort(MergedSection::instances.begin(), MergedSection::instances.end(),
section_compare);
sort(OutputSection::instances, section_compare);
sort(MergedSection::instances, section_compare);
// Add sections to the section lists
for (OutputSection *osec : OutputSection::instances)
@ -1185,10 +1180,9 @@ int main(int argc, char **argv) {
// Sort the sections by section flags so that we'll have to create
// as few segments as possible.
std::stable_sort(out::chunks.begin(), out::chunks.end(),
[](OutputChunk *a, OutputChunk *b) {
return get_section_rank(a->shdr) < get_section_rank(b->shdr);
});
sort(out::chunks, [](OutputChunk *a, OutputChunk *b) {
return get_section_rank(a->shdr) < get_section_rank(b->shdr);
});
// Create a dummy file containing linker-synthesized symbols
// (e.g. `__bss_start`).

View File

@ -14,8 +14,7 @@ void print_map() {
for (auto &pair : map) {
std::vector<Symbol *> &vec = pair.second;
std::stable_sort(vec.begin(), vec.end(),
[](Symbol *a, Symbol *b) { return a->value < b->value; });
sort(vec, [](Symbol *a, Symbol *b) { return a->value < b->value; });
}
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) {
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,11 +713,10 @@ void SharedFile::parse() {
// Sort symbols by value for find_aliases(), as find_aliases() does
// binary search on symbols.
std::stable_sort(pairs.begin(), pairs.end(),
[](const std::pair<const ElfSym *, u16> &a,
const std::pair<const ElfSym *, u16> &b) {
return a.first->st_value < b.first->st_value;
});
sort(pairs, [](const std::pair<const ElfSym *, u16> &a,
const std::pair<const ElfSym *, u16> &b) {
return a.first->st_value < b.first->st_value;
});
elf_syms.reserve(pairs.size());
versyms.reserve(pairs.size());

View File

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