logic / sh2dis

An SH2-compatible (Renesas SuperH) disassembler.
http://code.logic.net/sh2dis/
23 stars 4 forks source link

SH7055 segment 0xffffe000 missing ? #6

Closed smooker closed 5 years ago

smooker commented 5 years ago
[smooker@smoolap ~/Documents/VOLVO/DUMPS/ORIG]$ sh2dis -m -r ./icm.bin 
Traceback (most recent call last):
  File "/usr/local/bin/sh2dis", line 11, in <module>
    load_entry_point('sh2dis==1.0', 'console_scripts', 'sh2dis')()
  File "build/bdist.linux-x86_64/egg/sh2dis/__main__.py", line 163, in main
  File "build/bdist.linux-x86_64/egg/sh2dis/__main__.py", line 53, in setup_vectors
  File "build/bdist.linux-x86_64/egg/sh2dis/segment.py", line 295, in get_label
  File "build/bdist.linux-x86_64/egg/sh2dis/segment.py", line 260, in __lookup_segment
sh2dis.segment.SegmentError: invalid segment address: 0xffffe000
logic commented 5 years ago

(Apologies for the late reply, I was on an extended vacation, and then catching up from vacation.)

There's not a lot of information for me to go on here (specifically, you didn't say anything about the ROM you're working with, like where it came from, what memory layout it's using, etc), which means I can't really give you any concrete help.

The error you're getting is intentional, although I'll admit it's somewhat obtuse; your ROM (in the interrupt vector table, from the looks of things) is referencing an address that's not in one of the defined address space segments. (Think "illegal memory access" errors in typical programming, and you have the right idea.) It's there as a check to make sure the disassembler is doing the right thing; if you start accessing memory in places it shouldn't be, it's a good bet that something has gone horribly wrong.

My best guess is that the ROM you're disassembling either is in a different format than sh2dis is expecting, or needs a different segment map defined for it. If it's the former, there's probably not much I can do; you'd need someone with more expertise with your particular ROM format to weigh in here (is it a single flat segment or split into multiple sections? where is the interrupt table? where are the registers? where is the RAM? etc).

If it's a question of the segment map being incorrect for your ROM, I've added basic maps for the SH7052 and SH7055 platforms, but every vendor will likely do something different here, based on flash/RAM they've added to the board. See get_segments in __main__.py to get an idea of the really rudimentary logic I used to switch between the two; you'll want to add a heuristic there to identify your ROM and lay out the memory space appropriately.

If you don't know what your platform's memory space looks like (which wouldn't be surprising, if you're reverse-engineering it from scratch), one easy thing to try would be to add an appropriately-sized ROM segment, ditch the register segment (REG) entirely, and expand the RAM segment out to 0xFFFFFFFF (the maximum). (You might have to define a dummy REG segment at some ridiculous location to make things happy, it's been a while since I needed to play with this.)

And, if none of this made any sense, I'm going to go out on a limb and say you're probably not going to get anywhere with sh2dis, and might want to look into something else (like IDA Pro).

Anyway, I'm going to close this, since this sh2dis is actually working as intended here. Best of luck!