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) {