libyasm
|
Bytecode callback structure. More...
#include <bytecode.h>
Public Types | |
enum | yasm_bytecode_special_type { YASM_BC_SPECIAL_NONE = 0, YASM_BC_SPECIAL_RESERVE, YASM_BC_SPECIAL_OFFSET, YASM_BC_SPECIAL_INSN } |
Special bytecode classifications. More... | |
Data Fields | |
void(* | destroy )(void *contents) |
Destroys the implementation-specific data. More... | |
void(* | print )(const void *contents, FILE *f, int indent_level) |
Prints the implementation-specific data (for debugging purposes). More... | |
void(* | finalize )(yasm_bytecode *bc, yasm_bytecode *prev_bc) |
Finalizes the bytecode after parsing. More... | |
int(* | elem_size )(yasm_bytecode *bc) |
Return elements size of a data bytecode. More... | |
int(* | calc_len )(yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data) |
Calculates the minimum size of a bytecode. More... | |
int(* | expand )(yasm_bytecode *bc, int span, long old_val, long new_val, long *neg_thres, long *pos_thres) |
Recalculates the bytecode's length based on an expanded span length. More... | |
int(* | tobytes )(yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, yasm_output_value_func output_value, yasm_output_reloc_func output_reloc) |
Convert a bytecode into its byte representation. More... | |
enum yasm_bytecode_callback::yasm_bytecode_special_type | special |
Bytecode callback structure.
Any implementation of a specific bytecode must implement these functions and this callback structure. The bytecode implementation-specific data is stored in yasm_bytecode.contents.
Definition at line 63 of file bytecode.h.
Special bytecode classifications.
Most bytecode types should use #YASM_BC_SPECIAL_NONE. Others cause special handling to kick in in various parts of yasm.
Enumerator | |
---|---|
YASM_BC_SPECIAL_RESERVE |
Bytecode reserves space instead of outputting data. |
YASM_BC_SPECIAL_OFFSET |
Adjusts offset instead of calculating len. |
YASM_BC_SPECIAL_INSN |
Instruction bytecode. |
Definition at line 168 of file bytecode.h.
int(* yasm_bytecode_callback::calc_len)(yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data) |
Calculates the minimum size of a bytecode.
Called from yasm_bc_calc_len(). A generic fill-in for this is yasm_bc_calc_len_common(), but as this function internal errors when called, be very careful when using it! This function should simply add to bc->len and not set it directly (it's initialized by yasm_bc_calc_len() prior to passing control to this function).
bc | bytecode |
add_span | function to call to add a span |
add_span_data | extra data to be passed to add_span function |
Definition at line 108 of file bytecode.h.
void(* yasm_bytecode_callback::destroy)(void *contents) |
Destroys the implementation-specific data.
Called from yasm_bc_destroy().
contents | yasm_bytecode.contents |
Definition at line 68 of file bytecode.h.
int(* yasm_bytecode_callback::elem_size)(yasm_bytecode *bc) |
Return elements size of a data bytecode.
This function should return the size of each elements of a data bytecode, for proper dereference of symbols attached to it.
bc | bytecode |
Definition at line 91 of file bytecode.h.
int(* yasm_bytecode_callback::expand)(yasm_bytecode *bc, int span, long old_val, long new_val,long *neg_thres,long *pos_thres) |
Recalculates the bytecode's length based on an expanded span length.
Called from yasm_bc_expand(). A generic fill-in for this is yasm_bc_expand_common(), but as this function internal errors when called, if used, ensure that calc_len() never adds a span. This function should simply add to bc->len to increase the length by a delta amount.
bc | bytecode |
span | span ID (as given to add_span in calc_len) |
old_val | previous span value |
new_val | new span value |
neg_thres | negative threshold for long/short decision (returned) |
pos_thres | positive threshold for long/short decision (returned) |
Definition at line 132 of file bytecode.h.
void(* yasm_bytecode_callback::finalize)(yasm_bytecode *bc, yasm_bytecode *prev_bc) |
Finalizes the bytecode after parsing.
Called from yasm_bc_finalize(). A generic fill-in for this is yasm_bc_finalize_common().
bc | bytecode |
prev_bc | bytecode directly preceding bc |
Definition at line 83 of file bytecode.h.
void(* yasm_bytecode_callback::print)(const void *contents, FILE *f, int indent_level) |
Prints the implementation-specific data (for debugging purposes).
Called from yasm_bc_print().
contents | yasm_bytecode.contents |
f | file |
indent_level | indentation level |
Definition at line 76 of file bytecode.h.
int(* yasm_bytecode_callback::tobytes)(yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, yasm_output_value_func output_value,yasm_output_reloc_func output_reloc) |
Convert a bytecode into its byte representation.
Called from yasm_bc_tobytes(). A generic fill-in for this is yasm_bc_tobytes_common(), but as this function internal errors when called, be very careful when using it!
bc | bytecode |
bufp | byte representation destination buffer; should be incremented as it's written to, so that on return its delta from the passed-in buf matches the bytecode length (it's okay not to do this if an error indication is returned) |
bufstart | For calculating the correct offset parameter for the output_value calls: *bufp - bufstart. |
d | data to pass to each call to output_value/output_reloc |
output_value | function to call to convert values into their byte representation |
output_reloc | function to call to output relocation entries for a single sym |
Definition at line 159 of file bytecode.h.