diff --git a/crypto/fipsmodule/delocate.go b/crypto/fipsmodule/delocate.go index 039360a5..d0998239 100644 --- a/crypto/fipsmodule/delocate.go +++ b/crypto/fipsmodule/delocate.go @@ -164,7 +164,7 @@ func transform(lines []string, symbols map[string]bool) (ret []string) { } switch parts[0] { - case "call", "callq", "jmp": + case "call", "callq", "jmp", "jne", "jb", "jz", "jnz", "ja": target := parts[1] // indirect via register or local label if strings.HasPrefix(target, "*") || strings.HasPrefix(target, ".L") { @@ -201,6 +201,22 @@ func transform(lines []string, symbols map[string]bool) (ret []string) { redirectors[redirectorName] = target continue + case "leaq": + if strings.Contains(line, "BORINGSSL_bcm_text_dummy_") { + line = strings.Replace(line, "BORINGSSL_bcm_text_dummy_", "BORINGSSL_bcm_text_", -1) + } + + target := strings.SplitN(parts[1], ",", 2)[0] + if strings.HasSuffix(target, "(%rip)") { + target = target[:len(target)-6] + if isGlobal := symbols[target]; isGlobal { + line = strings.Replace(line, target, localTargetName(target), 1) + } + } + + ret = append(ret, line) + continue + case ".file": // Do not reorder .file directives. These define // numbered files which are referenced by other debug @@ -265,9 +281,6 @@ func transform(lines []string, symbols map[string]bool) (ret []string) { } } - if parts[0] == "leaq" { - line = strings.Replace(line, "BORINGSSL_bcm_text_dummy_", "BORINGSSL_bcm_text_", -1) - } ret = append(ret, line) } }