From c1f9d8adb198fb74e589ea6e00e07d2a3187d404 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Sun, 22 Nov 2020 17:25:46 +0900 Subject: [PATCH] libs/libc/machine/risc-v/rv64/arch_elf.c: Fix syslog formats --- libs/libc/machine/risc-v/rv64/arch_elf.c | 38 +++++++++++++----------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/libs/libc/machine/risc-v/rv64/arch_elf.c b/libs/libc/machine/risc-v/rv64/arch_elf.c index d27ac92439..acc02435d2 100644 --- a/libs/libc/machine/risc-v/rv64/arch_elf.c +++ b/libs/libc/machine/risc-v/rv64/arch_elf.c @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -222,7 +223,7 @@ bool up_checkarch(FAR const Elf64_Ehdr *ehdr) if ((ehdr->e_entry & 1) != 0) { - berr("ERROR: Entry point is not properly aligned: %08x\n", + berr("ERROR: Entry point is not properly aligned: %08" PRIx64 "\n", ehdr->e_entry); } @@ -274,9 +275,9 @@ int up_relocateadd(FAR const Elf64_Rela *rel, FAR const Elf64_Sym *sym, { /* NOTE: RELAX has no symbol, so just return */ - binfo("%s at %08lx [%08x] \n", + binfo("%s at %08" PRIxPTR " [%08" PRIx32 "] \n", _get_rname(relotype), - (long)addr, _get_val((uint16_t *)addr)); + addr, _get_val((uint16_t *)addr)); return OK; } @@ -292,10 +293,11 @@ int up_relocateadd(FAR const Elf64_Rela *rel, FAR const Elf64_Sym *sym, { case R_RISCV_64: { - binfo("%s at %08lx [%08x] to sym=%p st_value=%08lx\n", + binfo("%s at %08" PRIxPTR " [%08" PRIx32 "] " + "to sym=%p st_value=%08" PRIx64 "\n", _get_rname(relotype), - (long)addr, _get_val((uint16_t *)addr), - sym, (long)sym->st_value); + addr, _get_val((uint16_t *)addr), + sym, sym->st_value); _set_val((uint16_t *)addr, (uint32_t)(sym->st_value + rel->r_addend)); @@ -305,10 +307,11 @@ int up_relocateadd(FAR const Elf64_Rela *rel, FAR const Elf64_Sym *sym, case R_RISCV_PCREL_LO12_I: case R_RISCV_PCREL_LO12_S: { - binfo("%s at %08lx [%08x] to sym=%p st_value=%08lx\n", + binfo("%s at %08" PRIxPTR " [%08" PRIx32 "] " + "to sym=%p st_value=%08" PRIx64 "\n", _get_rname(relotype), - (long)addr, _get_val((uint16_t *)addr), - sym, (long)sym->st_value); + addr, _get_val((uint16_t *)addr), + sym, sym->st_value); /* NOTE: imm value for mv has been adjusted in previous HI20 */ } @@ -317,10 +320,11 @@ int up_relocateadd(FAR const Elf64_Rela *rel, FAR const Elf64_Sym *sym, case R_RISCV_PCREL_HI20: case R_RISCV_CALL: { - binfo("%s at %08lx [%08x] to sym=%p st_value=%08lx\n", + binfo("%s at %08" PRIxPTR " [%08" PRIx32 "] " + "to sym=%p st_value=%08" PRIx64 "\n", _get_rname(relotype), - (long)addr, _get_val((uint16_t *)addr), - sym, (long)sym->st_value); + addr, _get_val((uint16_t *)addr), + sym, sym->st_value); offset = (long)sym->st_value - (long)addr; @@ -341,7 +345,7 @@ int up_relocateadd(FAR const Elf64_Rela *rel, FAR const Elf64_Sym *sym, (((int32_t)imm_lo >> 5) << 25) + (((int32_t)imm_lo & 0x1f) << 7); - binfo("imm_lo=%d (%x), val=%x \n", imm_lo, imm_lo, val); + binfo("imm_lo=%ld (%lx), val=%x \n", imm_lo, imm_lo, val); _add_val((uint16_t *)(addr + 4), val); } @@ -370,7 +374,7 @@ int up_relocateadd(FAR const Elf64_Rela *rel, FAR const Elf64_Sym *sym, ASSERT(offset && val); - binfo("offset for Bx=%ld (0x%x) (val=0x%08x) already set! \n", + binfo("offset for Bx=%ld (0x%lx) (val=0x%08x) already set! \n", offset, offset, val); } break; @@ -393,7 +397,7 @@ int up_relocateadd(FAR const Elf64_Rela *rel, FAR const Elf64_Sym *sym, ASSERT(offset && val); - binfo("offset for C.J=%ld (0x%x) (val=0x%04x) already set! \n", + binfo("offset for C.J=%ld (0x%lx) (val=0x%04x) already set! \n", offset, offset, val); } break; @@ -416,13 +420,13 @@ int up_relocateadd(FAR const Elf64_Rela *rel, FAR const Elf64_Sym *sym, ASSERT(offset && val); - binfo("offset for C.Bx=%ld (0x%x) (val=0x%04x) already set!\n", + binfo("offset for C.Bx=%ld (0x%lx) (val=0x%04x) already set!\n", offset, offset, val); } break; default: - berr("ERROR: Unsupported relocation: %d\n", + berr("ERROR: Unsupported relocation: %" PRId64 "\n", ELF64_R_TYPE(rel->r_info)); ASSERT(false); return -EINVAL;