/*
- * Copyright (C) 2012-2019 Free Software Foundation, Inc.
+ * Copyright (C) 2012-2023 Free Software Foundation, Inc.
*
* This file is part of GNU lightning.
*
static FILE *disasm_stream;
#endif
+#if BINUTILS_2_38
+static int fprintf_styled(void * stream, enum disassembler_style style, const char* fmt, ...)
+{
+ va_list args;
+ int r;
+
+ va_start(args, fmt);
+ r = vfprintf(disasm_stream, fmt, args);
+ va_end(args);
+
+ return r;
+}
+#endif
+
/*
* Implementation
*/
if (!disasm_stream)
disasm_stream = stdout;
+#if BINUTILS_2_38
+ INIT_DISASSEMBLE_INFO(disasm_info, disasm_stream, fprintf, fprintf_styled);
+#else
INIT_DISASSEMBLE_INFO(disasm_info, disasm_stream, fprintf);
+#endif
disasm_info.arch = bfd_get_arch(disasm_bfd);
disasm_info.mach = bfd_get_mach(disasm_bfd);
int line;
char buffer[address_buffer_length];
- sprintf(buffer, address_buffer_format, (long long)addr);
+ sprintf(buffer, address_buffer_format, addr);
(*info->fprintf_func)(info->stream, "0x%s", buffer);
# define _jit disasm_jit
char *name, *old_name;
char *file, *old_file;
int line, old_line;
-#if __arm__
+#if __riscv && __WORDSIZE == 64
+ jit_word_t *vector;
+ jit_int32_t offset;
+#elif __arm__
jit_int32_t offset;
jit_bool_t data_info;
jit_int32_t data_offset;
jit_uword_t prevw;
#endif
+#if __riscv && __WORDSIZE == 64
+ end -= _jitc->consts.hash.count * 8;
+#endif
+
#if __arm__
data_info = _jitc && _jitc->data_info.ptr;
data_offset = 0;
}
while (node && (jit_uword_t)(prevw + node->offset) == (jit_uword_t)pc) {
jit_print_node(node);
- fputc('\n', stdout);
+ fputc('\n', disasm_stream);
prevw += node->offset;
node = node->next;
}
old_line = line;
}
- bytes = sprintf(buffer, address_buffer_format, (long long)pc);
+ bytes = sprintf(buffer, address_buffer_format, pc);
(*disasm_info.fprintf_func)(disasm_stream, "%*c0x%s\t",
16 - bytes, ' ', buffer);
pc += (*disasm_print)(pc, &disasm_info);
putc('\n', disasm_stream);
}
+#if __riscv && __WORDSIZE == 64
+ for (vector = (jit_word_t *)end, offset = 0;
+ offset < _jitc->consts.hash.count; offset++) {
+ bytes = sprintf(buffer, address_buffer_format,
+ (long long)end + offset * sizeof(jit_word_t));
+ (*disasm_info.fprintf_func)(disasm_stream,
+ "%*c0x%s\t.quad\t0x%016lx\t# (%ld)\n",
+ 16 - bytes, ' ', buffer,
+ vector[offset], vector[offset]);
+ }
+#endif
}
#endif