mirror of
https://github.com/lifting-bits/remill
synced 2026-06-21 13:56:07 +00:00
bef332fd2a
* Added in more aarch64 instructions. Fixed some x86 instructions. The x86 test cases now exercise each test through every possible combination of flags. * Adding missing files * Another missing file * Rename file * Fixup some macros * IPR * More improvements on the test runner * Test runner fixes related to me not being familiar with aarch64 assembly * Fixing default data layout * Trying to use llc to compile bitcode to aarch64 assembly. wth. * Revert back to using the CMAKE_BC_COMPILER for building the test assembly file instead of the whole CMAKE_LL_COMPILER stuff, now that I've adjusted cxx-common to use the right build target for aarch64. * Documentation updates. Fixes for aarch64. * Making progress. The native tests can run, but the first lifted test faults. Not yet sure why. * Weirdest issue is happening on aarch64. A pointer argument is being compiled to an integer, and that's really screwing things up. * Add caching of the libraries path to the main cmakelists to avoid having to re-run build.sh all the time when the TRAILOBITS_LIBRARIES env var is not globally defined. Experimenting with trying to force the semantics to be compiled using the x86_64 target, regardless of host arch, or modelled arch of the semantics. This is to try to get around the issue where a single-element struct containing a pointer is lowered into a uintptr_t when passed by value as an argument on aarch64. * Alright, falling back on handling this problem in the lifter (for now, at least). Really not ideal. * Test runner works afaict
100 lines
3.8 KiB
C++
100 lines
3.8 KiB
C++
/*
|
|
* Copyright (c) 2017 Trail of Bits, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* dildributed under the License is dildributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include <cstddef>
|
|
#include <cstdio>
|
|
|
|
#define ADDRESS_SIZE_BITS 64
|
|
|
|
#include "remill/Arch/AArch64/Runtime/State.h"
|
|
|
|
int main(void) {
|
|
|
|
printf("/* Auto-generated file! Don't modify! */\n\n");
|
|
|
|
// Build up the `nzcv` bits from the `State` structure.
|
|
printf("mov x2, #0\n");
|
|
|
|
printf("ldrb w1, [x28, #%lu]\n", offsetof(State, sr.n));
|
|
printf("orr x2, x2, x1, LSL 31\n");
|
|
|
|
printf("ldrb w1, [x28, #%lu]\n", offsetof(State, sr.z));
|
|
printf("orr x2, x2, x1, LSL 30\n");
|
|
|
|
printf("ldrb w1, [x28, #%lu]\n", offsetof(State, sr.c));
|
|
printf("orr x2, x2, x1, LSL 29\n");
|
|
|
|
printf("ldrb w1, [x28, #%lu]\n", offsetof(State, sr.v));
|
|
printf("orr x2, x2, x1, LSL 28\n");
|
|
|
|
// Sync `nzcv` between native and lifted.
|
|
printf("str x2, [x28, #%lu]\n", offsetof(State, nzcv));
|
|
printf("msr nzcv, x2\n");
|
|
|
|
// Floating point condition register.
|
|
printf("ldr x1, [x28, #%lu]\n", offsetof(State, fpcr));
|
|
printf("msr fpcr, x1\n");
|
|
|
|
// Floating point status register.
|
|
printf("ldr x1, [x28, #%lu]\n", offsetof(State, fpsr));
|
|
printf("msr fpsr, x1\n");
|
|
|
|
// User-space thread pointer register.
|
|
printf("ldr x1, [x28, #%lu]\n", offsetof(State, sr.tpidr_el0));
|
|
printf("msr tpidr_el0, x1\n");
|
|
|
|
// Secondary user space thread pointer register is read-only.
|
|
|
|
// General purpose regs (except x28, which contains State *).
|
|
printf("ldr x0, [x28, #%lu]\n", offsetof(State, gpr.x0));
|
|
printf("ldr x1, [x28, #%lu]\n", offsetof(State, gpr.x1));
|
|
printf("ldr x2, [x28, #%lu]\n", offsetof(State, gpr.x2));
|
|
printf("ldr x3, [x28, #%lu]\n", offsetof(State, gpr.x3));
|
|
printf("ldr x4, [x28, #%lu]\n", offsetof(State, gpr.x4));
|
|
printf("ldr x5, [x28, #%lu]\n", offsetof(State, gpr.x5));
|
|
printf("ldr x6, [x28, #%lu]\n", offsetof(State, gpr.x6));
|
|
printf("ldr x7, [x28, #%lu]\n", offsetof(State, gpr.x7));
|
|
printf("ldr x8, [x28, #%lu]\n", offsetof(State, gpr.x8));
|
|
printf("ldr x9, [x28, #%lu]\n", offsetof(State, gpr.x9));
|
|
printf("ldr x10, [x28, #%lu]\n", offsetof(State, gpr.x10));
|
|
printf("ldr x11, [x28, #%lu]\n", offsetof(State, gpr.x11));
|
|
printf("ldr x12, [x28, #%lu]\n", offsetof(State, gpr.x12));
|
|
printf("ldr x13, [x28, #%lu]\n", offsetof(State, gpr.x13));
|
|
printf("ldr x14, [x28, #%lu]\n", offsetof(State, gpr.x14));
|
|
printf("ldr x15, [x28, #%lu]\n", offsetof(State, gpr.x15));
|
|
printf("ldr x16, [x28, #%lu]\n", offsetof(State, gpr.x16));
|
|
printf("ldr x17, [x28, #%lu]\n", offsetof(State, gpr.x17));
|
|
printf("ldr x18, [x28, #%lu]\n", offsetof(State, gpr.x18));
|
|
printf("ldr x19, [x28, #%lu]\n", offsetof(State, gpr.x19));
|
|
printf("ldr x20, [x28, #%lu]\n", offsetof(State, gpr.x20));
|
|
printf("ldr x21, [x28, #%lu]\n", offsetof(State, gpr.x21));
|
|
printf("ldr x22, [x28, #%lu]\n", offsetof(State, gpr.x22));
|
|
printf("ldr x23, [x28, #%lu]\n", offsetof(State, gpr.x23));
|
|
printf("ldr x24, [x28, #%lu]\n", offsetof(State, gpr.x24));
|
|
printf("ldr x25, [x28, #%lu]\n", offsetof(State, gpr.x25));
|
|
printf("ldr x26, [x28, #%lu]\n", offsetof(State, gpr.x26));
|
|
printf("ldr x27, [x28, #%lu]\n", offsetof(State, gpr.x27));
|
|
printf("ldr x30, [x28, #%lu]\n", offsetof(State, gpr.x30));
|
|
|
|
// Restore the stack pointer.
|
|
printf("ldr x29, [x28, #%lu]\n", offsetof(State, gpr.sp));
|
|
printf("mov sp, x29\n");
|
|
|
|
printf("ldr x29, [x28, #%lu]\n", offsetof(State, gpr.x29));
|
|
|
|
return 0;
|
|
}
|