Skip to content

Commit 3842469

Browse files
committed
ARM64: init AES pointers in a safe way
1 parent 6dca84f commit 3842469

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/jit_compiler_a64.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,11 @@ void JitCompilerA64::generateProgram(Program& program, ProgramConfiguration& con
185185

186186
offset = (uint8_t*)randomx_program_aarch64_aes_lut_pointers - (uint8_t*)randomx_program_aarch64;
187187

188-
*(uint64_t*)(code + offset + 0) = (uint64_t) &randomx_aes_lut_enc[0][0];
189-
*(uint64_t*)(code + offset + 8) = (uint64_t) &randomx_aes_lut_dec[0][0];
188+
const void* lut_enc = &randomx_aes_lut_enc[0][0];
189+
const void* lut_dec = &randomx_aes_lut_dec[0][0];
190+
191+
memcpy(code + offset + 0, &lut_enc, sizeof(lut_enc));
192+
memcpy(code + offset + 8, &lut_dec, sizeof(lut_dec));
190193
}
191194
}
192195
else {
@@ -281,8 +284,11 @@ void JitCompilerA64::generateProgramLight(Program& program, ProgramConfiguration
281284

282285
offset = (uint8_t*)randomx_program_aarch64_aes_lut_pointers - (uint8_t*)randomx_program_aarch64;
283286

284-
*(uint64_t*)(code + offset + 0) = (uint64_t) &randomx_aes_lut_enc[0][0];
285-
*(uint64_t*)(code + offset + 8) = (uint64_t) &randomx_aes_lut_dec[0][0];
287+
const void* lut_enc = &randomx_aes_lut_enc[0][0];
288+
const void* lut_dec = &randomx_aes_lut_dec[0][0];
289+
290+
memcpy(code + offset + 0, &lut_enc, sizeof(lut_enc));
291+
memcpy(code + offset + 8, &lut_dec, sizeof(lut_dec));
286292
}
287293
}
288294
else {

0 commit comments

Comments
 (0)