English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 14 February 2023, 11:59   #1
LittleSandra88
Registered User
 
LittleSandra88's Avatar
 
Join Date: Jan 2023
Location: Denmark
Posts: 36
Big grin How is Ghidra compared to ReSource 6.02?

Dear all =)

Ghidra lists 68xxx as supported, so is that the one to use instead of ReSource 6.02?

Does anyone use Ghidra for their WHD work?

Hugs
Sandra =)
LittleSandra88 is offline  
Old 14 February 2023, 14:38   #2
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,379
I don't

I'm using IRA + cheapres.py (that I have written). Text files, old school.

I tried Ghidra on a Z80 program it looped forever and did produce nothing... I suspect that old CPUs are better off with older tools. Kroah made a killing with IDAPro 68000.
jotd is offline  
Old 14 February 2023, 15:11   #3
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
ReSource can directly produce a source that will assemble and run.
Ghidra does not.
meynaf is offline  
Old 14 February 2023, 19:00   #4
LittleSandra88
Registered User
 
LittleSandra88's Avatar
 
Join Date: Jan 2023
Location: Denmark
Posts: 36
Quote:
Originally Posted by meynaf View Post
ReSource can directly produce a source that will assemble and run.
Ghidra does not.
I found this howto which links to this plugin.

Quote:
It can handle the the 68000 platform, and thanks to a plugin called ghidra_amiga_ldr, it can specifically handle Amiga executable files.
Or is this plugin to resolve another problem?
LittleSandra88 is offline  
Old 14 February 2023, 19:09   #5
LittleSandra88
Registered User
 
LittleSandra88's Avatar
 
Join Date: Jan 2023
Location: Denmark
Posts: 36
Quote:
Originally Posted by jotd View Post
I don't

I'm using IRA + cheapres.py (that I have written). Text files, old school.

I tried Ghidra on a Z80 program it looped forever and did produce nothing... I suspect that old CPUs are better off with older tools. Kroah made a killing with IDAPro 68000.
So the way IRA works, is that you do an initial run, write a config file what you want to change, and then run IRA again. And then repeat?
LittleSandra88 is offline  
Old 14 February 2023, 19:25   #6
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
Quote:
Originally Posted by LittleSandra88 View Post
I found this howto which links to this plugin.
Reverse engineering and resourcing are two different things.
A disassembly listing is not an assemblable source.
meynaf is offline  
Old 14 February 2023, 20:14   #7
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,223
In my limited experience Ghidra is an OK supplement, but doesn't really work that well with most amiga software (even if it's written in C and doesn't use dynamic loading/encryption) as common idioms aren't handled, e.g. custom calling conventions (limited support, but requires much effort), negative struct offsets, etc.

BTW the plugin mentioned here https://eab.abime.net/showthread.php?t=111845 seems to be an improvement, but isn't compatible with latest ghidra, so I haven't tried it.
paraj is offline  
Old 14 February 2023, 20:43   #8
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,379
Quote:
Originally Posted by LittleSandra88 View Post
So the way IRA works, is that you do an initial run, write a config file what you want to change, and then run IRA again. And then repeat?

it's supposed to work that way, but I don't use it like that. I run it once, then I have written a post-processing tool (cheapres.py) which is able to find LVOs, custom chip offsets, annotate Ax-relative jumps and in the latest version you can name offsets/variables in special comments at the start of the asm file (which avoids to use a config file).
jotd is offline  
Old 14 February 2023, 22:17   #9
LittleSandra88
Registered User
 
LittleSandra88's Avatar
 
Join Date: Jan 2023
Location: Denmark
Posts: 36
Quote:
Originally Posted by paraj View Post
In my limited experience Ghidra is an OK supplement, but doesn't really work that well with most amiga software (even if it's written in C and doesn't use dynamic loading/encryption) as common idioms aren't handled, e.g. custom calling conventions (limited support, but requires much effort), negative struct offsets, etc.

BTW the plugin mentioned here https://eab.abime.net/showthread.php?t=111845 seems to be an improvement, but isn't compatible with latest ghidra, so I haven't tried it.
Ok, thanks for clearing that out. I'll stick with ReSource then =)
LittleSandra88 is offline  
Old 14 February 2023, 22:19   #10
LittleSandra88
Registered User
 
LittleSandra88's Avatar
 
Join Date: Jan 2023
Location: Denmark
Posts: 36
Quote:
Originally Posted by jotd View Post
it's supposed to work that way, but I don't use it like that. I run it once, then I have written a post-processing tool (cheapres.py) which is able to find LVOs, custom chip offsets, annotate Ax-relative jumps and in the latest version you can name offsets/variables in special comments at the start of the asm file (which avoids to use a config file).
With ReSource I often have to change a data block into code, because it guessed wrong. How do you handle this case in IRA?
LittleSandra88 is offline  
Old 14 February 2023, 23:45   #11
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,379
this is the most annoying issue IRA doesn't do better than the rest because it's a difficult issue. Maybe the worst issue.

I have other tools to detect data "sections", but they're not perfect. If you have one illegal instruction somewhere between 2 labels you could tell that the whole block is data, except that sometimes the entrypoint of the next routine is in a table somewhere and you're missing it because there's no direct jump / label to it (that's when you're reversing absolute assembled code, doesn't happen when reversing relocated executables)

So now I try to relocate all the code when it's not already relocated, figuring out jump tables. If you have all entrypoints figured out, then it's more secure to detect data in code "sections".
jotd is offline  
Old 15 February 2023, 00:53   #12
LittleSandra88
Registered User
 
LittleSandra88's Avatar
 
Join Date: Jan 2023
Location: Denmark
Posts: 36
Quote:
Originally Posted by jotd View Post
this is the most annoying issue IRA doesn't do better than the rest because it's a difficult issue. Maybe the worst issue.

I have other tools to detect data "sections", but they're not perfect. If you have one illegal instruction somewhere between 2 labels you could tell that the whole block is data, except that sometimes the entrypoint of the next routine is in a table somewhere and you're missing it because there's no direct jump / label to it (that's when you're reversing absolute assembled code, doesn't happen when reversing relocated executables)

So now I try to relocate all the code when it's not already relocated, figuring out jump tables. If you have all entrypoints figured out, then it's more secure to detect data in code "sections".
Ok, then it makes more sense =)
LittleSandra88 is offline  
Old 15 February 2023, 22:18   #13
kamelito
Zone Friend
 
kamelito's Avatar
 
Join Date: May 2006
Location: France
Posts: 1,859
I use resource quite a bit but I use more IRA and cheapres.py these days because the iteration os a lot faster. To determine datas vs code I have WinUAE running and use Monam.
kamelito is offline  
Old 15 February 2023, 23:30   #14
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,379
get the latest cheapres.py: https://github.com/jotd666/amiga68ktools.git

there's a nice FAQ I've written where new features are explained.
jotd is offline  
Old 16 February 2023, 10:29   #15
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,549
Quote:
Originally Posted by jotd View Post
it's supposed to work that way, but I don't use it like that. I run it once, then I have written a post-processing tool (cheapres.py) which is able to find LVOs, custom chip offsets, annotate Ax-relative jumps
Hmm... but wouldn't cheapres.py be more effective if you call IRA with
-preproc
and then do a few iterations to find code/data?

Quote:
and in the latest version you can name offsets/variables in special comments at the start of the asm file (which avoids to use a config file).
But the config file is your friend!
You could even assign symbol names in the config file, which stay on further iterations.

Of course, it always depends on what you want to do with the reassembled source. Do you just want to have a quick look what it does (then your approach could be sufficient), or do you want to modify and assemble it into a new executable?
phx is offline  
Old 16 February 2023, 10:40   #16
alexh
Thalion Webshrine
 
alexh's Avatar
 
Join Date: Jan 2004
Location: Oxford
Posts: 14,470
Ambermoon was disassembled using Ghidra by Nico Bendlin and Pyrdacor with help from KermitFrog using a forked version of ghidra_amiga_ldr which has since been merged back upstream and and re-sourced using an exporter written by Pyrdacor.

It's a very impressive project.

https://github.com/Pyrdacor/AmigaAsm

I am not involved, so I don't know the full details, only screenshots of them working. As the code is understood and branch labels changed from their auto-generated ones to readable ones, macros defined the code slowly appears to becoming almost high level code once again. I think that is the power of Ghidra you can create a high-level description of the disassembly as you go. As a result Ambermoon is becoming more maintainable and modifiable while retaining the ability to be reassembled (unmodified) into a 1:1 binary.

It has allowed Pyrdacor to find and fix lots of bugs. Before re-sourcing bugfixes could only be made if the fix was the same size (or smaller) than the original code, now it doesn't matter. It has allowed him to make sweeping changes such as his universal executable that replaces separate English and German versions and loads text from files making it much easier to maintain and add new localisations.

Last edited by alexh; 16 February 2023 at 11:58.
alexh is offline  
Old 16 February 2023, 11:19   #17
Wepl
Moderator
 
Wepl's Avatar
 
Join Date: Nov 2001
Location: Germany
Posts: 876
I use ReSource because I usually need to understand how code works. This is for me best achived by navigating through the code. Which is supported by interactive working with ReSource. I can also save my work (deciding code/data, labels, comments). Also searching in ReSoure is powerful.
Wepl is offline  
Old 09 December 2023, 22:30   #18
hop
Registered User
 
hop's Avatar
 
Join Date: Apr 2019
Location: UK
Posts: 259
Quote:
Originally Posted by jotd View Post
My typical ira scripts disassemble, reassemble the diff the output vs input.
I've just added a call to cheapres.py in there (nice!).

I've just found myself modifying the cheapres.py source to add these lines:

Code:
    INCLUDE "custom.i"
    INCLUDE "LVOs.i"
I looked for a way of forcing vasm to include files on the command line, but couldn't find one. What's your solution for this, or do you always hand-edit after disassembling?
hop is offline  
Old 10 December 2023, 03:27   #19
copse
Registered User
 
Join Date: Jul 2009
Location: Lala Land
Posts: 608
I've switched over to ghidra. The code might not compile directly when I am done, due to use of non-standard data types and so on, but I can run a script over the code and probably only have to write it once for any future projects.

I am currently working on disassembling a chunk of memory saved out from WinUAE.

Some notes:
  • One particular feature I like is going to a label and pressing CONTROL+SHIFT+f and I get a window with all the locations where that address is being referenced in a table alongside the code at each location.
  • I don't know if it is possible in Ghidra, but I do miss Resource's macros. I am going word, word, string repeatedly. But if it has set the type of the string automatically it drags in a ambiguous byte from the preceding word, and I have to untype the string before I can set the type of the second word.
  • Also finding broken code where there are unknown bytes in the middle of it is something I haven't been able to do in Ghidra easily.
  • Both misidentify data as addresses if the value is in the range of the binary file memory location. But that's likely hard to avoid.

Ghidra is fine. I'd say give it a shot. Maybe you have to bodge the plugin version to get it to load in the latest release, given it's not actively maintained. But that's not a deal breaker.
copse is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ghidra for amiga disassembling copse Coders. General 29 02 June 2024 22:38
New Ghidra Amiga extension released Bartman News 0 08 September 2022 15:43
Ghidra disassembler / decompiler supports 68000 mark_k Coders. Asm / Hardware 21 20 March 2019 12:09
Speed issue 3.3.0 compared 3.2.2 bladecgn support.WinUAE 6 13 August 2016 11:30
Amiga security compared to other OS matthey Amiga scene 114 21 April 2015 08:30

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:52.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10285 seconds with 15 queries