/[gentoo-alt]/trunk/toolchain-prefix-wrapper/ld/hpuxplugin.c
Gentoo

Diff of /trunk/toolchain-prefix-wrapper/ld/hpuxplugin.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1630 Revision 1631
31 bool withDefaultRunpath = true; /* +nodefaultrpath */ 31 bool withDefaultRunpath = true; /* +nodefaultrpath */
32 envrunpath_t withEnvRunpath = envrunpath_no; /* +s */ 32 envrunpath_t withEnvRunpath = envrunpath_no; /* +s */
33 33
34 StringList *tmpArgList = NULL; 34 StringList *tmpArgList = NULL;
35 StringList *runpathList = NULL; 35 StringList *runpathList = NULL;
36 StringList *libpathList = NULL;
37 StringList *defaultRunpathList = NULL; 36 StringList *defaultRunpathList = NULL;
38 String *newString = NULL; 37 String *newString = NULL;
39 String const *argString; 38 String const *argString;
40 char const *argBuffer; 39 char const *argBuffer;
41 int argBufferLength; 40 int argBufferLength;
47 if (tmpArgList == NULL) 46 if (tmpArgList == NULL)
48 break; 47 break;
49 48
50 runpathList = StringListCreate(NULL, 0, 0); 49 runpathList = StringListCreate(NULL, 0, 0);
51 if (runpathList == NULL) 50 if (runpathList == NULL)
52 break;
53
54 libpathList = StringListCreate(NULL, 0, 0);
55 if (libpathList == NULL)
56 break; 51 break;
57 52
58 defaultRunpathList = StringListCreate(NULL, 0, 0); 53 defaultRunpathList = StringListCreate(NULL, 0, 0);
59 if (defaultRunpathList == NULL) 54 if (defaultRunpathList == NULL)
60 break; 55 break;
120 115
121 /* end "+b" handling */ 116 /* end "+b" handling */
122 continue; 117 continue;
123 } else 118 } else
124 if (strncmp(argBuffer, "-L", 2) == 0) { 119 if (strncmp(argBuffer, "-L", 2) == 0) {
125 /* collect libpath from "-L libpath" */ 120 /* drop -L arguments from commandline,
121 * we need to pass them before any libs.
122 * The path list already is collected in userLibpath.
123 */
124 continue;
125 } else
126 if (strncmp(argBuffer, "-R", 2) == 0) {
127 /* extension:
128 * collect additional default runpath from "-R runpath"
129 */
126 130
127 argBuffer += 2; 131 argBuffer += 2;
128 argBufferLength -= 2; 132 argBufferLength -= 2;
129 133
130 if (*argBuffer == 0 && argc < StringListGetSize(data->in->argList)) { 134 if (*argBuffer == 0 && argc < StringListGetSize(data->in->argList)) {
134 argBufferLength = StringGetLength(argString); 138 argBufferLength = StringGetLength(argString);
135 } 139 }
136 if (StringListContains(data->in->sysLibpath, argBuffer, argBufferLength)) 140 if (StringListContains(data->in->sysLibpath, argBuffer, argBufferLength))
137 continue; 141 continue;
138 142
139 if (StringListAppendConcat(libpathList, argBuffer, argBufferLength, NULL) < 0)
140 break;
141
142 continue;
143 } else
144 if (strncmp(argBuffer, "-R", 2) == 0) {
145 /* extension:
146 * collect additional default runpath from "-R runpath"
147 */
148
149 argBuffer += 2;
150 argBufferLength -= 2;
151
152 if (*argBuffer == 0 && argc < StringListGetSize(data->in->argList)) {
153 argc++;
154 argString = StringListGetString(data->in->argList, argc);
155 argBuffer = StringGetBuffer(argString);
156 argBufferLength = StringGetLength(argString);
157 }
158 if (StringListContains(data->in->sysLibpath, argBuffer, argBufferLength))
159 continue;
160
161 if (StringListAppendConcat(defaultRunpathList, argBuffer, argBufferLength, NULL) < 0) 143 if (StringListAppendConcat(defaultRunpathList, argBuffer, argBufferLength, NULL) < 0)
162 break; 144 break;
163 145
164 continue; 146 continue;
165 } 147 }
171 if (argc < StringListGetSize(data->in->argList)) { 153 if (argc < StringListGetSize(data->in->argList)) {
172 /* error during argument parsing */ 154 /* error during argument parsing */
173 break; 155 break;
174 } 156 }
175 157
158 /*
159 * first, put libpath list (-L) on the commandline
160 */
161 if (StringListAppendListModify(data->out->argList, data->in->userLibpath, 0, -1, "-L", 2, NULL, 0) < 0)
162 break;
163
164 /* also put sys libpath list as libpath (-L) on commandline */
165 if (StringListAppendListModify(data->out->argList, data->in->sysLibpath, 0, -1, "-L", 2, NULL, 0) < 0)
166 break;
167
168 /* do we need to use env-runpath first? */
169 if (withEnvRunpath == envrunpath_first
170 && StringListAppendConcat(data->out->argList, "+s", 2, NULL) < 0
171 ) break;
172
173 /*
174 * now put runpath list (from -R, +b) on the commandline
175 */
176
177 /* append "+b" to commandline */
178 if (StringListAppendConcat(data->out->argList, "+b", 2, NULL) < 0)
179 break;
180
176 /* if there is no runpath (+b), use libpath as runpath 181 /* if there is no runpath (+b), use libpath as runpath
177 * if not disabled with "+nodefaultrpath" 182 * if not disabled with "+nodefaultrpath"
178 */ 183 */
179 if (StringListGetSize(runpathList) == 0 184 if (StringListGetSize(runpathList) == 0
180 && withDefaultRunpath == true 185 && withDefaultRunpath == true
181 && StringListAppendList(runpathList, libpathList, 0, -1) < 0 186 && StringListAppendList(runpathList, data->in->userLibpath, 0, -1) < 0
182 ) break; 187 ) break;
183
184 /*
185 * first, put libpath list (-L) on the commandline
186 */
187 if (StringListAppendListModify(data->out->argList, libpathList, 0, -1, "-L", 2, NULL, 0) < 0)
188 break;
189
190 /* also put sys libpath list as libpath (-L) on commandline */
191 if (StringListAppendListModify(data->out->argList, data->in->sysLibpath, 0, -1, "-L", 2, NULL, 0) < 0)
192 break;
193
194 /*
195 * second, put runpath list (-R, +b) on the commandline
196 */
197
198 /* append "+b" to commandline */
199 if (StringListAppendConcat(data->out->argList, "+b", 2, NULL) < 0)
200 break;
201 188
202 /* append default runpath list (-R) to runpath list */ 189 /* append default runpath list (-R) to runpath list */
203 if (StringListAppendList(runpathList, defaultRunpathList, 0, -1) < 0) 190 if (StringListAppendList(runpathList, defaultRunpathList, 0, -1) < 0)
204 break; 191 break;
205 192
214 201
215 /* append runpath string to commandline */ 202 /* append runpath string to commandline */
216 if (StringListAppendString(data->out->argList, newString) < 0) 203 if (StringListAppendString(data->out->argList, newString) < 0)
217 break; 204 break;
218 205
206 /* do we need to use env-runpath second? */
207 if (withEnvRunpath == envrunpath_second
208 && StringListAppendConcat(data->out->argList, "+s", 2, NULL) < 0
209 ) break;
210
219 /* 211 /*
220 * third, put other arguments on commandline 212 * third, put other arguments on commandline
221 */ 213 */
222 if (StringListAppendList(data->out->argList, tmpArgList, 0, -1) < 0) 214 if (StringListAppendList(data->out->argList, tmpArgList, 0, -1) < 0)
223 break; 215 break;
225 err = 0; 217 err = 0;
226 } while(0); /* end dummy loop */ 218 } while(0); /* end dummy loop */
227 219
228 newString = StringDestroy(newString); 220 newString = StringDestroy(newString);
229 defaultRunpathList = StringListDestroy(defaultRunpathList); 221 defaultRunpathList = StringListDestroy(defaultRunpathList);
230 libpathList = StringListDestroy(libpathList);
231 runpathList = StringListDestroy(runpathList); 222 runpathList = StringListDestroy(runpathList);
232 tmpArgList = StringListDestroy(tmpArgList); 223 tmpArgList = StringListDestroy(tmpArgList);
233 224
234 return err; 225 return err;
235} 226}

Legend:
Removed from v.1630  
changed lines
  Added in v.1631

  ViewVC Help
Powered by ViewVC 1.1.20