mtasaka / rpms / blender

Forked from rpms/blender 2 years ago
Clone
Blob Blame History Raw
From aa31976394c6439b5baa823e578f5122a9cf3685 Mon Sep 17 00:00:00 2001
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
Date: Sat, 27 Nov 2021 23:22:55 +0900
Subject: [PATCH] Fix T93425: makesdna: force DNAstr to be 4 bytes aligned.

init_structDNA() in dna_gen.c expects that the input sdna->data is 4-bytes aligned.
DNAstr[] buffer written by makesdna is used for this data, so make DNAstr forcely
4-bytes aligned.
---
 source/blender/makesdna/intern/makesdna.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 114c0b4..d709582 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -1555,8 +1555,14 @@ int main(int argc, char **argv)
         base_directory = BASE_HEADER;
       }
 
+#ifdef __GNUC__
+#define FORCE_ALIGN_4 " __attribute__((aligned(4))) "
+#else
+#define FORCE_ALIGN_4 " "
+#endif
+
       fprintf(file_dna, "extern const unsigned char DNAstr[];\n");
-      fprintf(file_dna, "const unsigned char DNAstr[] = {\n");
+      fprintf(file_dna, "const unsigned char " FORCE_ALIGN_4 "DNAstr[] = {\n");
       if (make_structDNA(base_directory, file_dna, file_dna_offsets, file_dna_verify)) {
         /* error */
         fclose(file_dna);
-- 
2.33.1