mirror of
https://github.com/rui314/mold.git
synced 2024-09-22 10:27:48 +03:00
temporary
This commit is contained in:
parent
f88ae30ead
commit
f076039162
8
main.cc
8
main.cc
@ -1270,9 +1270,15 @@ int main(int argc, char **argv) {
|
||||
// Copy input sections to the output file
|
||||
{
|
||||
Timer t("copy_buf");
|
||||
tbb::task_group tg;
|
||||
tg.run([]() { Timer t("eh_copy"); out::ehframe->copy_buf(); });
|
||||
|
||||
tbb::parallel_for_each(out::chunks, [&](OutputChunk *chunk) {
|
||||
chunk->copy_buf();
|
||||
if (chunk != out::ehframe)
|
||||
chunk->copy_buf();
|
||||
});
|
||||
|
||||
tg.wait();
|
||||
Error::checkpoint();
|
||||
}
|
||||
|
||||
|
2
mold.h
2
mold.h
@ -667,6 +667,8 @@ struct CieRecord {
|
||||
std::string_view contents;
|
||||
std::vector<EhReloc> rels;
|
||||
std::vector<FdeRecord> fdes;
|
||||
|
||||
u32 fde_size = -1;
|
||||
};
|
||||
|
||||
class EhFrameSection : public OutputChunk {
|
||||
|
@ -700,14 +700,14 @@ void MergedSection::copy_buf() {
|
||||
}
|
||||
|
||||
void EhFrameSection::construct() {
|
||||
std::vector<u32> fde_size(out::objs.size());
|
||||
|
||||
tbb::parallel_for(0, (int)out::objs.size(), [&](int i) {
|
||||
ObjectFile *file = out::objs[i];
|
||||
for (CieRecord &cie : file->cies) {
|
||||
erase(cie.fdes, [&](FdeRecord &fde) { return !fde.is_alive(); });
|
||||
|
||||
cie.fde_size = 0;
|
||||
for (FdeRecord &fde : cie.fdes)
|
||||
fde_size[i] += fde.contents.size();
|
||||
cie.fde_size += fde.contents.size();
|
||||
}
|
||||
});
|
||||
|
||||
@ -724,19 +724,21 @@ void EhFrameSection::construct() {
|
||||
});
|
||||
|
||||
for (CieRecord *cie : vec) {
|
||||
if (cies.empty() || cies.back() != cie)
|
||||
if (cies.empty() || cies.back() != cie) {
|
||||
cies.push_back(cie);
|
||||
else
|
||||
} else {
|
||||
std::move(cie->fdes.begin(), cie->fdes.end(),
|
||||
std::back_inserter(cies.back()->fdes));
|
||||
cies.back()->fde_size += cie->fde_size;
|
||||
}
|
||||
}
|
||||
|
||||
// Compute output size
|
||||
u32 size = 0;
|
||||
for (CieRecord *cie : cies)
|
||||
for (CieRecord *cie : vec) {
|
||||
size += cie->contents.size();
|
||||
for (u32 x : fde_size)
|
||||
size += x;
|
||||
size += cie->fde_size;
|
||||
}
|
||||
|
||||
shdr.sh_size = size;
|
||||
}
|
||||
|
||||
@ -749,9 +751,23 @@ void EhFrameSection::copy_buf() {
|
||||
memcpy(base + offset, cie->contents.data(), cie->contents.size());
|
||||
offset += cie->contents.size();
|
||||
|
||||
for (EhReloc &rel : cie->rels) {
|
||||
u32 P = shdr.sh_offset + cie_offset + rel.offset;
|
||||
u32 S = rel.sym->get_addr();
|
||||
*(u32 *)(out::buf + P) = S - P;
|
||||
}
|
||||
|
||||
for (FdeRecord &fde : cie->fdes) {
|
||||
u32 fde_offset = offset;
|
||||
memcpy(base + offset, fde.contents.data(), fde.contents.size());
|
||||
*(u32 *)(base + offset + 4) = fde_offset + 4 - cie_offset;
|
||||
offset += fde.contents.size();
|
||||
|
||||
for (EhReloc &rel : fde.rels) {
|
||||
u32 P = shdr.sh_offset + fde_offset + rel.offset;
|
||||
u32 S = rel.sym->get_addr();
|
||||
*(u32 *)(out::buf + P) = S - P;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user