view: show syscall numbers even when the function has a name

This commit is contained in:
Lephenixnoir 2024-01-15 18:56:46 +01:00
parent 593d486185
commit 10e7334524
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
2 changed files with 24 additions and 15 deletions

View File

@ -73,10 +73,12 @@ struct ViewAssemblyOptions
Promotion PCAddr_to_Location = Promote;
/* In a read with a know location, promote address to pointed value */
Promotion ReadLocation_to_Constant = Promote;
/* Promote an integer to a binary object's name */
Promotion Constant_to_ObjectName = Promote;
/* Promote an integer to a syscall number (if no name is available) */
/* Promote an integer to a syscall number */
Promotion Constant_to_SyscallNumber = Promote;
/* Promote an integer (not a syscall) to a binary object's name */
Promotion Constant_to_ObjectName = Promote;
/* Promote a syscall number to a binary object's name */
Promotion SyscallNumber_to_ObjectName = Append;
} promotions;
/* Binary to get symbols from */

View File

@ -96,18 +96,6 @@ static void renderOperand(AsmOperand const &op, u32 pc, int opsize,
type = Constant;
}
/* Promote to object name first if available... */
if(type == Constant && hasValue && opts.binary) {
auto p = opts.promotions.Constant_to_ObjectName;
BinaryObject *obj = opts.binary->objectAt(value);
if(obj) {
if(output(out, p, {}, obj->name()))
return;
type = ObjectName;
}
}
/* ... or, as a default, a syscall number */
if(type == Constant && hasValue && os) {
int syscall_id = os->find_syscall(value);
if(syscall_id >= 0) {
@ -117,6 +105,25 @@ static void renderOperand(AsmOperand const &op, u32 pc, int opsize,
type = SyscallNumber;
}
}
if(type == Constant && hasValue && opts.binary) {
auto p = opts.promotions.Constant_to_ObjectName;
BinaryObject *obj = opts.binary->objectAt(value);
if(obj) {
if(output(out, p, {}, obj->name()))
return;
type = ObjectName;
}
}
if(type == SyscallNumber && hasValue && opts.binary) {
auto p = opts.promotions.SyscallNumber_to_ObjectName;
BinaryObject *obj = opts.binary->objectAt(value);
if(obj) {
if(output(out, p, {}, obj->name()))
return;
type = ObjectName;
}
}
}
//=== Legacy-style instruction printer ===//