-
Notifications
You must be signed in to change notification settings - Fork 162
[RFC][Sleigh] Add base implementation for MIPS (WIP) #698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
m4xw
wants to merge
15
commits into
lifting-bits:master
Choose a base branch
from
m4xw:mips
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9876545
[Sleigh] Add base implementation for MIPS (WIP)
m4xw 67911a5
Fix for existing function references in DeclareLiftedFunction
m4xw 32e2ff1
Remove custom spec sleigh_compile
m4xw b7a1d42
Use WeakAnyLinkage for func declartions
m4xw 6eaee55
[TraceLifter] StoreProgramCounter in kCategoryDirectFunctionCall case
m4xw 5e1cb33
[MIPSArch] Format and clean unused things
m4xw 97d7429
Placeholder impl for HI/LO regs
m4xw ce1b4a1
[Lift] Pass IntrinsicTable to SimpleTraceManager and use function_cal…
m4xw f97f65a
[MIPS] Pass Arch to PCodeCFG
m4xw ebaed42
Use Arch::isMIPS instead of arch_name check
m4xw 91e0d38
[MIPS] Implement __remill_set_coprocessor_reg Intrinsic
m4xw bbb3fa5
[MIPS] Expose FCSR
m4xw 5af2876
Attempt at solving the negated CBranch Issue
m4xw cb31543
[Lift] Support for passing a file via --bytes using @file.ext syntax
m4xw f412378
[MIPS] Fix State Reg
m4xw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,278 @@ | ||
| /* | ||
| * Copyright (c) 2022-present 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 | ||
| * distributed under the License is distributed 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. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #pragma clang diagnostic push | ||
| #pragma clang diagnostic fatal "-Wpadded" | ||
|
|
||
| #include "remill/Arch/Runtime/State.h" | ||
|
|
||
| #if !defined(INCLUDED_FROM_REMILL) | ||
| # include "remill/Arch/Runtime/Types.h" | ||
| #endif | ||
|
|
||
| struct Reg final { | ||
| union { | ||
| alignas(4) uint32_t dword; | ||
| alignas(8) uint64_t qword; | ||
| } __attribute__((packed)); | ||
| } __attribute__((packed)); | ||
|
|
||
| static_assert(sizeof(uint64_t) == sizeof(Reg), "Invalid packing of `Reg`."); | ||
| static_assert(0 == __builtin_offsetof(Reg, dword), | ||
| "Invalid packing of `Reg::dword`."); | ||
|
|
||
| static_assert(0 == __builtin_offsetof(Reg, qword), | ||
| "Invalid packing of `Reg::qword`."); | ||
|
|
||
| // General Purpose Registers | ||
| struct alignas(8) GPR final { | ||
| volatile uint64_t _0; | ||
| Reg zero; | ||
| volatile uint64_t _1; | ||
| Reg at; | ||
| volatile uint64_t _2; | ||
| Reg v0; | ||
| volatile uint64_t _3; | ||
| Reg v1; | ||
| volatile uint64_t _4; | ||
| Reg a0; | ||
| volatile uint64_t _5; | ||
| Reg a1; | ||
| volatile uint64_t _6; | ||
| Reg a2; | ||
| volatile uint64_t _7; | ||
| Reg a3; | ||
| volatile uint64_t _8; | ||
| Reg t0; | ||
| volatile uint64_t _9; | ||
| Reg t1; | ||
| volatile uint64_t _10; | ||
| Reg t2; | ||
| volatile uint64_t _11; | ||
| Reg t3; | ||
| volatile uint64_t _12; | ||
| Reg t4; | ||
| volatile uint64_t _13; | ||
| Reg t5; | ||
| volatile uint64_t _14; | ||
| Reg t6; | ||
| volatile uint64_t _15; | ||
| Reg t7; | ||
| volatile uint64_t _16; | ||
| Reg s0; | ||
| volatile uint64_t _17; | ||
| Reg s1; | ||
| volatile uint64_t _18; | ||
| Reg s2; | ||
| volatile uint64_t _19; | ||
| Reg s3; | ||
| volatile uint64_t _20; | ||
| Reg s4; | ||
| volatile uint64_t _21; | ||
| Reg s5; | ||
| volatile uint64_t _22; | ||
| Reg s6; | ||
| volatile uint64_t _23; | ||
| Reg s7; | ||
| volatile uint64_t _24; | ||
| Reg t8; | ||
| volatile uint64_t _25; | ||
| Reg t9; | ||
| volatile uint64_t _26; | ||
| Reg k0; | ||
| volatile uint64_t _27; | ||
| Reg k1; | ||
| volatile uint64_t _28; | ||
| Reg gp; | ||
| volatile uint64_t _29; | ||
| Reg sp; | ||
| volatile uint64_t _30; | ||
| Reg s8; | ||
| volatile uint64_t _31; | ||
| Reg ra; | ||
| volatile uint64_t _32; | ||
| Reg pc; | ||
|
|
||
| } __attribute__((packed)); | ||
|
|
||
| static_assert(528 == sizeof(GPR), "Invalid structure packing of `GPR`."); | ||
|
|
||
| // Floating Pointer Registers | ||
| struct alignas(8) FPR final { | ||
| volatile uint64_t _0; | ||
| Reg f0; | ||
| volatile uint64_t _1; | ||
| Reg f1; | ||
| volatile uint64_t _2; | ||
| Reg f2; | ||
| volatile uint64_t _3; | ||
| Reg f3; | ||
| volatile uint64_t _4; | ||
| Reg f4; | ||
| volatile uint64_t _5; | ||
| Reg f5; | ||
| volatile uint64_t _6; | ||
| Reg f6; | ||
| volatile uint64_t _7; | ||
| Reg f7; | ||
| volatile uint64_t _8; | ||
| Reg f8; | ||
| volatile uint64_t _9; | ||
| Reg f9; | ||
| volatile uint64_t _10; | ||
| Reg f10; | ||
| volatile uint64_t _11; | ||
| Reg f11; | ||
| volatile uint64_t _12; | ||
| Reg f12; | ||
| volatile uint64_t _13; | ||
| Reg f13; | ||
| volatile uint64_t _14; | ||
| Reg f14; | ||
| volatile uint64_t _15; | ||
| Reg f15; | ||
| volatile uint64_t _16; | ||
| Reg f16; | ||
| volatile uint64_t _17; | ||
| Reg f17; | ||
| volatile uint64_t _18; | ||
| Reg f18; | ||
| volatile uint64_t _19; | ||
| Reg f19; | ||
| volatile uint64_t _20; | ||
| Reg f20; | ||
| volatile uint64_t _21; | ||
| Reg f21; | ||
| volatile uint64_t _22; | ||
| Reg f22; | ||
| volatile uint64_t _23; | ||
| Reg f23; | ||
| volatile uint64_t _24; | ||
| Reg f24; | ||
| volatile uint64_t _25; | ||
| Reg f25; | ||
| volatile uint64_t _26; | ||
| Reg f26; | ||
| volatile uint64_t _27; | ||
| Reg f27; | ||
| volatile uint64_t _28; | ||
| Reg f28; | ||
| volatile uint64_t _29; | ||
| Reg f29; | ||
| volatile uint64_t _30; | ||
| Reg f30; | ||
| volatile uint64_t _31; | ||
| Reg f31; | ||
|
|
||
| } __attribute__((packed)); | ||
|
|
||
| static_assert(512 == sizeof(FPR), "Invalid structure packing of `FPR`."); | ||
|
|
||
| struct alignas(8) FlagRegisters final { | ||
| volatile uint64_t _0; | ||
| Reg ISAModeSwitch; | ||
| } __attribute__((packed)); | ||
|
|
||
| struct alignas(8) COP0Registers final { | ||
| volatile uint64_t _0; | ||
| Reg Index; | ||
| volatile uint64_t _1; | ||
| Reg Random; | ||
| volatile uint64_t _2; | ||
| Reg EntryLo0; | ||
| volatile uint64_t _3; | ||
| Reg EntryLo1; | ||
| volatile uint64_t _4; | ||
| Reg Context; | ||
| volatile uint64_t _5; | ||
| Reg PageMask; | ||
| volatile uint64_t _6; | ||
| Reg Wired; | ||
| volatile uint64_t _7; | ||
| Reg HWREna; | ||
| volatile uint64_t _8; | ||
| Reg BadVAddr; | ||
| volatile uint64_t _9; | ||
| Reg Count; | ||
| volatile uint64_t _10; | ||
| Reg EntryHi; | ||
| volatile uint64_t _11; | ||
| Reg Compare; | ||
| volatile uint64_t _12; | ||
| Reg Status; | ||
| volatile uint64_t _13; | ||
| Reg Cause; | ||
| volatile uint64_t _14; | ||
| Reg EPC; | ||
| volatile uint64_t _15; | ||
| Reg PRId; | ||
| volatile uint64_t _16; | ||
| Reg Config; | ||
| volatile uint64_t _17; | ||
| Reg LLAddr; | ||
| volatile uint64_t _18; | ||
| Reg WatchLo; | ||
| volatile uint64_t _19; | ||
| Reg WatchHi; | ||
| volatile uint64_t _20; | ||
| Reg XContext; | ||
| volatile uint64_t _21; | ||
| Reg cop0_reg21; | ||
| volatile uint64_t _22; | ||
| Reg cop0_reg22; | ||
| volatile uint64_t _23; | ||
| Reg Debug; | ||
| volatile uint64_t _24; | ||
| Reg DEPC; | ||
| volatile uint64_t _25; | ||
| Reg PerfCnt; | ||
| volatile uint64_t _26; | ||
| Reg ErrCtl; | ||
| volatile uint64_t _27; | ||
| Reg CacheErr; | ||
| volatile uint64_t _28; | ||
| Reg TagLo; | ||
| volatile uint64_t _29; | ||
| Reg TagHi; | ||
| volatile uint64_t _30; | ||
| Reg ErrorEPC; | ||
| volatile uint64_t _31; | ||
| Reg DESAVE; | ||
| } __attribute__((packed)); | ||
|
|
||
| struct alignas(8) MIPSState : public ArchState { | ||
| GPR gpr; // 528 bytes. | ||
|
|
||
| uint64_t _0; | ||
|
|
||
| FPR fpr; | ||
|
|
||
| uint64_t _1; | ||
|
|
||
| FlagRegisters flags; | ||
|
|
||
| uint64_t _2; | ||
|
|
||
| COP0Registers cop0; | ||
|
|
||
| uint64_t _3; | ||
| } __attribute__((packed)); | ||
|
|
||
| struct State : public MIPSState {}; | ||
|
|
||
| #pragma clang diagnostic pop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.