Skip to content

Commit

Permalink
fixup! Refactor <fields> from RzList to RzPVector in RzBinPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
PeiweiHu committed Nov 7, 2023
1 parent 9657301 commit ab9f956
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion librz/bin/bobj_process_field.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RZ_IPI void rz_bin_set_and_process_fields(RzBinFile *bf, RzBinObject *o) {

rz_pvector_free(o->fields);
if (!plugin->fields || !(o->fields = plugin->fields(bf))) {
o->fields = rz_pvector_new((RzListFree)rz_bin_field_free);
o->fields = rz_pvector_new((RzPVectorFree)rz_bin_field_free);
return;
}

Expand Down
1 change: 0 additions & 1 deletion librz/bin/p/bin_coff.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <rz_util/ht_uu.h>

#include "coff/coff.h"
#include "rz_vector.h"

#define VFILE_NAME_RELOC_TARGETS "reloc-targets"
#define VFILE_NAME_PATCHED "patched"
Expand Down
2 changes: 1 addition & 1 deletion librz/main/rz-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ static RzDiff *rz_diff_fields_new(DiffFile *dfile_a, DiffFile *dfile_b, bool com
rz_pvector_sort(vec_b, (RzPVectorComparator)field_compare);

RzDiffMethods methods = {
.elem_at = (RzDiffMethodElemAt)rz_diff_list_elem_at,
.elem_at = (RzDiffMethodElemAt)rz_diff_pvector_elem_at,
.elem_hash = (RzDiffMethodElemHash)(compare_addr ? field_hash_addr : field_hash),
.compare = (RzDiffMethodCompare)(compare_addr ? field_compare_addr : field_compare),
.stringify = (RzDiffMethodStringify)(compare_addr ? field_stringify_addr : field_stringify),
Expand Down
8 changes: 4 additions & 4 deletions test/db/tools/rz_diff
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,10 @@ EXPECT=<<EOF
-virt: 0x000000000000032c phys: 0x000000000000032c load_command_7_LC_LOAD_DYLINKER
-virt: 0x0000000000000348 phys: 0x0000000000000348 load_command_8_LC_UUID
-virt: 0x0000000000000360 phys: 0x0000000000000360 load_command_9_LC_VERSION_MIN_IPHONEOS
-virt: 0x00000000000001d4 phys: 0x00000000000001d4 section_0
-virt: 0x000000000000008c phys: 0x000000000000008c section_0
-virt: 0x0000000000000218 phys: 0x0000000000000218 section_1
-virt: 0x00000000000001d4 phys: 0x00000000000001d4 section_0
-virt: 0x00000000000000d0 phys: 0x00000000000000d0 section_1
-virt: 0x0000000000000218 phys: 0x0000000000000218 section_1
-virt: 0x0000000000000114 phys: 0x0000000000000114 section_2
-virt: 0x0000000000000158 phys: 0x0000000000000158 section_3
+virt: 0x0000000000000020 phys: 0x0000000000000020 load_command_0_LC_SEGMENT_64
Expand All @@ -520,8 +520,8 @@ EXPECT=<<EOF
+virt: 0x0000000000000440 phys: 0x0000000000000440 load_command_9_LC_VERSION_MIN_IPHONEOS
+virt: 0x0000000000000288 phys: 0x0000000000000288 section_0
+virt: 0x00000000000000b0 phys: 0x00000000000000b0 section_0
+virt: 0x00000000000002d8 phys: 0x00000000000002d8 section_1
+virt: 0x0000000000000100 phys: 0x0000000000000100 section_1
+virt: 0x00000000000002d8 phys: 0x00000000000002d8 section_1
+virt: 0x0000000000000150 phys: 0x0000000000000150 section_2
+virt: 0x00000000000001a0 phys: 0x00000000000001a0 section_3
+virt: 0x00000000000001f0 phys: 0x00000000000001f0 section_4
Expand All @@ -533,7 +533,7 @@ NAME=rz-diff fields comparison with addresses JSON
FILE==
CMDS=!rz-diff -C -Ajt fields bins/mach0/test-arm32 bins/mach0/test-arm64
EXPECT=<<EOF
{"from":"bins/mach0/test-arm32","to":"bins/mach0/test-arm64","diff":[{"from":[-1,25],"to":[-1,26],"ops":[{"op":"equal","value":"virt: 0x0000000000000000 phys: 0x0000000000000000 header\n"},{"op":"delete","value":"virt: 0x000000000000001c phys: 0x000000000000001c load_command_0_LC_SEGMENT\n"},{"op":"delete","value":"virt: 0x0000000000000370 phys: 0x0000000000000370 load_command_10_LC_SOURCE_VERSION\n"},{"op":"delete","value":"virt: 0x0000000000000380 phys: 0x0000000000000380 load_command_11_LC_MAIN\n"},{"op":"delete","value":"virt: 0x0000000000000398 phys: 0x0000000000000398 load_command_12_LC_ENCRYPTION_INFO\n"},{"op":"delete","value":"virt: 0x00000000000003ac phys: 0x00000000000003ac load_command_13_LC_LOAD_DYLIB\n"},{"op":"delete","value":"virt: 0x00000000000003e0 phys: 0x00000000000003e0 load_command_14_LC_FUNCTION_STARTS\n"},{"op":"delete","value":"virt: 0x00000000000003f0 phys: 0x00000000000003f0 load_command_15_LC_DATA_IN_CODE\n"},{"op":"delete","value":"virt: 0x0000000000000054 phys: 0x0000000000000054 load_command_1_LC_SEGMENT\n"},{"op":"delete","value":"virt: 0x000000000000019c phys: 0x000000000000019c load_command_2_LC_SEGMENT\n"},{"op":"delete","value":"virt: 0x000000000000025c phys: 0x000000000000025c load_command_3_LC_SEGMENT\n"},{"op":"delete","value":"virt: 0x0000000000000294 phys: 0x0000000000000294 load_command_4_LC_DYLD_INFO_ONLY\n"},{"op":"delete","value":"virt: 0x00000000000002c4 phys: 0x00000000000002c4 load_command_5_LC_SYMTAB\n"},{"op":"delete","value":"virt: 0x00000000000002dc phys: 0x00000000000002dc load_command_6_LC_DYSYMTAB\n"},{"op":"delete","value":"virt: 0x000000000000032c phys: 0x000000000000032c load_command_7_LC_LOAD_DYLINKER\n"},{"op":"delete","value":"virt: 0x0000000000000348 phys: 0x0000000000000348 load_command_8_LC_UUID\n"},{"op":"delete","value":"virt: 0x0000000000000360 phys: 0x0000000000000360 load_command_9_LC_VERSION_MIN_IPHONEOS\n"},{"op":"delete","value":"virt: 0x00000000000001d4 phys: 0x00000000000001d4 section_0\n"},{"op":"delete","value":"virt: 0x000000000000008c phys: 0x000000000000008c section_0\n"},{"op":"delete","value":"virt: 0x0000000000000218 phys: 0x0000000000000218 section_1\n"},{"op":"delete","value":"virt: 0x00000000000000d0 phys: 0x00000000000000d0 section_1\n"},{"op":"delete","value":"virt: 0x0000000000000114 phys: 0x0000000000000114 section_2\n"},{"op":"delete","value":"virt: 0x0000000000000158 phys: 0x0000000000000158 section_3\n"},{"op":"insert","value":"virt: 0x0000000000000020 phys: 0x0000000000000020 load_command_0_LC_SEGMENT_64\n"},{"op":"insert","value":"virt: 0x0000000000000450 phys: 0x0000000000000450 load_command_10_LC_SOURCE_VERSION\n"},{"op":"insert","value":"virt: 0x0000000000000460 phys: 0x0000000000000460 load_command_11_LC_MAIN\n"},{"op":"insert","value":"virt: 0x0000000000000478 phys: 0x0000000000000478 load_command_12_LC_ENCRYPTION_INFO_64\n"},{"op":"insert","value":"virt: 0x0000000000000490 phys: 0x0000000000000490 load_command_13_LC_LOAD_DYLIB\n"},{"op":"insert","value":"virt: 0x00000000000004c8 phys: 0x00000000000004c8 load_command_14_LC_FUNCTION_STARTS\n"},{"op":"insert","value":"virt: 0x00000000000004d8 phys: 0x00000000000004d8 load_command_15_LC_DATA_IN_CODE\n"},{"op":"insert","value":"virt: 0x0000000000000068 phys: 0x0000000000000068 load_command_1_LC_SEGMENT_64\n"},{"op":"insert","value":"virt: 0x0000000000000240 phys: 0x0000000000000240 load_command_2_LC_SEGMENT_64\n"},{"op":"insert","value":"virt: 0x0000000000000328 phys: 0x0000000000000328 load_command_3_LC_SEGMENT_64\n"},{"op":"insert","value":"virt: 0x0000000000000370 phys: 0x0000000000000370 load_command_4_LC_DYLD_INFO_ONLY\n"},{"op":"insert","value":"virt: 0x00000000000003a0 phys: 0x00000000000003a0 load_command_5_LC_SYMTAB\n"},{"op":"insert","value":"virt: 0x00000000000003b8 phys: 0x00000000000003b8 load_command_6_LC_DYSYMTAB\n"},{"op":"insert","value":"virt: 0x0000000000000408 phys: 0x0000000000000408 load_command_7_LC_LOAD_DYLINKER\n"},{"op":"insert","value":"virt: 0x0000000000000428 phys: 0x0000000000000428 load_command_8_LC_UUID\n"},{"op":"insert","value":"virt: 0x0000000000000440 phys: 0x0000000000000440 load_command_9_LC_VERSION_MIN_IPHONEOS\n"},{"op":"insert","value":"virt: 0x0000000000000288 phys: 0x0000000000000288 section_0\n"},{"op":"insert","value":"virt: 0x00000000000000b0 phys: 0x00000000000000b0 section_0\n"},{"op":"insert","value":"virt: 0x00000000000002d8 phys: 0x00000000000002d8 section_1\n"},{"op":"insert","value":"virt: 0x0000000000000100 phys: 0x0000000000000100 section_1\n"},{"op":"insert","value":"virt: 0x0000000000000150 phys: 0x0000000000000150 section_2\n"},{"op":"insert","value":"virt: 0x00000000000001a0 phys: 0x00000000000001a0 section_3\n"},{"op":"insert","value":"virt: 0x00000000000001f0 phys: 0x00000000000001f0 section_4\n"}]}]}
{"from":"bins/mach0/test-arm32","to":"bins/mach0/test-arm64","diff":[{"from":[-1,25],"to":[-1,26],"ops":[{"op":"equal","value":"virt: 0x0000000000000000 phys: 0x0000000000000000 header\n"},{"op":"delete","value":"virt: 0x000000000000001c phys: 0x000000000000001c load_command_0_LC_SEGMENT\n"},{"op":"delete","value":"virt: 0x0000000000000370 phys: 0x0000000000000370 load_command_10_LC_SOURCE_VERSION\n"},{"op":"delete","value":"virt: 0x0000000000000380 phys: 0x0000000000000380 load_command_11_LC_MAIN\n"},{"op":"delete","value":"virt: 0x0000000000000398 phys: 0x0000000000000398 load_command_12_LC_ENCRYPTION_INFO\n"},{"op":"delete","value":"virt: 0x00000000000003ac phys: 0x00000000000003ac load_command_13_LC_LOAD_DYLIB\n"},{"op":"delete","value":"virt: 0x00000000000003e0 phys: 0x00000000000003e0 load_command_14_LC_FUNCTION_STARTS\n"},{"op":"delete","value":"virt: 0x00000000000003f0 phys: 0x00000000000003f0 load_command_15_LC_DATA_IN_CODE\n"},{"op":"delete","value":"virt: 0x0000000000000054 phys: 0x0000000000000054 load_command_1_LC_SEGMENT\n"},{"op":"delete","value":"virt: 0x000000000000019c phys: 0x000000000000019c load_command_2_LC_SEGMENT\n"},{"op":"delete","value":"virt: 0x000000000000025c phys: 0x000000000000025c load_command_3_LC_SEGMENT\n"},{"op":"delete","value":"virt: 0x0000000000000294 phys: 0x0000000000000294 load_command_4_LC_DYLD_INFO_ONLY\n"},{"op":"delete","value":"virt: 0x00000000000002c4 phys: 0x00000000000002c4 load_command_5_LC_SYMTAB\n"},{"op":"delete","value":"virt: 0x00000000000002dc phys: 0x00000000000002dc load_command_6_LC_DYSYMTAB\n"},{"op":"delete","value":"virt: 0x000000000000032c phys: 0x000000000000032c load_command_7_LC_LOAD_DYLINKER\n"},{"op":"delete","value":"virt: 0x0000000000000348 phys: 0x0000000000000348 load_command_8_LC_UUID\n"},{"op":"delete","value":"virt: 0x0000000000000360 phys: 0x0000000000000360 load_command_9_LC_VERSION_MIN_IPHONEOS\n"},{"op":"delete","value":"virt: 0x000000000000008c phys: 0x000000000000008c section_0\n"},{"op":"delete","value":"virt: 0x00000000000001d4 phys: 0x00000000000001d4 section_0\n"},{"op":"delete","value":"virt: 0x00000000000000d0 phys: 0x00000000000000d0 section_1\n"},{"op":"delete","value":"virt: 0x0000000000000218 phys: 0x0000000000000218 section_1\n"},{"op":"delete","value":"virt: 0x0000000000000114 phys: 0x0000000000000114 section_2\n"},{"op":"delete","value":"virt: 0x0000000000000158 phys: 0x0000000000000158 section_3\n"},{"op":"insert","value":"virt: 0x0000000000000020 phys: 0x0000000000000020 load_command_0_LC_SEGMENT_64\n"},{"op":"insert","value":"virt: 0x0000000000000450 phys: 0x0000000000000450 load_command_10_LC_SOURCE_VERSION\n"},{"op":"insert","value":"virt: 0x0000000000000460 phys: 0x0000000000000460 load_command_11_LC_MAIN\n"},{"op":"insert","value":"virt: 0x0000000000000478 phys: 0x0000000000000478 load_command_12_LC_ENCRYPTION_INFO_64\n"},{"op":"insert","value":"virt: 0x0000000000000490 phys: 0x0000000000000490 load_command_13_LC_LOAD_DYLIB\n"},{"op":"insert","value":"virt: 0x00000000000004c8 phys: 0x00000000000004c8 load_command_14_LC_FUNCTION_STARTS\n"},{"op":"insert","value":"virt: 0x00000000000004d8 phys: 0x00000000000004d8 load_command_15_LC_DATA_IN_CODE\n"},{"op":"insert","value":"virt: 0x0000000000000068 phys: 0x0000000000000068 load_command_1_LC_SEGMENT_64\n"},{"op":"insert","value":"virt: 0x0000000000000240 phys: 0x0000000000000240 load_command_2_LC_SEGMENT_64\n"},{"op":"insert","value":"virt: 0x0000000000000328 phys: 0x0000000000000328 load_command_3_LC_SEGMENT_64\n"},{"op":"insert","value":"virt: 0x0000000000000370 phys: 0x0000000000000370 load_command_4_LC_DYLD_INFO_ONLY\n"},{"op":"insert","value":"virt: 0x00000000000003a0 phys: 0x00000000000003a0 load_command_5_LC_SYMTAB\n"},{"op":"insert","value":"virt: 0x00000000000003b8 phys: 0x00000000000003b8 load_command_6_LC_DYSYMTAB\n"},{"op":"insert","value":"virt: 0x0000000000000408 phys: 0x0000000000000408 load_command_7_LC_LOAD_DYLINKER\n"},{"op":"insert","value":"virt: 0x0000000000000428 phys: 0x0000000000000428 load_command_8_LC_UUID\n"},{"op":"insert","value":"virt: 0x0000000000000440 phys: 0x0000000000000440 load_command_9_LC_VERSION_MIN_IPHONEOS\n"},{"op":"insert","value":"virt: 0x0000000000000288 phys: 0x0000000000000288 section_0\n"},{"op":"insert","value":"virt: 0x00000000000000b0 phys: 0x00000000000000b0 section_0\n"},{"op":"insert","value":"virt: 0x0000000000000100 phys: 0x0000000000000100 section_1\n"},{"op":"insert","value":"virt: 0x00000000000002d8 phys: 0x00000000000002d8 section_1\n"},{"op":"insert","value":"virt: 0x0000000000000150 phys: 0x0000000000000150 section_2\n"},{"op":"insert","value":"virt: 0x00000000000001a0 phys: 0x00000000000001a0 section_3\n"},{"op":"insert","value":"virt: 0x00000000000001f0 phys: 0x00000000000001f0 section_4\n"}]}]}
EOF
RUN

Expand Down

0 comments on commit ab9f956

Please sign in to comment.