TE: 16 bit for _TEXT_RE and fixes for virtual addresses calculations
This commit is contained in:
parent
0f807f1bdb
commit
e62e837b7a
2 changed files with 11 additions and 3 deletions
|
|
@ -8,6 +8,10 @@
|
||||||
#include "te_specs.h"
|
#include "te_specs.h"
|
||||||
#include "te.h"
|
#include "te.h"
|
||||||
|
|
||||||
|
ut64 r_bin_te_get_stripped_delta(struct r_bin_te_obj_t *bin) {
|
||||||
|
return bin->header->StrippedSize - sizeof(TE_image_file_header);
|
||||||
|
}
|
||||||
|
|
||||||
ut64 r_bin_te_get_main_offset(struct r_bin_te_obj_t *bin) {
|
ut64 r_bin_te_get_main_offset(struct r_bin_te_obj_t *bin) {
|
||||||
struct r_bin_te_addr_t *entry = r_bin_te_get_entrypoint (bin);
|
struct r_bin_te_addr_t *entry = r_bin_te_get_entrypoint (bin);
|
||||||
ut64 addr = 0LL;
|
ut64 addr = 0LL;
|
||||||
|
|
@ -128,7 +132,7 @@ struct r_bin_te_addr_t* r_bin_te_get_entrypoint(struct r_bin_te_obj_t* bin) {
|
||||||
perror("malloc (entrypoint)");
|
perror("malloc (entrypoint)");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
entry->rva = bin->header->AddressOfEntryPoint;
|
entry->rva = bin->header->AddressOfEntryPoint - r_bin_te_get_stripped_delta(bin);
|
||||||
if (entry->rva == 0) // in TE if EP = 0 then EP = baddr
|
if (entry->rva == 0) // in TE if EP = 0 then EP = baddr
|
||||||
entry->rva = bin->header->ImageBase;
|
entry->rva = bin->header->ImageBase;
|
||||||
entry->offset = r_bin_te_rva_to_offset(bin, entry->rva);
|
entry->offset = r_bin_te_rva_to_offset(bin, entry->rva);
|
||||||
|
|
@ -277,10 +281,10 @@ struct r_bin_te_section_t* r_bin_te_get_sections(struct r_bin_te_obj_t* bin) {
|
||||||
for (i = 0; i < sections_count; i++) {
|
for (i = 0; i < sections_count; i++) {
|
||||||
memcpy (sections[i].name, shdr[i].Name, TE_IMAGE_SIZEOF_NAME);
|
memcpy (sections[i].name, shdr[i].Name, TE_IMAGE_SIZEOF_NAME);
|
||||||
sections[i].name[TE_IMAGE_SIZEOF_NAME] = '\0';
|
sections[i].name[TE_IMAGE_SIZEOF_NAME] = '\0';
|
||||||
sections[i].rva = shdr[i].VirtualAddress;
|
sections[i].rva = shdr[i].VirtualAddress - r_bin_te_get_stripped_delta(bin);
|
||||||
sections[i].size = shdr[i].SizeOfRawData;
|
sections[i].size = shdr[i].SizeOfRawData;
|
||||||
sections[i].vsize = shdr[i].VirtualSize;
|
sections[i].vsize = shdr[i].VirtualSize;
|
||||||
sections[i].offset = shdr[i].PointerToRawData;
|
sections[i].offset = shdr[i].PointerToRawData - r_bin_te_get_stripped_delta(bin);
|
||||||
sections[i].flags = shdr[i].Characteristics;
|
sections[i].flags = shdr[i].Characteristics;
|
||||||
sections[i].last = 0;
|
sections[i].last = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,10 @@ static RList* sections(RBinArch *arch) {
|
||||||
ptr->srwx |= 0x4;
|
ptr->srwx |= 0x4;
|
||||||
if (R_BIN_TE_SCN_IS_SHAREABLE (sections[i].flags))
|
if (R_BIN_TE_SCN_IS_SHAREABLE (sections[i].flags))
|
||||||
ptr->srwx |= 0x8;
|
ptr->srwx |= 0x8;
|
||||||
|
/* All TE files have _TEXT_RE section, which is 16-bit, because of
|
||||||
|
* CPU start in this mode */
|
||||||
|
if (!strncmp(ptr->name, "_TEXT_RE", 8))
|
||||||
|
ptr->bits = 16;
|
||||||
r_list_append (ret, ptr);
|
r_list_append (ret, ptr);
|
||||||
}
|
}
|
||||||
free (sections);
|
free (sections);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue