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

/* gplink - GNU PIC Linker
   Copyright 2001, 2002, 2003, 2004, 2005
   Craig Franklin

    Copyright 2015-2016 Molnár Károly
*/

#pragma once
#include <list>

#define GPLINK_VERSION_STRING       ("gplink-" VERSION " #" REVISION " (" __DATE__ ")")

#define MAX_PATHS                   100

enum outfile {
  OUT_NORMAL,
  OUT_SUPPRESS,
  OUT_NAMED
};

typedef struct archivelist {
  char               *name;
  gp_archive_t       *archive;
  struct archivelist *next;
} archivelist_t;

//struct srcfns_t {
//  srcfns_t *next;
//  char     *file_name;
//  srcfns_t(const char*arg):next(0),file_name(GP_Strdup(arg)) {}
//};

typedef struct source_context {
  struct source_context  *prev;
  char                   *name;
  FILE                   *f;
  unsigned            line_number;
  struct yy_buffer_state *yybuf;
  bool              last_char_is_nl;  /* If the last read character is a newline. */
} source_context_t;

typedef struct ifdef {
  struct ifdef *prev;
  bool    is_true;
  bool    in_else;
} ifdef_t;

typedef struct list_context {
  struct list_context *prev;
  char                *name;
  gp_symbol_t         *symbol;
  FILE                *f;
  bool           missing_source;
  unsigned         line_number;
} list_context_t;

extern struct gplink_state {
  bool       mplink_compatible;   /* MPLINK compatibility mode. */
  char       start_date[80];      /* When gplink ran. */
  enum formats     hex_format;          /* Format of the output. */
  char            *paths[MAX_PATHS];    /* The list of include paths. */
  int              num_paths;           /* Number of paths in the list. */
  pic_processor_t  processor;
  proc_class_t     pclass;
  int              strict_level;        /* 0, 1 */

  struct {
    int    level;
    bool   dead_sections;
    bool   weak_symbols;
    unsigned pagesel;
    unsigned banksel;
  } optimize;

  enum outfile
    cod_file,                           /* Symbol output file control. */
    hex_file,                           /* Hex output file control. */
    lst_file,                           /* List output file control. */
    map_file,                           /* Map output file control. */
    obj_file;                           /* Executable object file control. */

  bool     fill_enable;           /* Fill unused program memory with value. */
  unsigned fill_value;            /* Value to fill program memory with. */
  bool     has_stack;             /* Has stack directive in linker script. */
  unsigned stack_size;            /* Value to fill program memory with. */
  bool     has_idata;             /* Has initialized data memory. */
  std::list<const char*> src_file_names;        /* List of script file names. */
//  srcfns_t*src_file_names_tail;   /* List tail of script file names. */

  char base_file_name[BUFSIZ],          /* Basename for generating hex,list,symbol filenames. */
    cod_file_name[BUFSIZ],              /* Symbol (.cod) file name. */
    hex_file_name[BUFSIZ],              /* Hex (.hex) file name. */
    lst_file_name[BUFSIZ],              /* Symbol (.lst) file name. */
    map_file_name[BUFSIZ],              /* List (.map) file name. */
    obj_file_name[BUFSIZ];              /* Object (.o) file name. */

  source_context_t *src;                /* Top of the stack of the script files. */
  ifdef_t          *ifdef;              /* Top of the stack of ifdef nesting. */
  symbol_table_t   *script_symbols;

  struct {                              /* Map file state: */
    FILE *f;                            /*   Map file output. */
  } map;

  struct {                              /* Symbol file state: */
    FILE       *f;                      /*   Symbol file output. */
    bool  enabled;                /*   Symbol file is enabled. */
    bool  emitting;               /*   Flag indicating when an opcode is emitted. */
    bool  no_save_local;          /*   Disable saving the local symbols. */
  } cod;

  struct {                              /* List file state: */
    FILE    *f;                  /*   List file output. */
    bool     enabled;            /*   List file is enabled. */
    list_context_t *src;                /*   List file context. */
    unsigned was_byte_addr;      /*   Last address that generated code. */
  } lst;

  struct {
    symbol_table_t *definition;         /* Section definitions from script. */
    symbol_table_t *logical;            /* Logical definitions from script. */
  } section;

  struct {
    symbol_table_t *extern_global;      /* External and global symbol definition. */
    symbol_table_t *local;              /* Local symbol definition. */
    symbol_table_t *missing;            /* Missing external symbols. */
    symbol_table_t *archive;            /* Archive symbol index. */
  } symbol;

  archivelist_t    *archives;
  archivelist_t    *archives_tail;
  gp_object_t      *object;             /* Object files. */
  MemBlock_t       *i_memory;           /* Instruction memory linked list. */
} state;

void gplink_open_coff(const char *Name);
void gplink_add_path(const char *Path);
Detected encoding: UTF-80