Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disassembler Crashes When Code is Loaded on an Odd Byte Boundary #21

Open
AlexanderAdelAU opened this issue Apr 18, 2020 · 4 comments
Open

Comments

@AlexanderAdelAU
Copy link

AlexanderAdelAU commented Apr 18, 2020

LiClipse produces the following error when running xda99 against the file at this link: https://www.dropbox.com/s/zk87ceivpet63pd/sieve.rar?dl=1

I am not sure if the error lies within the disassembler or the PyDev implementation on LiClipse however I thought that I would flag it as a possible issue. I have walked though the code manually (not run native) and it appears to be sound.

Traceback (most recent call last): File "C:\Development-W7DEV\LiClipse Workspace\xda99\src\xda99.py", line 909, in <module> status = main() File "C:\Development-W7DEV\LiClipse Workspace\xda99\src\xda99.py", line 872, in main program = Program(binary, addr, symbols=symbols) File "C:\Development-W7DEV\LiClipse Workspace\xda99\src\xda99.py", line 580, in __init__ self.code = [Unknown(addr + i, ordw(binary[i:i + 2])) # listing of entries File "C:\Development-W7DEV\LiClipse Workspace\xda99\src\xda99.py", line 580, in <listcomp> self.code = [Unknown(addr + i, ordw(binary[i:i + 2])) # listing of entries File "C:\Development-W7DEV\LiClipse Workspace\xda99\src\xda99.py", line 34, in ordw return (word[0] << 8) | word[1] IndexError: index out of range

@endlos99
Copy link
Owner

OK, this seems like another bug.

Could you tell me how you invoked xda99, i.e., what the arguments were?

@AlexanderAdelAU
Copy link
Author

Yes, sieve.bin -a 0100 -f 0100

@AlexanderAdelAU
Copy link
Author

AlexanderAdelAU commented Apr 24, 2020

For your info. I discovered the source of the problem. The crash dump is caused if any of executable source code lies on an odd boundary.

For example

cc1: BYTE 49,48,0  <--- ODD NUMBER OF BYTES
    ENT main
ENT flags
EXT printf
EVEN   <---  ADDING THIS MAKES SURE FOLLOWING MODULE ARE LOADED ON AN EVEN BOUNDARY
END`

So in summary, you probably don't need to fix you disassembler if you trust the users will load properly aligned code, however I thought I would pass this on in case you want to perform any additional checks in your python code.

By the way, I have found your software exceedingly useful - so thank you very much.

@AlexanderAdelAU AlexanderAdelAU changed the title Disassembler Crashes on Large Data File Disassembler Crashes When Code is Loaded on an Odd Byte Boundary Apr 24, 2020
@endlos99
Copy link
Owner

I think it's related to that, but xda99 will always disassemble at even addresses. If code is located at odd addresses, then xda99 will just return nonsense.

The actual issue is that your file has odd length, but xda99 reads words. The simplest fix would be to pad odd-length code with a zero byte, but I hope to handle this more gracefully when I got time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants