From ce8f071b7c2ac4172ec898beb202aeee2c8a603c Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 12 Jul 2002 04:50:31 +0000 Subject: [PATCH] implement partial linking (doesn't work any better than full, though :P) --- tools/qfcc/include/options.h | 1 + tools/qfcc/source/linker.c | 15 +++++++++------ tools/qfcc/source/options.c | 4 ++++ tools/qfcc/source/qfcc.c | 12 ++++++++---- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/tools/qfcc/include/options.h b/tools/qfcc/include/options.h index bf5d3866e..e59581313 100644 --- a/tools/qfcc/include/options.h +++ b/tools/qfcc/include/options.h @@ -64,6 +64,7 @@ typedef struct { qboolean files_dat; // generate files.dat qboolean traditional; // behave more like qcc qboolean compile; // serparate compilation mode + qboolean partial_link; // partial linking int strip_path; // number of leading path elements to strip // from source file names const char *output_file; diff --git a/tools/qfcc/source/linker.c b/tools/qfcc/source/linker.c index 046d84661..8c20d0c4d 100644 --- a/tools/qfcc/source/linker.c +++ b/tools/qfcc/source/linker.c @@ -49,6 +49,7 @@ static const char rcsid[] = #include "immediate.h" #include "linker.h" #include "obj_file.h" +#include "options.h" #include "qfcc.h" #include "reloc.h" #include "strpool.h" @@ -353,13 +354,15 @@ linker_finish (void) qfo_t *qfo; undef_defs = (qfo_def_t **) Hash_GetList (extern_defs); - for (def = undef_defs; *def; def++) { - pr.source_file = (*def)->file; - pr.source_line = (*def)->line; - error (0, "undefined symbol %s", strings->strings + (*def)->name); + if (!options.partial_link) { + for (def = undef_defs; *def; def++) { + pr.source_file = (*def)->file; + pr.source_line = (*def)->line; + error (0, "undefined symbol %s", strings->strings + (*def)->name); + } + if (pr.error_count) + return 0; } - if (pr.error_count) - return 0; qfo = qfo_new (); qfo_add_code (qfo, code->code, code->size); diff --git a/tools/qfcc/source/options.c b/tools/qfcc/source/options.c index 9f3a8bc14..fc1865440 100644 --- a/tools/qfcc/source/options.c +++ b/tools/qfcc/source/options.c @@ -83,6 +83,7 @@ static const char *short_options = "l:" // lib file "o:" // output file "c" // separate compilation + "r" // partial linking "s:" // source dir "P:" // progs.src name "F" // generate files.dat @@ -211,6 +212,9 @@ DecodeArgs (int argc, char **argv) case 'c': // traditional options.compile = true; break; + case 'r': // traditional + options.partial_link = true; + break; case 'C':{ // code options char *opts = strdup (optarg); char *temp = strtok (opts, ","); diff --git a/tools/qfcc/source/qfcc.c b/tools/qfcc/source/qfcc.c index 1fb440dab..4c5f9139c 100644 --- a/tools/qfcc/source/qfcc.c +++ b/tools/qfcc/source/qfcc.c @@ -547,10 +547,14 @@ separate_compile (void) } qfo = linker_finish (); if (qfo) { - qfo_to_progs (qfo, &pr); - setup_sym_file (options.output_file); - finish_compilation (); - WriteData (0); + if (options.partial_link) { + qfo_write (qfo, options.output_file); + } else { + qfo_to_progs (qfo, &pr); + setup_sym_file (options.output_file); + finish_compilation (); + WriteData (0); + } } } return err;