[aot] Fix emission of external aot data by aligning tables in the file.
authorRolf Bjarne Kvinge <rolf@xamarin.com>
Wed, 6 Jan 2016 12:56:43 +0000 (13:56 +0100)
committerZoltan Varga <vargaz@gmail.com>
Wed, 6 Jan 2016 13:46:32 +0000 (08:46 -0500)
The table reading code depends on data being aligned, so make sure it is.

mono/mini/aot-compiler.c

index 63a330d537097562e70e49bfd89c1bbae9e913ae..b066a590993d1e9232d9a40b50ef299cd8d06744 100644 (file)
@@ -2338,6 +2338,12 @@ emit_aot_data (MonoAotCompile *acfg, MonoAotFileTable table, const char *symbol,
                acfg->table_offsets [(int)table] = acfg->datafile_offset;
                fwrite (data,1, size, acfg->data_outfile);
                acfg->datafile_offset += size;
+               // align the data to 8 bytes. Put zeros in the file (so that every build results in consistent output).
+               int align = 8 - size % 8;
+               acfg->datafile_offset += align;
+               guint8 align_buf [16];
+               memset (&align_buf, 0, sizeof (align_buf));
+               fwrite (align_buf, align, 1, acfg->data_outfile);
        } else if (acfg->llvm) {
                mono_llvm_emit_aot_data (symbol, data, size);
        } else {