diff options
author | Freya Murphy <freya@freyacat.org> | 2024-09-20 20:46:37 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-09-20 21:02:38 -0400 |
commit | 3b0a87254f8a1e48a155f5571c274297353a0106 (patch) | |
tree | 8aab94632c01c50e4adafc8a4d062902d5cdfe4e /mld/main.c | |
parent | remove test file (diff) | |
download | mips-3b0a87254f8a1e48a155f5571c274297353a0106.tar.gz mips-3b0a87254f8a1e48a155f5571c274297353a0106.tar.bz2 mips-3b0a87254f8a1e48a155f5571c274297353a0106.zip |
start mld, add loading of object files, add fuzzing support
Diffstat (limited to '')
-rw-r--r-- | mld/main.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/mld/main.c b/mld/main.c new file mode 100644 index 0000000..3dd5b5c --- /dev/null +++ b/mld/main.c @@ -0,0 +1,50 @@ +#include <stdio.h> +#include <unistd.h> +#include <merror.h> +#include <string.h> + +#include "link.h" + +void help(void) { + printf("usage: mld [options] objfile...\n\n"); + printf("options:\n"); + printf("\t-h\t\tprints this help message\n"); + printf("\t-o <output>\tselect a output file destination\n"); +} + +int main(int argc, char **argv) { + + struct linker_arguments args = { + .in_files = NULL, + .in_count = 0, + .out_file = "a.out", + }; + + int c; + + while ((c = getopt(argc, argv, "ho:")) != 1) { + switch(c) { + case 'h': + help(); + return M_SUCCESS; + case 'o': + args.out_file = optarg; + break; + case '?': + return M_ERROR; + default: + goto next; + } + } + +next: + if (optind >= argc) { + ERROR("no object files passed"); + return M_ERROR; + } + + args.in_files = &argv[optind]; + args.in_count = argc - optind; + + return link_files(args); +} |