From 05f3a96e41a1c2ad78a080a192876517a8aefc78 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Tue, 14 Jun 2016 13:25:45 -0500 Subject: [PATCH] Fix for -n and -l flags. Thanks to C. Forhan for reporting. --- rln.c | 40 ++++++++++++++++++++++++---------------- rln.h | 2 +- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/rln.c b/rln.c index 5b33232..f97b490 100644 --- a/rln.c +++ b/rln.c @@ -22,7 +22,7 @@ unsigned sflag = 0; // Output only global symbols unsigned vflag = 0; // Verbose flag unsigned wflag = 0; // Show warnings flag unsigned zflag = 0; // Suppress banner flag -unsigned pflag = 0, uflag = 0; // Unimplemented flags +unsigned pflag = 0, uflag = 0; // Unimplemented flags (partial link, don't abort on unresolved symbols) unsigned hd = 0; // Index of next file handle to fill unsigned secalign = 7; // Section Alignment (8=phrase) unsigned tbase = 0; // TEXT base address @@ -1050,11 +1050,11 @@ int WriteOutputFile(struct OHEADER * header) if (strchr(ofile, '.') == NULL) { if (aflag && cflag) - strcat(ofile, ".cof"); // COF files + strcat(ofile, ".cof"); // COF files (a type of abs) else if (aflag && !cflag) strcat(ofile, ".abs"); // ABS files else - strcat(ofile, ".o"); // Object files (partial linking etc) + strcat(ofile, ".o"); // Object files (partial linking, etc) } FILE * fd = fopen(ofile, "wb"); // Attempt to open output file @@ -1157,18 +1157,20 @@ int WriteOutputFile(struct OHEADER * header) } // Write the header, but not if noheaderflag - // Absolute (ABS) header - if (!cflag) + if (!noheaderflag) { - if (!noheaderflag) + // Absolute (ABS) header + if (!cflag) + { if (fwrite(himage, 36, 1, fd) != 1) goto werror; - } - // Absolute (COF) header - else - { - if (fwrite(himage, 168, 1, fd) != 1) - goto werror; + } + // Absolute (COF) header + else + { + if (fwrite(himage, 168, 1, fd) != 1) + goto werror; + } } // Write the TEXT segment of each object file @@ -1215,7 +1217,12 @@ int WriteOutputFile(struct OHEADER * header) } } - if (!noheaderflag) +//wha? if (!noheaderflag) + // This isn't quite right, but it's closer... + // (the l and s flags tell the linker to output local & global symbols + // in the symbol table, so it seems there's some other thing that's a + // default set somewhere. Not 100% sure. Setting -s kills -l, BTW...) + if (lflag || sflag) { // Write the symbols table and string table // Absolute (COF) symbol/string table @@ -3008,10 +3015,11 @@ void ShowHelp(void) printf(" -d wait for key after link\n"); printf(" -e output COF absolute file\n"); printf(" -g output source-level debugging\n"); - printf(" -i