-
Notifications
You must be signed in to change notification settings - Fork 146
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
all: enables dynamic linking, removes R15 is clobbered #407
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanted to quickly review this, but it will take me more time.
See bug in the compiler (issue #58632).
See bug in the compiler (issue #58632).
See bug in the compiler (issue #58632).
See bug in the compiler (issue #58632).
See bug in the compiler (issue #58735).
See bug in the compiler (issue #58735).
See bug in the compiler (issue #58735).
See bug in the compiler (issue #58735).
This time I found another bug in the compiler. (See golang/go#58735) This reduction on the patches indicates that the original code is correct, but it is affected by the compiler bugs. The only exception was the code for ecc/p384, which required more changes. Other changes are easier to follow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, most of it looks fine, but I don't understand some parts of it where you use the AX register seemingly pointlessly. I think I might misunderstand something obvious.
@@ -29,27 +29,36 @@ | |||
// |-128-| x |--- 256 ---| = |------ 384 ------| | |||
// Assuming the first digit multiplication was already performed. | |||
#define MULX128x256(I1, M1, T1, T2, T3, T4, T5) \ | |||
MULXQ M1+ 8(SB), T4, T2 \ | |||
MOVQ M1+ 8(SB), AX \ | |||
MULXQ AX, T4, T2 \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change (and some a few similar ones below) seem unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it's unnecessary, but it is included due to bug in the compiler. (see go/issues/58735). So this is a workaround.
In short, what is happening here is that MULXQ cannot reference to the M1 location because is a global variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, makes sense! A note may be nice.
Issue: CIRCL cannot be compiled as a plugin, i.e., cannot be dynamically linked.
Fixes #391
Detection
Adds a CI job that checks whether CIRCL can be compiled using
-buildmode=plugin
.When compiling, the compiler shows errors such as:
Why?: The main reason is that Go compiler uses R15 to access to global variables, so it alters its value (do not restore it).
Solution
There are two solutions:
MOV $0x22434, AX
)Using R15 is still possible if there are no reads to R15 after accessing a global variable. Writes to R15 are allowed.
Note: I detected that MULXQ is incorrectly signaled as clobbered. This is a bug in the compiler (golang/go#58632).
For example: In these two cases, R15 is the output of MULX, and the compiler stops the compilation with error.
In this case R15 is used as an input, so the compiler should stop with error.
Changes
The best way to review this PR is going commit by commit.