Skip to content

Commit d6b5340

Browse files
authored
librz/bin: add iH header printing support for CGC format (#5962)
1 parent ab82fc9 commit d6b5340

File tree

2 files changed

+69
-2
lines changed

2 files changed

+69
-2
lines changed

librz/bin/p/bin_cgc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ static bool check_buffer(RzBuffer *buf) {
1212
return r > SCGCMAG && !memcmp(tmp, CGCMAG, SCGCMAG) && tmp[4] != 2;
1313
}
1414

15+
static RzStructuredData *cgc_info_structure(RzBinFile *bf) {
16+
rz_return_val_if_fail(bf && bf->o && bf->o->bin_obj, NULL);
17+
18+
ELFOBJ *bin = (ELFOBJ *)bf->o->bin_obj;
19+
return elf_structure(bin);
20+
}
21+
1522
static RzBuffer *create(RzBin *bin, const ut8 *code, int codelen, const ut8 *data, int datalen, RzBinArchOptions *opt) {
1623
ut32 filesize, code_va, code_pa, phoff;
1724
ut32 p_start, p_phoff, p_phdr;
@@ -118,6 +125,7 @@ RzBinPlugin rz_bin_plugin_cgc = {
118125
.symbols = &elf_symbols,
119126
.imports = &elf_imports,
120127
.info = &elf_info,
128+
.bin_structure = &cgc_info_structure,
121129
.fields = &elf_fields,
122130
.size = &elf_size,
123131
.libs = &elf_libs,

test/db/formats/cgc

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,67 @@
11
NAME=CGC: Open/iI
22
FILE=bins/cgc/CADET_00001
3-
CMDS=i~?format cgc
3+
CMDS=<<EOF
4+
iI
5+
iH
6+
EOF
47
EXPECT=<<EOF
5-
1
8+
arch x86
9+
cpu N/A
10+
features N/A
11+
baddr 0x08048000
12+
binsz 0x00014a45
13+
bintype elf
14+
bits 32
15+
class ELF32
16+
compiler clang-cgc version 3.4 (10208)
17+
dbg_file N/A
18+
endian LE
19+
hdr.csum N/A
20+
guid N/A
21+
intrp N/A
22+
laddr 0x00000000
23+
lang c
24+
machine Intel 80386
25+
maxopsz 16
26+
minopsz 1
27+
os linux
28+
cc N/A
29+
pcalign 1
30+
rpath NONE
31+
subsys linux
32+
stripped true
33+
crypto false
34+
havecode true
35+
va true
36+
sanitiz false
37+
static true
38+
linenum false
39+
lsyms false
40+
canary false
41+
PIE false
42+
RELROCS false
43+
NX false
44+
elf:
45+
e_ident:
46+
bytes: "7f 43 47 43 01 01 01 43 01 4d 65 72 69 6e 6f 00"
47+
ei_class: 1
48+
ei_data: 1
49+
ei_version: 1
50+
ei_osabi: 67
51+
ei_abiversion: 1
52+
e_machine: 3
53+
e_version: 1
54+
e_entry: 0x80485fc
55+
e_phoff: 0x34
56+
e_shoff: 0x14a48
57+
e_flags: 0x0
58+
e_ehsize: 52
59+
e_phentsize: 32
60+
e_phnum: 3
61+
e_shentsize: 40
62+
e_shnum: 6
63+
e_shstrndx: 5
64+
665
EOF
766
RUN
867

0 commit comments

Comments
 (0)