Mercurial > hg-old > index.cgi
comparison 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 |
comparison
equal
deleted
inserted
replaced
179:3711cd1c01e2 | 180:6ebb93b409ba |
---|---|
42 char *scriptfile = NULL; | 42 char *scriptfile = NULL; |
43 | 43 |
44 fileinfo_t **inputfiles = NULL; | 44 fileinfo_t **inputfiles = NULL; |
45 int ninputfiles = 0; | 45 int ninputfiles = 0; |
46 | 46 |
47 int nlibdirs = 0; | |
48 char **libdirs = NULL; | |
49 | |
50 int nscriptls = 0; | |
51 char **scriptls = NULL; | |
52 | |
47 void add_input_file(char *fn) | 53 void add_input_file(char *fn) |
48 { | 54 { |
49 inputfiles = lw_realloc(inputfiles, sizeof(fileinfo_t *) * (ninputfiles + 1)); | 55 inputfiles = lw_realloc(inputfiles, sizeof(fileinfo_t *) * (ninputfiles + 1)); |
50 inputfiles[ninputfiles] = lw_malloc(sizeof(fileinfo_t)); | 56 inputfiles[ninputfiles] = lw_malloc(sizeof(fileinfo_t)); |
51 memset(inputfiles[ninputfiles], 0, sizeof(fileinfo_t)); | 57 memset(inputfiles[ninputfiles], 0, sizeof(fileinfo_t)); |
52 inputfiles[ninputfiles++] -> filename = lw_strdup(fn); | 58 inputfiles[ninputfiles++] -> filename = lw_strdup(fn); |
53 } | 59 } |
54 | 60 |
61 void add_input_library(char *libname) | |
62 { | |
63 inputfiles = lw_realloc(inputfiles, sizeof(fileinfo_t *) * (ninputfiles + 1)); | |
64 inputfiles[ninputfiles] = lw_malloc(sizeof(fileinfo_t)); | |
65 memset(inputfiles[ninputfiles], 0, sizeof(fileinfo_t)); | |
66 inputfiles[ninputfiles] -> islib = 1; | |
67 inputfiles[ninputfiles++] -> filename = lw_strdup(libname); | |
68 } | |
69 | |
70 void add_library_search(char *libdir) | |
71 { | |
72 libdirs = lw_realloc(libdirs, sizeof(char*) * (nlibdirs + 1)); | |
73 libdirs[nlibdirs] = lw_strdup(libdir); | |
74 nlibdirs++; | |
75 } | |
76 | |
77 void add_section_base(char *sectspec) | |
78 { | |
79 char *base; | |
80 int baseaddr; | |
81 char *t; | |
82 int l; | |
83 | |
84 base = strchr(sectspec, '='); | |
85 if (!base) | |
86 { | |
87 l = strlen(sectspec); | |
88 baseaddr = 0; | |
89 } | |
90 else | |
91 { | |
92 baseaddr = strtol(base + 1, NULL, 16); | |
93 l = base - sectspec; | |
94 *base = '\0'; | |
95 } | |
96 baseaddr = baseaddr & 0xffff; | |
97 | |
98 t = lw_malloc(l + 25); | |
99 sprintf(t, "section %s load %04X", sectspec, baseaddr); | |
100 if (base) | |
101 *base = '='; | |
102 | |
103 scriptls = lw_realloc(scriptls, sizeof(char *) * (nscriptls + 1)); | |
104 scriptls[nscriptls++] = t; | |
105 } |