mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
Rename qfo_reloc_t's def to target and correct its usage.
This commit is contained in:
parent
c8f1b5b1f0
commit
8b661bbb89
4 changed files with 47 additions and 33 deletions
|
@ -234,7 +234,7 @@ typedef struct qfo_reloc_s {
|
|||
pr_int_t space; ///< index of space holding data to be adjusted
|
||||
pr_int_t offset; ///< offset of the relocation
|
||||
pr_int_t type; ///< type of the relocation (::reloc_type)
|
||||
pr_int_t def; ///< "def" this relocation is for
|
||||
pr_int_t target; ///< def/func/etc this relocation is for
|
||||
} qfo_reloc_t;
|
||||
|
||||
/** In-memory representation of a QFO space
|
||||
|
|
|
@ -269,10 +269,10 @@ qfo_relocs (qfo_t *qfo)
|
|||
case rel_op_a_def:
|
||||
case rel_op_b_def:
|
||||
case rel_op_c_def:
|
||||
def = qfo->defs + reloc->def;
|
||||
def = qfo->defs + reloc->target;
|
||||
printf (" op.%c@%d def#%d %s",
|
||||
reloc->type - rel_op_a_def + 'a',
|
||||
reloc->offset, reloc->def,
|
||||
reloc->offset, reloc->target,
|
||||
QFO_GETSTR (qfo, def->name));
|
||||
break;
|
||||
case rel_op_a_op:
|
||||
|
@ -283,22 +283,22 @@ qfo_relocs (qfo_t *qfo)
|
|||
break;
|
||||
case rel_def_op:
|
||||
printf (" def@%d:%x op@%d", reloc->space, reloc->offset,
|
||||
reloc->def);
|
||||
reloc->target);
|
||||
break;
|
||||
case rel_def_def:
|
||||
def = qfo->defs + reloc->def;
|
||||
def = qfo->defs + reloc->target;
|
||||
printf (" def@%d:%x def#%d %s", reloc->space, reloc->offset,
|
||||
reloc->def, QFO_GETSTR (qfo, def->name));
|
||||
reloc->target, QFO_GETSTR (qfo, def->name));
|
||||
break;
|
||||
case rel_def_func:
|
||||
//func = qfo->funcs + reloc->def;
|
||||
func = qfo->funcs + QFO_FUNCTION (qfo, reloc->space,
|
||||
reloc->offset);
|
||||
func = qfo->funcs + reloc->target;
|
||||
//func = qfo->funcs + QFO_FUNCTION (qfo, reloc->space,
|
||||
// reloc->offset);
|
||||
printf (" def@%d:%x func#%d %s %x",
|
||||
reloc->space, reloc->offset,
|
||||
QFO_FUNCTION (qfo, reloc->space, reloc->offset),
|
||||
QFO_GETSTR (qfo, func->name),
|
||||
reloc->def);
|
||||
reloc->target);
|
||||
break;
|
||||
case rel_def_string:
|
||||
printf (" def@%d:%x string:%x `%s'",
|
||||
|
@ -307,31 +307,31 @@ qfo_relocs (qfo_t *qfo)
|
|||
QFO_GSTRING (qfo, reloc->space, reloc->offset));
|
||||
break;
|
||||
case rel_def_field:
|
||||
def = qfo->defs + reloc->def;
|
||||
def = qfo->defs + reloc->target;
|
||||
printf (" def@%d:%x def#%d %s", reloc->space, reloc->offset,
|
||||
reloc->def, QFO_GETSTR (qfo, def->name));
|
||||
reloc->target, QFO_GETSTR (qfo, def->name));
|
||||
break;
|
||||
case rel_op_a_def_ofs:
|
||||
case rel_op_b_def_ofs:
|
||||
case rel_op_c_def_ofs:
|
||||
def = qfo->defs + reloc->def;
|
||||
def = qfo->defs + reloc->target;
|
||||
printf (" op.%c@%x def#%d %s",
|
||||
reloc->type - rel_op_a_def_ofs + 'a',
|
||||
reloc->offset, reloc->def,
|
||||
reloc->offset, reloc->target,
|
||||
QFO_GETSTR (qfo, def->name));
|
||||
break;
|
||||
case rel_def_def_ofs:
|
||||
def = qfo->defs + reloc->def;
|
||||
def = qfo->defs + reloc->target;
|
||||
printf (" def@%d:%x def#%d+%d %s+%d",
|
||||
reloc->space, reloc->offset, reloc->def,
|
||||
reloc->space, reloc->offset, reloc->target,
|
||||
QFO_INT (qfo, reloc->space, reloc->offset),
|
||||
QFO_GETSTR (qfo, def->name),
|
||||
QFO_INT (qfo, reloc->space, reloc->offset));
|
||||
break;
|
||||
case rel_def_field_ofs:
|
||||
def = qfo->defs + reloc->def;
|
||||
def = qfo->defs + reloc->target;
|
||||
printf (" def@%d:%x def#%d+%d %s+%d",
|
||||
reloc->space, reloc->offset, reloc->def,
|
||||
reloc->space, reloc->offset, reloc->target,
|
||||
QFO_INT (qfo, reloc->space, reloc->offset),
|
||||
QFO_GETSTR (qfo, def->name),
|
||||
QFO_INT (qfo, reloc->space, reloc->offset));
|
||||
|
|
|
@ -185,7 +185,7 @@ update_relocs (qfo_t *qfo)
|
|||
} else {
|
||||
reloc->space += work->num_spaces;
|
||||
}
|
||||
reloc->def += work->num_defs;
|
||||
reloc->target += work->num_defs; //FIXME wrong
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
|||
#include "options.h"
|
||||
#include "qfcc.h"
|
||||
#include "reloc.h"
|
||||
#include "statements.h"
|
||||
#include "strpool.h"
|
||||
#include "symtab.h"
|
||||
#include "type.h"
|
||||
|
@ -92,22 +93,28 @@ qfo_def_flags (def_t *def)
|
|||
return flags;
|
||||
}
|
||||
|
||||
static void
|
||||
qfo_encode_one_reloc (reloc_t *reloc, qfo_reloc_t **qfo_reloc, pr_int_t target)
|
||||
{
|
||||
qfo_reloc_t *q;
|
||||
|
||||
q = (*qfo_reloc)++;
|
||||
if (reloc->space) // op_* relocs do not have a space (code is implied)
|
||||
q->space = reloc->space->qfo_space;
|
||||
q->offset = reloc->offset;
|
||||
q->type = reloc->type;
|
||||
q->target = target;
|
||||
}
|
||||
|
||||
static int
|
||||
qfo_encode_relocs (qfo_t *qfo, reloc_t *relocs, qfo_reloc_t **qfo_relocs,
|
||||
qfo_def_t *def)
|
||||
qfo_encode_relocs (reloc_t *relocs, qfo_reloc_t **qfo_relocs, pr_int_t target)
|
||||
{
|
||||
int count;
|
||||
reloc_t *r;
|
||||
qfo_reloc_t *q;
|
||||
|
||||
for (count = 0, r = relocs; r; r = r->next) {
|
||||
count++;
|
||||
q = (*qfo_relocs)++;
|
||||
if (r->space) // op_* relocs do not have a space (code is implied)
|
||||
q->space = r->space->qfo_space;
|
||||
q->offset = r->offset;
|
||||
q->type = r->type;
|
||||
q->def = def - qfo->defs;
|
||||
qfo_encode_one_reloc (r, qfo_relocs, target);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
@ -130,7 +137,8 @@ qfo_encode_defs (qfo_t *qfo, def_t *defs, qfo_def_t **qfo_defs,
|
|||
q->name = ReuseString (d->name);
|
||||
q->offset = d->offset;
|
||||
q->relocs = *qfo_relocs - qfo->relocs;
|
||||
q->num_relocs = qfo_encode_relocs (qfo, d->relocs, qfo_relocs, q);
|
||||
q->num_relocs = qfo_encode_relocs (d->relocs, qfo_relocs,
|
||||
q - qfo->defs);
|
||||
q->flags = qfo_def_flags (d);
|
||||
q->file = d->file;
|
||||
q->line = d->line;
|
||||
|
@ -256,7 +264,7 @@ qfo_encode_functions (qfo_t *qfo, qfo_def_t **defs, qfo_reloc_t **relocs,
|
|||
if (f->aux)
|
||||
q->line_info = f->aux->line_info;
|
||||
q->relocs = *relocs - qfo->relocs;
|
||||
q->num_relocs = qfo_encode_relocs (qfo, f->refs, relocs, 0);
|
||||
q->num_relocs = qfo_encode_relocs (f->refs, relocs, q - qfo->funcs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,6 +274,7 @@ qfo_from_progs (pr_info_t *pr)
|
|||
qfo_t *qfo;
|
||||
qfo_def_t *def;
|
||||
qfo_reloc_t *reloc;
|
||||
reloc_t *r;
|
||||
|
||||
qfo = calloc (1, sizeof (qfo_t));
|
||||
qfo->num_spaces = qfo_num_spaces; // certain spaces are always present
|
||||
|
@ -297,7 +306,12 @@ qfo_from_progs (pr_info_t *pr)
|
|||
qfo_init_string_space (qfo, &qfo->spaces[qfo_strings_space], pr->strings);
|
||||
|
||||
qfo->num_loose_relocs = qfo->num_relocs - (reloc - qfo->relocs);
|
||||
qfo_encode_relocs (qfo, pr->relocs, &reloc, 0);
|
||||
for (r = pr->relocs; r; r = r->next) {
|
||||
if (r->type == rel_def_op)
|
||||
qfo_encode_one_reloc (r, &reloc, r->label->dest->offset);
|
||||
else
|
||||
qfo_encode_one_reloc (r, &reloc, 0);
|
||||
}
|
||||
|
||||
return qfo;
|
||||
}
|
||||
|
@ -416,7 +430,7 @@ qfo_write (qfo_t *qfo, const char *filename)
|
|||
relocs[i].space = LittleLong (qfo->relocs[i].space);
|
||||
relocs[i].offset = LittleLong (qfo->relocs[i].offset);
|
||||
relocs[i].type = LittleLong (qfo->relocs[i].type);
|
||||
relocs[i].def = LittleLong (qfo->relocs[i].def);
|
||||
relocs[i].target = LittleLong (qfo->relocs[i].target);
|
||||
}
|
||||
for (i = 0; i < qfo->num_defs; i++) {
|
||||
defs[i].type = LittleLong (qfo->defs[i].type);
|
||||
|
@ -504,7 +518,7 @@ qfo_read (QFile *file)
|
|||
qfo->relocs[i].space = LittleLong (qfo->relocs[i].space);
|
||||
qfo->relocs[i].offset = LittleLong (qfo->relocs[i].offset);
|
||||
qfo->relocs[i].type = LittleLong (qfo->relocs[i].type);
|
||||
qfo->relocs[i].def = LittleLong (qfo->relocs[i].def);
|
||||
qfo->relocs[i].target = LittleLong (qfo->relocs[i].target);
|
||||
}
|
||||
for (i = 0; i < qfo->num_defs; i++) {
|
||||
qfo->defs[i].type = LittleLong (qfo->defs[i].type);
|
||||
|
|
Loading…
Reference in a new issue