-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1686 from Sonicadvance1/add_relocation_definitions
ArchHelpers: Adds relocation struct defines
- Loading branch information
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
External/FEXCore/Source/Interface/Core/ObjectCache/Relocations.h
This file contains 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,78 @@ | ||
#pragma once | ||
#include <FEXCore/IR/IR.h> | ||
|
||
namespace FEXCore::CPU { | ||
enum class RelocationTypes : uint8_t { | ||
// 8 byte literal in memory for symbol | ||
// Aligned to struct RelocNamedSymbolLiteral | ||
RELOC_NAMED_SYMBOL_LITERAL, | ||
|
||
// Fixed size named thunk move | ||
// 4 instruction constant generation on AArch64 | ||
// 64-bit mov on x86-64 | ||
// Aligned to struct RelocNamedThunkMove | ||
RELOC_NAMED_THUNK_MOVE, | ||
|
||
// Fixed size guest RIP move | ||
// 4 instruction constant generation on AArch64 | ||
// 64-bit mov on x86-64 | ||
// Aligned to struct RelocGuestRIPMove | ||
RELOC_GUEST_RIP_MOVE, | ||
}; | ||
|
||
struct RelocationTypeHeader final { | ||
RelocationTypes Type; | ||
}; | ||
|
||
struct RelocNamedSymbolLiteral final { | ||
enum class NamedSymbol : uint8_t { | ||
///< Thread specific relocations | ||
// JIT Literal pointers | ||
SYMBOL_LITERAL_EXITFUNCTION_LINKER, | ||
}; | ||
|
||
RelocationTypeHeader Header{}; | ||
|
||
NamedSymbol Symbol; | ||
|
||
// Offset in to the code section to begin the relocation | ||
uint64_t Offset{}; | ||
}; | ||
|
||
struct RelocNamedThunkMove final { | ||
RelocationTypeHeader Header{}; | ||
|
||
// GPR index the constant is being moved to | ||
uint8_t RegisterIndex; | ||
|
||
// The thunk SHA256 hash | ||
IR::SHA256Sum Symbol; | ||
|
||
// Offset in to the code section to begin the relocation | ||
uint64_t Offset{}; | ||
}; | ||
|
||
struct RelocGuestRIPMove final { | ||
RelocationTypeHeader Header{}; | ||
|
||
// GPR index the constant is being moved to | ||
uint8_t RegisterIndex; | ||
|
||
// Offset in to the code section to begin the relocation | ||
uint64_t Offset{}; | ||
|
||
// The unrelocated RIP that is being moved | ||
uint64_t GuestRIP; | ||
}; | ||
|
||
union Relocation { | ||
RelocationTypeHeader Header{}; | ||
|
||
RelocNamedSymbolLiteral NamedSymbolLiteral; | ||
// This makes our union of relocations at least 48 bytes | ||
// It might be more efficient to not use a union | ||
RelocNamedThunkMove NamedThunkMove; | ||
|
||
RelocGuestRIPMove GuestRIPMove; | ||
}; | ||
} |