From da438af6ef5fed6f04276311d5398a6e4cfb5d33 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 26 Oct 2020 10:03:17 +0900 Subject: [PATCH] temporary --- main.cc | 4 ++-- mold.h | 2 +- output_chunks.cc | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/main.cc b/main.cc index 04cf28e2..d25dbb20 100644 --- a/main.cc +++ b/main.cc @@ -320,7 +320,7 @@ int main(int argc, char **argv) { int i = 0; while (i < output_chunks.size() && !output_chunks[i]->is_bss()) { int j = i + 1; - while (j < output_chunks.size() && !output_chunks[j]->starts_segment && + while (j < output_chunks.size() && !output_chunks[j]->starts_new_ptload && !output_chunks[j]->is_bss()) j++; @@ -366,7 +366,7 @@ int main(int argc, char **argv) { if (last->is_bss()) fileoff = last->shdr.sh_offset; else - fileoff = last->shdr.sh_offset + last->shdr.sh_size; + fileoff = last->shdr.sh_offset + last->get_filesz(); } for (OutputChunk *chunk : output_chunks) { diff --git a/mold.h b/mold.h index 9991b76f..95d24f20 100644 --- a/mold.h +++ b/mold.h @@ -234,7 +234,7 @@ public: virtual uint64_t get_filesz() const = 0; StringRef name; - bool starts_segment = false; + bool starts_new_ptload = false; ELF64LE::Shdr shdr = {}; }; diff --git a/output_chunks.cc b/output_chunks.cc index 3f295502..dfbb3fae 100644 --- a/output_chunks.cc +++ b/output_chunks.cc @@ -100,7 +100,8 @@ void OutputPhdr::construct(std::vector &chunks) { ent.phdr.p_align = std::max(ent.phdr.p_align, chunk->shdr.sh_addralign); for (Phdr &ent : entries) - ent.members.front()->starts_segment = true; + if (ent.phdr.p_type == PT_LOAD) + ent.members.front()->starts_new_ptload = true; } void OutputPhdr::copy_to(uint8_t *buf) {