mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-23 06:14:53 +00:00
Fix buffer read callback on all gnu disassembler plugins (#17992) ##disasm
This commit is contained in:
parent
35c6432e62
commit
b782a02ae3
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
12
test/db/anal/v850.gnu
Normal 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
|
Loading…
x
Reference in New Issue
Block a user