Closed ret2libc closed 2 years ago
[XX] db/cmd/types tpv
RZ_NOPLUGINS=1 rizin -escr.utf8=0 -escr.color=0 -escr.interactive=0 -N -Qc 'td "struct s16ui { uint16_t a_u; int16_t b_i; uint16_t c_u; int16_t d_i;}"
td "struct s16iu { int16_t a_i; uint16_t b_u; int16_t c_i; uint16_t d_u;}"
td "struct s32ui { uint32_t e_u; int16_t f_i;}"
td "struct s32iu { int32_t e_i; uint16_t f_u;}"
e asm.bits=16
e cfg.bigendian=true
tpv s16ui 0xcafebabecafebabe
tpv s16iu 0xcafebabecafebabe
tpv s32ui 0xcafebabecafebabe
tpv s32iu 0xcafebabecafebabe
e cfg.bigendian=false
tpv s16ui 0xcafebabecafebabe
tpv s16iu 0xcafebabecafebabe
tpv s32ui 0xcafebabecafebabe
tpv s32iu 0xcafebabecafebabe
e asm.bits=32
e cfg.bigendian=true
tpv s16ui 0xcafebabecafebabe
tpv s16iu 0xcafebabecafebabe
tpv s32ui 0xcafebabecafebabe
tpv s32iu 0xcafebabecafebabe
e cfg.bigendian=false
tpv s16ui 0xcafebabecafebabe
tpv s16iu 0xcafebabecafebabe
tpv s32ui 0xcafebabecafebabe
tpv s32iu 0xcafebabecafebabe
e asm.bits=64
e cfg.bigendian=true
tpv s16ui 0xcafebabecafebabe
tpv s16iu 0xcafebabecafebabe
tpv s32ui 0xcafebabecafebabe
tpv s32iu 0xcafebabecafebabe
e cfg.bigendian=false
tpv s16ui 0xcafebabecafebabe
tpv s16iu 0xcafebabecafebabe
tpv s32ui 0xcafebabecafebabe
tpv s32iu 0xcafebabecafebabe
' =
-- stdout
--- expected
+++ actual
@@ -1,27 +1,27 @@
+ a_u : 0x00000000 = 0xcafe
+ b_i : 0x00000002 = 0xbabe
+ c_u : 0x00000004 = 0xcafe
+ d_i : 0x00000006 = 0xbabe
+ a_i : 0x00000000 = 0xcafe
+ b_u : 0x00000002 = 0xbabe
+ c_i : 0x00000004 = 0xcafe
+ d_u : 0x00000006 = 0xbabe
+ e_u : 0x00000000 = 3405691582
+ f_i : 0x00000004 = 0xcafe
+ e_i : 0x00000000 = 3405691582
+ f_u : 0x00000004 = 0xcafe
a_u : 0x00000000 = 0xbabe
- b_i : 0x00000002 = 0x0000
- c_u : 0x00000004 = 0x0000
- d_i : 0x00000006 = 0x0000
+ b_i : 0x00000002 = 0xcafe
+ c_u : 0x00000004 = 0xbabe
+ d_i : 0x00000006 = 0xcafe
a_i : 0x00000000 = 0xbabe
- b_u : 0x00000002 = 0x0000
- c_i : 0x00000004 = 0x0000
- d_u : 0x00000006 = 0x0000
- e_u : 0x00000000 = 3133014016
- f_i : 0x00000004 = 0x0000
- e_i : 0x00000000 = 3133014016
- f_u : 0x00000004 = 0x0000
- a_u : 0x00000000 = 0xbabe
- b_i : 0x00000002 = 0x0000
- c_u : 0x00000004 = 0x0000
- d_i : 0x00000006 = 0x0000
- a_i : 0x00000000 = 0xbabe
- b_u : 0x00000002 = 0x0000
- c_i : 0x00000004 = 0x0000
- d_u : 0x00000006 = 0x0000
- e_u : 0x00000000 = 47806
- f_i : 0x00000004 = 0x0000
- e_i : 0x00000000 = 47806
- f_u : 0x00000004 = 0x0000
+ b_u : 0x00000002 = 0xcafe
+ c_i : 0x00000004 = 0xbabe
+ d_u : 0x00000006 = 0xcafe
+ e_u : 0x00000000 = 3405691582
+ f_i : 0x00000004 = 0xbabe
+ e_i : 0x00000000 = 3405691582
+ f_u : 0x00000004 = 0xbabe
a_u : 0x00000000 = 0xcafe
b_i : 0x00000002 = 0xbabe
c_u : 0x00000004 = 0x0000
this issue is located within pf
static RzCmdStatus type_format_print_value(RzCore *core, const char *type, ut64 val) {
char *fmt = rz_type_format(core->analysis->typedb, type);
if (RZ_STR_ISEMPTY(fmt)) {
eprintf("Cannot find type %s\n", type);
free(fmt);
return RZ_CMD_STATUS_ERROR;
}
rz_core_cmdf(core, "pf %s @v:0x%08" PFMT64x "\n", fmt, val);
free(fmt);
return RZ_CMD_STATUS_OK;
}
@wargio that's the easy part. Then it starts the gore of librz/type/format.c
.
The same happens on S390 (System Z) target.
Issues resides in asm.bits
not setting due default asm arch.
See https://github.com/rizinorg/rizin/pull/1250#issuecomment-869583762 .