From 9e369a6eeca81017f78881d3d332ddf1d2187150 Mon Sep 17 00:00:00 2001 From: Robert Pengelly Date: Sun, 9 Jun 2024 05:08:03 +0100 Subject: [PATCH] Output all relocations for a.out --- aout.c | 2 +- lib.c | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/aout.c b/aout.c index 27cf88d..b3200a7 100644 --- 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 f92ad15..6a1111a 100644 --- a/lib.c +++ b/lib.c @@ -2,6 +2,8 @@ * @file lib.c *****************************************************************************/ #include +#include +#include #include #include #include @@ -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); -- 2.34.1