Add a field for loose relocation records.

Loose relocation records are those that are not bound to a def or a
function.
This commit is contained in:
Bill Currie 2011-02-24 15:21:06 +09:00
parent 8f1e2c143a
commit a106c1fb51
2 changed files with 7 additions and 2 deletions

View file

@ -67,7 +67,8 @@ typedef struct qfo_header_s {
pr_int_t num_defs; ///< number of def records pr_int_t num_defs; ///< number of def records
pr_int_t num_funcs; ///< number of function records pr_int_t num_funcs; ///< number of function records
pr_int_t num_lines; ///< number of line records pr_int_t num_lines; ///< number of line records
pr_int_t reserved[1]; pr_int_t num_loose_relocs; ///< number of loose relocation records
///< included in num_relocs
} qfo_header_t; } qfo_header_t;
typedef enum qfos_type_e { typedef enum qfos_type_e {
@ -258,13 +259,14 @@ typedef struct qfo_s {
qfo_mspace_t *spaces; qfo_mspace_t *spaces;
int num_spaces; int num_spaces;
qfo_reloc_t *relocs; qfo_reloc_t *relocs;
int num_relocs; int num_relocs; // includes num_loose_relocs
qfo_def_t *defs; qfo_def_t *defs;
int num_defs; int num_defs;
qfo_func_t *funcs; qfo_func_t *funcs;
int num_funcs; int num_funcs;
pr_lineno_t *lines; pr_lineno_t *lines;
int num_lines; int num_lines;
int num_loose_relocs; // included in num_relocs
} qfo_t; } qfo_t;
enum { enum {

View file

@ -296,6 +296,7 @@ qfo_from_progs (pr_info_t *pr)
// names // names
qfo_init_string_space (qfo, &qfo->spaces[qfo_strings_space], pr->strings); qfo_init_string_space (qfo, &qfo->spaces[qfo_strings_space], pr->strings);
qfo->num_loose_relocs = qfo->num_relocs - (reloc - qfo->relocs);
qfo_encode_relocs (qfo, pr->relocs, &reloc, 0); qfo_encode_relocs (qfo, pr->relocs, &reloc, 0);
return qfo; return qfo;
@ -389,6 +390,7 @@ qfo_write (qfo_t *qfo, const char *filename)
header->num_defs = LittleLong (qfo->num_defs); header->num_defs = LittleLong (qfo->num_defs);
header->num_funcs = LittleLong (qfo->num_funcs); header->num_funcs = LittleLong (qfo->num_funcs);
header->num_lines = LittleLong (qfo->num_lines); header->num_lines = LittleLong (qfo->num_lines);
header->num_loose_relocs = LittleLong (qfo->num_loose_relocs);
spaces = (qfo_space_t *) &header[1]; spaces = (qfo_space_t *) &header[1];
relocs = (qfo_reloc_t *) &spaces[qfo->num_spaces]; relocs = (qfo_reloc_t *) &spaces[qfo->num_spaces];
defs = (qfo_def_t *) &relocs[qfo->num_relocs]; defs = (qfo_def_t *) &relocs[qfo->num_relocs];
@ -477,6 +479,7 @@ qfo_read (QFile *file)
qfo->num_defs = LittleLong (header->num_defs); qfo->num_defs = LittleLong (header->num_defs);
qfo->num_funcs = LittleLong (header->num_funcs); qfo->num_funcs = LittleLong (header->num_funcs);
qfo->num_lines = LittleLong (header->num_lines); qfo->num_lines = LittleLong (header->num_lines);
qfo->num_loose_relocs = LittleLong (header->num_loose_relocs);
spaces = (qfo_space_t *) &header[1]; spaces = (qfo_space_t *) &header[1];
qfo->data = data; qfo->data = data;