Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Aug 22, 2024
1 parent 7fa5616 commit 25794c6
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/arch-loongarch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -587,17 +587,18 @@ void InputSection<E>::apply_reloc_alloc(Context<E> &ctx, u8 *base) {
//
// Note that if section-shrinking relaxation is enabled, nop may be
// completely deleted.
if (removed_bytes == 0) {
if (sym.has_tlsdesc(ctx))
if (sym.has_tlsdesc(ctx)) {
if (removed_bytes == 0) {
write_j20(loc, hi20(sym.get_tlsdesc_addr(ctx) + A, P));
else
*(ul32 *)loc = 0x0340'0000; // nop
} else {
// Rewrite pcalau12i + addi.d with pcaddi
assert(removed_bytes == 4);
*(ul32 *)loc = 0x1800'0000 | get_rd(*(ul32 *)loc); // pcaddi
write_j20(loc, (sym.get_tlsdesc_addr(ctx) + A - P) >> 2);
i += 3;
} else {
// Rewrite pcalau12i + addi.d with pcaddi
assert(removed_bytes == 4);
*(ul32 *)loc = 0x1800'0000 | get_rd(*(ul32 *)loc); // pcaddi
write_j20(loc, (sym.get_tlsdesc_addr(ctx) + A - P) >> 2);
i += 3;
}
} else if (removed_bytes == 0) {
*(ul32 *)loc = 0x0340'0000; // nop
}
break;
case R_LARCH_TLS_DESC_PC_LO12:
Expand Down

0 comments on commit 25794c6

Please sign in to comment.