Fix buffer read callback on all gnu disassembler plugins (#17992) ##disasm

This commit is contained in:
Jeroen Domburg 2020-11-29 18:41:57 +00:00 committed by GitHub
parent 35c6432e62
commit b782a02ae3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 67 additions and 6 deletions

View File

@ -26,7 +26,14 @@ static RStrBuf *buf_global = NULL;
static unsigned char bytes[8];
static int cris_buffer_read_memory (bfd_vma memaddr, bfd_byte *myaddr, ut32 length, struct disassemble_info *info) {
memcpy (myaddr, bytes, length);
int delta = (memaddr - Offset);
if (delta < 0) {
return -1; // disable backward reads
}
if ((delta + length) > 8) {
return -1;
}
memcpy (myaddr, bytes + delta, length);
return 0;
}

View File

@ -27,7 +27,14 @@ static int hppa_buffer_read_memory (bfd_vma memaddr, bfd_byte *myaddr, ut32 leng
return 0;
}
#endif
memcpy (myaddr, bytes, length);
int delta = (memaddr - Offset);
if (delta < 0) {
return -1; // disable backward reads
}
if ((delta + length) > 4) {
return -1;
}
memcpy (myaddr, bytes + delta, length);
return 0;
}

View File

@ -14,7 +14,14 @@ static RStrBuf *buf_global = NULL;
static unsigned char bytes[4];
static int lanai_buffer_read_memory(bfd_vma memaddr, bfd_byte *myaddr, ut32 length, struct disassemble_info *info) {
memcpy (myaddr, bytes, length);
int delta = (memaddr - Offset);
if (delta < 0) {
return -1; // disable backward reads
}
if ((delta + length) > 4) {
return -1;
}
memcpy (myaddr, bytes + delta, length);
return 0;
}

View File

@ -21,7 +21,14 @@ static char *pre_cpu = NULL;
static char *pre_features = NULL;
static int mips_buffer_read_memory(bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, struct disassemble_info *info) {
memcpy (myaddr, bytes, length);
int delta = (memaddr - Offset);
if (delta < 0) {
return -1; // disable backward reads
}
if ((delta + length) > 4) {
return -1;
}
memcpy (myaddr, bytes + delta, length);
return 0;
}

View File

@ -17,7 +17,14 @@ static RStrBuf *buf_global = NULL;
static unsigned char bytes[4];
static int ppc_buffer_read_memory (bfd_vma memaddr, bfd_byte *myaddr, ut32 length, struct disassemble_info *info) {
memcpy (myaddr, bytes, length);
int delta = (memaddr - Offset);
if (delta < 0) {
return -1; // disable backward reads
}
if ((delta + length) > 4) {
return -1;
}
memcpy (myaddr, bytes + delta, length);
return 0;
}

View File

@ -15,6 +15,13 @@ static RStrBuf *buf_global = NULL;
static unsigned char bytes[4];
static int sparc_buffer_read_memory (bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, struct disassemble_info *info) {
int delta = (memaddr - Offset);
if (delta < 0) {
return -1; // disable backward reads
}
if ((delta + length) > 4) {
return -1;
}
memcpy (myaddr, bytes, length);
return 0;
}

View File

@ -16,7 +16,14 @@ static RStrBuf *buf_global = NULL;
static ut8 bytes[8];
static int v850_buffer_read_memory(bfd_vma memaddr, bfd_byte *myaddr, ut32 length, struct disassemble_info *info) {
memcpy (myaddr, bytes, length);
int delta = (memaddr - Offset);
if (delta < 0) {
return -1; // disable backward reads
}
if ((delta + length) > 8) {
return -1;
}
memcpy (myaddr, bytes + delta, length);
return 0;
}

12
test/db/anal/v850.gnu Normal file
View File

@ -0,0 +1,12 @@
NAME=v850.gnu proper imm32 handling
FILE=malloc://1024
CMDS=<<EOF
e asm.arch = v850.gnu
wx 210674060000210674061234
pi 2 @0
EOF
EXPECT=<<EOF
mov 0x674, r1
mov 0x34120674, r1
EOF
RUN