avmpack.c

Include dependency graph for avmpack.c:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "8" [label="stdbool.h" tooltip="stdbool.h"]
    "24" [label="refc_binary.h" tooltip="refc_binary.h"]
    "5" [label="atom.h" tooltip="atom.h"]
    "11" [label="assert.h" tooltip="assert.h"]
    "22" [label="utils.h" tooltip="utils.h"]
    "16" [label="synclist.h" tooltip="synclist.h"]
    "15" [label="list.h" tooltip="list.h"]
    "4" [label="stdint.h" tooltip="stdint.h"]
    "6" [label="stdlib.h" tooltip="stdlib.h"]
    "21" [label="memory.h" tooltip="memory.h"]
    "25" [label="resources.h" tooltip="resources.h"]
    "19" [label="term.h" tooltip="term.h"]
    "23" [label="stddef.h" tooltip="stddef.h"]
    "9" [label="erl_nif.h" tooltip="erl_nif.h"]
    "12" [label="limits.h" tooltip="limits.h"]
    "7" [label="atom_table.h" tooltip="atom_table.h"]
    "1" [label="/__w/AtomVM/AtomVM/src/libAtomVM/avmpack.c" tooltip="/__w/AtomVM/AtomVM/src/libAtomVM/avmpack.c" fillcolor="#BFBFBF"]
    "2" [label="avmpack.h" tooltip="avmpack.h"]
    "20" [label="string.h" tooltip="string.h"]
    "10" [label="term_typedef.h" tooltip="term_typedef.h"]
    "3" [label="globalcontext.h" tooltip="globalcontext.h"]
    "18" [label="smp.h" tooltip="smp.h"]
    "27" [label="timer_list.h" tooltip="timer_list.h"]
    "26" [label="mailbox.h" tooltip="mailbox.h"]
    "17" [label="stdio.h" tooltip="stdio.h"]
    "14" [label="ets.h" tooltip="ets.h"]
    "13" [label="inttypes.h" tooltip="inttypes.h"]
    "24" -> "8" [dir=forward tooltip="include"]
    "24" -> "6" [dir=forward tooltip="include"]
    "24" -> "15" [dir=forward tooltip="include"]
    "24" -> "25" [dir=forward tooltip="include"]
    "5" -> "4" [dir=forward tooltip="include"]
    "5" -> "6" [dir=forward tooltip="include"]
    "22" -> "23" [dir=forward tooltip="include"]
    "22" -> "17" [dir=forward tooltip="include"]
    "22" -> "6" [dir=forward tooltip="include"]
    "16" -> "17" [dir=forward tooltip="include"]
    "16" -> "15" [dir=forward tooltip="include"]
    "16" -> "18" [dir=forward tooltip="include"]
    "15" -> "8" [dir=forward tooltip="include"]
    "21" -> "4" [dir=forward tooltip="include"]
    "21" -> "6" [dir=forward tooltip="include"]
    "21" -> "9" [dir=forward tooltip="include"]
    "21" -> "10" [dir=forward tooltip="include"]
    "21" -> "22" [dir=forward tooltip="include"]
    "25" -> "6" [dir=forward tooltip="include"]
    "25" -> "9" [dir=forward tooltip="include"]
    "25" -> "15" [dir=forward tooltip="include"]
    "25" -> "21" [dir=forward tooltip="include"]
    "19" -> "8" [dir=forward tooltip="include"]
    "19" -> "4" [dir=forward tooltip="include"]
    "19" -> "17" [dir=forward tooltip="include"]
    "19" -> "6" [dir=forward tooltip="include"]
    "19" -> "20" [dir=forward tooltip="include"]
    "19" -> "21" [dir=forward tooltip="include"]
    "19" -> "24" [dir=forward tooltip="include"]
    "19" -> "22" [dir=forward tooltip="include"]
    "19" -> "10" [dir=forward tooltip="include"]
    "9" -> "10" [dir=forward tooltip="include"]
    "7" -> "8" [dir=forward tooltip="include"]
    "7" -> "5" [dir=forward tooltip="include"]
    "1" -> "2" [dir=forward tooltip="include"]
    "1" -> "22" [dir=forward tooltip="include"]
    "1" -> "6" [dir=forward tooltip="include"]
    "1" -> "20" [dir=forward tooltip="include"]
    "1" -> "17" [dir=forward tooltip="include"]
    "2" -> "3" [dir=forward tooltip="include"]
    "2" -> "15" [dir=forward tooltip="include"]
    "2" -> "8" [dir=forward tooltip="include"]
    "2" -> "23" [dir=forward tooltip="include"]
    "2" -> "4" [dir=forward tooltip="include"]
    "10" -> "11" [dir=forward tooltip="include"]
    "10" -> "12" [dir=forward tooltip="include"]
    "10" -> "13" [dir=forward tooltip="include"]
    "10" -> "4" [dir=forward tooltip="include"]
    "3" -> "4" [dir=forward tooltip="include"]
    "3" -> "5" [dir=forward tooltip="include"]
    "3" -> "7" [dir=forward tooltip="include"]
    "3" -> "9" [dir=forward tooltip="include"]
    "3" -> "14" [dir=forward tooltip="include"]
    "3" -> "15" [dir=forward tooltip="include"]
    "3" -> "26" [dir=forward tooltip="include"]
    "3" -> "18" [dir=forward tooltip="include"]
    "3" -> "16" [dir=forward tooltip="include"]
    "3" -> "19" [dir=forward tooltip="include"]
    "3" -> "27" [dir=forward tooltip="include"]
    "18" -> "8" [dir=forward tooltip="include"]
    "27" -> "8" [dir=forward tooltip="include"]
    "27" -> "4" [dir=forward tooltip="include"]
    "27" -> "15" [dir=forward tooltip="include"]
    "26" -> "8" [dir=forward tooltip="include"]
    "26" -> "15" [dir=forward tooltip="include"]
    "26" -> "10" [dir=forward tooltip="include"]
    "26" -> "22" [dir=forward tooltip="include"]
    "14" -> "15" [dir=forward tooltip="include"]
    "14" -> "16" [dir=forward tooltip="include"]
    "14" -> "19" [dir=forward tooltip="include"]
}

Defines

AVMPACK_SIZE 24

Functions

static inline int pad(int size)
bool avmpack_is_valid(const void *avmpack_binary, uint32_t size)

Returns true if the pointed binary is a valid AVM Pack.

Returns if the pointed binary is a valid AVM Pack binary or not.

Parameters:
  • avmpack_binary – a pointer to an AVM Pack binary.

  • size – the size of AVM Pack binary.

Returns:

true if it is a valid AVM Pack binary, false otherwise.

int avmpack_find_section_by_flag(const void *avmpack_binary, uint32_t flags_mask, const void **ptr, uint32_t *size, const char **name)

Finds an AVM Pack section that has certain flags set.

Finds an AVM Pack section that has certain flags set and returns a pointer to it, its size and its name.

Parameters:
  • avmpack_binary – a pointer to valid AVM Pack file data.

  • flags_mask – that will be matched against file sections.

  • ptr – will point to the found file section.

  • size – will be set to the file section size that has been found, if the section has not been found it will not be updated.

  • name – the section name, as defined in the module header.

Returns:

1 if the file section has been found, 0 otherwise.

int avmpack_find_section_by_name(const void *avmpack_binary, const char *name, const void **ptr, uint32_t *size)

Finds an AVM Pack section that has certain name.

Finds an AVM Pack section with a certain name and returns a pointer to it and its size.

Parameters:
  • avmpack_binary – a pointer to valid AVM Pack file data.

  • name – the file section name that will be searched.

  • ptr – will point to the found file section, if the section has not been found it will not be updated.

  • size – will be set to the file section size that has been found, if the section has not been found it will not be updated.

Returns:

1 if the file section has been found, 0 otherwise.

void *avmpack_fold(void *accum, const void *avmpack_binary, avmpack_fold_fun fold_fun)

Fold over all the sections in an AVM Pack.

This function will call the callback on each section of the AVM Pack, passing in the current section of each module in the AVM binary to the supplied fold function.

Parameters:
  • accum – The accumulator supplied by the application.

  • avmpack_binary – a pointer to an AVM Pack binary.

  • fold_fun – function that will be called for each AVM section.

static void in_memory_avm_pack_destructor(struct AVMPackData *obj, GlobalContext *global)
static void const_avm_pack_destructor(struct AVMPackData *obj, GlobalContext *global)

Variables

const struct AVMPackInfo in_memory_avm_pack_info = {.destructor = in_memory_avm_pack_destructor}
const struct AVMPackInfo const_avm_pack_info = {.destructor = const_avm_pack_destructor}