/* They must be the same */
g_assert ((const void *) image->tables_base == (const void *) rows);
+ if (image->heap_pdb.size) {
+ /*
+ * Obtain token sizes from the pdb stream.
+ */
+ /* 24 = guid + entry point */
+ int pos = 24;
+ image->referenced_tables = read64 (image->heap_pdb.data + pos);
+ pos += 8;
+ image->referenced_table_rows = g_new0 (int, 64);
+ for (int i = 0; i < 64; ++i) {
+ if (image->referenced_tables & ((guint64)1 << i)) {
+ image->referenced_table_rows [i] = read32 (image->heap_pdb.data + pos);
+ pos += 4;
+ }
+ }
+ }
+
mono_metadata_compute_table_bases (image);
return TRUE;
}
const char *tables_base;
+ /* For PPDB files */
+ guint64 referenced_tables;
+ int *referenced_table_rows;
+
/**/
MonoTableInfo tables [MONO_TABLE_NUM];
static inline int
idx_size (MonoImage *meta, int tableidx)
{
- return meta->tables [tableidx].rows < 65536 ? 2 : 4;
+ if (meta->referenced_tables && (meta->referenced_tables & ((guint64)1 << tableidx)))
+ return meta->referenced_table_rows [tableidx] < 65536 ? 2 : 4;
+ else
+ return meta->tables [tableidx].rows < 65536 ? 2 : 4;
}
static inline int
get_nrows (MonoImage *meta, int tableidx)
{
- return meta->tables [tableidx].rows;
+ if (meta->referenced_tables && (meta->referenced_tables & ((guint64)1 << tableidx)))
+ return meta->referenced_table_rows [tableidx];
+ else
+ return meta->tables [tableidx].rows;
}
/* Reference: Partition II - 23.2.6 */