Skip to content
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

hvcall_341.c:28:2: error: PIC register clobbered by 'r2' in 'asm' __asm__ __volatile__( #11

Open
crystalct opened this issue Jun 6, 2020 · 11 comments

Comments

@crystalct
Copy link

Using last ps3toolchain (gcc 7.2).
PowerPC / PowerPC64 / RS6000
GCC now diagnoses inline assembly that clobbers register r2. This has always been invalid code....

@bucanero
Copy link

I think that removing "r2" references from all the payload sources should be enough to fix the clobbered issue.
At least that's what we did with Tiny3d , right?

@aldostools
Copy link
Owner

aldostools commented Aug 17, 2020

I use this toolchain and don't get that error:
https://github.com/Estwald/PSDK3v2

Extract this include.zip in the following path for the additional features added to the toolchain (unrar, un7zip, ff, etc.)
C:\PSDK3v2\ps3dev\portlibs\ppu\include

@bucanero
Copy link

yes, the r2 register didn't bring any issue with the older gcc 4 toolchain, but with gcc 7 it doesn't compile.

recently @crystalct was updating the tiny3d lib to the latest toolchain and we've got that error. We removed the r2 from the inline and it worked alright. I'm just not sure if removing r2 works ok with the gcc4 toolchain or not.

@bucanero
Copy link

bucanero commented Aug 17, 2020

@aldostools , I've forked and applied the register patch on my fork

whenever you have a chance, could you check if you can compile Irisman with that change (bucanero@0350bb7) too using Estwalds toolchain?
if the patch also works on your end then I can submit a PR and we keep the change for everyone

@aldostools
Copy link
Owner

I built your fork and it compiled fine.

Since your changes were in hvcall.c of the initial payloads 3.41 and 3.55, I cannot validate if they work fine on the PS3 or not.

I'm using 4.86.1 Rebug Lite, and that code is executed only when IRISMAN starts on these FW versions.

@bucanero
Copy link

thanks for try it out! 👍

does anyone still uses fw 3.41 or 3.55? shall we go ahead and merge the fix? what do you think?

I'd say that we can just merge this change, and if someone with such old firmware ever tries it out, we'll get some feedback and rollback the change if it didn't work.

let me know your ideas 😄

@aldostools
Copy link
Owner

I'm don't like the idea of change a working code... I could add a comment about removing "r2" if cause issues with GCC 7.

I never had reports about it and this change could break it for CFW users.

I'm not aware of people still using 3.41, but 3.55 is still used by many people for downgrades and troubleshooting.

@bucanero
Copy link

I'm don't like the idea of change a working code... I could add a comment about removing "r2" if cause issues with GCC 7.

well, if you prefer, we could do a conditional #ifdef (like crystal did on Tiny3d), for example:

// GCC now diagnoses inline assembly that clobbers register r2. 
// This has always been invalid code, and is no longer quietly tolerated.
#if __GNUC__ >= 7		
          :"r0", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "lr", "ctr", "xer",
#else
          :"r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "lr", "ctr", "xer",
#endif

that way the source will keep the original code when compiling with GCC 4 (Estwald), and will use the the updated code only if we use the new toolchain with GCC 7+

I never had reports about it and this change could break it for CFW users.

from my experience, a lot of people uses Windows and usually just downloads Estwald's SDKv2. Since they never tried building the toolchain from scratch, they won't have the newer gcc 7.2 (and won't find any issues building it)

I'm not aware of people still using 3.41, but 3.55 is still used by many people for downgrades and troubleshooting.

let me know what you think about the #ifdef alternative, I think it's the best way to have the fix while keeping the original code for older gcc compiler.

@crystalct
Copy link
Author

crystalct commented Aug 18, 2020 via email

aldostools added a commit that referenced this issue Aug 18, 2020
- Increased buffer in unzip function
- Fixed compilation error on GCC 7 and later. Thanks crystalct/bucanero (issue #11)
@bucanero
Copy link

thanks @aldostools for adding the fix! 👍

@aldostools
Copy link
Owner

Thanks to you @bucanero & @crystalct for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants