Output all relocations for a.out
authorRobert Pengelly <robertapengelly@hotmail.com>
Sun, 9 Jun 2024 04:08:03 +0000 (05:08 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Sun, 9 Jun 2024 04:08:03 +0000 (05:08 +0100)
aout.c
lib.c

diff --git a/aout.c b/aout.c
index 27cf88dc97de03f0551fa6517d8ca3cfff3c1f09..b3200a7d063b2148808c5ea302fc1c0a70845c5f 100644 (file)
--- a/aout.c
+++ b/aout.c
@@ -376,7 +376,7 @@ static int relocate (struct aout_object *object, struct relocation_info *r, int
             r_symbolnum = GET_UINT32 (r->r_symbolnum) & (3L << 29);
             r_address = GET_INT32 (r->r_address);
             
-            if (/*state->format == LD_FORMAT_I386_AOUT || */((r_symbolnum >> 28) & 0xff) != N_ABS) {
+            if (state->format == LD_FORMAT_I386_AOUT || ((r_symbolnum >> 28) & 0xff) != N_ABS) {
             
                 if (state->format == LD_FORMAT_BIN || state->format == LD_FORMAT_COM) {
                 
diff --git a/lib.c b/lib.c
index f92ad155561598a1b1664f39ec1950acf1b27646..6a1111a73278b941f4ae2296d95bd8b7582a7ef4 100644 (file)
--- a/lib.c
+++ b/lib.c
@@ -2,6 +2,8 @@
  * @file            lib.c
  *****************************************************************************/
 #include    <ctype.h>
+#include    <errno.h>
+#include    <limits.h>
 #include    <stdio.h>
 #include    <stdlib.h>
 #include    <string.h>
@@ -33,10 +35,13 @@ struct ld_option {
 #define     LD_OPTION_IMPURE            4
 #define     LD_OPTION_MAP               5
 #define     LD_OPTION_OUTFILE           6
+#define     LD_OPTION_PSP               7
 
 static struct ld_option opts[] = {
 
     {   "-N",           LD_OPTION_IMPURE,       LD_OPTION_NO_ARG    },
+    {   "-T",           LD_OPTION_PSP,          LD_OPTION_HAS_ARG   },
+    
     {   "-e",           LD_OPTION_ENTRY,        LD_OPTION_HAS_ARG   },
     {   "-o",           LD_OPTION_OUTFILE,      LD_OPTION_HAS_ARG   },
     
@@ -56,7 +61,7 @@ static void print_usage (void) {
         fprintf (stderr, "Options:\n\n");
         
         fprintf (stderr, "    -N                    Do not page align data.\n");
-        /*fprintf (stderr, "    -T OFFSET             Offset addresses by the specified offset.\n");*/
+        fprintf (stderr, "    -T OFFSET             Offset addresses by the specified offset.\n");
         
         fprintf (stderr, "    --oformat FORMAT      Specify the format of output file (default msdos)\n");
         fprintf (stderr, "                              Supported formats are:\n");
@@ -289,6 +294,33 @@ void parse_args (int argc, char **argv, int optind) {
             
             }
             
+            case LD_OPTION_PSP: {
+            
+                long conversion;
+                char *temp;
+                
+                errno = 0;
+                conversion = strtol (optarg, &temp, 0);
+                
+                if (!*optarg || isspace ((int) *optarg) || errno || *temp) {
+                
+                    report_at (program_name, 0, REPORT_ERROR, "bad number for text start");
+                    exit (EXIT_FAILURE);
+                
+                }
+                
+                if (conversion < 0 || conversion > LONG_MAX) {
+                
+                    report_at (program_name, 0, REPORT_ERROR, "text start must be between 0 and %u", ULONG_MAX);
+                    exit (EXIT_FAILURE);
+                
+                }
+                
+                state->psp = (unsigned long) conversion;
+                break;
+            
+            }
+            
             default: {
             
                 report_at (program_name, 0, REPORT_ERROR, "unsupported option '%s'", r);