mirror of
https://github.com/rui314/mold.git
synced 2024-09-22 02:20:51 +03:00
temporary
This commit is contained in:
parent
2ea3e32fa4
commit
1e0a23468d
@ -79,7 +79,7 @@ void InputSection::copy_buf() {
|
||||
else
|
||||
*(u64 *)loc = S + A;
|
||||
|
||||
if (config.pie) {
|
||||
if (sym.needs_relative_rel()) {
|
||||
assert(sz == 8);
|
||||
memset(dynrel, 0, sizeof(*dynrel));
|
||||
dynrel->r_offset = P;
|
||||
@ -88,12 +88,6 @@ void InputSection::copy_buf() {
|
||||
dynrel++;
|
||||
}
|
||||
break;
|
||||
case R_ZERO:
|
||||
if (sz == 4)
|
||||
*(u32 *)loc = 0;
|
||||
else
|
||||
*(u64 *)loc = 0;
|
||||
break;
|
||||
case R_DYN:
|
||||
memset(dynrel, 0, sizeof(*dynrel));
|
||||
dynrel->r_offset = P;
|
||||
@ -218,11 +212,9 @@ void InputSection::scan_relocations() {
|
||||
rel_types[i] = R_DYN;
|
||||
sym.flags |= NEEDS_DYNSYM;
|
||||
file->num_reldyn++;
|
||||
} else if (sym.is_undef_weak) {
|
||||
rel_types[i] = R_ZERO;
|
||||
} else {
|
||||
rel_types[i] = R_ABS;
|
||||
if (config.pie)
|
||||
if (sym.needs_relative_rel())
|
||||
file->num_reldyn++;
|
||||
}
|
||||
break;
|
||||
|
5
mold.h
5
mold.h
@ -178,6 +178,10 @@ public:
|
||||
inline u64 get_tlsld_addr() const;
|
||||
inline u64 get_plt_addr() const;
|
||||
|
||||
bool needs_relative_rel() const {
|
||||
return config.pie && !is_undef_weak;
|
||||
}
|
||||
|
||||
std::string_view name;
|
||||
InputFile *file = nullptr;
|
||||
const ElfSym *esym = nullptr;
|
||||
@ -233,7 +237,6 @@ protected:
|
||||
enum RelType : u8 {
|
||||
R_NONE,
|
||||
R_ABS,
|
||||
R_ZERO,
|
||||
R_DYN,
|
||||
R_PC,
|
||||
R_GOT,
|
||||
|
@ -143,13 +143,9 @@ void RelDynSection::update_shdr() {
|
||||
|
||||
int n = 0;
|
||||
|
||||
if (config.pie) {
|
||||
n = out::got->got_syms.size();
|
||||
} else {
|
||||
for (Symbol *sym : out::got->got_syms)
|
||||
if (sym->is_imported)
|
||||
n++;
|
||||
}
|
||||
for (Symbol *sym : out::got->got_syms)
|
||||
if (sym->is_imported || sym->needs_relative_rel())
|
||||
n++;
|
||||
|
||||
n += out::got->tlsgd_syms.size() * 2;
|
||||
n += out::got->tlsld_syms.size();
|
||||
@ -178,7 +174,7 @@ void RelDynSection::copy_buf() {
|
||||
for (Symbol *sym : out::got->got_syms) {
|
||||
if (sym->is_imported) {
|
||||
write(sym, R_X86_64_GLOB_DAT, sym->get_got_addr());
|
||||
} else if (config.pie) {
|
||||
} else if (sym->needs_relative_rel()) {
|
||||
rel->r_type = R_X86_64_RELATIVE;
|
||||
rel->r_offset = sym->get_got_addr();
|
||||
rel->r_addend = sym->get_addr();
|
||||
|
Loading…
Reference in New Issue
Block a user