mirror of
https://github.com/lifting-bits/remill
synced 2026-06-21 13:56:07 +00:00
Mirror Sleigh's Byte-width Flags (#668)
* add sleigh state * remove bad include * add volatile * dont run tests in docker deploys * remove ccache * Revert "remove ccache" This reverts commit221b70a1bc. * Revert "dont run tests in docker deploys" This reverts commit72229acd6e. * disable packaging in dockerfile * fix block packagingA * fix syntax
This commit is contained in:
+2
-1
@@ -36,7 +36,8 @@ RUN git config --global user.email "41898282+github-actions[bot]@users.noreply.g
|
||||
RUN ./scripts/build.sh \
|
||||
--llvm-version ${LLVM_VERSION} \
|
||||
--prefix /opt/trailofbits \
|
||||
--extra-cmake-args "-DCMAKE_BUILD_TYPE=Release"
|
||||
--extra-cmake-args "-DCMAKE_BUILD_TYPE=Release" \
|
||||
--disable-package
|
||||
|
||||
RUN pip3 install ./scripts/diff_tester_export_insns
|
||||
|
||||
|
||||
@@ -279,6 +279,31 @@ struct alignas(16) SIMD {
|
||||
|
||||
static_assert(512 == sizeof(SIMD), "Invalid packing of `struct SIMD`.");
|
||||
|
||||
struct alignas(8) SleighFlagState {
|
||||
uint8_t NG;
|
||||
volatile uint8_t _1;
|
||||
uint8_t ZR;
|
||||
volatile uint8_t _2;
|
||||
uint8_t CY;
|
||||
volatile uint8_t _3;
|
||||
uint8_t OV;
|
||||
volatile uint8_t _4;
|
||||
uint8_t shift_carry;
|
||||
volatile uint8_t _5;
|
||||
uint8_t tmpCY;
|
||||
volatile uint8_t _6;
|
||||
uint8_t tmpOV;
|
||||
volatile uint8_t _7;
|
||||
uint8_t tmpNG;
|
||||
volatile uint8_t _8;
|
||||
uint8_t tmpZR;
|
||||
volatile uint8_t _9;
|
||||
uint8_t padding[6];
|
||||
} __attribute__((packed));
|
||||
|
||||
static_assert(24 == sizeof(SleighFlagState),
|
||||
"Invalid packing of `struct SleighFlagState`.");
|
||||
|
||||
struct alignas(16) AArch64State : public ArchState {
|
||||
SIMD simd; // 512 bytes.
|
||||
|
||||
@@ -298,9 +323,13 @@ struct alignas(16) AArch64State : public ArchState {
|
||||
|
||||
uint64_t _3;
|
||||
|
||||
SleighFlagState sleigh_flags;
|
||||
|
||||
uint8_t padding[8];
|
||||
|
||||
} __attribute__((packed));
|
||||
|
||||
static_assert((1152 + 16) == sizeof(AArch64State),
|
||||
static_assert((1152 + 16 + 24 + 8) == sizeof(AArch64State),
|
||||
"Invalid packing of `struct State`");
|
||||
|
||||
struct State : public AArch64State {};
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "remill/Arch/AArch64/AArch64Base.h"
|
||||
#include "remill/Arch/Instruction.h"
|
||||
#include "remill/Arch/Name.h"
|
||||
#include "remill/BC/ABI.h"
|
||||
@@ -24,8 +25,7 @@ namespace remill {
|
||||
// TODO(Ian): support different arm versions
|
||||
SleighAArch64Decoder::SleighAArch64Decoder(const remill::Arch &arch)
|
||||
: SleighDecoder(arch, "AARCH64.sla", "AARCH64.pspec",
|
||||
sleigh::ContextRegMappings({}, {}),
|
||||
{{"CY", "C"}, {"NG", "N"}, {"ZR", "Z"}, {"OV", "V"}}) {}
|
||||
sleigh::ContextRegMappings({}, {}), {}) {}
|
||||
|
||||
|
||||
void SleighAArch64Decoder::InitializeSleighContext(
|
||||
@@ -76,6 +76,32 @@ DecodingContext AArch64Arch::CreateInitialContext(void) const {
|
||||
return DecodingContext();
|
||||
}
|
||||
|
||||
void AArch64Arch::PopulateRegisterTable(void) const {
|
||||
AArch64ArchBase::PopulateRegisterTable();
|
||||
|
||||
#define OFFSET_OF(type, access) \
|
||||
(reinterpret_cast<uintptr_t>(&reinterpret_cast<const volatile char &>( \
|
||||
static_cast<type *>(nullptr)->access)))
|
||||
|
||||
#define REG(name, access, type) \
|
||||
AddRegister(#name, type, OFFSET_OF(AArch64State, access), nullptr)
|
||||
|
||||
#define SUB_REG(name, access, type, parent_reg_name) \
|
||||
AddRegister(#name, type, OFFSET_OF(AArch64State, access), #parent_reg_name)
|
||||
|
||||
auto u8 = llvm::Type::getInt8Ty(*context);
|
||||
|
||||
REG(NG, sleigh_flags.NG, u8);
|
||||
REG(ZR, sleigh_flags.ZR, u8);
|
||||
REG(CY, sleigh_flags.CY, u8);
|
||||
REG(OV, sleigh_flags.OV, u8);
|
||||
REG(SHIFT_CARRY, sleigh_flags.shift_carry, u8);
|
||||
REG(TMPCY, sleigh_flags.tmpCY, u8);
|
||||
REG(TMPOV, sleigh_flags.tmpOV, u8);
|
||||
REG(TMPZR, sleigh_flags.tmpZR, u8);
|
||||
REG(TMPNG, sleigh_flags.tmpNG, u8);
|
||||
}
|
||||
|
||||
|
||||
// TODO(pag): We pretend that these are singletons, but they aren't really!
|
||||
Arch::ArchPtr Arch::GetAArch64Sleigh(llvm::LLVMContext *context_,
|
||||
|
||||
@@ -27,6 +27,8 @@ class AArch64Arch final : public AArch64ArchBase {
|
||||
virtual ~AArch64Arch(void);
|
||||
|
||||
|
||||
void PopulateRegisterTable(void) const override;
|
||||
|
||||
virtual DecodingContext CreateInitialContext(void) const override;
|
||||
|
||||
bool DecodeInstruction(uint64_t address, std::string_view instr_bytes,
|
||||
|
||||
+16
-4
@@ -28,6 +28,7 @@ OS_VERSION=
|
||||
ARCH_VERSION=
|
||||
BUILD_FLAGS=
|
||||
CXX_COMMON_VERSION="0.3.1"
|
||||
CREATE_PACKAGES=true
|
||||
|
||||
# There are pre-build versions of various libraries for specific
|
||||
# Ubuntu releases.
|
||||
@@ -275,9 +276,12 @@ function Package
|
||||
cmake --build . \
|
||||
--target install
|
||||
|
||||
cpack -D REMILL_DATA_PATH="${DESTDIR}" \
|
||||
-R ${remill_version} \
|
||||
--config "${SRC_DIR}/packaging/main.cmake"
|
||||
|
||||
if [ "$CREATE_PACKAGES" = true ]; then
|
||||
cpack -D REMILL_DATA_PATH="${DESTDIR}" \
|
||||
-R ${remill_version} \
|
||||
--config "${SRC_DIR}/packaging/main.cmake"
|
||||
fi
|
||||
) || return $?
|
||||
|
||||
return $?
|
||||
@@ -366,6 +370,14 @@ function main
|
||||
shift # past argument
|
||||
;;
|
||||
|
||||
# Disable packages
|
||||
--disable-package)
|
||||
CREATE_PACKAGES=false
|
||||
echo "[+] Disabled building packages"
|
||||
shift # past argument
|
||||
;;
|
||||
|
||||
|
||||
# Make the build type to be a debug build.
|
||||
--debug)
|
||||
BUILD_FLAGS="${BUILD_FLAGS} -DCMAKE_BUILD_TYPE=Debug"
|
||||
@@ -407,7 +419,7 @@ function main
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
cd "${BUILD_DIR}" || exit 1
|
||||
|
||||
if ! (DownloadLibraries && Configure && Build && Package); then
|
||||
if ! (DownloadLibraries && Configure && Build && Package ); then
|
||||
echo "[x] Build aborted."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user