From aba7818b004164b42d74317207f218a7e7a716b2 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 17 May 2023 09:59:48 +0300 Subject: [PATCH] Fixed disassembler output --- ir_disasm.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ir_disasm.c b/ir_disasm.c index 56c45d2..0638db9 100644 --- a/ir_disasm.c +++ b/ir_disasm.c @@ -302,6 +302,7 @@ static const char* ir_disasm_resolver(uint64_t addr, if (dladdr(a, &info) && info.dli_sname != NULL && info.dli_saddr == a) { + *offset = 0; return info.dli_sname; } #else @@ -576,15 +577,24 @@ int ir_disasm(const char *name, fwrite(p, 1, r - p, f); } } else if ((sym = ir_disasm_resolver(addr, &offset))) { +#if defined(IR_TARGET_X86) || defined(IR_TARGET_X64) + if (offset && *(q-1) == '$') { + if (r > p) { + fwrite(p, 1, r - p, f); + } + p = r; + continue; + } +#endif if (q > p) { fwrite(p, 1, q - p, f); } fputs(sym, f); if (offset != 0) { if (offset > 0) { - fprintf(f, "+%" PRIx64, offset); + fprintf(f, "+0x%" PRIx64, offset); } else { - fprintf(f, "-%" PRIx64, offset); + fprintf(f, "-0x%" PRIx64, -offset); } } } else if (r > p) {