-
Notifications
You must be signed in to change notification settings - Fork 13.5k
MIPS: .cpsetup broken for n32 #52785
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
Comments
Looking at it more, n32 is supposed to use whatever label, not fixed at __gnu_local_gp |
Could you check that this patch fixes the issue? The patch adds the |
On Fri, Dec 18
… —
Reply to this email directly, view it on GitHub
<#52785>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUTMQR3D3NWGFW7I5YQQJ4DURPNRXANCNFSM5KKA3RHA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Unfortunately that's incomplete. It's adding the "absolute" address of __gnu_local_gp, which won't work to get a relative address. It really should be doing what is done for N64 below in the function, from what I can tell. |
It's due to a typo in - if (getABI().IsN32()) {
+#if 0
+ // We haven't support -mabicalls -mno-shared yet.
+ if (-mno-shared) {
MCSymbol *GPSym = MCA.getContext().getOrCreateSymbol("__gnu_local_gp");
const MipsMCExpr *HiExpr = MipsMCExpr::create(
MipsMCExpr::MEK_HI, MCSymbolRefExpr::create(GPSym, MCA.getContext()),
@@ -1273,6 +1275,7 @@ void MipsTargetELFStreamer::emitDirectiveCpsetup(unsigned RegNo,
return;
}
+#endif |
In the current code, we don't support -mno-shared yet, and for N32, .cpsetup is expand as the style -f -mno-shared. It will generate bad code for PIC binaries like: 00000000 <t1>: 0: ffbc0008 sd gp,8(sp) 4: 3c1c0000 lui gp,0x0 4: R_MIPS_HI16 __gnu_local_gp 8: 279c0000 addiu gp,gp,0 8: R_MIPS_LO16 __gnu_local_gp In fact which style of .cpsetup is used should be determined by -m(no-)shared option instead of -mabi=n32 option. Fixes: llvm#52785
In the current code, we don't support -mno-shared yet, and for N32, .cpsetup is expand as the style -f -mno-shared. It will generate bad code for PIC binaries like: 00000000 <t1>: 0: ffbc0008 sd gp,8(sp) 4: 3c1c0000 lui gp,0x0 4: R_MIPS_HI16 __gnu_local_gp 8: 279c0000 addiu gp,gp,0 8: R_MIPS_LO16 __gnu_local_gp In fact which style of .cpsetup is used should be determined by -m(no-)shared option instead of -mabi=n32 option. Fixes: llvm#52785
In the current code, we don't support -mno-shared yet, and for N32, .cpsetup is expand as the style -f -mno-shared. It will generate bad code for PIC binaries like: 00000000 <t1>: 0: ffbc0008 sd gp,8(sp) 4: 3c1c0000 lui gp,0x0 4: R_MIPS_HI16 __gnu_local_gp 8: 279c0000 addiu gp,gp,0 8: R_MIPS_LO16 __gnu_local_gp In fact which style of .cpsetup is used should be determined by -m(no-)shared option instead of -mabi=n32 option. Fixes: llvm#52785
In gas, .cpsetup may expand to one of two code sequences (one is related to `__gnu_local_gp`), depending on -mno-shared and -msym32. Since Clang doesn't support -mno-shared or -msym32, .cpsetup expands to one code sequence. The N32 condition incorrectly leads to the incorrect `__gnu_local_gp` code sequence. ``` 00000000 <t1>: 0: ffbc0008 sd gp,8(sp) 4: 3c1c0000 lui gp,0x0 4: R_MIPS_HI16 __gnu_local_gp 8: 279c0000 addiu gp,gp,0 8: R_MIPS_LO16 __gnu_local_gp ``` Fixes: #52785
In gas, .cpsetup may expand to one of two code sequences (one is related to `__gnu_local_gp`), depending on -mno-shared and -msym32. Since Clang doesn't support -mno-shared or -msym32, .cpsetup expands to one code sequence. The N32 condition incorrectly leads to the incorrect `__gnu_local_gp` code sequence. ``` 00000000 <t1>: 0: ffbc0008 sd gp,8(sp) 4: 3c1c0000 lui gp,0x0 4: R_MIPS_HI16 __gnu_local_gp 8: 279c0000 addiu gp,gp,0 8: R_MIPS_LO16 __gnu_local_gp ``` Fixes: llvm#52785 (cherry picked from commit 860b6ed)
In gas, .cpsetup may expand to one of two code sequences (one is related to `__gnu_local_gp`), depending on -mno-shared and -msym32. Since Clang doesn't support -mno-shared or -msym32, .cpsetup expands to one code sequence. The N32 condition incorrectly leads to the incorrect `__gnu_local_gp` code sequence. ``` 00000000 <t1>: 0: ffbc0008 sd gp,8(sp) 4: 3c1c0000 lui gp,0x0 4: R_MIPS_HI16 __gnu_local_gp 8: 279c0000 addiu gp,gp,0 8: R_MIPS_LO16 __gnu_local_gp ``` Fixes: llvm#52785 (cherry picked from commit 860b6ed)
MIPS n32 ABI requires '.cpsetup , <off | reg>, ' to generate the following sequence:
The MIPS code generator currently does not include the final
addu
, leading to crashes in n32 ABI position independent code.The text was updated successfully, but these errors were encountered: