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

[Backport] Use x30 instead of lr which otherwise trip some versions of gcc #1465

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions util/fipstools/delocate/delocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

// delocate performs several transformations of textual assembly code. See
// crypto/fipsmodule/FIPS.md for an overview.
Expand Down Expand Up @@ -444,17 +444,17 @@ func (d *delocation) loadAarch64Address(statement *node32, targetReg string, sym
// Save x0 (which will be stomped by the return value) and the link register
// to the stack. Then save the program counter into the link register and
// jump to the helper function.
d.output.WriteString("\tstp x0, lr, [sp, #-16]!\n")
d.output.WriteString("\tstp x0, x30, [sp, #-16]!\n")
d.output.WriteString("\tbl " + helperFunc + "\n")

if targetReg == "x0" {
// If the target happens to be x0 then restore the link register from the
// stack and send the saved value of x0 to the zero register.
d.output.WriteString("\tldp xzr, lr, [sp], #16\n")
d.output.WriteString("\tldp xzr, x30, [sp], #16\n")
} else {
// Otherwise move the result into place and restore registers.
d.output.WriteString("\tmov " + targetReg + ", x0\n")
d.output.WriteString("\tldp x0, lr, [sp], #16\n")
d.output.WriteString("\tldp x0, x30, [sp], #16\n")
}

// Revert the red-zone adjustment.
Expand Down
20 changes: 10 additions & 10 deletions util/fipstools/delocate/testdata/aarch64-Basic/out.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@ foo:
// GOT load
// WAS adrp x1, :got:stderr
sub sp, sp, 128
stp x0, lr, [sp, #-16]!
stp x0, x30, [sp, #-16]!
bl .Lboringssl_loadgot_stderr
mov x1, x0
ldp x0, lr, [sp], #16
ldp x0, x30, [sp], #16
add sp, sp, 128
// WAS ldr x0, [x1, :got_lo12:stderr]
mov x0, x1

// GOT load to x0
// WAS adrp x0, :got:stderr
sub sp, sp, 128
stp x0, lr, [sp, #-16]!
stp x0, x30, [sp, #-16]!
bl .Lboringssl_loadgot_stderr
ldp xzr, lr, [sp], #16
ldp xzr, x30, [sp], #16
add sp, sp, 128
// WAS ldr x1, [x0, :got_lo12:stderr]
mov x1, x0

// GOT load with no register move
// WAS adrp x0, :got:stderr
sub sp, sp, 128
stp x0, lr, [sp, #-16]!
stp x0, x30, [sp, #-16]!
bl .Lboringssl_loadgot_stderr
ldp xzr, lr, [sp], #16
ldp xzr, x30, [sp], #16
add sp, sp, 128
// WAS ldr x0, [x0, :got_lo12:stderr]

Expand All @@ -56,20 +56,20 @@ foo:
// armcap
// WAS adrp x1, OPENSSL_armcap_P
sub sp, sp, 128
stp x0, lr, [sp, #-16]!
stp x0, x30, [sp, #-16]!
bl .LOPENSSL_armcap_P_addr
mov x1, x0
ldp x0, lr, [sp], #16
ldp x0, x30, [sp], #16
add sp, sp, 128
// WAS ldr w2, [x1, :lo12:OPENSSL_armcap_P]
ldr w2, [x1]

// armcap to w0
// WAS adrp x0, OPENSSL_armcap_P
sub sp, sp, 128
stp x0, lr, [sp, #-16]!
stp x0, x30, [sp, #-16]!
bl .LOPENSSL_armcap_P_addr
ldp xzr, lr, [sp], #16
ldp xzr, x30, [sp], #16
add sp, sp, 128
// WAS ldr w1, [x1, :lo12:OPENSSL_armcap_P]
ldr w1, [x1]
Expand Down
Loading