@@ -313,7 +313,7 @@ bool RISCVLDBackend::doRelaxationCall(Relocation *reloc) {
313313 ->getInput ()
314314 ->decoratedPath ();
315315
316- region->replaceInstruction (offset, reloc, c_j, 2 );
316+ region->replaceInstruction (offset, reloc, reinterpret_cast < uint8_t *>(& c_j) , 2 );
317317 reloc->setTargetData (c_j);
318318 reloc->setType (llvm::ELF::R_RISCV_RVC_JUMP);
319319 relaxDeleteBytes (" RISCV_CALL_C" , *region, offset + 2 , 6 ,
@@ -326,7 +326,7 @@ bool RISCVLDBackend::doRelaxationCall(Relocation *reloc) {
326326 // Replace the instruction to JAL
327327 uint32_t jal = 0x6fu | rd << 7 ;
328328
329- region->replaceInstruction (offset, reloc, jal, 4 /* Replace bytes */ );
329+ region->replaceInstruction (offset, reloc, reinterpret_cast < uint8_t *>(& jal) , 4 );
330330 reloc->setTargetData (jal);
331331 reloc->setType (llvm::ELF::R_RISCV_JAL);
332332 // Delete the next instruction
@@ -345,7 +345,7 @@ bool RISCVLDBackend::doRelaxationCall(Relocation *reloc) {
345345 const char *msg =
346346 (rd == 1 ) ? " R_RISCV_CALL_QC_E_JAL" : " R_RISCV_CALL_QC_E_J" ;
347347
348- region->replaceInstruction (offset, reloc, qc_e_j, 6 );
348+ region->replaceInstruction (offset, reloc, reinterpret_cast < uint8_t *>(& qc_e_j) , 6 );
349349 reloc->setTargetData (qc_e_j);
350350 reloc->setType (ELF::riscv::internal::R_RISCV_QC_E_CALL_PLT);
351351 relaxDeleteBytes (msg, *region, offset + 6 , 2 , reloc->symInfo ()->name ());
@@ -406,7 +406,7 @@ bool RISCVLDBackend::doRelaxationQCCall(Relocation *reloc) {
406406 ->getInput ()
407407 ->decoratedPath ();
408408
409- region->replaceInstruction (offset, reloc, compressed, 2 );
409+ region->replaceInstruction (offset, reloc, reinterpret_cast < uint8_t *>(& compressed) , 2 );
410410 // Replace the reloc to R_RISCV_RVC_JUMP
411411 reloc->setType (llvm::ELF::R_RISCV_RVC_JUMP);
412412 reloc->setTargetData (compressed);
@@ -418,7 +418,7 @@ bool RISCVLDBackend::doRelaxationQCCall(Relocation *reloc) {
418418 // Replace the instruction to JAL
419419 unsigned rd = isTailCall ? /* x0*/ 0 : /* ra*/ 1 ;
420420 uint32_t jal_instr = 0x6fu | rd << 7 ;
421- region->replaceInstruction (offset, reloc, jal_instr, 4 );
421+ region->replaceInstruction (offset, reloc, reinterpret_cast < uint8_t *>(& jal_instr) , 4 );
422422 // Replace the reloc to R_RISCV_JAL
423423 reloc->setType (llvm::ELF::R_RISCV_JAL);
424424 reloc->setTargetData (jal_instr);
@@ -622,7 +622,7 @@ bool RISCVLDBackend::doRelaxationQCELi(Relocation *reloc, Relocator::DWord G) {
622622 if (canRelaxQcLi) {
623623 uint32_t qc_li = 0x0000001bu | rd << 7 ;
624624
625- region->replaceInstruction (offset, reloc, qc_li, 4 );
625+ region->replaceInstruction (offset, reloc, reinterpret_cast < uint8_t *>(& qc_li) , 4 );
626626 reloc->setTargetData (qc_li);
627627 reloc->setType (ELF::riscv::internal::R_RISCV_QC_ABS20_U);
628628 relaxDeleteBytes (msg, *region, offset + 4 , 2 , reloc->symInfo ()->name ());
@@ -634,7 +634,7 @@ bool RISCVLDBackend::doRelaxationQCELi(Relocation *reloc, Relocator::DWord G) {
634634 unsigned rs = 3 ; // x3 = gp
635635 uint32_t addi = 0x00000013u | (rd << 7 ) | (rs << 15 );
636636
637- region->replaceInstruction (offset, reloc, addi, 4 );
637+ region->replaceInstruction (offset, reloc, reinterpret_cast < uint8_t *>(& addi) , 4 );
638638 reloc->setTargetData (addi);
639639 reloc->setType (ELF::riscv::internal::R_RISCV_GPREL_I);
640640 relaxDeleteBytes (msg, *region, offset + 4 , 2 , reloc->symInfo ()->name ());
@@ -669,7 +669,9 @@ bool RISCVLDBackend::doRelaxationTLSDESC(Relocation &R, bool Relax) {
669669 else {
670670 // Otherwise, the instruction is replaced with a NOP.
671671 reportMissedRelaxation (RelaxType, *region, offset, 4 , Sym.name ());
672- region->replaceInstruction (offset, &R, NOP, 4 );
672+ uint32_t NOPi32 = static_cast <uint32_t >(NOP);
673+ region->replaceInstruction (
674+ offset, &R, reinterpret_cast <uint8_t *>(&NOPi32), 4 );
673675 }
674676 R.setType (llvm::ELF::R_RISCV_NONE);
675677 return Relaxed;
0 commit comments