diff --git a/tools/qfcc/include/reloc.h b/tools/qfcc/include/reloc.h index 83126d5d6..2272dab5d 100644 --- a/tools/qfcc/include/reloc.h +++ b/tools/qfcc/include/reloc.h @@ -239,6 +239,8 @@ void reloc_def_field_ofs (struct def_s *def, struct def_s *location); */ void reloc_def_op (struct ex_label_s *label, struct def_s *location); +void reloc_attach_relocs (reloc_t *relocs, reloc_t **location); + ///@} #endif//__reloc_h diff --git a/tools/qfcc/source/def.c b/tools/qfcc/source/def.c index 82386f74f..a710626a5 100644 --- a/tools/qfcc/source/def.c +++ b/tools/qfcc/source/def.c @@ -391,7 +391,7 @@ init_field_def (def_t *def, expr_t *init, storage_class_t storage) } if (!field_sym->s.def) { field_sym->s.def = new_def (def->name, type, pr.entity_data, storage); - field_sym->s.def->relocs = relocs; + reloc_attach_relocs (relocs, &field_sym->s.def->relocs); field_sym->s.def->nosave = 1; } field_def = field_sym->s.def; @@ -470,7 +470,7 @@ initialize_def (symbol_t *sym, type_t *type, expr_t *init, defspace_t *space, } if (!sym->s.def) { sym->s.def = new_def (sym->name, type, space, storage); - sym->s.def->relocs = relocs; + reloc_attach_relocs (relocs, &sym->s.def->relocs); } if (type == &type_vector && options.code.vector_components) init_vector_components (sym, 0); diff --git a/tools/qfcc/source/function.c b/tools/qfcc/source/function.c index 5f28e95f3..37448fd3c 100644 --- a/tools/qfcc/source/function.c +++ b/tools/qfcc/source/function.c @@ -513,7 +513,7 @@ make_function (symbol_t *sym, const char *nice_name, defspace_t *space, } if (!sym->s.func->def) { sym->s.func->def = new_def (sym->name, sym->type, space, storage); - sym->s.func->def->relocs = relocs; + reloc_attach_relocs (relocs, &sym->s.func->def->relocs); } } diff --git a/tools/qfcc/source/obj_type.c b/tools/qfcc/source/obj_type.c index 5cb1bbf95..99eb189d7 100644 --- a/tools/qfcc/source/obj_type.c +++ b/tools/qfcc/source/obj_type.c @@ -255,6 +255,8 @@ qfo_encode_class (type_t *type) def_t * qfo_encode_type (type_t *type) { + reloc_t *relocs = 0; + static encode_f funcs[] = { qfo_encode_none, // ty_none qfo_encode_struct, // ty_struct @@ -265,7 +267,7 @@ qfo_encode_type (type_t *type) }; if (type->type_def && type->type_def->external) { - //FIXME relocs + relocs = type->type_def->relocs; free_def (type->type_def); type->type_def = 0; } @@ -276,5 +278,6 @@ qfo_encode_type (type_t *type) if (!type->encoding) type->encoding = type_get_encoding (type); type->type_def = funcs[type->meta] (type); + reloc_attach_relocs (relocs, &type->type_def->relocs); return type->type_def; } diff --git a/tools/qfcc/source/reloc.c b/tools/qfcc/source/reloc.c index 3ecd378cc..921d20a6f 100644 --- a/tools/qfcc/source/reloc.c +++ b/tools/qfcc/source/reloc.c @@ -282,3 +282,16 @@ reloc_def_op (ex_label_t *label, def_t *location) ref->label = label; pr.relocs = ref; } + +void +reloc_attach_relocs (reloc_t *relocs, reloc_t **location) +{ + reloc_t *r; + + if (!relocs) + return; + for (r = relocs; r->next; r = r->next) + ; + r->next = *location; + *location = relocs; +} diff --git a/tools/qfcc/source/symtab.c b/tools/qfcc/source/symtab.c index 3264b0f84..95de15970 100644 --- a/tools/qfcc/source/symtab.c +++ b/tools/qfcc/source/symtab.c @@ -42,6 +42,7 @@ #include "diagnostic.h" #include "function.h" #include "qfcc.h" +#include "reloc.h" #include "strpool.h" #include "symtab.h" #include "type.h" @@ -213,7 +214,7 @@ make_symbol (const char *name, type_t *type, defspace_t *space, } if (!sym->s.def) { sym->s.def = new_def (name, type, space, storage); - sym->s.def->relocs = relocs; + reloc_attach_relocs (relocs, &sym->s.def->relocs); } return sym; }