Skip to content

Commit 775e091

Browse files
committed
[SPARC64] Turn the delay slot of R_SPARC_TLS_LDM_CALL to nop if it sets %o0
GCC might put the argument-setting instruction to R_SPARC_TLS_LDM_CALL in its delay slot as an unmarked regular instruction. If we're optimizing the call into a nop then we need to detect and turn the delay slot into nop too as needed.
1 parent 5fb6d8a commit 775e091

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/arch-sparc64.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,13 @@ void InputSection<E>::apply_reloc_alloc(Context<E> &ctx, u8 *base) {
429429
*(ub32 *)loc |= bits(addr + A - P, 31, 2);
430430
} else {
431431
*(ub32 *)loc = 0x0100'0000; // nop
432+
433+
// If the argument to __tls_get_addr is set in the delay slot of the call,
434+
// turn the delay slot instruction into a nop too.
435+
u32 ds_rd = bits(*(ub32 *)(loc + 4), 29, 25);
436+
if (ds_rd == 8) { // rd is %o0
437+
*(ub32 *)(loc + 4) = 0x0100'0000; // nop
438+
}
432439
}
433440
break;
434441
case R_SPARC_TLS_LDO_HIX22:

0 commit comments

Comments
 (0)