libyasm
bytecode.h
Go to the documentation of this file.
1 
30 #ifndef YASM_BYTECODE_H
31 #define YASM_BYTECODE_H
32 
33 #ifndef YASM_LIB_DECL
34 #define YASM_LIB_DECL
35 #endif
36 
38 typedef struct yasm_dataval yasm_dataval;
41 
44 
55 typedef void (*yasm_bc_add_span_func)
56  (void *add_span_data, yasm_bytecode *bc, int id, const yasm_value *value,
57  long neg_thres, long pos_thres);
58 
63 typedef struct yasm_bytecode_callback {
68  void (*destroy) (/*@only@*/ void *contents);
69 
76  void (*print) (const void *contents, FILE *f, int indent_level);
77 
83  void (*finalize) (yasm_bytecode *bc, yasm_bytecode *prev_bc);
84 
91  int (*elem_size) (yasm_bytecode *bc);
92 
109  void *add_span_data);
110 
132  int (*expand) (yasm_bytecode *bc, int span, long old_val, long new_val,
133  /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres);
134 
159  int (*tobytes) (yasm_bytecode *bc, unsigned char **bufp,
160  unsigned char *bufstart, void *d,
161  yasm_output_value_func output_value,
162  /*@null@*/ yasm_output_reloc_func output_reloc);
163 
169  YASM_BC_SPECIAL_NONE = 0,
170 
173 
176 
179  } special;
181 
187  /*@reldef@*/ STAILQ_ENTRY(yasm_bytecode) link;
188 
192  /*@null@*/ const yasm_bytecode_callback *callback;
193 
197  /*@dependent@*/ /*@null@*/ yasm_section *section;
198 
202  /*@only@*/ /*@null@*/ yasm_expr *multiple;
203 
205  unsigned long len;
206 
208  long mult_int;
209 
211  unsigned long line;
212 
216  unsigned long offset;
217 
219  unsigned long bc_index;
220 
224  /*@null@*/ yasm_symrec **symrecs;
225 
227  void *contents;
228 };
229 
237 YASM_LIB_DECL
239  (/*@null@*/ const yasm_bytecode_callback *callback,
240  /*@only@*/ /*@null@*/ void *contents, unsigned long line);
241 
247 YASM_LIB_DECL
249  const yasm_bytecode_callback *callback,
250  void *contents);
251 
255 YASM_LIB_DECL
257 
261 YASM_LIB_DECL
263  void *add_span_data);
264 
269 YASM_LIB_DECL
271  (yasm_bytecode *bc, int span, long old_val, long new_val,
272  /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres);
273 
277 YASM_LIB_DECL
279  (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
280  yasm_output_value_func output_value,
281  /*@null@*/ yasm_output_reloc_func output_reloc);
282 
287 #define yasm_bc__next(bc) STAILQ_NEXT(bc, link)
288 
295 YASM_LIB_DECL
296 void yasm_bc_set_multiple(yasm_bytecode *bc, /*@keep@*/ yasm_expr *e);
297 
308 YASM_LIB_DECL
310  (yasm_datavalhead *datahead, unsigned int size, int append_zero,
311  /*@null@*/ yasm_arch *arch, unsigned long line);
312 
319 YASM_LIB_DECL
321  (yasm_datavalhead *datahead, int sign, unsigned long line);
322 
329 YASM_LIB_DECL
331  (/*@only@*/ yasm_expr *numitems, unsigned int itemsize,
332  unsigned long line);
333 
341 YASM_LIB_DECL
342 /*@null@*/ const yasm_expr *yasm_bc_reserve_numitems
343  (yasm_bytecode *bc, /*@out@*/ unsigned int *itemsize);
344 
355 YASM_LIB_DECL
357  (/*@only@*/ char *filename, /*@only@*/ /*@null@*/ yasm_expr *start,
358  /*@only@*/ /*@null@*/ yasm_expr *maxlen, yasm_linemap *linemap,
359  unsigned long line);
360 
373 YASM_LIB_DECL
375  (/*@keep@*/ yasm_expr *boundary, /*@keep@*/ /*@null@*/ yasm_expr *fill,
376  /*@keep@*/ /*@null@*/ yasm_expr *maxskip,
377  /*@null@*/ const unsigned char **code_fill, unsigned long line);
378 
386 YASM_LIB_DECL
388  (unsigned long start, unsigned long fill, unsigned long line);
389 
395 YASM_LIB_DECL
396 /*@dependent@*/ /*@null@*/ yasm_section *yasm_bc_get_section
397  (yasm_bytecode *bc);
398 
404 YASM_LIB_DECL
405 void yasm_bc__add_symrec(yasm_bytecode *bc, /*@dependent@*/ yasm_symrec *sym);
406 
410 YASM_LIB_DECL
411 void yasm_bc_destroy(/*@only@*/ /*@null@*/ yasm_bytecode *bc);
412 
418 YASM_LIB_DECL
419 void yasm_bc_print(const yasm_bytecode *bc, FILE *f, int indent_level);
420 
425 YASM_LIB_DECL
426 void yasm_bc_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc);
427 
435 YASM_LIB_DECL
436 /*@null@*/ /*@only@*/ yasm_intnum *yasm_calc_bc_dist
437  (yasm_bytecode *precbc1, yasm_bytecode *precbc2);
438 
445 YASM_LIB_DECL
446 unsigned long yasm_bc_next_offset(yasm_bytecode *precbc);
447 
454 YASM_LIB_DECL
456 
469 YASM_LIB_DECL
471  void *add_span_data);
472 
487 YASM_LIB_DECL
488 int yasm_bc_expand(yasm_bytecode *bc, int span, long old_val, long new_val,
489  /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres);
490 
511 YASM_LIB_DECL
512 /*@null@*/ /*@only@*/ unsigned char *yasm_bc_tobytes
513  (yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
514  /*@out@*/ int *gap, void *d, yasm_output_value_func output_value,
515  /*@null@*/ yasm_output_reloc_func output_reloc)
516  /*@sets *buf@*/;
517 
525 YASM_LIB_DECL
526 int yasm_bc_get_multiple(yasm_bytecode *bc, /*@out@*/ long *multiple,
527  int calc_bc_dist);
528 
533 YASM_LIB_DECL
535 
541 YASM_LIB_DECL
542 /*@dependent@*/ /*@null@*/ yasm_insn *yasm_bc_get_insn(yasm_bytecode *bc);
543 
548 YASM_LIB_DECL
549 yasm_dataval *yasm_dv_create_expr(/*@keep@*/ yasm_expr *expn);
550 
556 YASM_LIB_DECL
557 yasm_dataval *yasm_dv_create_string(/*@keep@*/ char *contents, size_t len);
558 
564 YASM_LIB_DECL
565 yasm_dataval *yasm_dv_create_raw(/*@keep@*/ unsigned char *contents,
566  unsigned long len);
567 
571 YASM_LIB_DECL
573 
574 #ifndef YASM_DOXYGEN
575 #define yasm_dv_create_string(s, l) yasm_dv_create_raw((unsigned char *)(s), \
576  (unsigned long)(l))
577 #endif
578 
583 YASM_LIB_DECL
585 
592 YASM_LIB_DECL
593 void yasm_dv_set_multiple(yasm_dataval *dv, /*@keep@*/ yasm_expr *e);
594 
600 YASM_LIB_DECL
601 int yasm_dv_get_multiple(yasm_dataval *dv, /*@out@*/ unsigned long *multiple);
602 
607 #ifndef YASM_DOXYGEN
608 #define yasm_dvs_initialize(headp) STAILQ_INIT(headp)
609 #endif
610 
614 YASM_LIB_DECL
615 void yasm_dvs_delete(yasm_datavalhead *headp);
616 
626 YASM_LIB_DECL
627 /*@null@*/ yasm_dataval *yasm_dvs_append
628  (yasm_datavalhead *headp, /*@returned@*/ /*@null@*/ yasm_dataval *dv);
629 
635 YASM_LIB_DECL
636 void yasm_dvs_print(const yasm_datavalhead *headp, FILE *f, int indent_level);
637 
638 #endif