mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
Align local and far data spaces
I plan on adding doubles, and so it's necessary to ensure that attempts to align doubles in local or far data spaces remain aligned after final linking.
This commit is contained in:
parent
197f856a30
commit
16f8dca72e
1 changed files with 17 additions and 7 deletions
|
@ -795,6 +795,14 @@ qfo_relocate_refs (qfo_t *qfo)
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned
|
||||
align_globals_size (unsigned size)
|
||||
{
|
||||
if (options.code.progsversion == PROG_ID_VERSION)
|
||||
return size;
|
||||
return RUP (size, 16 / sizeof (pr_type_t));
|
||||
}
|
||||
|
||||
dprograms_t *
|
||||
qfo_to_progs (qfo_t *qfo, int *size)
|
||||
{
|
||||
|
@ -811,6 +819,7 @@ qfo_to_progs (qfo_t *qfo, int *size)
|
|||
dprograms_t *progs;
|
||||
qfo_def_t *types_def = 0;
|
||||
unsigned i, j;
|
||||
unsigned near_data_size = 0;
|
||||
unsigned locals_size = 0;
|
||||
int locals_start;
|
||||
unsigned big_locals = 0;
|
||||
|
@ -827,9 +836,8 @@ qfo_to_progs (qfo_t *qfo, int *size)
|
|||
progs->numfunctions = qfo->num_funcs + 1;
|
||||
progs->numstrings = qfo->spaces[qfo_strings_space].data_size;
|
||||
progs->numglobals = qfo->spaces[qfo_near_data_space].data_size;
|
||||
progs->numglobals += qfo->spaces[qfo_far_data_space].data_size;
|
||||
progs->numglobals += qfo->spaces[qfo_type_space].data_size;
|
||||
locals_start = qfo->spaces[qfo_near_data_space].data_size;
|
||||
progs->numglobals = align_globals_size (progs->numglobals);
|
||||
locals_start = progs->numglobals;
|
||||
for (i = qfo_num_spaces; i < qfo->num_spaces; i++) {
|
||||
if (options.code.local_merging) {
|
||||
if (locals_size < qfo->spaces[i].data_size) {
|
||||
|
@ -837,11 +845,14 @@ qfo_to_progs (qfo_t *qfo, int *size)
|
|||
big_locals = i;
|
||||
}
|
||||
} else {
|
||||
locals_size += qfo->spaces[i].data_size;
|
||||
locals_size += align_globals_size (qfo->spaces[i].data_size);
|
||||
}
|
||||
}
|
||||
progs->numglobals += locals_size;
|
||||
near_data_size = progs->numglobals;
|
||||
progs->numglobals = RUP (progs->numglobals, 16 / sizeof (pr_type_t));
|
||||
progs->numglobals += qfo->spaces[qfo_far_data_space].data_size;
|
||||
progs->numglobals += qfo->spaces[qfo_type_space].data_size;
|
||||
progs->entityfields = qfo->spaces[qfo_entity_space].data_size;
|
||||
*size += progs->numstatements * sizeof (dstatement_t);
|
||||
*size += progs->numglobaldefs * sizeof (ddef_t);
|
||||
|
@ -902,7 +913,7 @@ qfo_to_progs (qfo_t *qfo, int *size)
|
|||
for (j = 0; j < space->num_defs; j++)
|
||||
space->defs[j].offset += locals_start;
|
||||
if (!options.code.local_merging)
|
||||
locals_start += df->locals;
|
||||
locals_start += align_globals_size (df->locals);
|
||||
df->profile = 0;
|
||||
df->s_name = qf->name;
|
||||
df->s_file = qf->file;
|
||||
|
@ -978,8 +989,7 @@ qfo_to_progs (qfo_t *qfo, int *size)
|
|||
printf ("%6i global defs\n", progs->numglobaldefs);
|
||||
printf ("%6i fielddefs\n", progs->numfielddefs);
|
||||
printf ("%6i globals\n", progs->numglobals);
|
||||
printf (" %6i near globals\n",
|
||||
qfo->spaces[qfo_near_data_space].data_size + locals_size);
|
||||
printf (" %6i near globals\n", near_data_size);
|
||||
printf (" %6i locals size%s\n", locals_size, big_function);
|
||||
printf (" %6i far globals\n",
|
||||
qfo->spaces[qfo_far_data_space].data_size);
|
||||
|
|
Loading…
Reference in a new issue