Delocate more types of references. References to global symbols generate relocations, which breaks the integrity check. Change-Id: If6fa06d5d924294ab496c32e7f082a1ae60fdb24 Reviewed-on: https://boringssl-review.googlesource.com/15025 Commit-Queue: David Benjamin <davidben@google.com> Reviewed-by: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/crypto/fipsmodule/delocate.go b/crypto/fipsmodule/delocate.go index 039360a..d099823 100644 --- a/crypto/fipsmodule/delocate.go +++ b/crypto/fipsmodule/delocate.go
@@ -164,7 +164,7 @@ } 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 @@ 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 @@ } } - if parts[0] == "leaq" { - line = strings.Replace(line, "BORINGSSL_bcm_text_dummy_", "BORINGSSL_bcm_text_", -1) - } ret = append(ret, line) } }