/* storage for optimizer flags */
unsigned long opt_flags;
+
+ /* NULL-terminated array of labels that point to this bytecode (as the
+ * bytecode previous to the label). NULL if no labels point here. */
+ /*@null@*/ yasm_symrec **symrecs;
};
/** Create a bytecode of any specified type.
bc->opt_flags = 0;
+ bc->symrecs = NULL;
+
return bc;
}
return bc->section;
}
+void
+yasm_bc__add_symrec(yasm_bytecode *bc, yasm_symrec *sym)
+{
+ if (!bc->symrecs) {
+ bc->symrecs = yasm_xmalloc(2*sizeof(yasm_symrec *));
+ bc->symrecs[0] = sym;
+ bc->symrecs[1] = NULL;
+ } else {
+ /* Very inefficient implementation for large numbers of symbols. But
+ * that would be very unusual, so use the simple algorithm instead.
+ */
+ size_t count = 1;
+ while (bc->symrecs[count])
+ count++;
+ bc->symrecs = yasm_xrealloc(bc->symrecs,
+ (count+2)*sizeof(yasm_symrec *));
+ bc->symrecs[count] = sym;
+ bc->symrecs[count+1] = NULL;
+ }
+}
+
void
yasm_bc_destroy(yasm_bytecode *bc)
{
if (bc->callback)
bc->callback->destroy(bc);
yasm_expr_destroy(bc->multiple);
+ yasm_xfree(bc->symrecs);
yasm_xfree(bc);
}
*/
/*@dependent@*/ /*@null@*/ yasm_section *yasm_bc_get_section
(yasm_bytecode *bc);
+
+#ifdef YASM_LIB_INTERNAL
+/** Add to the list of symrecs that reference a bytecode. For symrec use
+ * only.
+ * \param bc bytecode
+ * \param sym symbol
+ */
+void yasm_bc__add_symrec(yasm_bytecode *bc, /*@dependent@*/ yasm_symrec *sym);
+#endif
/** Delete (free allocated memory for) a bytecode.
* \param bc bytecode (only pointer to it); may be NULL
yasm_symrec *rec;
rec = symtab_define(symtab, name, SYM_LABEL, in_table, line);
rec->value.precbc = precbc;
+ if (precbc)
+ yasm_bc__add_symrec(precbc, rec);
return rec;
}