mirror of
https://github.com/rui314/mold.git
synced 2024-12-28 19:04:27 +03:00
wip
This commit is contained in:
parent
0f46de23d2
commit
3e454c2175
12
icf.cc
12
icf.cc
@ -264,8 +264,11 @@ void icf_sections() {
|
|||||||
break;
|
break;
|
||||||
num_classes = n;
|
num_classes = n;
|
||||||
}
|
}
|
||||||
|
t2.stop();
|
||||||
|
|
||||||
|
|
||||||
// Group sections by SHA1 digest.
|
// Group sections by SHA1 digest.
|
||||||
|
Timer t3("merge");
|
||||||
std::vector<std::pair<InputSection *, Digest>> entries;
|
std::vector<std::pair<InputSection *, Digest>> entries;
|
||||||
entries.resize(sections.size());
|
entries.resize(sections.size());
|
||||||
|
|
||||||
@ -273,8 +276,13 @@ void icf_sections() {
|
|||||||
entries[i] = {sections[i], digests[slot][i]};
|
entries[i] = {sections[i], digests[slot][i]};
|
||||||
});
|
});
|
||||||
|
|
||||||
tbb::parallel_sort(entries.begin(), entries.end(),
|
tbb::parallel_sort(entries.begin(), entries.end(), [](auto &a, auto &b) {
|
||||||
[](auto &a, auto &b) { return a.second < b.second; });
|
if (a.second != b.second)
|
||||||
|
return a.second < b.second;
|
||||||
|
if (a.first->file->priority != b.first->file->priority)
|
||||||
|
return a.first->file->priority < b.first->file->priority;
|
||||||
|
return a.first->get_section_idx() < b.first->get_section_idx();
|
||||||
|
});
|
||||||
|
|
||||||
tbb::enumerable_thread_specific<i64> counter;
|
tbb::enumerable_thread_specific<i64> counter;
|
||||||
tbb::parallel_for((i64)0, (i64)entries.size() - 1, [&](i64 i) {
|
tbb::parallel_for((i64)0, (i64)entries.size() - 1, [&](i64 i) {
|
||||||
|
@ -11,6 +11,12 @@ std::string_view InputChunk::get_contents() const {
|
|||||||
return file->get_string(shdr);
|
return file->get_string(shdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i64 InputChunk::get_section_idx() const {
|
||||||
|
assert(&file->elf_sections.front() <= &shdr &&
|
||||||
|
&shdr < &file->elf_sections.back());
|
||||||
|
return &shdr - &file->elf_sections.front();
|
||||||
|
}
|
||||||
|
|
||||||
static std::string rel_to_string(u64 r_type) {
|
static std::string rel_to_string(u64 r_type) {
|
||||||
switch (r_type) {
|
switch (r_type) {
|
||||||
case R_X86_64_NONE: return "R_X86_64_NONE";
|
case R_X86_64_NONE: return "R_X86_64_NONE";
|
||||||
|
1
mold.h
1
mold.h
@ -300,6 +300,7 @@ public:
|
|||||||
virtual void copy_buf() {}
|
virtual void copy_buf() {}
|
||||||
inline u64 get_addr() const;
|
inline u64 get_addr() const;
|
||||||
std::string_view get_contents() const;
|
std::string_view get_contents() const;
|
||||||
|
i64 get_section_idx() const;
|
||||||
|
|
||||||
ObjectFile *file;
|
ObjectFile *file;
|
||||||
const ElfShdr &shdr;
|
const ElfShdr &shdr;
|
||||||
|
Loading…
Reference in New Issue
Block a user