Fixed disassembler output

This commit is contained in:
Dmitry Stogov 2023-05-17 09:59:48 +03:00
parent 2a60d1416d
commit aba7818b00

View File

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