From b98b792c502b5da6428076894682db36138e4854 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sat, 27 Feb 2021 01:08:38 +0900 Subject: [PATCH] wip --- input_sections.cc | 15 +++++++++++++-- main.cc | 4 ++-- mold.h | 4 ++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/input_sections.cc b/input_sections.cc index 9ba6dac6..5205d411 100644 --- a/input_sections.cc +++ b/input_sections.cc @@ -434,8 +434,7 @@ void InputSection::scan_relocations() { } case R_X86_64_PC8: case R_X86_64_PC16: - case R_X86_64_PC32: - case R_X86_64_PC64: { + case R_X86_64_PC32: { std::function table[][4] = { // Absolute Local Imported data Imported code { none, none, copyrel, plt }, // PDE @@ -447,6 +446,18 @@ void InputSection::scan_relocations() { table[output_type][get_sym_type(sym)](); break; } + case R_X86_64_PC64: { + std::function table[][4] = { + // Absolute Local Imported data Imported code + { none, none, copyrel, plt }, // PDE + { baserel, none, copyrel, plt }, // PIE + { baserel, none, error, error }, // DSO + }; + + rel_types[i] = R_PC; + table[output_type][get_sym_type(sym)](); + break; + } case R_X86_64_GOT32: sym.flags |= NEEDS_GOT; rel_types[i] = R_GOT; diff --git a/main.cc b/main.cc index 944c86d3..87724d5a 100644 --- a/main.cc +++ b/main.cc @@ -675,8 +675,8 @@ static void fix_synthetic_symbols(std::span chunks) { // __start_ and __stop_ symbols for (OutputChunk *chunk : chunks) { if (is_c_identifier(chunk->name)) { - start(Symbol::intern("__start_" + std::string(chunk->name)), chunk); - stop(Symbol::intern("__stop_" + std::string(chunk->name)), chunk); + start(Symbol::intern_alloc("__start_" + std::string(chunk->name)), chunk); + stop(Symbol::intern_alloc("__stop_" + std::string(chunk->name)), chunk); } } } diff --git a/mold.h b/mold.h index 98835c6e..5f2eb96a 100644 --- a/mold.h +++ b/mold.h @@ -253,6 +253,10 @@ public: return map.insert(name, {name}); } + static Symbol *intern_alloc(std::string name) { + return intern(*new std::string(name)); + } + inline u64 get_addr() const; inline u64 get_got_addr() const; inline u64 get_gotplt_addr() const;