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
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __obj_file_h
|
|
|
|
#define __obj_file_h
|
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
/** \defgroup qfcc_qfo Object file functions
|
|
|
|
\ingroup qfcc
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
|
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-08-27 07:16:28 +00:00
|
|
|
#include "QF/quakeio.h"
|
2002-06-21 20:46:56 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
/** Identifier string for qfo object files (includes terminating nul)
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2002-06-18 21:00:41 +00:00
|
|
|
#define QFO "QFO"
|
2011-02-21 01:32:20 +00:00
|
|
|
/** QFO object file format version (MMmmmRRR 0.001.006 (hex))
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2011-02-21 01:32:20 +00:00
|
|
|
#define QFO_VERSION 0x00001006
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** Header block of QFO object files. The sections of the object file
|
|
|
|
come immediately after the header, and are always in the order given by
|
|
|
|
the struct.
|
2002-06-17 05:29:20 +00:00
|
|
|
|
2011-02-21 01:32:20 +00:00
|
|
|
All indices to records are 0-based from the beginning of the relevant
|
2008-08-01 00:47:38 +00:00
|
|
|
section.
|
|
|
|
*/
|
2002-06-17 05:29:20 +00:00
|
|
|
typedef struct qfo_header_s {
|
2008-08-01 00:47:38 +00:00
|
|
|
int8_t qfo[4]; ///< identifier string (includes nul) (#QFO)
|
|
|
|
pr_int_t version; ///< QFO format version (#QFO_VERSION)
|
2011-02-17 06:02:09 +00:00
|
|
|
pr_int_t num_spaces;
|
2008-08-01 00:47:38 +00:00
|
|
|
pr_int_t num_relocs; ///< number of relocation records
|
|
|
|
pr_int_t num_defs; ///< number of def records
|
|
|
|
pr_int_t num_funcs; ///< number of function records
|
|
|
|
pr_int_t num_lines; ///< number of line records
|
2011-02-24 06:21:06 +00:00
|
|
|
pr_int_t num_loose_relocs; ///< number of loose relocation records
|
|
|
|
///< included in num_relocs
|
2002-06-17 05:29:20 +00:00
|
|
|
} qfo_header_t;
|
|
|
|
|
2011-02-17 06:02:09 +00:00
|
|
|
typedef enum qfos_type_e {
|
|
|
|
qfos_null, ///< null space. no data or defs. first in qfo
|
|
|
|
qfos_code, ///< progs code. dstatement_t data
|
|
|
|
qfos_data, ///< progs data. pr_type_t data
|
|
|
|
qfos_string, ///< strings. char data
|
|
|
|
qfos_entity, ///< entity field defs. no data
|
|
|
|
qfos_type, ///< type encodings
|
|
|
|
} qfos_type_t;
|
|
|
|
|
|
|
|
/** Representation of a space in the object file.
|
|
|
|
*/
|
|
|
|
typedef struct qfo_space_s {
|
|
|
|
pr_int_t type; ///< code, string, data, entity...
|
|
|
|
pr_int_t defs; ///< index of first def
|
2011-02-21 01:32:20 +00:00
|
|
|
pr_int_t num_defs; ///< zero for code or string spaces
|
2011-02-17 06:02:09 +00:00
|
|
|
pr_int_t data; ///< byte offset in qfo
|
2011-02-21 01:32:20 +00:00
|
|
|
pr_int_t data_size; ///< in elements. zero for entity spaces
|
2011-02-17 06:02:09 +00:00
|
|
|
pr_int_t id;
|
2011-02-23 01:40:35 +00:00
|
|
|
pr_int_t reserved[2];
|
2011-02-17 06:02:09 +00:00
|
|
|
} qfo_space_t;
|
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
/** Representation of a def in the object file.
|
|
|
|
*/
|
2002-06-17 05:29:20 +00:00
|
|
|
typedef struct qfo_def_s {
|
2011-02-21 01:32:20 +00:00
|
|
|
pointer_t type; ///< offset in type space
|
2008-08-01 00:47:38 +00:00
|
|
|
string_t name; ///< def name
|
2011-02-21 01:32:20 +00:00
|
|
|
pointer_t offset; ///< def offset (address)
|
2002-06-17 05:29:20 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
pr_int_t relocs; ///< index of first reloc record
|
|
|
|
pr_int_t num_relocs; ///< number of reloc records
|
2002-06-17 05:29:20 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
pr_uint_t flags; ///< \ref qfcc_qfo_QFOD "QFOD flags"
|
2002-06-17 05:29:20 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
string_t file; ///< source file name
|
|
|
|
pr_int_t line; ///< source line number
|
2002-06-17 05:29:20 +00:00
|
|
|
} qfo_def_t;
|
2010-08-11 23:42:14 +00:00
|
|
|
//@}
|
2002-06-17 05:29:20 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
/** \defgroup qfcc_qfo_QFOD QFOD flags
|
|
|
|
\ingroup qfcc_qfo
|
|
|
|
*/
|
2010-08-11 23:42:14 +00:00
|
|
|
//@{
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** The def has been initialized.
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2002-06-18 21:00:41 +00:00
|
|
|
#define QFOD_INITIALIZED (1u<<0)
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** The def is a shared constant and must not be modified.
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2002-06-18 21:00:41 +00:00
|
|
|
#define QFOD_CONSTANT (1u<<1)
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** The def offset is an absolute address.
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2002-06-28 17:59:32 +00:00
|
|
|
#define QFOD_ABSOLUTE (1u<<2)
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** The def is visible to other object files.
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2002-06-28 17:59:32 +00:00
|
|
|
#define QFOD_GLOBAL (1u<<3)
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** The def is undefined and need to be supplied by another object file.
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2002-06-28 17:59:32 +00:00
|
|
|
#define QFOD_EXTERNAL (1u<<4)
|
2002-06-18 21:00:41 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
/** The def is local to a function and is not visible to other functions or
|
|
|
|
object files.
|
2002-06-17 05:29:20 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
\hideinitializer
|
|
|
|
*/
|
|
|
|
#define QFOD_LOCAL (1u<<5)
|
2002-06-17 05:29:20 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
/** The def is a system def and needs to be allocated before other defs
|
2002-06-17 05:29:20 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
\hideinitializer
|
|
|
|
*/
|
|
|
|
#define QFOD_SYSTEM (1u<<6)
|
2002-06-17 05:29:20 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
/** The def does not need to be saved when saving game state.
|
2002-06-17 05:29:20 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
\hideinitializer
|
|
|
|
*/
|
|
|
|
#define QFOD_NOSAVE (1u<<7)
|
2010-08-11 23:42:14 +00:00
|
|
|
//@}
|
2002-06-21 20:46:56 +00:00
|
|
|
|
2010-08-11 23:42:14 +00:00
|
|
|
/** \addtogroup qfcc_qfo
|
2010-08-11 23:41:30 +00:00
|
|
|
*/
|
2010-08-11 23:42:14 +00:00
|
|
|
//@{
|
2010-08-11 23:41:30 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
/** Representation of a function in the object file.
|
|
|
|
*/
|
|
|
|
typedef struct qfo_func_s {
|
|
|
|
string_t name; ///< function name
|
2011-02-23 01:40:35 +00:00
|
|
|
pointer_t type; ///< function type (in type data space)
|
2008-08-01 00:47:38 +00:00
|
|
|
string_t file; ///< source file name
|
|
|
|
pr_int_t line; ///< source line number
|
|
|
|
|
|
|
|
/** \name Function code location.
|
2011-02-23 01:40:35 +00:00
|
|
|
If #code is negative, then the function is a VM builtin function.
|
|
|
|
If #code is 0, then the function is a VM builtin function and the
|
|
|
|
VM resolves the function number using the function name.
|
|
|
|
If #code is positive, then the function is in progs and #code is
|
|
|
|
the first statement of the function.
|
2008-08-01 00:47:38 +00:00
|
|
|
*/
|
2011-02-23 01:40:35 +00:00
|
|
|
pr_int_t code;
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
pr_int_t def; ///< def that references this function. Index
|
|
|
|
///< to ::qfo_def_t. The data word pointed to
|
|
|
|
///< by the def stores the index of this
|
|
|
|
///< function.
|
|
|
|
|
2011-02-23 01:40:35 +00:00
|
|
|
pr_int_t locals_space; ///< space holding the function's local data
|
2008-08-01 00:47:38 +00:00
|
|
|
|
2010-08-11 23:41:30 +00:00
|
|
|
pr_int_t line_info; ///< Index to first ::pr_lineno_t line record.
|
2008-08-01 00:47:38 +00:00
|
|
|
///< Zero if there are no records.
|
|
|
|
|
|
|
|
/** \name Function relocation records.
|
|
|
|
XXX not sure how these work
|
|
|
|
*/
|
2010-08-11 23:42:14 +00:00
|
|
|
//@{
|
2008-08-01 00:47:38 +00:00
|
|
|
pr_int_t relocs; ///< Index to first ::qfo_reloc_t reloc record.
|
|
|
|
pr_int_t num_relocs; ///< Number of reloc records.
|
2010-08-11 23:42:14 +00:00
|
|
|
//@}
|
2011-02-23 01:40:35 +00:00
|
|
|
pr_int_t reserved[2];
|
2002-07-15 21:37:52 +00:00
|
|
|
} qfo_func_t;
|
2002-06-17 05:29:20 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
/** Evil source of many headaches. The whole reason I've started writing this
|
|
|
|
documentation.
|
2008-08-01 13:54:24 +00:00
|
|
|
relocs are always in the order:
|
|
|
|
referenced relocs
|
|
|
|
unreferenced relocs
|
|
|
|
|
|
|
|
For \c ref_op_* relocation types, \c ofs is the code section address of the
|
|
|
|
statement that needs to be adjusted.
|
|
|
|
|
|
|
|
For \c rel_def_* relocation types,
|
|
|
|
\c ofs refers to the data section address of the word that needs to be
|
|
|
|
adjusted.
|
|
|
|
|
|
|
|
For \c ref_*_def(_ofs) relocation types, \c def is the index of the
|
|
|
|
referenced def.
|
|
|
|
|
|
|
|
For \c ref_*_op relocation types, \c def is the address of
|
|
|
|
the referenced statement.
|
|
|
|
|
|
|
|
For \c ref_*_string relocation types, \c def is
|
|
|
|
always 0.
|
|
|
|
|
|
|
|
For \c ref_*_field(_ofs) relocation types, \c def is the index of
|
|
|
|
the referenced field def.
|
2008-08-01 00:47:38 +00:00
|
|
|
*/
|
2002-06-22 05:10:34 +00:00
|
|
|
typedef struct qfo_reloc_s {
|
2011-02-17 06:02:09 +00:00
|
|
|
pr_int_t space; ///< index of space holding data to be adjusted
|
|
|
|
pr_int_t offset; ///< offset of the relocation
|
2008-08-01 13:54:24 +00:00
|
|
|
pr_int_t type; ///< type of the relocation (::reloc_type)
|
2011-02-27 02:37:01 +00:00
|
|
|
pr_int_t target; ///< def/func/etc this relocation is for
|
2002-06-22 05:10:34 +00:00
|
|
|
} qfo_reloc_t;
|
|
|
|
|
2011-02-17 06:02:09 +00:00
|
|
|
/** In-memory representation of a QFO space
|
|
|
|
*/
|
|
|
|
typedef struct qfo_mspace_s {
|
|
|
|
qfos_type_t type;
|
|
|
|
qfo_def_t *defs;
|
|
|
|
int num_defs;
|
|
|
|
union {
|
|
|
|
dstatement_t *code;
|
|
|
|
pr_type_t *data;
|
|
|
|
char *strings;
|
|
|
|
} d;
|
2011-02-22 06:41:35 +00:00
|
|
|
int data_size;
|
2011-02-17 06:02:09 +00:00
|
|
|
int id;
|
|
|
|
} qfo_mspace_t;
|
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
/** In-memory representation of a QFO object file.
|
|
|
|
*/
|
2002-06-22 05:10:34 +00:00
|
|
|
typedef struct qfo_s {
|
2011-02-23 09:10:38 +00:00
|
|
|
void *data; ///< data buffer holding qfo file when read
|
2011-02-21 01:32:20 +00:00
|
|
|
qfo_mspace_t *spaces;
|
2011-02-17 06:02:09 +00:00
|
|
|
int num_spaces;
|
2002-06-22 05:10:34 +00:00
|
|
|
qfo_reloc_t *relocs;
|
2011-02-24 06:21:06 +00:00
|
|
|
int num_relocs; // includes num_loose_relocs
|
2002-06-22 05:10:34 +00:00
|
|
|
qfo_def_t *defs;
|
|
|
|
int num_defs;
|
2002-07-15 21:37:52 +00:00
|
|
|
qfo_func_t *funcs;
|
|
|
|
int num_funcs;
|
2002-06-24 22:36:04 +00:00
|
|
|
pr_lineno_t *lines;
|
|
|
|
int num_lines;
|
2011-02-24 06:21:06 +00:00
|
|
|
int num_loose_relocs; // included in num_relocs
|
2002-06-22 05:10:34 +00:00
|
|
|
} qfo_t;
|
2011-02-23 09:10:38 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
qfo_null_space,
|
|
|
|
qfo_strings_space,
|
|
|
|
qfo_code_space,
|
|
|
|
qfo_near_data_space,
|
|
|
|
qfo_far_data_space,
|
|
|
|
qfo_entity_space,
|
|
|
|
qfo_type_space,
|
|
|
|
|
|
|
|
qfo_num_spaces
|
|
|
|
};
|
2010-08-11 23:42:14 +00:00
|
|
|
//@}
|
2002-06-21 20:46:56 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
/** \defgroup qfcc_qfo_data_access QFO Data Acess
|
|
|
|
\ingroup qfcc_qfo
|
|
|
|
Macros for accessing data in the QFO address space
|
|
|
|
*/
|
2010-08-11 23:42:14 +00:00
|
|
|
//@{
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** \internal
|
|
|
|
\param q pointer to ::qfo_t struct
|
2011-02-25 00:38:22 +00:00
|
|
|
\param s space index
|
2008-08-01 00:47:38 +00:00
|
|
|
\param t typename prefix (see pr_type_u)
|
|
|
|
\param o offset into object file data space
|
|
|
|
\return lvalue of the appropriate type
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2011-02-25 00:38:22 +00:00
|
|
|
#define QFO_var(q, s, t, o) ((q)->spaces[s].d.data[o].t##_var)
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** Access a float variable in the object file. Can be assigned to.
|
|
|
|
|
|
|
|
\par QC type:
|
|
|
|
\c float
|
|
|
|
\param q pointer to ::qfo_t struct
|
2011-02-25 00:38:22 +00:00
|
|
|
\param s space index
|
2008-08-01 00:47:38 +00:00
|
|
|
\param o offset into object file data space
|
|
|
|
\return float lvalue
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2011-02-25 00:38:22 +00:00
|
|
|
#define QFO_FLOAT(q, s, o) QFO_var (q, s, float, o)
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** Access a integer variable in the object file. Can be assigned to.
|
|
|
|
|
|
|
|
\par QC type:
|
|
|
|
\c integer
|
|
|
|
\param q pointer to ::qfo_t struct
|
2011-02-25 00:38:22 +00:00
|
|
|
\param s space index
|
2008-08-01 00:47:38 +00:00
|
|
|
\param o offset into object file data space
|
|
|
|
\return int lvalue
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2011-02-25 00:38:22 +00:00
|
|
|
#define QFO_INT(q, s, o) QFO_var (q, s, integer, o)
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** Access a vector variable in the object file. Can be assigned to.
|
|
|
|
|
|
|
|
\par QC type:
|
|
|
|
\c vector
|
|
|
|
\param q pointer to ::qfo_t struct
|
2011-02-25 00:38:22 +00:00
|
|
|
\param s space index
|
2008-08-01 00:47:38 +00:00
|
|
|
\param o offset into object file data space
|
|
|
|
\return vec3_t lvalue
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2011-02-25 00:38:22 +00:00
|
|
|
#define QFO_VECTOR(q, s, o) QFO_var (q, s, vector, o)
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** Access a string index variable in the object file. Can be assigned to.
|
|
|
|
|
|
|
|
\par QC type:
|
|
|
|
\c string
|
|
|
|
\param q pointer to ::qfo_t struct
|
2011-02-25 00:38:22 +00:00
|
|
|
\param s space index
|
2008-08-01 00:47:38 +00:00
|
|
|
\param o offset into object file data space
|
|
|
|
\return string_t lvalue
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2011-02-25 00:38:22 +00:00
|
|
|
#define QFO_STRING(q, s, o) QFO_var (q, s, string, o)
|
2008-08-01 13:54:24 +00:00
|
|
|
|
|
|
|
/** Retrieve a string from the object file, converting it to a C string.
|
|
|
|
|
|
|
|
\param q pointer to ::qfo_t struct
|
2011-02-25 00:38:22 +00:00
|
|
|
\param s space index
|
2008-08-01 13:54:24 +00:00
|
|
|
\param s offset into object file string space
|
|
|
|
\return (char *)
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2011-02-25 00:38:22 +00:00
|
|
|
#define QFO_GETSTR(q, s) ((q)->spaces[qfo_strings_space].d.strings + (s))
|
2008-08-01 13:54:24 +00:00
|
|
|
|
|
|
|
/** Retrieve a type string from the object file, converting it to a C string.
|
|
|
|
|
|
|
|
\param q pointer to ::qfo_t struct
|
2011-02-25 00:38:22 +00:00
|
|
|
\param t offset to type encoding
|
2008-08-01 13:54:24 +00:00
|
|
|
\return (char *)
|
|
|
|
|
2011-03-01 06:18:12 +00:00
|
|
|
\note Assumes standard space order.
|
2008-08-01 13:54:24 +00:00
|
|
|
\hideinitializer
|
|
|
|
*/
|
2011-02-25 00:38:22 +00:00
|
|
|
#define QFO_TYPESTR(q, t) QFO_GSTRING (q, qfo_type_space, (t) + 2)
|
2008-08-01 13:54:24 +00:00
|
|
|
|
2011-03-01 06:18:12 +00:00
|
|
|
#define QFO_TYPEMETA(q, t) QFO_INT (q, qfo_type_space, (t) + 0)
|
|
|
|
#define QFO_TYPETYPE(q, t) QFO_INT (q, qfo_type_space, (t) + 3)
|
|
|
|
|
2011-03-04 23:41:14 +00:00
|
|
|
#define QFO_STATEMENT(q, s) ((q)->spaces[qfo_code_space].d.code + (s))
|
|
|
|
|
2008-08-01 13:54:24 +00:00
|
|
|
/** Access a string global, converting it to a C string.
|
|
|
|
|
|
|
|
\param q pointer to ::qfo_t struct
|
2011-02-25 00:38:22 +00:00
|
|
|
\param s space index
|
2008-08-01 13:54:24 +00:00
|
|
|
\param o offset into object file data space
|
|
|
|
\return (char *)
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2011-02-25 00:38:22 +00:00
|
|
|
#define QFO_GSTRING(q, s, o) (QFO_GETSTR (q, QFO_STRING (q, s, o)))
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** Access a function variable in the object file. Can be assigned to.
|
|
|
|
|
|
|
|
\par QC type:
|
|
|
|
\c void ()
|
|
|
|
\param q pointer to ::qfo_t struct
|
2011-02-25 00:38:22 +00:00
|
|
|
\param s space index
|
2008-08-01 00:47:38 +00:00
|
|
|
\param o offset into object file data space
|
|
|
|
\return func_t lvalue
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2011-02-25 00:38:22 +00:00
|
|
|
#define QFO_FUNCTION(q, s, o) QFO_var (q, s, func, o)
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** Access a pointer variable in the object file. Can be assigned to.
|
|
|
|
|
|
|
|
\par QC type:
|
|
|
|
\c void []
|
|
|
|
\param q pointer to ::qfo_t struct
|
2011-02-25 00:38:22 +00:00
|
|
|
\param s space index
|
2010-08-11 23:41:30 +00:00
|
|
|
\param t C type of the structure
|
2008-08-01 00:47:38 +00:00
|
|
|
\param o offset into object file data space
|
|
|
|
\return pointer_t lvalue
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2011-02-26 15:31:52 +00:00
|
|
|
#define QFO_POINTER(q, s, t, o) ((t *)(char *)&QFO_var (q, s, integer, o))
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** Access a structure variable in the object file. Can be assigned to.
|
|
|
|
|
|
|
|
\par QC type:
|
|
|
|
\c void [](?)
|
|
|
|
\param q pointer to ::qfo_t struct
|
2011-02-25 00:38:22 +00:00
|
|
|
\param s space index
|
2008-08-01 00:47:38 +00:00
|
|
|
\param t C type of the structure
|
|
|
|
\param o offset into object file data space
|
|
|
|
\return structure lvalue. use & to make a pointer of the appropriate type.
|
|
|
|
|
|
|
|
\hideinitializer
|
|
|
|
*/
|
2011-02-25 00:38:22 +00:00
|
|
|
#define QFO_STRUCT(q, s, t, o) (*QFO_POINTER (q, s, t, o))
|
2002-07-03 20:16:32 +00:00
|
|
|
|
2010-08-11 23:42:14 +00:00
|
|
|
//@}
|
2008-08-01 00:47:38 +00:00
|
|
|
|
2010-08-11 23:42:14 +00:00
|
|
|
/** \addtogroup qfcc_qfo
|
2010-08-11 23:41:30 +00:00
|
|
|
*/
|
2010-08-11 23:42:14 +00:00
|
|
|
//@{
|
2010-08-11 23:41:30 +00:00
|
|
|
|
2002-07-11 20:17:26 +00:00
|
|
|
struct pr_info_s;
|
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
/** Convert ::pr_info_t structure to ::qfo_t.
|
|
|
|
\param pr pointer to ::pr_info_t struct
|
|
|
|
\return pointer to new ::qfo_t struct, or 0 on error.
|
|
|
|
*/
|
2002-07-11 20:17:26 +00:00
|
|
|
qfo_t *qfo_from_progs (struct pr_info_s *pr);
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** Write a ::qfo_t struct to the named file.
|
|
|
|
\param qfo pointer to ::qfo_t struct to write
|
|
|
|
\param filename name of the file to write
|
|
|
|
\return 0 for success, -1 for error.
|
|
|
|
*/
|
2002-07-11 20:17:26 +00:00
|
|
|
int qfo_write (qfo_t *qfo, const char *filename);
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** Read a ::qfo_t strcut from a ::QFile stream.
|
|
|
|
\param file ::QFile stream to read from
|
|
|
|
\return pointer to new ::qfo_t struct, or 0 on error.
|
|
|
|
*/
|
2002-08-27 07:16:28 +00:00
|
|
|
qfo_t *qfo_read (QFile *file);
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** Wrapper around qfo_read() to allow reading from a named file.
|
|
|
|
\param filename name of the file to read
|
|
|
|
\return pointer to new ::qfo_t struct, or 0 on error.
|
|
|
|
*/
|
2002-07-21 07:12:17 +00:00
|
|
|
qfo_t *qfo_open (const char *filename);
|
2008-08-01 00:47:38 +00:00
|
|
|
|
2011-03-02 11:51:00 +00:00
|
|
|
dprograms_t *qfo_to_progs (qfo_t *qfo, int *size);
|
2011-03-04 09:44:02 +00:00
|
|
|
pr_debug_header_t *qfo_to_sym (qfo_t *qfo, int *size);
|
2002-07-11 20:17:26 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
/** Create a new ::qfo_t struct
|
|
|
|
\return pointer to new ::qfo_t struct, or 0 on error.
|
|
|
|
*/
|
2002-07-11 17:06:15 +00:00
|
|
|
qfo_t *qfo_new (void);
|
2008-08-01 00:47:38 +00:00
|
|
|
|
|
|
|
/** Delete a ::qfo_t struct, as well as any substructure data.
|
|
|
|
\param qfo ::qfo_t struct to delete
|
|
|
|
*/
|
2002-07-11 17:06:15 +00:00
|
|
|
void qfo_delete (qfo_t *qfo);
|
2002-06-21 20:46:56 +00:00
|
|
|
|
2008-08-01 00:47:38 +00:00
|
|
|
//@}
|
|
|
|
|
2002-06-17 05:29:20 +00:00
|
|
|
#endif//__obj_file_h
|