libyasm
|
YASM section interface. More...
Go to the source code of this file.
Data Structures | |
struct | yasm_reloc |
struct | yasm_overrides |
Structure of functions that can be overridden. More... | |
struct | yasm_object |
An object. More... | |
Typedefs | |
typedef struct yasm_reloc | yasm_reloc |
Basic YASM relocation. More... | |
typedef struct yasm_overrides | yasm_overrides |
Structure of functions that can be overridden. | |
Functions | |
YASM_LIB_DECL yasm_object * | yasm_object_create (const char *src_filename, const char *obj_filename, yasm_arch *arch, const yasm_objfmt_module *objfmt_module, const yasm_dbgfmt_module *dbgfmt_module) |
Create a new object. More... | |
YASM_LIB_DECL yasm_section * | yasm_object_get_general (yasm_object *object, const char *name, unsigned long align, int code, int res_only, int *isnew, unsigned long line) |
Create a new, or continue an existing, general section. More... | |
YASM_LIB_DECL int | yasm_object_directive (yasm_object *object, const char *name, const char *parser, yasm_valparamhead *valparams, yasm_valparamhead *objext_valparams, unsigned long line) |
Handle a directive. More... | |
YASM_LIB_DECL void | yasm_object_destroy (yasm_object *object) |
Delete (free allocated memory for) an object. More... | |
YASM_LIB_DECL void | yasm_object_print (const yasm_object *object, FILE *f, int indent_level) |
Print an object. More... | |
YASM_LIB_DECL void | yasm_object_finalize (yasm_object *object, yasm_errwarns *errwarns) |
Finalize an object after parsing. More... | |
YASM_LIB_DECL int | yasm_object_sections_traverse (yasm_object *object, void *d, int(*func)(yasm_section *sect, void *d)) |
Traverses all sections in an object, calling a function on each section. More... | |
YASM_LIB_DECL yasm_section * | yasm_object_find_general (yasm_object *object, const char *name) |
Find a general section in an object, based on its name. More... | |
YASM_LIB_DECL void | yasm_object_set_source_fn (yasm_object *object, const char *src_filename) |
Change the source filename for an object. More... | |
YASM_LIB_DECL void | yasm_object_set_global_prefix (yasm_object *object, const char *prefix) |
Change the prefix used for externally-visible symbols. More... | |
YASM_LIB_DECL void | yasm_object_set_global_suffix (yasm_object *object, const char *suffix) |
Change the suffix used for externally-visible symbols. More... | |
YASM_LIB_DECL void | yasm_object_optimize (yasm_object *object, yasm_errwarns *errwarns) |
Optimize an object. More... | |
YASM_LIB_DECL int | yasm_section_is_code (yasm_section *sect) |
Determine if a section is flagged to contain code. More... | |
YASM_LIB_DECL unsigned long | yasm_section_get_opt_flags (const yasm_section *sect) |
Get yasm_optimizer-specific flags. More... | |
YASM_LIB_DECL void | yasm_section_set_opt_flags (yasm_section *sect, unsigned long opt_flags) |
Set yasm_optimizer-specific flags. More... | |
YASM_LIB_DECL int | yasm_section_is_default (const yasm_section *sect) |
Determine if a section was declared as the "default" section (e.g. More... | |
YASM_LIB_DECL void | yasm_section_set_default (yasm_section *sect, int def) |
Set section "default" flag to a new value. More... | |
YASM_LIB_DECL yasm_object * | yasm_section_get_object (const yasm_section *sect) |
Get object owner of a section. More... | |
YASM_LIB_DECL void * | yasm_section_get_data (yasm_section *sect, const yasm_assoc_data_callback *callback) |
Get assocated data for a section and data callback. More... | |
YASM_LIB_DECL void | yasm_section_add_data (yasm_section *sect, const yasm_assoc_data_callback *callback, void *data) |
Add associated data to a section. More... | |
YASM_LIB_DECL void | yasm_section_add_reloc (yasm_section *sect, yasm_reloc *reloc, void(*destroy_func)(void *reloc)) |
Add a relocation to a section. More... | |
YASM_LIB_DECL yasm_reloc * | yasm_section_relocs_first (yasm_section *sect) |
Get the first relocation for a section. More... | |
yasm_reloc * | yasm_section_reloc_next (yasm_reloc *reloc) |
Get the next relocation for a section. More... | |
YASM_LIB_DECL void | yasm_reloc_get (yasm_reloc *reloc, yasm_intnum **addrp, yasm_symrec **symp) |
Get the basic relocation information for a relocation. More... | |
YASM_LIB_DECL yasm_bytecode * | yasm_section_bcs_first (yasm_section *sect) |
Get the first bytecode in a section. More... | |
YASM_LIB_DECL yasm_bytecode * | yasm_section_bcs_last (yasm_section *sect) |
Get the last bytecode in a section. More... | |
YASM_LIB_DECL yasm_bytecode * | yasm_section_bcs_append (yasm_section *sect, yasm_bytecode *bc) |
Add bytecode to the end of a section. More... | |
YASM_LIB_DECL int | yasm_section_bcs_traverse (yasm_section *sect, yasm_errwarns *errwarns, void *d, int(*func)(yasm_bytecode *bc, void *d)) |
Traverses all bytecodes in a section, calling a function on each bytecode. More... | |
YASM_LIB_DECL const char * | yasm_section_get_name (const yasm_section *sect) |
Get name of a section. More... | |
YASM_LIB_DECL void | yasm_section_set_align (yasm_section *sect, unsigned long align, unsigned long line) |
Change alignment of a section. More... | |
YASM_LIB_DECL unsigned long | yasm_section_get_align (const yasm_section *sect) |
Get alignment of a section. More... | |
YASM_LIB_DECL void | yasm_section_print (const yasm_section *sect, FILE *f, int indent_level, int print_bcs) |
Print a section. More... | |
YASM section interface.
Definition in file section.h.
typedef struct yasm_reloc yasm_reloc |
YASM_LIB_DECL yasm_object* yasm_object_create | ( | const char * | src_filename, |
const char * | obj_filename, | ||
yasm_arch * | arch, | ||
const yasm_objfmt_module * | objfmt_module, | ||
const yasm_dbgfmt_module * | dbgfmt_module | ||
) |
Create a new object.
A default section is created as the first section. An empty symbol table (yasm_symtab) and line mapping (yasm_linemap) are automatically created.
src_filename | source filename (e.g. "file.asm") |
obj_filename | object filename (e.g. "file.o") |
arch | architecture |
objfmt_module | object format module |
dbgfmt_module | debug format module |
YASM_LIB_DECL void yasm_object_destroy | ( | yasm_object * | object | ) |
Delete (free allocated memory for) an object.
All sections in the object and all bytecodes within those sections are also deleted.
object | object |
YASM_LIB_DECL int yasm_object_directive | ( | yasm_object * | object, |
const char * | name, | ||
const char * | parser, | ||
yasm_valparamhead * | valparams, | ||
yasm_valparamhead * | objext_valparams, | ||
unsigned long | line | ||
) |
Handle a directive.
Passed down to object format, debug format, or architecture as appropriate.
object | object |
name | directive name |
parser | parser keyword |
valparams | value/parameters |
objext_valparams | "object format-specific" value/parameters |
line | virtual line (from yasm_linemap) |
YASM_LIB_DECL void yasm_object_finalize | ( | yasm_object * | object, |
yasm_errwarns * | errwarns | ||
) |
Finalize an object after parsing.
object | object |
errwarns | error/warning set |
YASM_LIB_DECL yasm_section* yasm_object_find_general | ( | yasm_object * | object, |
const char * | name | ||
) |
Find a general section in an object, based on its name.
object | object |
name | section name |
YASM_LIB_DECL yasm_section* yasm_object_get_general | ( | yasm_object * | object, |
const char * | name, | ||
unsigned long | align, | ||
int | code, | ||
int | res_only, | ||
int * | isnew, | ||
unsigned long | line | ||
) |
Create a new, or continue an existing, general section.
The section is added to the object if there's not already a section by that name.
object | object |
name | section name |
align | alignment in bytes (0 if none) |
code | if nonzero, section is intended to contain code (e.g. alignment should be made with NOP instructions, not 0) |
res_only | if nonzero, only space-reserving bytecodes are allowed in the section (ignored if section already exists) |
isnew | output; set to nonzero if section did not already exist |
line | virtual line of section declaration (ignored if section already exists) |
YASM_LIB_DECL void yasm_object_optimize | ( | yasm_object * | object, |
yasm_errwarns * | errwarns | ||
) |
Optimize an object.
Takes the unoptimized object and optimizes it. If successful, the object is ready for output to an object file.
object | object |
errwarns | error/warning set |
YASM_LIB_DECL void yasm_object_print | ( | const yasm_object * | object, |
FILE * | f, | ||
int | indent_level | ||
) |
Print an object.
For debugging purposes.
object | object |
f | file |
indent_level | indentation level |
YASM_LIB_DECL int yasm_object_sections_traverse | ( | yasm_object * | object, |
void * | d, | ||
int(*)(yasm_section *sect, void *d) | func | ||
) |
Traverses all sections in an object, calling a function on each section.
object | object |
d | data pointer passed to func on each call |
func | function |
YASM_LIB_DECL void yasm_object_set_global_prefix | ( | yasm_object * | object, |
const char * | prefix | ||
) |
Change the prefix used for externally-visible symbols.
object | object |
prefix | new prefix |
YASM_LIB_DECL void yasm_object_set_global_suffix | ( | yasm_object * | object, |
const char * | suffix | ||
) |
Change the suffix used for externally-visible symbols.
object | object |
suffix | new suffix |
YASM_LIB_DECL void yasm_object_set_source_fn | ( | yasm_object * | object, |
const char * | src_filename | ||
) |
Change the source filename for an object.
object | object |
src_filename | new source filename (e.g. "file.asm") |
YASM_LIB_DECL void yasm_reloc_get | ( | yasm_reloc * | reloc, |
yasm_intnum ** | addrp, | ||
yasm_symrec ** | symp | ||
) |
Get the basic relocation information for a relocation.
reloc | relocation |
addrp | address of relocation within section (returned) |
symp | relocated symbol (returned) |
YASM_LIB_DECL void yasm_section_add_data | ( | yasm_section * | sect, |
const yasm_assoc_data_callback * | callback, | ||
void * | data | ||
) |
Add associated data to a section.
sect | section |
callback | callback |
data | data to associate |
YASM_LIB_DECL void yasm_section_add_reloc | ( | yasm_section * | sect, |
yasm_reloc * | reloc, | ||
void(*)(void *reloc) | destroy_func | ||
) |
Add a relocation to a section.
sect | section |
reloc | relocation |
destroy_func | function that can destroy the relocation |
YASM_LIB_DECL yasm_bytecode* yasm_section_bcs_append | ( | yasm_section * | sect, |
yasm_bytecode * | bc | ||
) |
Add bytecode to the end of a section.
sect | section |
bc | bytecode (may be NULL) |
YASM_LIB_DECL yasm_bytecode* yasm_section_bcs_first | ( | yasm_section * | sect | ) |
Get the first bytecode in a section.
sect | section |
YASM_LIB_DECL yasm_bytecode* yasm_section_bcs_last | ( | yasm_section * | sect | ) |
Get the last bytecode in a section.
sect | section |
YASM_LIB_DECL int yasm_section_bcs_traverse | ( | yasm_section * | sect, |
yasm_errwarns * | errwarns, | ||
void * | d, | ||
int(*)(yasm_bytecode *bc, void *d) | func | ||
) |
Traverses all bytecodes in a section, calling a function on each bytecode.
sect | section |
errwarns | error/warning set (may be NULL) |
d | data pointer passed to func on each call (may be NULL) |
func | function |
YASM_LIB_DECL unsigned long yasm_section_get_align | ( | const yasm_section * | sect | ) |
Get alignment of a section.
sect | section |
YASM_LIB_DECL void* yasm_section_get_data | ( | yasm_section * | sect, |
const yasm_assoc_data_callback * | callback | ||
) |
Get assocated data for a section and data callback.
sect | section |
callback | callback used when adding data |
YASM_LIB_DECL const char* yasm_section_get_name | ( | const yasm_section * | sect | ) |
Get name of a section.
sect | section |
YASM_LIB_DECL yasm_object* yasm_section_get_object | ( | const yasm_section * | sect | ) |
Get object owner of a section.
sect | section |
YASM_LIB_DECL unsigned long yasm_section_get_opt_flags | ( | const yasm_section * | sect | ) |
Get yasm_optimizer-specific flags.
For yasm_optimizer use only.
sect | section |
YASM_LIB_DECL int yasm_section_is_code | ( | yasm_section * | sect | ) |
Determine if a section is flagged to contain code.
sect | section |
YASM_LIB_DECL int yasm_section_is_default | ( | const yasm_section * | sect | ) |
Determine if a section was declared as the "default" section (e.g.
not created through a section directive).
sect | section |
YASM_LIB_DECL void yasm_section_print | ( | const yasm_section * | sect, |
FILE * | f, | ||
int | indent_level, | ||
int | print_bcs | ||
) |
Print a section.
For debugging purposes.
f | file |
indent_level | indentation level |
sect | section |
print_bcs | if nonzero, print bytecodes within section |
yasm_reloc* yasm_section_reloc_next | ( | yasm_reloc * | reloc | ) |
Get the next relocation for a section.
reloc | previous relocation |
YASM_LIB_DECL yasm_reloc* yasm_section_relocs_first | ( | yasm_section * | sect | ) |
Get the first relocation for a section.
sect | section |
YASM_LIB_DECL void yasm_section_set_align | ( | yasm_section * | sect, |
unsigned long | align, | ||
unsigned long | line | ||
) |
Change alignment of a section.
sect | section |
align | alignment in bytes |
line | virtual line |
YASM_LIB_DECL void yasm_section_set_default | ( | yasm_section * | sect, |
int | def | ||
) |
Set section "default" flag to a new value.
sect | section |
def | new value of default flag |
YASM_LIB_DECL void yasm_section_set_opt_flags | ( | yasm_section * | sect, |
unsigned long | opt_flags | ||
) |
Set yasm_optimizer-specific flags.
For yasm_optimizer use only.
sect | section |
opt_flags | optimizer-specific flags. |