mirror of
https://github.com/rui314/mold.git
synced 2024-12-26 18:02:30 +03:00
temporary
This commit is contained in:
parent
e45f797d22
commit
1161e4b4a9
@ -132,7 +132,8 @@ void InputSection::copy_buf() {
|
|||||||
|
|
||||||
// Copy data
|
// Copy data
|
||||||
u8 *base = out::buf + output_section->shdr.sh_offset + offset;
|
u8 *base = out::buf + output_section->shdr.sh_offset + offset;
|
||||||
copy_contents(base);
|
std::string_view contents = file->get_string(shdr);
|
||||||
|
memcpy(base, contents.data(), contents.size());
|
||||||
|
|
||||||
// Apply relocations
|
// Apply relocations
|
||||||
if (shdr.sh_flags & SHF_ALLOC)
|
if (shdr.sh_flags & SHF_ALLOC)
|
||||||
@ -141,11 +142,6 @@ void InputSection::copy_buf() {
|
|||||||
apply_reloc_nonalloc(base);
|
apply_reloc_nonalloc(base);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputSection::copy_contents(u8 *base) {
|
|
||||||
std::string_view contents = file->get_string(shdr);
|
|
||||||
memcpy(base, contents.data(), contents.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputSection::apply_reloc_alloc(u8 *base) {
|
void InputSection::apply_reloc_alloc(u8 *base) {
|
||||||
int ref_idx = 0;
|
int ref_idx = 0;
|
||||||
ElfRela *dynrel = nullptr;
|
ElfRela *dynrel = nullptr;
|
||||||
|
1
mold.h
1
mold.h
@ -336,7 +336,6 @@ public:
|
|||||||
bool is_comdat_member = false;
|
bool is_comdat_member = false;
|
||||||
bool is_alive = true;
|
bool is_alive = true;
|
||||||
|
|
||||||
void copy_contents(u8 *base);
|
|
||||||
void apply_reloc_alloc(u8 *base);
|
void apply_reloc_alloc(u8 *base);
|
||||||
void apply_reloc_nonalloc(u8 *base);
|
void apply_reloc_nonalloc(u8 *base);
|
||||||
};
|
};
|
||||||
|
@ -423,18 +423,19 @@ void OutputSection::copy_buf() {
|
|||||||
if (shdr.sh_type == SHT_NOBITS)
|
if (shdr.sh_type == SHT_NOBITS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int num_members = members.size();
|
tbb::parallel_for(0, (int)members.size(), [&](int i) {
|
||||||
|
InputSection &isec = *members[i];
|
||||||
|
if (isec.shdr.sh_type == SHT_NOBITS)
|
||||||
|
return;
|
||||||
|
|
||||||
tbb::parallel_for(0, num_members, [&](int i) {
|
|
||||||
if (members[i]->shdr.sh_type != SHT_NOBITS) {
|
|
||||||
// Copy section contents to an output file
|
// Copy section contents to an output file
|
||||||
members[i]->copy_buf();
|
isec.copy_buf();
|
||||||
|
|
||||||
// Zero-clear trailing padding
|
// Zero-clear trailing padding
|
||||||
u64 this_end = members[i]->offset + members[i]->shdr.sh_size;
|
u64 this_end = isec.offset + isec.shdr.sh_size;
|
||||||
u64 next_start = (i == num_members - 1) ? shdr.sh_size : members[i + 1]->offset;
|
u64 next_start = (i == members.size() - 1) ?
|
||||||
|
shdr.sh_size : members[i + 1]->offset;
|
||||||
memset(out::buf + shdr.sh_offset + this_end, 0, next_start - this_end);
|
memset(out::buf + shdr.sh_offset + this_end, 0, next_start - this_end);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user