Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peflags #23699

Merged
merged 7 commits into from
Nov 27, 2024
Merged

Peflags #23699

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libr/bin/format/pe/pe.c
Original file line number Diff line number Diff line change
Expand Up @@ -4377,6 +4377,7 @@ static struct r_bin_pe_section_t* PE_(r_bin_pe_get_sections)(RBinPEObj* pe) {
}
}
}
sections[j].flags = shdr[i].Characteristics;
sections[j].perm = shdr[i].Characteristics;
sections[j].last = 0;
j++;
Expand Down
1 change: 1 addition & 0 deletions libr/bin/format/pe/pe.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct r_bin_pe_section_t {
ut64 vaddr;
ut64 paddr;
ut64 perm;
ut32 flags;
int last;
};

Expand Down
1 change: 1 addition & 0 deletions libr/bin/p/bin_pe.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ static RList* sections(RBinFile *bf) {
sec->vaddr = sections[i].vaddr + ba;
sec->add = true;
sec->perm = 0;
sec->flags = sections[i].flags;
if (R_BIN_PE_SCN_IS_EXECUTABLE (sections[i].perm)) {
sec->perm |= R_PERM_X;
sec->perm |= R_PERM_R; // implicit
Expand Down
17 changes: 9 additions & 8 deletions libr/core/cbin.c
Original file line number Diff line number Diff line change
Expand Up @@ -3062,11 +3062,11 @@ static bool bin_sections(RCore *r, PJ *pj, int mode, ut64 laddr, int va, ut64 at
}
if (IS_MODE_NORMAL (mode)) {
if (hashtypes) {
r_table_set_columnsf (table, "dXxXxssss",
"nth", "paddr", "size", "vaddr", "vsize", "perm", hashtypes, "type", "name");
r_table_set_columnsf (table, "dXxXxsxsss",
"nth", "paddr", "size", "vaddr", "vsize", "perm", "flags", hashtypes, "type", "name");
} else {
r_table_set_columnsf (table, "dXxXxsss",
"nth", "paddr", "size", "vaddr", "vsize", "perm", "type", "name");
r_table_set_columnsf (table, "dXxXxsxss",
"nth", "paddr", "size", "vaddr", "vsize", "perm", "flags", "type", "name");
}
// r_table_align (table, 0, R_TABLE_ALIGN_CENTER);
r_table_align (table, 2, R_TABLE_ALIGN_RIGHT);
Expand Down Expand Up @@ -3243,6 +3243,7 @@ static bool bin_sections(RCore *r, PJ *pj, int mode, ut64 laddr, int va, ut64 at
pj_ks (pj, "type", section->type);
}
pj_ks (pj, "perm", perms);
pj_kN (pj, "flags", section->flags);
if (hashtypes && (int)section->size > 0) {
int datalen = section->size;
if (datalen > 0 && datalen < plimit) {
Expand Down Expand Up @@ -3302,15 +3303,15 @@ static bool bin_sections(RCore *r, PJ *pj, int mode, ut64 laddr, int va, ut64 at
stype = print_segments? "MAP": "----";
}
if (hashtypes) {
r_table_add_rowf (table, "dXxXxssss", i,
r_table_add_rowf (table, "dXxXxsxsss", i,
(ut64)section->paddr, (ut64)section->size,
(ut64)addr, (ut64)section->vsize,
perms, r_str_get (hashstr), stype, section_name);
perms, section->flags, r_str_get (hashstr), stype, section_name);
} else {
r_table_add_rowf (table, "dXxXxsss", i,
r_table_add_rowf (table, "dXxXxsxss", i,
(ut64)section->paddr, (ut64)section->size,
(ut64)addr, (ut64)section->vsize,
perms, stype, section_name);
perms, section->flags, stype, section_name);
}
free (hashstr);
}
Expand Down
48 changes: 38 additions & 10 deletions test/db/anal/x86_64
Original file line number Diff line number Diff line change
Expand Up @@ -827,18 +827,18 @@ iSj.
EOF
EXPECT=<<EOF
Current section
nth paddr size vaddr vsize perm type name
-----------------------------------------------------
0 0x00000188 0x24 0x08048188 0x24 -r-- NOTE .note.gnu.build-id
nth paddr size vaddr vsize perm flags type name
-----------------------------------------------------------
0 0x00000188 0x24 0x08048188 0x24 -r-- 0x2 NOTE .note.gnu.build-id
Current section
nth paddr size vaddr vsize perm type name
-------------------------------------------
{"name":".plt","size":240,"vsize":240,"type":"PROGBITS","perm":"-r-x","paddr":1888,"vaddr":134514528}
nth paddr size vaddr vsize perm flags type name
-------------------------------------------------
{"name":".plt","size":240,"vsize":240,"type":"PROGBITS","perm":"-r-x","flags":6,"paddr":1888,"vaddr":134514528}
Current section
nth paddr size vaddr vsize perm type name
-----------------------------------------------------
0 0x00000188 0x24 0x00000188 0x24 -r-- NOTE .note.gnu.build-id
{"name":".plt","size":240,"vsize":240,"type":"PROGBITS","perm":"-r-x","paddr":1888,"vaddr":1888}
nth paddr size vaddr vsize perm flags type name
-----------------------------------------------------------
0 0x00000188 0x24 0x00000188 0x24 -r-- 0x2 NOTE .note.gnu.build-id
{"name":".plt","size":240,"vsize":240,"type":"PROGBITS","perm":"-r-x","flags":6,"paddr":1888,"vaddr":1888}
EOF
RUN

Expand All @@ -856,6 +856,7 @@ EXPECT=<<EOF
"vsize": 0,
"type": "NULL",
"perm": "----",
"flags": 0,
"paddr": 0,
"vaddr": 0
},
Expand All @@ -865,6 +866,7 @@ EXPECT=<<EOF
"vsize": 19,
"type": "PROGBITS",
"perm": "-r--",
"flags": 2,
"entropy": "3.68188080",
"paddr": 340,
"vaddr": 134512980
Expand All @@ -875,6 +877,7 @@ EXPECT=<<EOF
"vsize": 32,
"type": "NOTE",
"perm": "-r--",
"flags": 2,
"entropy": "1.74868984",
"paddr": 360,
"vaddr": 134513000
Expand All @@ -885,6 +888,7 @@ EXPECT=<<EOF
"vsize": 36,
"type": "NOTE",
"perm": "-r--",
"flags": 2,
"entropy": "4.13605609",
"paddr": 392,
"vaddr": 134513032
Expand All @@ -895,6 +899,7 @@ EXPECT=<<EOF
"vsize": 176,
"type": "GNU_HASH",
"perm": "-r--",
"flags": 2,
"entropy": "4.74342302",
"paddr": 428,
"vaddr": 134513068
Expand All @@ -905,6 +910,7 @@ EXPECT=<<EOF
"vsize": 592,
"type": "DYNSYM",
"perm": "-r--",
"flags": 2,
"entropy": "2.53170115",
"paddr": 604,
"vaddr": 134513244
Expand All @@ -915,6 +921,7 @@ EXPECT=<<EOF
"vsize": 384,
"type": "STRTAB",
"perm": "-r--",
"flags": 2,
"entropy": "4.59829027",
"paddr": 1196,
"vaddr": 134513836
Expand All @@ -925,6 +932,7 @@ EXPECT=<<EOF
"vsize": 74,
"type": "GNU_VERSYM",
"perm": "-r--",
"flags": 2,
"entropy": "1.55329753",
"paddr": 1580,
"vaddr": 134514220
Expand All @@ -935,6 +943,7 @@ EXPECT=<<EOF
"vsize": 64,
"type": "GNU_VERNEED",
"perm": "-r--",
"flags": 2,
"entropy": "2.33399879",
"paddr": 1656,
"vaddr": 134514296
Expand All @@ -945,6 +954,7 @@ EXPECT=<<EOF
"vsize": 16,
"type": "REL",
"perm": "-r--",
"flags": 2,
"entropy": "3.25000000",
"paddr": 1720,
"vaddr": 134514360
Expand All @@ -955,6 +965,7 @@ EXPECT=<<EOF
"vsize": 112,
"type": "REL",
"perm": "-r--",
"flags": 2,
"entropy": "3.52414971",
"paddr": 1736,
"vaddr": 134514376
Expand All @@ -965,6 +976,7 @@ EXPECT=<<EOF
"vsize": 35,
"type": "PROGBITS",
"perm": "-r-x",
"flags": 6,
"entropy": "4.12467560",
"paddr": 1848,
"vaddr": 134514488
Expand All @@ -975,6 +987,7 @@ EXPECT=<<EOF
"vsize": 240,
"type": "PROGBITS",
"perm": "-r-x",
"flags": 6,
"entropy": "3.68026477",
"paddr": 1888,
"vaddr": 134514528
Expand All @@ -985,6 +998,7 @@ EXPECT=<<EOF
"vsize": 1170,
"type": "PROGBITS",
"perm": "-r-x",
"flags": 6,
"entropy": "5.89126869",
"paddr": 2128,
"vaddr": 134514768
Expand All @@ -995,6 +1009,7 @@ EXPECT=<<EOF
"vsize": 20,
"type": "PROGBITS",
"perm": "-r-x",
"flags": 6,
"entropy": "3.72192809",
"paddr": 3300,
"vaddr": 134515940
Expand All @@ -1005,6 +1020,7 @@ EXPECT=<<EOF
"vsize": 249,
"type": "PROGBITS",
"perm": "-r--",
"flags": 2,
"entropy": "4.65845607",
"paddr": 3320,
"vaddr": 134515960
Expand All @@ -1015,6 +1031,7 @@ EXPECT=<<EOF
"vsize": 84,
"type": "PROGBITS",
"perm": "-r--",
"flags": 2,
"entropy": "3.49291576",
"paddr": 3572,
"vaddr": 134516212
Expand All @@ -1025,6 +1042,7 @@ EXPECT=<<EOF
"vsize": 336,
"type": "PROGBITS",
"perm": "-r--",
"flags": 2,
"entropy": "4.46780720",
"paddr": 3656,
"vaddr": 134516296
Expand All @@ -1035,6 +1053,7 @@ EXPECT=<<EOF
"vsize": 4,
"type": "INIT_ARRAY",
"perm": "-rw-",
"flags": 3,
"entropy": "2.00000000",
"paddr": 7944,
"vaddr": 134520584
Expand All @@ -1045,6 +1064,7 @@ EXPECT=<<EOF
"vsize": 4,
"type": "FINI_ARRAY",
"perm": "-rw-",
"flags": 3,
"entropy": "2.00000000",
"paddr": 7948,
"vaddr": 134520588
Expand All @@ -1055,6 +1075,7 @@ EXPECT=<<EOF
"vsize": 4,
"type": "PROGBITS",
"perm": "-rw-",
"flags": 3,
"entropy": "0.00000000",
"paddr": 7952,
"vaddr": 134520592
Expand All @@ -1065,6 +1086,7 @@ EXPECT=<<EOF
"vsize": 232,
"type": "DYNAMIC",
"perm": "-rw-",
"flags": 3,
"entropy": "2.87462433",
"paddr": 7956,
"vaddr": 134520596
Expand All @@ -1075,6 +1097,7 @@ EXPECT=<<EOF
"vsize": 4,
"type": "PROGBITS",
"perm": "-rw-",
"flags": 3,
"entropy": "0.00000000",
"paddr": 8188,
"vaddr": 134520828
Expand All @@ -1085,6 +1108,7 @@ EXPECT=<<EOF
"vsize": 68,
"type": "PROGBITS",
"perm": "-rw-",
"flags": 3,
"entropy": "3.42061456",
"paddr": 8192,
"vaddr": 134520832
Expand All @@ -1095,6 +1119,7 @@ EXPECT=<<EOF
"vsize": 8,
"type": "PROGBITS",
"perm": "-rw-",
"flags": 3,
"entropy": "0.00000000",
"paddr": 8260,
"vaddr": 134520900
Expand All @@ -1105,6 +1130,7 @@ EXPECT=<<EOF
"vsize": 8,
"type": "NOBITS",
"perm": "-rw-",
"flags": 3,
"paddr": 8268,
"vaddr": 134520928
},
Expand All @@ -1114,6 +1140,7 @@ EXPECT=<<EOF
"vsize": 36,
"type": "PROGBITS",
"perm": "----",
"flags": 48,
"entropy": "4.04868811",
"paddr": 8268,
"vaddr": 0
Expand All @@ -1124,6 +1151,7 @@ EXPECT=<<EOF
"vsize": 246,
"type": "STRTAB",
"perm": "----",
"flags": 0,
"entropy": "4.28967882",
"paddr": 8304,
"vaddr": 0
Expand Down
Loading
Loading