1 #ifndef ROSE_BinaryAnalysis_Concolic_I386Linux_Architecture_H
2 #define ROSE_BinaryAnalysis_Concolic_I386Linux_Architecture_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_CONCOLIC_TESTING
6 #include <Rose/BinaryAnalysis/Concolic/Architecture.h>
7 #include <Rose/BinaryAnalysis/Concolic/ExecutionEvent.h>
8 #include <Rose/BinaryAnalysis/Concolic/SharedMemory.h>
9 #include <Rose/BinaryAnalysis/Concolic/SystemCall.h>
10 #include <Rose/Yaml.h>
12 #include <boost/filesystem.hpp>
13 #include <Sawyer/Callbacks.h>
16 namespace BinaryAnalysis {
26 using Super = Concolic::Architecture;
30 using Ptr = ArchitecturePtr;
33 bool markingArgvAsInput_ =
true;
34 bool markingEnvpAsInput_ =
false;
51 static Ptr instance(
const DatabasePtr&, TestCaseId,
const Yaml::Node &config);
52 static Ptr instance(
const DatabasePtr&,
const TestCasePtr&,
const Yaml::Node &config);
57 Debugger::LinuxPtr debugger()
const;
60 RegisterDescriptor systemCallReturnRegister();
64 virtual bool matchFactory(
const Yaml::Node&)
const override;
65 virtual Super::Ptr instanceFromFactory(
const DatabasePtr&, TestCaseId,
const Yaml::Node &config)
const override;
67 virtual void configureSystemCalls()
override;
68 virtual void configureSharedMemory(
const Yaml::Node &config)
override;
69 virtual void load(
const boost::filesystem::path&)
override;
70 virtual ByteOrder::Endianness memoryByteOrder()
override;
71 virtual std::vector<ExecutionEventPtr> createMemoryRestoreEvents()
override;
72 virtual std::vector<ExecutionEventPtr> createMemoryHashEvents()
override;
73 virtual std::vector<ExecutionEventPtr> createMemoryAdjustEvents(
const MemoryMap::Ptr&, rose_addr_t insnVa)
override;
74 virtual bool playEvent(
const ExecutionEventPtr&)
override;
75 virtual void mapMemory(
const AddressInterval&,
unsigned permissions)
override;
87 void mapScratchPage();
95 std::vector<MemoryMap::ProcessMapRecord> disposableMemory();
98 void unmapAllMemory();
130 class SyscallBase:
public SyscallCallback {
131 ExecutionEventPtr latestReturnEvent_;
132 ExecutionEventPtr penultimateReturnEvent_;
136 virtual ~SyscallBase();
143 void hello(
const std::string &name,
const SyscallContext&)
const;
150 virtual void playback(SyscallContext&) = 0;
169 virtual void handlePreSyscall(SyscallContext&) {}
170 virtual void handlePostSyscall(SyscallContext&) = 0;
187 ExecutionEventPtr latestReturnEvent()
const;
188 ExecutionEventPtr penultimateReturnEvent()
const;
195 void showRecentReturnValues(std::ostream&,
const SyscallContext&)
const;
202 SymbolicExpressionPtr penultimateSymbolicReturn()
const;
206 virtual bool operator()(
bool , SyscallContext&) override final;
214 class SyscallUnimplemented: public SyscallBase {
216 SyscallUnimplemented();
218 ~SyscallUnimplemented();
222 static Ptr instance();
224 void playback(SyscallContext&)
override;
225 void handlePostSyscall(SyscallContext&)
override;
232 class SyscallReturnsInput:
public SyscallBase {
234 SyscallReturnsInput();
236 ~SyscallReturnsInput();
240 static Ptr instance();
242 void playback(SyscallContext&)
override;
243 void handlePostSyscall(SyscallContext&)
override;
247 class SyscallTerminates:
public SyscallBase {
251 ~SyscallTerminates();
255 static Ptr instance();
257 void playback(SyscallContext&)
override;
258 void handlePostSyscall(SyscallContext&)
override;
264 class SyscallReturn:
public SyscallBase {
277 virtual std::pair<SymbolicExpressionPtr, Sawyer::Optional<uint64_t>> makeReturnConstraint(SyscallContext&) = 0;
280 void handlePostSyscall(SyscallContext&) override final;
288 class SyscallConstant: public SyscallReturn {
296 static Ptr instance();
298 void playback(SyscallContext&)
override;
299 std::pair<SymbolicExpressionPtr, Sawyer::Optional<uint64_t>> makeReturnConstraint(SyscallContext&)
override;
305 class SyscallNondecreasing:
public SyscallReturn {
307 SyscallNondecreasing();
309 ~SyscallNondecreasing();
313 static Ptr instance();
315 void playback(SyscallContext&)
override;
316 std::pair<SymbolicExpressionPtr, Sawyer::Optional<uint64_t>> makeReturnConstraint(SyscallContext&)
override;
320 class SyscallAccess:
public SyscallBase {
328 static Ptr instance();
330 void playback(SyscallContext&)
override;
331 void handlePostSyscall(SyscallContext&)
override;
335 class SyscallBrk:
public SyscallBase {
343 static Ptr instance();
345 void playback(SyscallContext&)
override;
346 void handlePostSyscall(SyscallContext&)
override;
350 class SyscallMmap2:
public SyscallBase {
358 static Ptr instance();
360 void playback(SyscallContext&)
override;
361 void handlePostSyscall(SyscallContext&)
override;
365 class SyscallOpenat:
public SyscallBase {
373 static Ptr instance();
375 void playback(SyscallContext&)
override;
376 void handlePostSyscall(SyscallContext&)
override;
SmtSolverPtr Ptr
Reference counting pointer for SMT solvers.
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
Main namespace for the ROSE library.
boost::shared_ptr< Dispatcher > DispatcherPtr
Shared-ownership pointer to a semantics instruction dispatcher.
MemoryMapPtr Ptr
Reference counting pointer.
Sawyer::SharedPointer< Partitioner > PartitionerPtr
Shared-ownership pointer for Partitioner.
ROSE_DLL_API void load(SgProject *project, std::list< std::string > const &filepaths)
Load ASTs that have been saved to files.
Sawyer::SharedPointer< const Partitioner > PartitionerConstPtr
Shared-ownership pointer for Partitioner.
const char * Architecture(int64_t)
Convert Rose::BinaryAnalysis::Disassembler::Mips::Decoder::Architecture enum constant to a string...
Sawyer::SharedPointer< Engine > EnginePtr
Shared-ownership pointer for Engine.
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.
Range of values delimited by endpoints.
Sawyer::SharedPointer< Node > Ptr
Reference counting pointer.