HACKERCHANNEL / PSL1GHT

A lightweight PS3 SDK
www.psl1ght.com
MIT License
182 stars 67 forks source link

rsxContextCallback() broken? #73

Closed andoma closed 13 years ago

andoma commented 13 years ago

s32 rsxContextCallback(gcmContextData* context, u32 count)
{
        opd32* callback = (opd32*)(u64)context->callback;
        opd64 opd = {
                (void*)(u64)callback->func,
                (void*)(u64)callback->rtoc,
                0
        };
        return ((s32(*)())&opd)();
}

compiles for me to:

0x000000000039ccb8 <+0>: mflr r0 0x000000000039ccbc <+4>: std r0,16(r1) 0x000000000039ccc0 <+8>: stdu r1,-144(r1) 0x000000000039ccc4 <+12>: addi r9,r1,112 0x000000000039ccc8 <+16>: ld r0,112(r1) 0x000000000039cccc <+20>: ld r11,128(r1) 0x000000000039ccd0 <+24>: mtctr r0 0x000000000039ccd4 <+28>: std r2,40(r1) 0x000000000039ccd8 <+32>: ld r2,8(r9) 0x000000000039ccdc <+36>: bctrl 0x000000000039cce0 <+40>: ld r2,40(r1) 0x000000000039cce4 <+44>: addi r1,r1,144 0x000000000039cce8 <+48>: ld r0,16(r1) 0x000000000039ccec <+52>: mtlr r0 0x000000000039ccf0 <+56>: blr 0x000000000039ccf4 <+60>: .long 0x0 0x000000000039ccf8 <+64>: .long 0x1 0x000000000039ccfc <+68>: lwz r0,0(0)

Ie, it does not seem to care about context (which is passed via r3) at all?

Switching back to the older ASM variant seems to work OK

AerialX commented 13 years ago

Dammit GCC, wtf are doing.

Marking the opd64 volatile seems to fix it at least, does it run properly then? It's not pretty, though.

shagkur commented 13 years ago

I reverted the function to the inline assembly version in my last commit.