Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Sep 27, 2023
1 parent ac3ee91 commit b8bcb8a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions elf/arch-x86-64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ void InputSection<E>::apply_reloc_alloc(Context<E> &ctx, u8 *base) {
u64 A = rel.r_addend;
u64 P = get_addr() + rel.r_offset;
u64 G = sym.get_got_addr(ctx) - ctx.gotplt->shdr.sh_addr;
u64 GOTPLT = ctx.gotplt->shdr.sh_addr;
u64 GOT = ctx.gotplt->shdr.sh_addr;

switch (rel.r_type) {
case R_X86_64_8:
Expand Down Expand Up @@ -388,19 +388,19 @@ void InputSection<E>::apply_reloc_alloc(Context<E> &ctx, u8 *base) {
break;
case R_X86_64_GOTOFF64:
case R_X86_64_PLTOFF64:
*(ul64 *)loc = S + A - GOTPLT;
*(ul64 *)loc = S + A - GOT;
break;
case R_X86_64_GOTPC32:
write32s(GOTPLT + A - P);
write32s(GOT + A - P);
break;
case R_X86_64_GOTPC64:
*(ul64 *)loc = GOTPLT + A - P;
*(ul64 *)loc = GOT + A - P;
break;
case R_X86_64_GOTPCREL:
write32s(G + GOTPLT + A - P);
write32s(G + GOT + A - P);
break;
case R_X86_64_GOTPCREL64:
*(ul64 *)loc = G + GOTPLT + A - P;
*(ul64 *)loc = G + GOT + A - P;
break;
case R_X86_64_GOTPCRELX:
// We always want to relax GOTPCRELX relocs even if --no-relax
Expand All @@ -416,7 +416,7 @@ void InputSection<E>::apply_reloc_alloc(Context<E> &ctx, u8 *base) {
break;
}
}
write32s(G + GOTPLT + A - P);
write32s(G + GOT + A - P);
break;
case R_X86_64_REX_GOTPCRELX:
if (sym.is_pcrel_linktime_const(ctx)) {
Expand All @@ -430,7 +430,7 @@ void InputSection<E>::apply_reloc_alloc(Context<E> &ctx, u8 *base) {
break;
}
}
write32s(G + GOTPLT + A - P);
write32s(G + GOT + A - P);
break;
case R_X86_64_TLSGD:
if (sym.has_tlsgd(ctx))
Expand Down

0 comments on commit b8bcb8a

Please sign in to comment.