aboutsummaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@google.com>2024-05-12 10:34:17 -0400
committerBoringssl LUCI CQ <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-05-15 23:22:12 +0000
commit07f27b1d445a27433f2c871935da2cefcfbdb458 (patch)
tree7c9adebc003032d7d5f84a64612754e81f758484 /crypto
parentfc953df2352e1c1bcb34cb5f75a0e409014c1690 (diff)
downloadboringssl-07f27b1d445a27433f2c871935da2cefcfbdb458.zip
boringssl-07f27b1d445a27433f2c871935da2cefcfbdb458.tar.gz
boringssl-07f27b1d445a27433f2c871935da2cefcfbdb458.tar.bz2
Fix alignment of generated UNWIND_INFO structures
I missed a few parts of the Windows documentation: > The UNWIND_INFO structure must be DWORD aligned in memory. > For alignment purposes, this array [unwind codes] always has an even > number of entries, and the final entry is potentially unused. In that > case, the array is one longer than indicated by the count of unwind > codes field. https://learn.microsoft.com/en-us/cpp/build/exception-handling-x64?view=msvc-170 This didn't seem to have any practical effect (unwinding tests worked as-is), but I noticed this while rewriting some handwritten codes. Bug: 259 Change-Id: I655f3a7f3a907797e7665a276f4926a31a1e1639 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/68407 Reviewed-by: Adam Langley <agl@google.com> Auto-Submit: David Benjamin <davidben@google.com> Commit-Queue: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto')
-rwxr-xr-xcrypto/perlasm/x86_64-xlate.pl10
1 files changed, 10 insertions, 0 deletions
diff --git a/crypto/perlasm/x86_64-xlate.pl b/crypto/perlasm/x86_64-xlate.pl
index 5b7705d..3011c91 100755
--- a/crypto/perlasm/x86_64-xlate.pl
+++ b/crypto/perlasm/x86_64-xlate.pl
@@ -903,6 +903,16 @@ $info{info_label}:
$info{unwind_codes}
____
+ # UNWIND_INFOs must be 4-byte aligned. If needed, we must add an extra
+ # unwind code. This does not change the unwind code count. Windows
+ # documentation says "For alignment purposes, this array always has an
+ # even number of entries, and the final entry is potentially unused. In
+ # that case, the array is one longer than indicated by the count of
+ # unwind codes field."
+ if ($info{num_codes} & 1) {
+ $xdata .= "\t.value\t0\n";
+ }
+
%info = ();
return $end_label;
}