Fix qfo reloc dumping.

This commit is contained in:
Bill Currie 2011-02-25 13:29:09 +09:00
parent f43eda63fe
commit 2b3436beed

View file

@ -270,9 +270,10 @@ qfo_relocs (qfo_t *qfo)
case rel_op_b_def: case rel_op_b_def:
case rel_op_c_def: case rel_op_c_def:
def = qfo->defs + reloc->def; def = qfo->defs + reloc->def;
// printf (" op.%c@%d def@%d %s", printf (" op.%c@%d def#%d %s",
// reloc->type - rel_op_a_def + 'a', reloc->type - rel_op_a_def + 'a',
// reloc->offset, def->offset, QFO_GETSTR (qfo, def->name)); reloc->offset, reloc->def,
QFO_GETSTR (qfo, def->name));
break; break;
case rel_op_a_op: case rel_op_a_op:
case rel_op_b_op: case rel_op_b_op:
@ -281,48 +282,59 @@ qfo_relocs (qfo_t *qfo)
reloc->offset); reloc->offset);
break; break;
case rel_def_op: case rel_def_op:
printf (" def@%d op@%d", reloc->offset, reloc->def); printf (" def@%d:%x op@%d", reloc->space, reloc->offset,
reloc->def);
break; break;
case rel_def_def: case rel_def_def:
def = qfo->defs + reloc->def; def = qfo->defs + reloc->def;
// printf (" def@%d def@%d %s", reloc->offset, reloc->def, printf (" def@%d:%x def#%d %s", reloc->space, reloc->offset,
// QFO_GETSTR (qfo, def->name)); reloc->def, QFO_GETSTR (qfo, def->name));
break; break;
case rel_def_func: case rel_def_func:
func = qfo->funcs + reloc->def; //func = qfo->funcs + reloc->def;
// printf (" def@%d func@%d %s", reloc->offset, reloc->def, func = qfo->funcs + QFO_FUNCTION (qfo, reloc->space,
// QFO_GETSTR (qfo, func->name)); 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);
break; break;
case rel_def_string: case rel_def_string:
// printf (" def@%d string:`%s'", reloc->offset, printf (" def@%d:%x string:%x `%s'",
// QFO_GSTRING (qfo, reloc->offset)); reloc->space, reloc->offset,
QFO_STRING (qfo, reloc->space, reloc->offset),
QFO_GSTRING (qfo, reloc->space, reloc->offset));
break; break;
case rel_def_field: case rel_def_field:
def = qfo->defs + reloc->def; def = qfo->defs + reloc->def;
// printf (" def@%d def@%d %s", reloc->offset, reloc->def, printf (" def@%d:%x def#%d %s", reloc->space, reloc->offset,
// QFO_GETSTR (qfo, def->name)); reloc->def, QFO_GETSTR (qfo, def->name));
break; break;
case rel_op_a_def_ofs: case rel_op_a_def_ofs:
case rel_op_b_def_ofs: case rel_op_b_def_ofs:
case rel_op_c_def_ofs: case rel_op_c_def_ofs:
def = qfo->defs + reloc->def; def = qfo->defs + reloc->def;
// printf (" op.%c@%d def@%d %s", printf (" op.%c@%x def#%d %s",
// reloc->type - rel_op_a_def_ofs + 'a', reloc->type - rel_op_a_def_ofs + 'a',
// reloc->offset, def->offset, QFO_GETSTR (qfo, def->name)); reloc->offset, reloc->def,
QFO_GETSTR (qfo, def->name));
break; break;
case rel_def_def_ofs: case rel_def_def_ofs:
def = qfo->defs + reloc->def; def = qfo->defs + reloc->def;
// printf (" def@%d def@%d+%d %s+%d", reloc->offset, reloc->def, printf (" def@%d:%x def#%d+%d %s+%d",
// qfo->data[reloc->offset].integer_var, reloc->space, reloc->offset, reloc->def,
// QFO_GETSTR (qfo, def->name), QFO_INT (qfo, reloc->space, reloc->offset),
// qfo->data[reloc->offset].integer_var); QFO_GETSTR (qfo, def->name),
QFO_INT (qfo, reloc->space, reloc->offset));
break; break;
case rel_def_field_ofs: case rel_def_field_ofs:
def = qfo->defs + reloc->def; def = qfo->defs + reloc->def;
// printf (" def@%d def@%d+%d %s+%d", reloc->offset, reloc->def, printf (" def@%d:%x def#%d+%d %s+%d",
// qfo->data[reloc->offset].integer_var, reloc->space, reloc->offset, reloc->def,
// QFO_GETSTR (qfo, def->name), QFO_INT (qfo, reloc->space, reloc->offset),
// qfo->data[reloc->offset].integer_var); QFO_GETSTR (qfo, def->name),
QFO_INT (qfo, reloc->space, reloc->offset));
break; break;
} }
if (def && def->flags & QFOD_EXTERNAL) if (def && def->flags & QFOD_EXTERNAL)
@ -330,9 +342,11 @@ qfo_relocs (qfo_t *qfo)
if (func && qfo->defs[func->def].flags & QFOD_EXTERNAL) if (func && qfo->defs[func->def].flags & QFOD_EXTERNAL)
printf (" external"); printf (" external");
if (def && (i < def->relocs || i >= def->relocs + def->num_relocs)) if (def && (i < def->relocs || i >= def->relocs + def->num_relocs))
printf (" BOGUS reloc!"); printf (" BOGUS def reloc! %d %d %d",
i, def->relocs, def->num_relocs);
if (func && (i < func->relocs || i >= func->relocs + func->num_relocs)) if (func && (i < func->relocs || i >= func->relocs + func->num_relocs))
printf (" BOGUS reloc!"); printf (" BOGUS func reloc! %d %d %d",
i, func->relocs, func->num_relocs);
puts (""); puts ("");
} }
} }