delocate: Preserve AVX-512 tokens when rewriting labels
Also fail closed, rather than failing open, when going through a
codepath that would silently discard such a token.
Change-Id: I31797445a9d8cfa02fe284aeab535efa545ba5f8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/77807
Commit-Queue: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/util/fipstools/delocate/delocate.go b/util/fipstools/delocate/delocate.go
index 2ea8f38..0252781 100644
--- a/util/fipstools/delocate/delocate.go
+++ b/util/fipstools/delocate/delocate.go
@@ -1183,6 +1183,10 @@
argStr += d.contents(memRef)
}
+ for suffix := arg.next; suffix != nil; suffix = suffix.next {
+ argStr += d.contents(suffix)
+ }
+
args = append(args, argStr)
case ruleGOTAddress:
@@ -1192,6 +1196,9 @@
if i != 0 || len(argNodes) != 2 {
return nil, fmt.Errorf("Load of _GLOBAL_OFFSET_TABLE_ address didn't have expected form")
}
+ if arg.next != nil {
+ return nil, fmt.Errorf("unexpected argument suffix")
+ }
d.gotDeltaNeeded = true
changed = true
targetReg := d.contents(argNodes[1])
@@ -1208,6 +1215,9 @@
if i != 0 || len(argNodes) != 2 {
return nil, fmt.Errorf("movabs of _GLOBAL_OFFSET_TABLE_ didn't expected form")
}
+ if arg.next != nil {
+ return nil, fmt.Errorf("unexpected argument suffix")
+ }
d.gotDeltaNeeded = true
changed = true
@@ -1228,6 +1238,9 @@
if i != 0 || len(argNodes) != 2 {
return nil, fmt.Errorf("movabs of _GLOBAL_OFFSET_TABLE_ offset didn't have expected form")
}
+ if arg.next != nil {
+ return nil, fmt.Errorf("unexpected argument suffix")
+ }
assertNodeType(arg.up, ruleSymbolName)
symbol := d.contents(arg.up)
diff --git a/util/fipstools/delocate/testdata/x86_64-LabelRewrite/in2.s b/util/fipstools/delocate/testdata/x86_64-LabelRewrite/in2.s
index 8500af9..e86f5b2 100644
--- a/util/fipstools/delocate/testdata/x86_64-LabelRewrite/in2.s
+++ b/util/fipstools/delocate/testdata/x86_64-LabelRewrite/in2.s
@@ -30,3 +30,6 @@
.set .Llocal_alias_to_local_label, .Llocal_label
.equ .Llocal_alias_to_local_label, .Llocal_label
.equiv .Llocal_alias_to_local_label, .Llocal_label
+
+ # When rewritten, AVX-512 tokens are preserved.
+ vpcmpneqq .Llabel(%rip){1to8}, %zmm1, %k0
diff --git a/util/fipstools/delocate/testdata/x86_64-LabelRewrite/out.s b/util/fipstools/delocate/testdata/x86_64-LabelRewrite/out.s
index 2ce18a7..abc0b71 100644
--- a/util/fipstools/delocate/testdata/x86_64-LabelRewrite/out.s
+++ b/util/fipstools/delocate/testdata/x86_64-LabelRewrite/out.s
@@ -147,6 +147,10 @@
.equ .Llocal_alias_to_local_label_BCM_1, .Llocal_label_BCM_1
# WAS .equiv .Llocal_alias_to_local_label, .Llocal_label
.equiv .Llocal_alias_to_local_label_BCM_1, .Llocal_label_BCM_1
+
+ # When rewritten, AVX-512 tokens are preserved.
+# WAS vpcmpneqq .Llabel(%rip){1to8}, %zmm1, %k0
+ vpcmpneqq .Llabel_BCM_1(%rip){1to8}, %zmm1, %k0
.text
.loc 1 2 0
BORINGSSL_bcm_text_end: