1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-22 02:20:51 +03:00
This commit is contained in:
Rui Ueyama 2021-02-27 01:08:38 +09:00
parent 9be4f63b90
commit b98b792c50
3 changed files with 19 additions and 4 deletions

View File

@ -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<void()> 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<void()> 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;

View File

@ -675,8 +675,8 @@ static void fix_synthetic_symbols(std::span<OutputChunk *> 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);
}
}
}

4
mold.h
View File

@ -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;