mirror of
https://github.com/rui314/mold.git
synced 2024-12-26 18:02:30 +03:00
Separate relocate() from copy_to()
This commit is contained in:
parent
80a4ecca34
commit
8986a6ad88
@ -21,7 +21,9 @@ void InputSection::copy_to(u8 *buf) {
|
||||
|
||||
ArrayRef<u8> data = check(file->obj.getSectionContents(shdr));
|
||||
memcpy(buf + output_section->shdr.sh_offset + offset, &data[0], data.size());
|
||||
}
|
||||
|
||||
void InputSection::relocate(u8 *buf) {
|
||||
for (int i = 0; i < rels.size(); i++) {
|
||||
const ELF64LE::Rela &rel = rels[i];
|
||||
StringPieceRef &ref = rel_pieces[i];
|
||||
|
5
main.cc
5
main.cc
@ -957,6 +957,11 @@ int main(int argc, char **argv) {
|
||||
for_each(output_chunks, [&](OutputChunk *chunk) { chunk->copy_to(buf); });
|
||||
}
|
||||
|
||||
{
|
||||
MyTimer t("relocate");
|
||||
for_each(output_chunks, [&](OutputChunk *chunk) { chunk->relocate(buf); });
|
||||
}
|
||||
|
||||
// Fill .plt, .got, got.plt and .rela.plt sections
|
||||
{
|
||||
MyTimer t("write_got");
|
||||
|
7
mold.h
7
mold.h
@ -230,6 +230,7 @@ public:
|
||||
InputSection(ObjectFile *file, const ELF64LE::Shdr &shdr, StringRef name);
|
||||
|
||||
void copy_to(u8 *buf);
|
||||
void relocate(u8 *buf);
|
||||
void scan_relocations();
|
||||
|
||||
ObjectFile *file;
|
||||
@ -263,6 +264,7 @@ public:
|
||||
OutputChunk() { shdr.sh_addralign = 1; }
|
||||
|
||||
virtual void copy_to(u8 *buf) {}
|
||||
virtual void relocate(u8 *buf) {}
|
||||
|
||||
StringRef name;
|
||||
int shndx = 0;
|
||||
@ -338,6 +340,11 @@ public:
|
||||
for_each(sections, [&](InputSection *isec) { isec->copy_to(buf); });
|
||||
}
|
||||
|
||||
void relocate(u8 *buf) override {
|
||||
if (shdr.sh_type != llvm::ELF::SHT_NOBITS)
|
||||
for_each(sections, [&](InputSection *isec) { isec->relocate(buf); });
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
if (!sections.empty())
|
||||
for (InputSection *isec : sections)
|
||||
|
Loading…
Reference in New Issue
Block a user