1 /* rdx.c RDOFF Object File loader program
3 * The Netwide Assembler is copyright (C) 1996 Simon Tatham and
4 * Julian Hall. All rights reserved. The software is
5 * redistributable under the licence given in the file "Licence"
6 * distributed in the NASM archive.
9 /* note: most of the actual work of this program is done by the modules
10 "rdfload.c", which loads and relocates the object file, and by "rdoff.c",
11 which contains general purpose routines to manipulate RDOFF object
12 files. You can use these files in your own program to load RDOFF objects
13 and execute the code in them in a similar way to what is shown here. */
22 typedef int (*main_fn
) (int,char**); /* Main function prototype */
24 int main(int argc
, char **argv
)
32 puts("usage: rdx <rdoff-executable> [params]\n");
40 rdfperror("rdx",argv
[1]);
44 rdf_relocate(m
); /* in this instance, the default relocation
45 values will work fine, but they may need changing
48 s
= symtabFind(m
->symtab
, "_main");
51 fprintf(stderr
,"rdx: could not find symbol '_main' in '%s'\n",argv
[1]);
55 code
= (main_fn
) s
->offset
;
57 argv
++, argc
--; /* remove 'rdx' from command line */
59 return code(argc
,argv
); /* execute */