mirror of
https://github.com/hedge-dev/XenonRecomp.git
synced 2025-06-06 18:31:03 +00:00
Place function table after the executable.
This commit is contained in:
parent
2cd41adf42
commit
7fb8af1bad
@ -2390,6 +2390,30 @@ void Recompiler::Recompile(const std::filesystem::path& headerFilePath)
|
|||||||
|
|
||||||
println("");
|
println("");
|
||||||
|
|
||||||
|
println("#define PPC_IMAGE_BASE 0x{:X}ull", image.base);
|
||||||
|
println("#define PPC_IMAGE_SIZE 0x{:X}ull", image.size);
|
||||||
|
|
||||||
|
// Extract the address of the minimum code segment to store the function table at.
|
||||||
|
size_t codeMin = ~0;
|
||||||
|
size_t codeMax = 0;
|
||||||
|
|
||||||
|
for (auto& section : image.sections)
|
||||||
|
{
|
||||||
|
if ((section.flags & SectionFlags_Code) != 0)
|
||||||
|
{
|
||||||
|
if (section.base < codeMin)
|
||||||
|
codeMin = section.base;
|
||||||
|
|
||||||
|
if ((section.base + section.size) > codeMax)
|
||||||
|
codeMax = (section.base + section.size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
println("#define PPC_CODE_BASE 0x{:X}ull", codeMin);
|
||||||
|
println("#define PPC_CODE_SIZE 0x{:X}ull", codeMax - codeMin);
|
||||||
|
|
||||||
|
println("");
|
||||||
|
|
||||||
println("#ifdef PPC_INCLUDE_DETAIL");
|
println("#ifdef PPC_INCLUDE_DETAIL");
|
||||||
println("#include \"ppc_detail.h\"");
|
println("#include \"ppc_detail.h\"");
|
||||||
println("#endif");
|
println("#endif");
|
||||||
|
@ -106,11 +106,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PPC_MEMORY_SIZE 0x100000000ull
|
#define PPC_MEMORY_SIZE 0x100000000ull
|
||||||
#define PPC_FUNC_TABLE_OFFSET PPC_MEMORY_SIZE
|
|
||||||
#define PPC_FUNC_TABLE_SIZE 0x200000000ull
|
#define PPC_LOOKUP_FUNC(x, y) *(PPCFunc**)(x + PPC_IMAGE_BASE + PPC_IMAGE_SIZE + (uint64_t(uint32_t(y) - PPC_CODE_BASE) * 2))
|
||||||
|
|
||||||
#ifndef PPC_CALL_INDIRECT_FUNC
|
#ifndef PPC_CALL_INDIRECT_FUNC
|
||||||
#define PPC_CALL_INDIRECT_FUNC(x) (*(PPCFunc**)(base + PPC_FUNC_TABLE_OFFSET + (uint64_t(x) * 2)))(ctx, base)
|
#define PPC_CALL_INDIRECT_FUNC(x) (PPC_LOOKUP_FUNC(base, x))(ctx, base)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void PPCFunc(struct PPCContext& __restrict__ ctx, uint8_t* base);
|
typedef void PPCFunc(struct PPCContext& __restrict__ ctx, uint8_t* base);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user