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>
This commit is contained in:
Adam Langley 2017-04-13 11:07:15 -07:00 committed by CQ bot account: commit-bot@chromium.org
parent d7bc3353f0
commit 61c4e27413

View File

@ -164,7 +164,7 @@ func transform(lines []string, symbols map[string]bool) (ret []string) {
} }
switch parts[0] { switch parts[0] {
case "call", "callq", "jmp": case "call", "callq", "jmp", "jne", "jb", "jz", "jnz", "ja":
target := parts[1] target := parts[1]
// indirect via register or local label // indirect via register or local label
if strings.HasPrefix(target, "*") || strings.HasPrefix(target, ".L") { 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 redirectors[redirectorName] = target
continue 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": case ".file":
// Do not reorder .file directives. These define // Do not reorder .file directives. These define
// numbered files which are referenced by other debug // 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) ret = append(ret, line)
} }
} }