summaryrefslogtreecommitdiff
path: root/src/codegen/struct_layout.rs
diff options
context:
space:
mode:
authorTheodore Dubois <tbodt@google.com>2021-10-13 15:00:47 -0700
committerEmilio Cobos Álvarez <emilio@crisal.io>2021-10-27 19:22:51 +0200
commit57853405463dd985dd49a2f14fb78bbf3595b1df (patch)
tree60566919f85f5289730c2a110e96fb0b7df9f55c /src/codegen/struct_layout.rs
parent9738fb9d0bafbc986412d695ec6933eda94dbe4f (diff)
Don't generate 2^64 byte padding fields on unions
The --explicit-padding flag would make bindgen try to add tail padding to rust unions, by adding up the size of all the union fields and subtracting from the size of the union as given by clang. The total size of a union's fields is always larger than the union, so the subtraction underflowed and bindgen produced padding fields larger than addressable RAM.
Diffstat (limited to 'src/codegen/struct_layout.rs')
-rw-r--r--src/codegen/struct_layout.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/codegen/struct_layout.rs b/src/codegen/struct_layout.rs
index b49fab41..657be0b4 100644
--- a/src/codegen/struct_layout.rs
+++ b/src/codegen/struct_layout.rs
@@ -279,6 +279,11 @@ impl<'a> StructLayoutTracker<'a> {
return None;
}
+ // Padding doesn't make sense for rust unions.
+ if self.is_rust_union {
+ return None;
+ }
+
if self.latest_offset == comp_layout.size {
// This struct does not contain tail padding.
return None;