mirror of
https://github.com/danog/ir.git
synced 2024-11-30 04:39:43 +01:00
Fixed disassembler output
This commit is contained in:
parent
2a60d1416d
commit
aba7818b00
14
ir_disasm.c
14
ir_disasm.c
@ -302,6 +302,7 @@ static const char* ir_disasm_resolver(uint64_t addr,
|
|||||||
if (dladdr(a, &info)
|
if (dladdr(a, &info)
|
||||||
&& info.dli_sname != NULL
|
&& info.dli_sname != NULL
|
||||||
&& info.dli_saddr == a) {
|
&& info.dli_saddr == a) {
|
||||||
|
*offset = 0;
|
||||||
return info.dli_sname;
|
return info.dli_sname;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -576,15 +577,24 @@ int ir_disasm(const char *name,
|
|||||||
fwrite(p, 1, r - p, f);
|
fwrite(p, 1, r - p, f);
|
||||||
}
|
}
|
||||||
} else if ((sym = ir_disasm_resolver(addr, &offset))) {
|
} 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) {
|
if (q > p) {
|
||||||
fwrite(p, 1, q - p, f);
|
fwrite(p, 1, q - p, f);
|
||||||
}
|
}
|
||||||
fputs(sym, f);
|
fputs(sym, f);
|
||||||
if (offset != 0) {
|
if (offset != 0) {
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
fprintf(f, "+%" PRIx64, offset);
|
fprintf(f, "+0x%" PRIx64, offset);
|
||||||
} else {
|
} else {
|
||||||
fprintf(f, "-%" PRIx64, offset);
|
fprintf(f, "-0x%" PRIx64, -offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (r > p) {
|
} else if (r > p) {
|
||||||
|
Loading…
Reference in New Issue
Block a user