Skip to content

Commit 0b5bf03

Browse files
[ppc64le] Fixed thunk address 8 byte alignment issue (#75259)
1 parent 3776c9f commit 0b5bf03

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/mono/mono/mini/mini-ppc.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,6 +2732,9 @@ handle_thunk (MonoCompile *cfg, guchar *code, const guchar *target)
27322732
if (!cfg->arch.thunks) {
27332733
cfg->arch.thunks = cfg->thunks;
27342734
cfg->arch.thunks_size = cfg->thunk_area;
2735+
#ifdef THUNK_ADDR_ALIGNMENT
2736+
cfg->arch.thunks = ALIGN_TO(cfg->arch.thunks, THUNK_ADDR_ALIGNMENT);
2737+
#endif
27352738
}
27362739
thunks = cfg->arch.thunks;
27372740
thunks_size = cfg->arch.thunks_size;
@@ -3907,11 +3910,11 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
39073910
if (cfg->compile_aot && ins->sreg1 == ppc_r12) {
39083911
/* The trampolines clobber this */
39093912
ppc_mr (code, ppc_r29, ins->sreg1);
3910-
ppc_ldptr (code, ppc_r0, ins->inst_offset, ppc_r29);
3913+
ppc_ldptr (code, ppc_r12, ins->inst_offset, ppc_r29);
39113914
} else {
3912-
ppc_ldptr (code, ppc_r0, ins->inst_offset, ins->sreg1);
3915+
ppc_ldptr (code, ppc_r12, ins->inst_offset, ins->sreg1);
39133916
}
3914-
ppc_mtlr (code, ppc_r0);
3917+
ppc_mtlr (code, ppc_r12);
39153918
ppc_blrl (code);
39163919
/* FIXME: this should be handled somewhere else in the new jit */
39173920
code = emit_move_return_value (cfg, ins, code);
@@ -5556,6 +5559,14 @@ mono_arch_emit_exceptions (MonoCompile *cfg)
55565559
}
55575560

55585561
set_code_cursor (cfg, code);
5562+
5563+
#ifdef THUNK_ADDR_ALIGNMENT
5564+
/* We need to align thunks_offset to 8 byte boundary, hence allocating first 8 bytes
5565+
for padding purpose */
5566+
if (cfg->thunk_area != 0) {
5567+
cfg->thunk_area += THUNK_ADDR_ALIGNMENT;
5568+
}
5569+
#endif
55595570
}
55605571
#endif
55615572

src/mono/mono/mini/mini-ppc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#ifdef TARGET_POWERPC64
3636
#if !defined(PPC_USES_FUNCTION_DESCRIPTOR)
3737
#define THUNK_SIZE 8
38+
#define THUNK_ADDR_ALIGNMENT 8
3839
#define GET_MEMORY_SLOT_THUNK_ADDRESS(c) \
3940
((guint64)(((c)) [0] & 0x0000ffff) << 48) \
4041
+ ((guint64)(((c)) [1] & 0x0000ffff) << 32) \

0 commit comments

Comments
 (0)