X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=tools%2Fprelink-riscv.inc;h=f2b5467f5b3c19be285153d3ad7cdb210a24a94c;hb=358b6f72c28c80699536f7137063095116e1675e;hp=8b40ec430a6a95a1ca40a6d8eb4d2ac0a1629254;hpb=8c650a9fed1395e50b011910084f25447ec661a5;p=oweals%2Fu-boot.git diff --git a/tools/prelink-riscv.inc b/tools/prelink-riscv.inc index 8b40ec430a..f2b5467f5b 100644 --- a/tools/prelink-riscv.inc +++ b/tools/prelink-riscv.inc @@ -27,6 +27,8 @@ #define target32_to_cpu CONCAT(PRELINK_BYTEORDER, 32_to_cpu) #define target64_to_cpu CONCAT(PRELINK_BYTEORDER, 64_to_cpu) #define targetnn_to_cpu CONCAT3(PRELINK_BYTEORDER, PRELINK_INC_BITS, _to_cpu) +#define cpu_to_target32 CONCAT3(cpu_to_, PRELINK_BYTEORDER, 32) +#define cpu_to_target64 CONCAT3(cpu_to_, PRELINK_BYTEORDER, 64) static void* get_offset_bonn (void* data, Elf_Phdr* phdrs, size_t phnum, Elf_Addr addr) { @@ -92,9 +94,9 @@ static void prelink_bonn(void *data) if (ELF_R_TYPE(targetnn_to_cpu(r->r_info)) == R_RISCV_RELATIVE) *((uintnn_t*) buf) = r->r_addend; else if (ELF_R_TYPE(targetnn_to_cpu(r->r_info)) == R_RISCV_32) - *((uint32_t*) buf) = dynsym[ELF_R_SYM(targetnn_to_cpu(r->r_info))].st_value; + *((uint32_t*) buf) = cpu_to_target32(targetnn_to_cpu(dynsym[ELF_R_SYM(targetnn_to_cpu(r->r_info))].st_value) + targetnn_to_cpu(r->r_addend)); else if (ELF_R_TYPE(targetnn_to_cpu(r->r_info)) == R_RISCV_64) - *((uint64_t*) buf) = dynsym[ELF_R_SYM(targetnn_to_cpu(r->r_info))].st_value; + *((uint64_t*) buf) = cpu_to_target64(targetnn_to_cpu(dynsym[ELF_R_SYM(targetnn_to_cpu(r->r_info))].st_value) + targetnn_to_cpu(r->r_addend)); } } @@ -113,6 +115,8 @@ static void prelink_bonn(void *data) #undef target32_to_cpu #undef target64_to_cpu #undef targetnn_to_cpu +#undef cpu_to_target32 +#undef cpu_to_target64 #undef CONCAT_IMPL #undef CONCAT