diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile.am | 6 | ||||
| -rw-r--r-- | src/compilo.c | 15 | ||||
| -rw-r--r-- | src/linker.c | 61 | 
3 files changed, 75 insertions, 7 deletions
| diff --git a/src/Makefile.am b/src/Makefile.am index f340432..5b3c985 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,12 +3,12 @@ DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@  AM_CFLAGS = -O3 -Wall -Wstrict-prototypes $(CFLAGS)  INCLUDES = -I. -I.. -I$(includedir) -I../include -bin_PROGRAMS = compilo simul +bin_PROGRAMS = compilo simul linker  compilo_SOURCES = compilo.c  simul_SOURCES = simul.c - -LDADD = ../lib/libCompilo.la +linker_SOURCES = linker.c  compilo_LDADD = ../lib/libCompilo.la  simul_LDADD = ../lib/libSimul.la +linker_LDADD = ../lib/libLinker.la diff --git a/src/compilo.c b/src/compilo.c index 883bd81..61ea761 100644 --- a/src/compilo.c +++ b/src/compilo.c @@ -12,7 +12,12 @@  typedef void (*sighandler_t)(int);  void invite(void) { -	fprintf(stderr, _("Assembler\n\n")); +	fprintf(stderr, _("Assembler v1.0\n\n")); +} + +void usage(void) { +	fprintf(stderr, _("Usage: compilo program.asm objet.out\n")); +	exit(0);  }  void init_all(void) { @@ -46,15 +51,17 @@ void segfaulthand(int i) {  	exception(1, _("Signal received: segfault"));  } -int main(void) { +int main(int argc, char ** argv) {  	invite();  /*	signal(SIGSEGV, segfaulthand); */ +	 +	if (argc != 3) usage();  	fprintf(stderr, _("\nPerforming initialisation...\n\n"));  	init_all(); -	 -	assemble_file("progtest.asm", "progtest.o"); + +	assemble_file(argv[1], argv[2]);  	fprintf(stderr, _("\nPerforming shutdown...\n\n"));  	flush_all(); diff --git a/src/linker.c b/src/linker.c new file mode 100644 index 0000000..61301de --- /dev/null +++ b/src/linker.c @@ -0,0 +1,61 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <signal.h> +#include "config.h" +#include "exceptions.h" +#include "linker.h" + +typedef void (*sighandler_t)(int); + +void invite(void) { +	fprintf(stderr, _("Linker v1.0\n\n")); +} + +void usage(void) { +	fprintf(stderr, _("Usage: linker obj1 [obj2 [obj3 [...]]] binary\n")); +	exit(0); +} + +void init_all(int n) { +	fprintf(stderr, _(" o Initialising the linker...   ")); + +	init(n); +	fprintf(stderr, _(" Done!\n")); +} + +void flush_all(void) { +	flush(); +} + +void segfaulthand(int i) { +	exception(1, _("Signal received: segfault")); +} + +int main(int argc, char ** argv) { +	int i; + +	invite(); +	 +	signal(SIGSEGV, segfaulthand); +	 +	if (argc < 3) usage(); + +	fprintf(stderr, _("\nPerforming initialisation...\n\n")); +	init_all(argc - 2); +	 +	fprintf(stderr, _("Linking files...\n")); +	 +	for (i = 1; i < argc - 1; i++) { +		addfile(argv[i]); +	} +		 +	fprintf(stderr, _("Generating output file...\n")); +	dumpfile(argv[i]); + +	fprintf(stderr, _("\nPerforming shutdown...\n\n")); +	flush_all(); +	 +	fprintf(stderr, _("Exitting, bye!\n")); +        return 0; +} | 
