diff --git a/tools/qfcc/include/obj_type.h b/tools/qfcc/include/obj_type.h index b8ff2b4e2..6d4811c7f 100644 --- a/tools/qfcc/include/obj_type.h +++ b/tools/qfcc/include/obj_type.h @@ -99,6 +99,11 @@ typedef struct qfot_type_s { } t; } qfot_type_t; +typedef struct qfot_type_encodings_s { + pointer_t types; + pr_int_t size; +} qfot_type_encodings_t; + struct type_s; struct def_s *qfo_encode_type (struct type_s *type); diff --git a/tools/qfcc/include/type.h b/tools/qfcc/include/type.h index a846d0206..337219e2a 100644 --- a/tools/qfcc/include/type.h +++ b/tools/qfcc/include/type.h @@ -114,6 +114,7 @@ extern type_t *type_default; // default type (float or int) extern type_t type_va_list; extern type_t type_param; extern type_t type_zero; +extern type_t type_type_encodings; extern struct symtab_s *vector_struct; extern struct symtab_s *quaternion_struct; diff --git a/tools/qfcc/source/obj_file.c b/tools/qfcc/source/obj_file.c index f475b5402..41fd0fd69 100644 --- a/tools/qfcc/source/obj_file.c +++ b/tools/qfcc/source/obj_file.c @@ -918,8 +918,12 @@ qfo_to_progs (qfo_t *qfo, int *size) qfo->spaces[qfo_type_space].d.data = type_data; qfo_relocate_refs (qfo); - if (types_def) - globals[types_def->offset].pointer_var = type_data - globals; + if (types_def) { + qfot_type_encodings_t *encodings; + encodings = (qfot_type_encodings_t *) &globals[types_def->offset]; + encodings->types = type_data - globals; + encodings->size = qfo->spaces[qfo_type_space].data_size; + } // undo the relocation of the offsets of local defs so the local defs have // the correct offset in the debug info diff --git a/tools/qfcc/source/qfcc.c b/tools/qfcc/source/qfcc.c index 4d34b1217..00e4fa1eb 100644 --- a/tools/qfcc/source/qfcc.c +++ b/tools/qfcc/source/qfcc.c @@ -402,7 +402,7 @@ finish_link (void) str = linker_add_string (options.debug_file); linker_add_def (".debug_file", &type_string, flags, &str); } - linker_add_def (".type_encodings", &type_pointer, flags, 0); + linker_add_def (".type_encodings", &type_type_encodings, flags, 0); qfo = linker_finish (); if (!qfo) diff --git a/tools/qfcc/source/type.c b/tools/qfcc/source/type.c index 6a8c45f13..9e5fa7c52 100644 --- a/tools/qfcc/source/type.c +++ b/tools/qfcc/source/type.c @@ -83,6 +83,7 @@ type_t *type_default; type_t type_va_list = { ev_invalid, "@va_list", ty_struct }; type_t type_param = { ev_invalid, "@param", ty_struct }; type_t type_zero = { ev_invalid, "@zero", ty_struct }; +type_t type_type_encodings = { ev_invalid, "@type_encodings", ty_struct }; type_t type_floatfield = { ev_field, ".float", ty_none, {{&type_float}} }; @@ -850,6 +851,11 @@ init_types (void) {"v", &type_vector}, {0, 0} }; + static struct_def_t type_encoding_struct[] = { + {"types", &type_pointer}, + {"size", &type_integer}, + {0, 0} + }; type_nil = &type_quaternion; type_default = &type_integer; @@ -869,6 +875,9 @@ init_types (void) type_vector.type = ev_vector; type_vector.meta = ty_none; + make_structure ("@type_encodings", 's', type_encoding_struct, + &type_type_encodings); + if (options.traditional) return; @@ -905,6 +914,7 @@ chain_initial_types (void) chain_type (&type_param); chain_type (&type_zero); + chain_type (&type_type_encodings); va_list_struct[1].type = pointer_type (&type_param); make_structure ("@va_list", 's', va_list_struct, &type_va_list);