diff --git a/include/fxos/view/assembly.h b/include/fxos/view/assembly.h index 63fd465..f9081d0 100644 --- a/include/fxos/view/assembly.h +++ b/include/fxos/view/assembly.h @@ -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 */ diff --git a/lib/view/assembly.cpp b/lib/view/assembly.cpp index 2fbefb5..40453be 100644 --- a/lib/view/assembly.cpp +++ b/lib/view/assembly.cpp @@ -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 ===//