Allow defs to specify use of offset relocations.

Access to struct fields in near data can be done using only one operand,
but offset relocs need to be used. However, as not all defs want offset
relocs, a flag has been added to the def struct.
This commit is contained in:
Bill Currie 2011-02-15 22:43:07 +09:00
parent d04865884f
commit 9c9a71f1af
2 changed files with 6 additions and 1 deletions

View file

@ -46,6 +46,7 @@ typedef struct def_s {
struct def_s *alias;
struct reloc_s *relocs; ///< for relocations
unsigned offset_reloc:1; ///< use *_def_ofs relocs
unsigned initialized:1;
unsigned constant:1; ///< stores constant value
unsigned global:1; ///< globally declared def

View file

@ -122,6 +122,7 @@ get_operand_def (expr_t *expr, operand_t *op)
if (op->o.pointer->val || op->type != def->type->type) {
def = alias_def (def, ev_types[op->type]);
def->offset = op->o.pointer->val;
def->offset_reloc = 1;
}
return def;
}
@ -135,7 +136,10 @@ add_statement_def_ref (def_t *def, dstatement_t *st, int field)
int st_ofs = st - pr.code->code;
if (def->alias) {
reloc_op_def (def->alias, st_ofs, field);
if (def->offset_reloc)
reloc_op_def_ofs (def->alias, st_ofs, field);
else
reloc_op_def (def->alias, st_ofs, field);
free_def (def);
} else {
reloc_op_def (def, st_ofs, field);