comparison lwlink/readfiles.c @ 180:6ebb93b409ba

Added library paths and --section-base
author lost
date Thu, 05 Mar 2009 02:23:25 +0000
parents 0395e6fd67e9
children 048ebb85f6ef
comparison
equal deleted inserted replaced
179:3711cd1c01e2 180:6ebb93b409ba
68 long size; 68 long size;
69 FILE *f; 69 FILE *f;
70 long bread; 70 long bread;
71 for (i = 0; i < ninputfiles; i++) 71 for (i = 0; i < ninputfiles; i++)
72 { 72 {
73 f = fopen(inputfiles[i] -> filename, "rb"); 73 if (inputfiles[i] -> islib)
74 if (!f) 74 {
75 { 75 char *tf;
76 fprintf(stderr, "Can't open file %s:", inputfiles[i] -> filename); 76 int s;
77 perror(""); 77 int j;
78 exit(1); 78
79 f = NULL;
80
81 for (j = 0; j < nlibdirs; j++)
82 {
83 s = strlen(libdirs[j]) + 7 + strlen(inputfiles[i] -> filename);
84 tf = lw_malloc(s + 1);
85 sprintf(tf, "%s/lib%s.a", libdirs[j], inputfiles[i] -> filename);
86 f = fopen(tf, "rb");
87 if (!f)
88 {
89 free(tf);
90 continue;
91 }
92 free(tf);
93 }
94 if (!f)
95 {
96 fprintf(stderr, "Can't open library: -l%s\n", inputfiles[i] -> filename);
97 exit(1);
98 }
99 }
100 else
101 {
102 f = fopen(inputfiles[i] -> filename, "rb");
103 if (!f)
104 {
105 fprintf(stderr, "Can't open file %s:", inputfiles[i] -> filename);
106 perror("");
107 exit(1);
108 }
79 } 109 }
80 fseek(f, 0, SEEK_END); 110 fseek(f, 0, SEEK_END);
81 size = ftell(f); 111 size = ftell(f);
82 rewind(f); 112 rewind(f);
83 113