Fix #14325 - Honor segments in DEX files (#15920) ##bin

This commit is contained in:
Zi Fan 2020-02-06 15:34:46 -08:00 committed by GitHub
parent 0e86459727
commit 9de9237c86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 7 deletions

View File

@ -2029,7 +2029,7 @@ static RList *sections(RBinFile *bf) {
ptr->size = ptr->vsize = sizeof (struct dex_header_t);
ptr->paddr= ptr->vaddr = 0;
ptr->perm = R_PERM_R;
ptr->add = true;
ptr->add = false;
r_list_append (ret, ptr);
}
if ((ptr = R_NEW0 (RBinSection))) {
@ -2045,7 +2045,7 @@ static RList *sections(RBinFile *bf) {
ptr->vsize = ptr->size;
ptr->format = r_str_newf ("Cd %d[%d]", 4, ptr->vsize / 4);
ptr->perm = R_PERM_R;
ptr->add = true;
ptr->add = false;
r_list_append (ret, ptr);
// Define as dwords!
}
@ -2055,7 +2055,7 @@ static RList *sections(RBinFile *bf) {
ptr->size = bin->code_to - ptr->paddr;
ptr->vsize = ptr->size;
ptr->perm = R_PERM_RX;
ptr->add = true;
ptr->add = false;
r_list_append (ret, ptr);
}
if ((ptr = R_NEW0 (RBinSection))) {
@ -2071,7 +2071,7 @@ static RList *sections(RBinFile *bf) {
//ptr->size = ptr->vsize = 1024;
}
ptr->perm = R_PERM_R; //|2;
ptr->add = true;
ptr->add = false;
r_list_append (ret, ptr);
}
if ((ptr = R_NEW0 (RBinSection))) {
@ -2081,6 +2081,27 @@ static RList *sections(RBinFile *bf) {
ptr->vsize = ptr->size;
ptr->perm = R_PERM_R;
// ptr->format = strdup ("Cs 4");
ptr->add = false;
r_list_append (ret, ptr);
}
if ((ptr = R_NEW0 (RBinSection))) {
ptr->name = strdup ("code");
ptr->vaddr = ptr->paddr = bin->code_from;
ptr->size = bin->code_to - ptr->paddr;
ptr->vsize = ptr->size;
ptr->perm = R_PERM_RX;
ptr->is_segment = true;
ptr->add = true;
r_list_append (ret, ptr);
}
if ((ptr = R_NEW0 (RBinSection))) {
ptr->name = strdup ("file");
ptr->vaddr = ptr->paddr = 0;
ptr->size = r_buf_size (bf->buf);
ptr->vsize = ptr->size;
ptr->perm = R_PERM_R;
ptr->is_segment = true;
ptr->add = true;
r_list_append (ret, ptr);
}

View File

@ -1,9 +1,6 @@
NAME=invalid codesize DEX file
FILE=../bins/dex/Call.dex
EXPECT=<<EOF
4 fd: 3 +0x00000000 0x00000000 - 0x0000006f r-- fmap.header
3 fd: 3 +0x00000070 0x00000070 - 0x0000035c r-- fmap.constpool
2 fd: 3 +0x00000000 0x00000000 - 0x0000041b r-- fmap.data
1 fd: 3 +0x00000000 0x00000000 - 0x0000041b r-- fmap.file
0x35d
EOF
@ -172,6 +169,7 @@ FILE=../bins/dex/HelloWorld.dex
EXPECT=<<EOF
0x00000000 112 section.header
0x00000000 1460 section.file
0x00000000 1460 segment.file
0x00000070 440 section.constpool
0x00000160 0 sym.LHello.ifield_localVar:I
0x00000168 0 sym.LHello.sfield_localVar2:I
@ -187,6 +185,7 @@ EXPECT=<<EOF
0x000001e8 1 class.LHello
0x00000208 1 class.LWorld
0x00000228 308 section.code
0x00000228 308 segment.code
0x00000238 20 sym.LHello.method._init___V
0x00000238 1 method.public.constructor.LHello.LHello.method._init___V
0x0000025c 1 entry0