From 6a643bdaaa75c63b4687ea40655dcdb2a8341a35 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 17 Dec 2020 21:36:38 +0900 Subject: [PATCH] temporary --- main.cc | 11 +++++------ mold.h | 1 - output_chunks.cc | 9 +-------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/main.cc b/main.cc index a1bb5188..aaf38085 100644 --- a/main.cc +++ b/main.cc @@ -797,7 +797,8 @@ int main(int argc, char **argv) { parse_version_script(std::string(arg)); } else if (read_flag(args, "pie")) { config.pie = true; - config.image_base = 0; + } else if (read_flag(args, "no-pie")) { + config.pie = false; } else if (read_flag(args, "perf")) { config.perf = true; } else if (read_arg(args, arg, "l")) { @@ -822,6 +823,9 @@ int main(int argc, char **argv) { if (config.output == "") error("-o option is missing"); + if (config.pie) + config.image_base = 0; + tbb::global_control tbb_cont(tbb::global_control::max_allowed_parallelism, config.thread_count); @@ -1058,11 +1062,6 @@ int main(int argc, char **argv) { }); } -#if 0 - if (out::reldyn) - out::reldyn->sort(); -#endif - // Zero-clear paddings between sections clear_padding(filesize); diff --git a/mold.h b/mold.h index 4a468cd9..9f030428 100644 --- a/mold.h +++ b/mold.h @@ -442,7 +442,6 @@ public: void update_shdr() override; void copy_buf() override; - void sort(); }; class StrtabSection : public OutputChunk { diff --git a/output_chunks.cc b/output_chunks.cc index 6855350f..46f0c050 100644 --- a/output_chunks.cc +++ b/output_chunks.cc @@ -175,6 +175,7 @@ void RelDynSection::copy_buf() { if (sym->is_imported) { write(sym, R_X86_64_GLOB_DAT, sym->get_got_addr()); } else if (sym->needs_relative_rel()) { + memset(rel, 0, sizeof(ElfRela)); rel->r_type = R_X86_64_RELATIVE; rel->r_offset = sym->get_got_addr(); rel->r_addend = sym->get_addr(); @@ -198,14 +199,6 @@ void RelDynSection::copy_buf() { write(sym, R_X86_64_COPY, sym->get_addr()); } -void RelDynSection::sort() { - ElfRela *begin = (ElfRela *)(out::buf + shdr.sh_offset); - ElfRela *end = begin + shdr.sh_size / sizeof(ElfRela); - std::stable_sort(begin, end, [](const ElfRela &a, const ElfRela &b) { - return a.r_type == R_X86_64_RELATIVE && b.r_type != R_X86_64_RELATIVE; - }); -} - void StrtabSection::update_shdr() { shdr.sh_size = 1; for (ObjectFile *file : out::objs) {