wargio / libvle

PowerPC VLE disassembler library
GNU Lesser General Public License v3.0
5 stars 5 forks source link

Add to API a way to calculate directly the right jumps/addresses from the current address #11

Closed arkup closed 5 years ago

arkup commented 5 years ago

Hi, seems the branch dest address decoding/calculation is incorrect(?)

==================================== 
libvle
====================================

.Bin:0009b7f0 78050C61                   e_bl 0x50c60
.Bin:0009b7f4 79FACB5F                   e_bl 0xfdfacb5e
.Bin:0009b7f8 79F69BAF                   e_bl 0xfdf69bae
.Bin:0009b7fc 79FACB59                   e_bl 0xfdfacb58
====================================
IDA
====================================

ROM:0009B7F0             # Segment type: Pure code
ROM:0009B7F0                             .section "ROM",text_vle
ROM:0009B7F0 78 05 0C 61                 e_bl      0xEC450
ROM:0009B7F4 79 FA CB 5F                 e_bl      0x48352
ROM:0009B7F8 79 F6 9B AF                 e_bl      0x53A6
ROM:0009B7FC 79 FA CB 59                 e_bl      0x48354
ROM:0009B7FC
====================================  
//Ghidra  0009b7f0
====================================   

0009b7f0 78 05 0c 61     e_bl       SUB_000ec450
0009b7f4 79 fa cb 5f     e_bl       SUB_00048352
0009b7f8 79 f6 9b af     e_bl       SUB_000053a6
0009b7fc 79 fa cb 59     e_bl       SUB_00048354
wargio commented 5 years ago

there is no error:

.Bin:0009b7f0 78050C61    e_bl 0x50c60      -> 0x9b7f0 + 0x50c60    = 0xec450
.Bin:0009b7f4 79FACB5F    e_bl 0xfffacb5e   -> 0x9b7f4 + 0xfffacb5e = 0x48352
.Bin:0009b7f8 79F69BAF    e_bl 0xfff69bae   -> 0x9b7f8 + 0xfff69bae = 0x53a6
.Bin:0009b7fc 79FACB59    e_bl 0xfffacb58   -> 0x9b7fc + 0xfffacb58 = 0x48354
wargio commented 5 years ago

but anyway there is a bug. i'm missing a bit on the negative mask.

arkup commented 5 years ago

thanks but how to get the final dest address? Parsing returned string by vle_snprint adding base and converting back to string? this is not very elegant solution :/

wargio commented 5 years ago

i can add a simple api for that or you can just sum the current address to the TYPE_JMP value

arkup commented 5 years ago

i can add a simple api for that or you can just sum the current address to the TYPE_JMP value

yea API function to calc absolute address that would be great and clean solution, thx

arkup commented 5 years ago

or better make it default behaviour ;) since it's more intuitive IMHO

wargio commented 5 years ago

fixed with https://github.com/wargio/libvle/commit/7ab6b86b1736aa26caa595f90696f716c192349c

arkup commented 5 years ago

cool thanks!