Skip to content

Commit 6be7bbb

Browse files
author
Axel Tillequin
committed
Squashed commit of the following:
* x86: add support for real mode execution * x86: add full support for segmentation/paging * add baremetal-x86 system for bios firmware analysis * merge new arch.io module to define IOs' stubs * merge cas.blobs module * add fast versions of rep stos/lods/scas/movs * add tracepoint method in emul class * add support for PE resources * improve amoco app load/emul commands * add set,display,nexti,until in emul ui.
1 parent f4081db commit 6be7bbb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+2773
-490
lines changed

README.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,14 @@ User documentation and API can be found at
5757
Todo
5858
====
5959

60-
Some components of Amoco are still in the
60+
Some components of amoco are still in the
6161
process of being pushed to the release branch or further developed.
6262
More precisely:
6363

6464
- x86 fpu instructions semantics are not implemented,
6565
- arm SIMD, VFP, NEON, TrustZone, Jazelle instruction sets are not implemented,
6666
- some solver-based disassembling strategies are not merged yet.
6767
- idb import/export features are not implemented.
68-
- 6502 and PPC archs are planned.
6968

7069
Contributions to fulfill uncomplete/unimplemented parts are welcome.
7170

@@ -88,6 +87,19 @@ Please see `LICENSE`_.
8887
Changelog
8988
=========
9089

90+
- `v2.9.10`_
91+
92+
* x86: add support for real mode execution
93+
* x86: add full support for segmentation/paging
94+
* add baremetal-x86 system for bios firmware analysis
95+
* merge new arch.io module to define IOs' stubs
96+
* merge cas.blobs module
97+
* add fast versions of rep stos/lods/scas/movs
98+
* add tracepoint method in emul class
99+
* add support for PE resources
100+
* improve amoco app load/emul commands
101+
* add set,display,nexti,until in emul ui.
102+
91103
- `v2.9.9`_
92104

93105
* add ppc32 (e200) architecture
@@ -397,6 +409,7 @@ Changelog
397409
.. _sqlalchemy: http://www.sqlalchemy.org
398410
.. _QDarkStyleSheet: https://github.com/ColinDuquesnoy/QDarkStyleSheet
399411
.. _LICENSE: https://github.com/bdcht/amoco/blob/release/LICENSE
412+
.. _v2.9.10: https://github.com/bdcht/amoco/releases/tag/v2.9.10
400413
.. _v2.9.9: https://github.com/bdcht/amoco/releases/tag/v2.9.9
401414
.. _v2.9.8: https://github.com/bdcht/amoco/releases/tag/v2.9.8
402415
.. _v2.9.7: https://github.com/bdcht/amoco/releases/tag/v2.9.7

amoco/arch/arm/cpu_armv7.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
disassemble = disassembler([spec_armv7, spec_thumb], instruction_armv7, mode, endian)
3030

3131

32-
def PC():
32+
def PC(state=None):
3333
return pc_
3434

3535

amoco/arch/arm/cpu_armv8.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
disassemble = disassembler([spec_armv8], endian=endian, iclass=instruction_armv8)
2626

2727

28-
def PC():
28+
def PC(state=None):
2929
return pc
3030

3131

amoco/arch/avr/cpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
disassemble = disassembler([spec], iclass=instruction_avr)
2222

2323

24-
def PC():
24+
def PC(state=None):
2525
return pc
2626

2727

amoco/arch/avr/env.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -81,30 +81,30 @@
8181
EEPM1 = slc(EECR,5, 1, "EEPM1") # 10=WriteOnly 11:Reserved
8282

8383
vectors = [
84-
ext("RESET",8),
85-
ext("INT0",8),
86-
ext("INT1",8),
87-
ext("PCINT0",8),
88-
ext("PCINT1",8),
89-
ext("PCINT2",8),
90-
ext("WDT",8),
91-
ext("TIMER2_COMPA",8),
92-
ext("TIMER2_COMPB",8),
93-
ext("TIMER2_OVF",8),
94-
ext("TIMER1_CAPT",8),
95-
ext("TIMER1_COMPA",8),
96-
ext("TIMER1_COMPB",8),
97-
ext("TIMER1_OVF",8),
98-
ext("TIMER0_COMPA",8),
99-
ext("TIMER0_COMPB",8),
100-
ext("TIMER0_OVF",8),
101-
ext("SPI_STC",8),
102-
ext("USART_RX",8),
103-
ext("USART_UDRE",8),
104-
ext("USART_TX",8),
105-
ext("ADC",8),
106-
ext("EE_READY",8),
107-
ext("ANALOG_COMP",8),
108-
ext("TWI",8),
109-
ext("SPM_READY",8),
84+
ext("RESET",size=8),
85+
ext("INT0",size=8),
86+
ext("INT1",size=8),
87+
ext("PCINT0",size=8),
88+
ext("PCINT1",size=8),
89+
ext("PCINT2",size=8),
90+
ext("WDT",size=8),
91+
ext("TIMER2_COMPA",size=8),
92+
ext("TIMER2_COMPB",size=8),
93+
ext("TIMER2_OVF",size=8),
94+
ext("TIMER1_CAPT",size=8),
95+
ext("TIMER1_COMPA",size=8),
96+
ext("TIMER1_COMPB",size=8),
97+
ext("TIMER1_OVF",size=8),
98+
ext("TIMER0_COMPA",size=8),
99+
ext("TIMER0_COMPB",size=8),
100+
ext("TIMER0_OVF",size=8),
101+
ext("SPI_STC",size=8),
102+
ext("USART_RX",size=8),
103+
ext("USART_UDRE",size=8),
104+
ext("USART_TX",size=8),
105+
ext("ADC",size=8),
106+
ext("EE_READY",size=8),
107+
ext("ANALOG_COMP",size=8),
108+
ext("TWI",size=8),
109+
ext("SPM_READY",size=8),
110110
]

amoco/arch/dwarf/cpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
disassemble.maxlen = 21
2222

2323

24-
def PC():
24+
def PC(state=None):
2525
return op_ptr
2626

2727

amoco/arch/eBPF/cpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
disassemble = disassembler([spec], iclass=instruction_eBPF)
2222

2323

24-
def PC():
24+
def PC(state=None):
2525
return pc
2626

2727

amoco/arch/eBPF/cpu_bpf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
disassemble = disassembler([spec_bpf], iclass=instruction_BPF)
2323

2424

25-
def PC():
25+
def PC(state=None):
2626
return pc
2727

2828

amoco/arch/io.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from amoco.cas.expressions import top
2+
from types import MethodType
3+
from amoco.logger import Log
4+
5+
logger = Log(__name__)
6+
logger.debug("loading module")
7+
8+
class DefineIO:
9+
10+
def __init__(self,port,name=None):
11+
self.io = IO(port,name)
12+
13+
def __enter__(self):
14+
return self
15+
16+
def __exit__(self, exc_type, exc_value, traceback):
17+
IO.ports[self.io.port] = self.io
18+
19+
def In(self, func):
20+
self.io.In = MethodType(func,self.io)
21+
return func
22+
23+
def Out(self, func):
24+
self.io.Out = MethodType(func,self.io)
25+
return func
26+
27+
class IO:
28+
ports = {}
29+
@classmethod
30+
def get_port(cls,port):
31+
return cls.ports.get(port,cls(port))
32+
33+
def __init__(self,port,name=None):
34+
self.port = port
35+
self.name = name or "IO#0x%x"%port
36+
def In(self,env,dl):
37+
logger.warning("undefined %s IN"%str(self))
38+
return top(dl*8)
39+
def Out(self,env,src):
40+
logger.warning("undefined %s OUT (%s)"%(str(self),src))
41+
def __str__(self):
42+
return self.name

amoco/arch/mips/cpu_r3000.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
disassemble = disassembler([spec], iclass=instruction_r3000,endian=endian)
2525

2626

27-
def PC():
27+
def PC(state=None):
2828
return pc
2929

3030
def get_data_endian():

amoco/arch/mips/cpu_r3000LE.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
disassemble = disassembler([spec], iclass=instruction_r3000)
2323

2424

25-
def PC():
25+
def PC(state=None):
2626
return pc
2727

2828

amoco/arch/msp430/cpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
disassemble.maxlen = 6
2424

2525

26-
def PC():
26+
def PC(state=None):
2727
return pc
2828

2929

amoco/arch/pic/cpu_pic18f46k22.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
disassemble = disassembler([spec_pic18], iclass=instruction_f46k22)
2222

2323

24-
def PC():
24+
def PC(state=None):
2525
return pc
2626

2727

amoco/arch/ppc32/cpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
disassemble = disassembler([spec], iclass=instruction_ppc32,endian=endian)
2424

2525

26-
def PC():
26+
def PC(state=None):
2727
return pc
2828

2929
def get_data_endian():

amoco/arch/ppc32/cpu_e200.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
disassemble = disassembler([spec_vle], iclass=instruction_e200,endian=endian)
2424

2525

26-
def PC():
26+
def PC(state=None):
2727
return pc
2828

2929
def get_data_endian():

amoco/arch/ppc32/e200/spec_e200.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88

99
# import generic PowerPC ISA (book E):
1010

11-
from amoco.arch.ppc32.spec import *
11+
from amoco.arch.ppc32.spec_booke import *
1212

amoco/arch/riscv/cpu_rv32i.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
disassemble = disassembler([spec_rv32i], iclass=instruction_riscv)
2323

2424

25-
def PC():
25+
def PC(state=None):
2626
return pc
2727

2828

amoco/arch/riscv/cpu_rv64i.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
disassemble = disassembler([spec_rv64i], iclass=instruction_riscv64)
2323

2424

25-
def PC():
25+
def PC(state=None):
2626
return pc
2727

2828

amoco/arch/sparc/cpu_v8.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
disassemble = disassembler([spec_v8], endian=lambda: -1, iclass=instruction_sparc)
2323

2424

25-
def PC():
25+
def PC(state=None):
2626
return pc
2727

2828

amoco/arch/superh/cpu_sh2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
disassemble = disassembler([spec_sh2], endian=lambda: -1, iclass=instruction_sh2)
2222

2323

24-
def PC():
24+
def PC(state=None):
2525
return pc
2626

2727

amoco/arch/superh/cpu_sh4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
disassemble = disassembler([spec_sh4], endian=lambda: -1, iclass=instruction_sh4)
2323

2424

25-
def PC():
25+
def PC(state=None):
2626
return pc

amoco/arch/tricore/cpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
disassemble = disassembler([spec], iclass=instruction_tricore)
2222

2323

24-
def PC():
24+
def PC(state=None):
2525
return pc
2626

2727

amoco/arch/v850/asm.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ def i_HSW(i, fmap):
477477
@_pc
478478
def i_SHR(i, fmap):
479479
shift, src = i.operands[0:2]
480+
dst = None
480481
if len(i.operands) == 3:
481482
dst = i.operands[2]
482483
if shift._is_reg:
@@ -490,12 +491,14 @@ def i_SHR(i, fmap):
490491
fmap[Z] = r == 0
491492
fmap[S] = r.bit(r.size - 1)
492493
fmap[OV] = bit0
493-
fmap[dst] = x
494+
if dst is not None:
495+
fmap[dst] = x
494496

495497

496498
@_pc
497499
def i_SHL(i, fmap):
498500
shift, src = i.operands[0:2]
501+
dst = None
499502
if len(i.operands) == 3:
500503
dst = i.operands[2]
501504
if shift._is_reg:
@@ -509,7 +512,8 @@ def i_SHL(i, fmap):
509512
fmap[Z] = r == 0
510513
fmap[S] = r.bit(r.size - 1)
511514
fmap[OV] = bit0
512-
fmap[dst] = x
515+
if dst is not None:
516+
fmap[dst] = x
513517

514518

515519
# conditionals :

amoco/arch/v850/cpu_v850e2s.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
disassemble = disassembler([spec], iclass=instruction_v850)
2222

2323

24-
def PC():
24+
def PC(state=None):
2525
return pc
2626

2727

amoco/arch/w65c02/cpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
disassemble = disassembler([spec], iclass=instruction_w65c02)
2222

2323

24-
def PC():
24+
def PC(state=None):
2525
return pc
2626

2727

amoco/arch/wasm/cpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
disassemble.maxlen = 16
2828

2929

30-
def PC():
30+
def PC(state=None):
3131
return op_ptr
3232

3333

amoco/arch/x64/cpu_x64.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
disassemble.maxlen = 15
2020

2121

22-
def PC():
23-
return rip
22+
def PC(state=None):
23+
return rip if state is None else state(ptr(rip,seg=cs))
2424

2525

2626
def get_data_endian():

0 commit comments

Comments
 (0)