Fixing alloy-sandbox.
This commit is contained in:
parent
c9d71486b0
commit
9b76d02f26
|
@ -37,7 +37,11 @@ using alloy::runtime::FunctionInfo;
|
||||||
X64Assembler::X64Assembler(X64Backend* backend)
|
X64Assembler::X64Assembler(X64Backend* backend)
|
||||||
: Assembler(backend), x64_backend_(backend) {}
|
: Assembler(backend), x64_backend_(backend) {}
|
||||||
|
|
||||||
X64Assembler::~X64Assembler() = default;
|
X64Assembler::~X64Assembler() {
|
||||||
|
// Emitter must be freed before the allocator.
|
||||||
|
emitter_.reset();
|
||||||
|
allocator_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
int X64Assembler::Initialize() {
|
int X64Assembler::Initialize() {
|
||||||
int result = Assembler::Initialize();
|
int result = Assembler::Initialize();
|
||||||
|
|
|
@ -26,10 +26,10 @@ using alloy::runtime::Runtime;
|
||||||
|
|
||||||
class ThreadState : public alloy::runtime::ThreadState {
|
class ThreadState : public alloy::runtime::ThreadState {
|
||||||
public:
|
public:
|
||||||
ThreadState(Runtime* runtime, uint32_t thread_id, size_t stack_size,
|
ThreadState(Runtime* runtime, uint32_t thread_id, uint64_t stack_address,
|
||||||
uint64_t thread_state_address, uint64_t thread_stack_address)
|
size_t stack_size, uint64_t thread_state_address)
|
||||||
: alloy::runtime::ThreadState(runtime, thread_id),
|
: alloy::runtime::ThreadState(runtime, thread_id),
|
||||||
stack_address_(thread_stack_address),
|
stack_address_(stack_address),
|
||||||
stack_size_(stack_size),
|
stack_size_(stack_size),
|
||||||
thread_state_address_(thread_state_address) {
|
thread_state_address_(thread_state_address) {
|
||||||
memset(memory_->Translate(stack_address_), 0, stack_size_);
|
memset(memory_->Translate(stack_address_), 0, stack_size_);
|
||||||
|
@ -87,10 +87,10 @@ int main(std::vector<std::wstring>& args) {
|
||||||
auto frontend =
|
auto frontend =
|
||||||
std::make_unique<alloy::frontend::ppc::PPCFrontend>(runtime.get());
|
std::make_unique<alloy::frontend::ppc::PPCFrontend>(runtime.get());
|
||||||
std::unique_ptr<alloy::backend::Backend> backend;
|
std::unique_ptr<alloy::backend::Backend> backend;
|
||||||
// auto backend =
|
// backend =
|
||||||
// std::make_unique<alloy::backend::ivm::IVMBackend>(runtime.get());
|
// std::make_unique<alloy::backend::ivm::IVMBackend>(runtime.get());
|
||||||
// auto backend =
|
// backend =
|
||||||
// std::make_unique<alloy::backend::x64::X64Backend>(runtime.get());
|
// std::make_unique<alloy::backend::x64::X64Backend>(runtime.get());
|
||||||
runtime->Initialize(std::move(frontend), std::move(backend));
|
runtime->Initialize(std::move(frontend), std::move(backend));
|
||||||
|
|
||||||
auto module = std::make_unique<alloy::runtime::RawModule>(runtime.get());
|
auto module = std::make_unique<alloy::runtime::RawModule>(runtime.get());
|
||||||
|
@ -98,9 +98,9 @@ int main(std::vector<std::wstring>& args) {
|
||||||
runtime->AddModule(std::move(module));
|
runtime->AddModule(std::move(module));
|
||||||
|
|
||||||
{
|
{
|
||||||
uint64_t thread_state_address = 0;
|
|
||||||
uint64_t stack_address = memory_size - 1024;
|
|
||||||
uint64_t stack_size = 64 * 1024;
|
uint64_t stack_size = 64 * 1024;
|
||||||
|
uint64_t stack_address = memory_size - stack_size;
|
||||||
|
uint64_t thread_state_address = stack_address - 0x1000;
|
||||||
auto thread_state = std::make_unique<ThreadState>(
|
auto thread_state = std::make_unique<ThreadState>(
|
||||||
runtime.get(), 100, stack_address, stack_size, thread_state_address);
|
runtime.get(), 100, stack_address, stack_size, thread_state_address);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue