File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2390,6 +2390,30 @@ void Recompiler::Recompile(const std::filesystem::path& headerFilePath)
23902390
23912391 println (" " );
23922392
2393+ println (" #define PPC_IMAGE_BASE 0x{:X}ull" , image.base );
2394+ println (" #define PPC_IMAGE_SIZE 0x{:X}ull" , image.size );
2395+
2396+ // Extract the address of the minimum code segment to store the function table at.
2397+ size_t codeMin = ~0 ;
2398+ size_t codeMax = 0 ;
2399+
2400+ for (auto & section : image.sections )
2401+ {
2402+ if ((section.flags & SectionFlags_Code) != 0 )
2403+ {
2404+ if (section.base < codeMin)
2405+ codeMin = section.base ;
2406+
2407+ if ((section.base + section.size ) > codeMax)
2408+ codeMax = (section.base + section.size );
2409+ }
2410+ }
2411+
2412+ println (" #define PPC_CODE_BASE 0x{:X}ull" , codeMin);
2413+ println (" #define PPC_CODE_SIZE 0x{:X}ull" , codeMax - codeMin);
2414+
2415+ println (" " );
2416+
23932417 println (" #ifdef PPC_INCLUDE_DETAIL" );
23942418 println (" #include \" ppc_detail.h\" " );
23952419 println (" #endif" );
Original file line number Diff line number Diff line change 105105#define PPC_CALL_FUNC (x ) x(ctx, base)
106106#endif
107107
108- #define PPC_MEMORY_SIZE 0x100000000ull
109- # define PPC_FUNC_TABLE_OFFSET PPC_MEMORY_SIZE
110- #define PPC_FUNC_TABLE_SIZE 0x200000000ull
108+ #define PPC_MEMORY_SIZE 0x100000000ull
109+
110+ #define PPC_LOOKUP_FUNC ( x, y ) *(PPCFunc**)(x + PPC_IMAGE_BASE + PPC_IMAGE_SIZE + ( uint64_t ( uint32_t (y) - PPC_CODE_BASE ) * 2 ))
111111
112112#ifndef PPC_CALL_INDIRECT_FUNC
113- #define PPC_CALL_INDIRECT_FUNC (x ) (*(PPCFunc**)( base + PPC_FUNC_TABLE_OFFSET + ( uint64_t (x) * 2 ) ))(ctx, base)
113+ #define PPC_CALL_INDIRECT_FUNC (x ) (PPC_LOOKUP_FUNC ( base, x ))(ctx, base)
114114#endif
115115
116116typedef void PPCFunc (struct PPCContext & __restrict__ ctx, uint8_t * base);
You can’t perform that action at this time.
0 commit comments