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.
This commit is contained in:
Bill Currie 2012-11-14 13:12:58 +09:00
parent 51236b0693
commit e05c12e16d
3 changed files with 11 additions and 8 deletions

View file

@ -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);

View file

@ -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 *

View file

@ -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));
&param_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);