diff lwlink/lwlink.c @ 180:6ebb93b409ba

Added library paths and --section-base
author lost
date Thu, 05 Mar 2009 02:23:25 +0000
parents d610b8aef91b
children 220a760ec654
line wrap: on
line diff
--- a/lwlink/lwlink.c	Wed Mar 04 05:34:17 2009 +0000
+++ b/lwlink/lwlink.c	Thu Mar 05 02:23:25 2009 +0000
@@ -44,6 +44,12 @@
 fileinfo_t **inputfiles = NULL;
 int ninputfiles = 0;
 
+int nlibdirs = 0;
+char **libdirs = NULL;
+
+int nscriptls = 0;
+char **scriptls = NULL;
+
 void add_input_file(char *fn)
 {
 	inputfiles = lw_realloc(inputfiles, sizeof(fileinfo_t *) * (ninputfiles + 1));
@@ -52,3 +58,48 @@
 	inputfiles[ninputfiles++] -> filename = lw_strdup(fn);
 }
 
+void add_input_library(char *libname)
+{
+	inputfiles = lw_realloc(inputfiles, sizeof(fileinfo_t *) * (ninputfiles + 1));
+	inputfiles[ninputfiles] = lw_malloc(sizeof(fileinfo_t));
+	memset(inputfiles[ninputfiles], 0, sizeof(fileinfo_t));
+	inputfiles[ninputfiles] -> islib = 1;
+	inputfiles[ninputfiles++] -> filename = lw_strdup(libname);	
+}
+
+void add_library_search(char *libdir)
+{
+	libdirs = lw_realloc(libdirs, sizeof(char*) * (nlibdirs + 1));
+	libdirs[nlibdirs] = lw_strdup(libdir);
+	nlibdirs++;
+}
+
+void add_section_base(char *sectspec)
+{
+	char *base;
+	int baseaddr;
+	char *t;
+	int l;
+	
+	base = strchr(sectspec, '=');
+	if (!base)
+	{
+		l = strlen(sectspec);
+		baseaddr = 0;
+	}
+	else
+	{
+		baseaddr = strtol(base + 1, NULL, 16);
+		l = base - sectspec;
+		*base = '\0';
+	}
+	baseaddr = baseaddr & 0xffff;
+	
+	t = lw_malloc(l + 25);
+	sprintf(t, "section %s load %04X", sectspec, baseaddr);
+	if (base)
+		*base = '=';
+	
+	scriptls = lw_realloc(scriptls, sizeof(char *) * (nscriptls + 1));
+	scriptls[nscriptls++] = t;
+}