diff options
| author | Rhys Hiltner <rhys@justin.tv> | 2021-09-29 17:35:27 -0700 |
|---|---|---|
| committer | Michael Pratt <mpratt@google.com> | 2021-10-04 21:10:16 +0000 |
| commit | f0db7eae74ea235e9fbc2598252bfd46c1cc5510 (patch) | |
| tree | 049a87ed3f3bc9264c5942d99818e371371a5c72 /src/runtime/defs_linux_arm64.go | |
| parent | e8a85e90aca4adb472c66f8c42f6d4a41b8cca99 (diff) | |
| download | go-f0db7eae74ea235e9fbc2598252bfd46c1cc5510.tar.xz | |
runtime: add padding to Linux kernel structures
Go exchanges siginfo and sigevent structures with the kernel. They
contain unions, but Go's use is limited to the first few fields. Pad out
the rest so the size Go sees is the same as what the Linux kernel sees.
This is a follow-up to CL 342052 which added the sigevent struct without
padding. It updates the siginfo struct as well so there are no bad
examples in the defs_linux_*.go files.
Change-Id: Id991d4a57826677dd7e6cc30ad113fa3b321cddf
Reviewed-on: https://go-review.googlesource.com/c/go/+/353136
Run-TryBot: Rhys Hiltner <rhys@justin.tv>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/defs_linux_arm64.go')
| -rw-r--r-- | src/runtime/defs_linux_arm64.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/runtime/defs_linux_arm64.go b/src/runtime/defs_linux_arm64.go index f9f175004b..6a126c4a15 100644 --- a/src/runtime/defs_linux_arm64.go +++ b/src/runtime/defs_linux_arm64.go @@ -3,6 +3,8 @@ package runtime +import "internal/goarch" + const ( _EINTR = 0x4 _EAGAIN = 0xb @@ -134,6 +136,11 @@ type siginfo struct { si_code int32 // below here is a union; si_addr is the only field we use si_addr uint64 + + // Pad struct to the max size in the kernel. Account for the 3 32-bit + // fields, the alignment to this architecture's pointer size, and the final + // pointer-length field. + _ [_si_max_size - (3*4 + (1-4/goarch.PtrSize)*4 + 1*goarch.PtrSize)]byte } type itimerspec struct { @@ -152,6 +159,10 @@ type sigevent struct { notify int32 // below here is a union; sigev_notify_thread_id is the only field we use sigev_notify_thread_id int32 + + // Pad struct to the max size in the kernel. Account for the pointer-length + // field and the 3 32-bit fields. + _ [_sigev_max_size - (1*goarch.PtrSize + 3*4)]byte } type epollevent struct { |
