Source file: /~heha/hs/gputils64-210929.zip/libgputils/gpcoffgen.h

/* GNU PIC general coff functions
   Copyright 2001, 2002, 2003, 2004, 2005
   Craig Franklin

    Copyright 2016 Molnár Károly
*/

#pragma once

/* annotation for symbol tables used by the linker and archive tool */
typedef struct gp_coffsymbol {
  gp_symbol_t *symbol;   /* the coff symbol */
  gp_object_t *file;     /* the object file the symbol is defined in */
} gp_coffsymbol_t;

    /*................................*/

FUNC(gp_object_t*) gp_coffgen_new_object(const char *File_name);
FUNC(void) gp_coffgen_transfer_object_data(gp_object_t *Receiver, gp_object_t *Sender);
FUNC(bool) gp_coffgen_update_all_object_id(gp_object_t *Object);

    /*................................*/

FUNC(gp_section_t*) gp_coffgen_find_section(gp_object_t *Object, gp_section_t *Start,
                                             const char *Name);

FUNC(gp_section_t*) gp_coffgen_new_section(const char *Name, MemBlock_t *Data);
FUNC(gp_section_t*) gp_coffgen_make_block_section(gp_object_t *Object, unsigned Num_sections);
FUNC(gp_section_t*) gp_coffgen_add_exists_section(gp_object_t *Object, gp_section_t *Section);

FUNC(gp_section_t*) gp_coffgen_insert_after_section(gp_object_t *Object, gp_section_t *Ancestor,
                                                     gp_section_t *Following);

FUNC(gp_section_t*) gp_coffgen_add_section(gp_object_t *Object, const char *Name, MemBlock_t *Data);
FUNC(void) gp_coffgen_transfer_section_data(gp_section_t *Receiver, gp_section_t *Sender);
FUNC(bool) gp_coffgen_update_all_section_id(gp_section_t *Section);
FUNC(bool) gp_coffgen_update_section_id(gp_object_t *Object);
FUNC(void) gp_coffgen_del_section_symbols(gp_object_t *Object, gp_section_t *Section);
FUNC(void) gp_coffgen_move_reserve_section_symbols(gp_object_t *Object, gp_section_t *Section);
FUNC(gp_section_t*) gp_coffgen_move_reserve_section(gp_object_t *Object, gp_section_t *Section);
FUNC(bool) gp_coffgen_del_section(gp_object_t *Object, gp_section_t *Section);

FUNC(gp_section_t**) gp_coffgen_make_section_array(gp_object_t *Object, unsigned *Num_sections,
                                                    unsigned Page_addr, uint32_t Flags);

    /*................................*/


FUNC(gp_aux_t*) gp_coffgen_add_aux(gp_object_t *Object, gp_symbol_t *Symbol);
FUNC(gp_aux_t*) gp_coffgen_make_block_aux(gp_symbol_t *Symbol, unsigned Num_auxsyms);
FUNC(gp_symbol_t*) gp_coffgen_move_reserve_symbol(gp_object_t *Object, gp_symbol_t *Symbol);
FUNC(gp_symbol_t**) gp_coffgen_make_symbol_array(const gp_object_t *Object, int (_cdecl*Cmp)(const void *, const void *));
FUNC(const char*) gp_coffgen_symbol_type_to_str(uint8_t Type);
FUNC(const char*) gp_coffgen_symbol_derived_type_to_str(uint32_t Type);
FUNC(const char*) gp_coffgen_symbol_class_to_str(uint8_t Class);

    /*................................*/

FUNC(gp_reloc_t*) gp_coffgen_make_block_reloc(gp_section_t *Section, unsigned Num_relocations);
FUNC(gp_reloc_t*) gp_coffgen_add_reloc(gp_section_t *Section);

/* for "Behavior" */
#define RELOC_DISABLE_WARN              (1 << 0)
#define RELOC_ENABLE_CINIT_WARN         (1 << 1)

FUNC(void) gp_coffgen_check_relocations(const gp_object_t *Object, bool Behavior);

FUNC(bool) gp_coffgen_del_reloc(gp_section_t *Section, gp_reloc_t *Relocation);
FUNC(const char*) gp_coffgen_reloc_type_to_str(uint16_t Type);

    /*................................*/

FUNC(gp_linenum_t*) gp_coffgen_make_block_linenum(gp_section_t *Section, unsigned Num_linenums);
FUNC(gp_linenum_t*) gp_coffgen_add_linenum(gp_section_t *Section);
FUNC(gp_linenum_t*) gp_coffgen_find_linenum_by_address(gp_section_t *Section, unsigned Address);
FUNC(bool) gp_coffgen_del_linenum(gp_section_t *Section, gp_linenum_t *Linenum);
FUNC(bool) gp_coffgen_del_linenum_by_address(gp_section_t *Section, unsigned Address);
FUNC(unsigned) gp_coffgen_del_linenum_by_address_area(gp_section_t *Section, unsigned Address_start,
                                                           unsigned Address_end);

FUNC(void) gp_coffgen_make_linenum_array(gp_object_t *Object);

FUNC(gp_linenum_t*) gp_coffgen_find_linenum(const gp_section_t *Section, const gp_symbol_t *Symbol,
                                             unsigned Line_number);


    /*................................*/

FUNC(bool) gp_coffgen_is_absolute_object(const gp_object_t *Object);

FUNC(bool) gp_coffgen_section_has_data(const gp_section_t *Section);

/* gp_coffgen_symbol_has_reloc() "Type" parameter */
#define COFF_SYM_RELOC_ALL          0
#define COFF_SYM_RELOC_OWN          1
#define COFF_SYM_RELOC_OTHER        2

FUNC(void) gp_coffgen_free_section(gp_section_t *Section);
FUNC(unsigned) gp_coffgen_free_symbol(gp_symbol_t *Symbol);
FUNC(bool) gp_coffgen_free_object(gp_object_t *Object);

FUNC(unsigned) gp_coffgen_determine_aux_symbol(const gp_symbol_t *Symbol);
Detected encoding: UTF-80