Teach delocate.go to handle loading function pointers into XMM registers.

Sadly, LEA cannot target XMM registers.

Change-Id: I5f4245b5df1625ba3ea7ebf7ccf6dcceb9dab1d9
Reviewed-on: https://boringssl-review.googlesource.com/15988
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
This commit is contained in:
Adam Langley 2017-05-05 16:02:17 -07:00 committed by CQ bot account: commit-bot@chromium.org
parent c862c31f4c
commit c0485d67f4

View File

@ -348,6 +348,7 @@ func transform(lines []string, symbols map[string]bool) (ret []string) {
if isGlobal := symbols[target]; isGlobal {
line = strings.Replace(line, target, localTargetName(target), 1)
target = localTargetName(target)
} else if !strings.HasPrefix(target, "BORINGSSL_bcm_") {
redirectorName := "bcm_redirector_" + target
redirectors[redirectorName] = target
@ -367,6 +368,24 @@ func transform(lines []string, symbols map[string]bool) (ret []string) {
ret = append(ret, "\tj" + invertedCondition + " 1f")
}
destination := args[1]
if strings.HasPrefix(destination, "%xmm") {
if instr != "movq" {
panic("unhandled: " + orig)
}
// MOV can target XMM
// registers, but LEA cannot.
ret = append(ret, "leaq -128(%rsp), %rsp") // Clear the red zone.
ret = append(ret, "pushq %rax")
ret = append(ret, "leaq " + target + "(%rip), %rax")
ret = append(ret, "movq %rax, " + destination)
ret = append(ret, "popq %rax")
ret = append(ret, "leaq 128(%rsp), %rsp")
continue
}
// Nobody actually wants to read the
// code of a function. This is a load
// from the GOT which, now that we're