2002-06-17 05:29:20 +00:00
|
|
|
/*
|
|
|
|
obj_file.h
|
|
|
|
|
|
|
|
object file support
|
|
|
|
|
2002-07-05 20:02:10 +00:00
|
|
|
Copyright (C) 2002 Bill Currie <bill@taniwha.org>
|
2002-06-17 05:29:20 +00:00
|
|
|
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2002/6/16
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __obj_file_h
|
|
|
|
#define __obj_file_h
|
|
|
|
|
2002-06-21 20:46:56 +00:00
|
|
|
#include "QF/pr_comp.h"
|
2002-07-03 20:16:32 +00:00
|
|
|
#include "QF/pr_debug.h"
|
2002-06-21 20:46:56 +00:00
|
|
|
|
2002-06-18 21:00:41 +00:00
|
|
|
#define QFO "QFO"
|
2002-07-08 05:26:50 +00:00
|
|
|
#define QFO_VERSION 0x00001002 // MMmmmRRR 0.001.002 (hex)
|
2002-06-17 05:29:20 +00:00
|
|
|
|
|
|
|
typedef struct qfo_header_s {
|
|
|
|
char qfo[4];
|
|
|
|
int version;
|
|
|
|
int code_size;
|
|
|
|
int data_size;
|
|
|
|
int far_data_size;
|
|
|
|
int strings_size;
|
|
|
|
int num_relocs;
|
|
|
|
int num_defs;
|
|
|
|
int num_functions;
|
2002-06-24 22:36:04 +00:00
|
|
|
int num_lines;
|
2002-07-08 05:26:50 +00:00
|
|
|
int types_size;
|
2002-06-17 05:29:20 +00:00
|
|
|
} qfo_header_t;
|
|
|
|
|
|
|
|
typedef struct qfo_def_s {
|
|
|
|
etype_t basic_type;
|
|
|
|
string_t full_type;
|
|
|
|
string_t name;
|
|
|
|
int ofs;
|
|
|
|
|
2002-06-22 05:10:34 +00:00
|
|
|
int relocs;
|
|
|
|
int num_relocs;
|
2002-06-17 05:29:20 +00:00
|
|
|
|
2002-06-18 21:00:41 +00:00
|
|
|
unsigned flags;
|
2002-06-17 05:29:20 +00:00
|
|
|
|
|
|
|
string_t file;
|
|
|
|
int line;
|
|
|
|
} qfo_def_t;
|
|
|
|
|
2002-06-18 21:00:41 +00:00
|
|
|
#define QFOD_INITIALIZED (1u<<0)
|
|
|
|
#define QFOD_CONSTANT (1u<<1)
|
2002-06-28 17:59:32 +00:00
|
|
|
#define QFOD_ABSOLUTE (1u<<2)
|
|
|
|
#define QFOD_GLOBAL (1u<<3)
|
|
|
|
#define QFOD_EXTERNAL (1u<<4)
|
2002-07-11 17:06:15 +00:00
|
|
|
#define QFOD_LOCAL (1u<<5)
|
2002-06-18 21:00:41 +00:00
|
|
|
|
2002-06-17 05:29:20 +00:00
|
|
|
typedef struct qfo_function_s {
|
|
|
|
string_t name;
|
|
|
|
string_t file;
|
|
|
|
int line;
|
|
|
|
|
|
|
|
int builtin;
|
|
|
|
int code;
|
|
|
|
|
|
|
|
int def;
|
|
|
|
|
|
|
|
int locals_size;
|
|
|
|
int local_defs;
|
|
|
|
int num_local_defs;
|
|
|
|
|
|
|
|
int line_info;
|
|
|
|
|
|
|
|
int num_parms;
|
|
|
|
byte parm_size[MAX_PARMS];
|
2002-06-21 20:46:56 +00:00
|
|
|
|
2002-06-22 05:10:34 +00:00
|
|
|
int relocs;
|
|
|
|
int num_relocs;
|
2002-06-17 05:29:20 +00:00
|
|
|
} qfo_function_t;
|
|
|
|
|
2002-06-22 05:10:34 +00:00
|
|
|
typedef struct qfo_reloc_s {
|
2002-06-21 20:46:56 +00:00
|
|
|
int ofs;
|
|
|
|
int type;
|
2002-06-22 05:10:34 +00:00
|
|
|
} qfo_reloc_t;
|
|
|
|
|
|
|
|
typedef struct qfo_s {
|
|
|
|
dstatement_t *code;
|
|
|
|
int code_size;
|
|
|
|
pr_type_t *data;
|
|
|
|
int data_size;
|
|
|
|
pr_type_t *far_data;
|
|
|
|
int far_data_size;
|
|
|
|
char *strings;
|
|
|
|
int strings_size;
|
|
|
|
qfo_reloc_t *relocs;
|
|
|
|
int num_relocs;
|
|
|
|
qfo_def_t *defs;
|
|
|
|
int num_defs;
|
|
|
|
qfo_function_t *functions;
|
|
|
|
int num_functions;
|
2002-06-24 22:36:04 +00:00
|
|
|
pr_lineno_t *lines;
|
|
|
|
int num_lines;
|
2002-07-08 05:26:50 +00:00
|
|
|
char *types;
|
|
|
|
int types_size;
|
2002-06-22 05:10:34 +00:00
|
|
|
} qfo_t;
|
2002-06-21 20:46:56 +00:00
|
|
|
|
2002-07-03 20:16:32 +00:00
|
|
|
#define QFO_var(q, t, o) ((q)->data[o].t##_var)
|
|
|
|
#define QFO_FLOAT(q, o) QFO_var (q, float, o)
|
|
|
|
#define QFO_INT(q, o) QFO_var (q, integer, o)
|
|
|
|
#define QFO_VECTOR(q, o) QFO_var (q, vector, o)
|
2002-07-05 20:02:10 +00:00
|
|
|
#define QFO_STRING(q, o) G_GETSTR (QFO_var (q, string, o))
|
2002-07-03 20:16:32 +00:00
|
|
|
#define QFO_FUNCTION(q, o) QFO_var (q, func, o)
|
|
|
|
#define QFO_POINTER(q, t,o) ((t *)((q)->data + o))
|
|
|
|
#define QFO_STRUCT(q, t,o) (*QFO_POINTER (q, t, o))
|
|
|
|
|
2002-06-21 20:46:56 +00:00
|
|
|
int write_obj_file (const char *filename);
|
2002-07-03 20:16:32 +00:00
|
|
|
qfo_t *read_obj_file (const char *filename);
|
2002-07-11 17:06:15 +00:00
|
|
|
qfo_t *qfo_new (void);
|
|
|
|
void qfo_add_code (qfo_t *qfo, dstatement_t *code, int code_size);
|
|
|
|
void qfo_add_data (qfo_t *qfo, pr_type_t *data, int data_size);
|
|
|
|
void qfo_add_far_data (qfo_t *qfo, pr_type_t *far_data, int far_data_size);
|
|
|
|
void qfo_add_strings (qfo_t *qfo, const char *strings, int strings_size);
|
|
|
|
void qfo_add_relocs (qfo_t *qfo, qfo_reloc_t *relocs, int num_relocs);
|
|
|
|
void qfo_add_defs (qfo_t *qfo, qfo_def_t *defs, int num_defs);
|
|
|
|
void qfo_add_functions (qfo_t *qfo, qfo_function_t *functions, int num_functions);
|
|
|
|
void qfo_add_types (qfo_t *qfo, const char *types, int types_size);
|
|
|
|
void qfo_delete (qfo_t *qfo);
|
2002-06-21 20:46:56 +00:00
|
|
|
|
2002-06-17 05:29:20 +00:00
|
|
|
#endif//__obj_file_h
|