summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPixel <>2001-04-16 14:25:48 +0000
committerPixel <>2001-04-16 14:25:48 +0000
commit47f363829678a02111423cd5d374e6739d8ea500 (patch)
tree5c288a8902492e1a91d87ba4ab1cca658e39cbfa /src
parent27f796ab6a9f455bbd2a1c85088db5304cece75a (diff)
Linker + bugfixes
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am6
-rw-r--r--src/compilo.c15
-rw-r--r--src/linker.c61
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;
+}