From e05c12e16d64723f22c406a9deb1c87e5899bf6c Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 14 Nov 2012 13:12:58 +0900 Subject: [PATCH] Make linker_add_def take a pointer for the value. While it looks like I might not use it for the type encodings, it should be useful in the future. --- tools/qfcc/include/linker.h | 2 +- tools/qfcc/source/linker.c | 10 ++++++---- tools/qfcc/source/qfcc.c | 7 ++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/qfcc/include/linker.h b/tools/qfcc/include/linker.h index cae7a0b38..4f13b22f7 100644 --- a/tools/qfcc/include/linker.h +++ b/tools/qfcc/include/linker.h @@ -37,7 +37,7 @@ struct type_s; void linker_begin (void); int linker_add_string (const char *str); void linker_add_def (const char *name, struct type_s *type, unsigned flags, - int v); + void *val); struct qfo_def_s *linker_find_def (const char *name); int linker_add_qfo (struct qfo_s *qfo); int linker_add_object_file (const char *filename); diff --git a/tools/qfcc/source/linker.c b/tools/qfcc/source/linker.c index 0e59cae9e..4f1d9af1d 100644 --- a/tools/qfcc/source/linker.c +++ b/tools/qfcc/source/linker.c @@ -551,7 +551,7 @@ add_data_space (qfo_t *qfo, qfo_mspace_t *space) } static defref_t * -make_def (int s, const char *name, type_t *type, unsigned flags, int v) +make_def (int s, const char *name, type_t *type, unsigned flags, void *val) { qfo_def_t *def; defref_t *ref; @@ -572,7 +572,9 @@ make_def (int s, const char *name, type_t *type, unsigned flags, int v) def->type = REF (ref)->offset; def->offset = alloc_data (s, type_size (type)); def->flags = flags; - def_space->data[def->offset].integer_var = v; + if (val) + memcpy (&def_space->data[def->offset], val, + type_size (type) * sizeof (pr_type_t)); space->d.data = def_space->data; space->data_size = def_space->size; @@ -590,9 +592,9 @@ make_def (int s, const char *name, type_t *type, unsigned flags, int v) } void -linker_add_def (const char *name, type_t *type, unsigned flags, int v) +linker_add_def (const char *name, type_t *type, unsigned flags, void *val) { - make_def (qfo_near_data_space, name, type, flags, v); + make_def (qfo_near_data_space, name, type, flags, val); } qfo_def_t * diff --git a/tools/qfcc/source/qfcc.c b/tools/qfcc/source/qfcc.c index bdc43d677..4d34b1217 100644 --- a/tools/qfcc/source/qfcc.c +++ b/tools/qfcc/source/qfcc.c @@ -390,16 +390,17 @@ finish_link (void) flags = (QFOD_GLOBAL | QFOD_CONSTANT | QFOD_INITIALIZED | QFOD_NOSAVE); if (options.code.progsversion != PROG_ID_VERSION) { + pr_int_t param_size = type_size (&type_param); linker_add_def (".param_size", &type_integer, flags, - type_size (&type_param)); + ¶m_size); } if (options.code.debug) { - int str; + pr_int_t str; setup_sym_file (options.output_file); str = linker_add_string (options.debug_file); - linker_add_def (".debug_file", &type_string, flags, str); + linker_add_def (".debug_file", &type_string, flags, &str); } linker_add_def (".type_encodings", &type_pointer, flags, 0);