GNU Binutils with patches for OS216
Revision | 617cd5714278da0e0c57cce0f2f0c748f821788d (tree) |
---|---|
Zeit | 1991-03-27 05:52:21 |
Autor | Steve Chamberlain <steve@cygn...> |
Commiter | Steve Chamberlain |
Now returns correct status.
@@ -203,38 +203,36 @@ bfd *obfd; | ||
203 | 203 | } |
204 | 204 | |
205 | 205 | static |
206 | -boolean | |
206 | +void | |
207 | 207 | copy_file(input_filename, output_filename) |
208 | 208 | char *input_filename; |
209 | 209 | char *output_filename; |
210 | 210 | { |
211 | - bfd *ibfd; | |
211 | + bfd *ibfd; | |
212 | 212 | |
213 | + ibfd = bfd_openr(input_filename, input_target); | |
214 | + if (ibfd == NULL) | |
215 | + bfd_fatal(input_filename); | |
213 | 216 | |
214 | - ibfd = bfd_openr(input_filename, input_target); | |
215 | - if (ibfd == NULL) | |
216 | - bfd_fatal(input_filename); | |
217 | + if (bfd_check_format(ibfd, bfd_object)) { | |
218 | + bfd * obfd = bfd_openw(output_filename, output_target); | |
219 | + if (obfd == NULL) | |
220 | + bfd_fatal(output_filename); | |
217 | 221 | |
218 | - if (bfd_check_format(ibfd, bfd_object)) { | |
219 | - bfd * obfd = bfd_openw(output_filename, output_target); | |
220 | - if (obfd == NULL) | |
221 | - bfd_fatal(output_filename); | |
222 | - | |
223 | - copy_object(ibfd, obfd); | |
224 | - | |
225 | - if (!bfd_close(obfd)) | |
226 | - bfd_fatal(output_filename); | |
222 | + copy_object(ibfd, obfd); | |
227 | 223 | |
228 | - if (!bfd_close(ibfd)) | |
229 | - bfd_fatal(input_filename); | |
230 | - } | |
231 | - else if (bfd_check_format(ibfd, bfd_archive)) { | |
232 | - bfd * obfd = bfd_openw(output_filename, output_target); | |
233 | - if (obfd == NULL) | |
234 | - bfd_fatal(output_filename); | |
224 | + if (!bfd_close(obfd)) | |
225 | + bfd_fatal(output_filename); | |
235 | 226 | |
236 | - copy_archive(ibfd, obfd); | |
237 | - } | |
227 | + if (!bfd_close(ibfd)) | |
228 | + bfd_fatal(input_filename); | |
229 | + } | |
230 | + else if (bfd_check_format(ibfd, bfd_archive)) { | |
231 | + bfd * obfd = bfd_openw(output_filename, output_target); | |
232 | + if (obfd == NULL) | |
233 | + bfd_fatal(output_filename); | |
234 | + copy_archive(ibfd, obfd); | |
235 | + } | |
238 | 236 | } |
239 | 237 | |
240 | 238 |
@@ -313,13 +311,17 @@ copy_sections(ibfd, isection, obfd) | ||
313 | 311 | if (size == 0) |
314 | 312 | return; |
315 | 313 | |
316 | - if (get_reloc_upper_bound(ibfd, isection) != 0) { | |
314 | + if (strip == false && get_reloc_upper_bound(ibfd, isection) != 0) { | |
317 | 315 | relpp = (arelent **) xmalloc(get_reloc_upper_bound(ibfd, isection)); |
318 | 316 | |
319 | 317 | relcount = bfd_canonicalize_reloc(ibfd, isection, relpp, sympp); |
320 | 318 | |
321 | 319 | bfd_set_reloc(obfd, osection, relpp, relcount); |
322 | 320 | } |
321 | + else { | |
322 | + bfd_set_reloc(obfd, osection, (arelent **)NULL, 0); | |
323 | + } | |
324 | + | |
323 | 325 | |
324 | 326 | if (bfd_get_section_flags(ibfd, isection) & SEC_HAS_CONTENTS) { |
325 | 327 | memhunk = (unsigned char *) xmalloc(size); |
@@ -338,73 +340,67 @@ main(argc, argv) | ||
338 | 340 | int argc; |
339 | 341 | char *argv[]; |
340 | 342 | { |
341 | - int i; | |
342 | - | |
343 | - | |
344 | - program_name = argv[0]; | |
345 | - | |
346 | - if (strcmp(program_name,"strip") == 0) { | |
347 | - strip = true; | |
348 | - } | |
349 | - | |
350 | - for (i = 1; i < argc; i++) | |
351 | - { | |
352 | - if (argv[i][0] == '-') { | |
353 | - switch (argv[i][1]) { | |
354 | - case 'v': | |
355 | - verbose = true; | |
356 | - break; | |
357 | - case 'b': | |
358 | - i++; | |
359 | - input_target = output_target = argv[i]; | |
360 | - break; | |
361 | - case 'S': | |
362 | - strip = true; | |
363 | - break; | |
364 | - case 's': | |
365 | - i++; | |
366 | - input_target = argv[i]; | |
367 | - break; | |
368 | - case 'd': | |
369 | - i++; | |
370 | - output_target = argv[i]; | |
371 | - break; | |
372 | - default: | |
373 | - usage(); | |
374 | - } | |
375 | - } | |
376 | - else { | |
377 | - if (input_filename) { | |
378 | - output_filename = argv[i]; | |
379 | - } | |
380 | - else { | |
381 | - input_filename = argv[i]; | |
382 | - } | |
383 | - } | |
343 | + int i; | |
344 | + | |
345 | + program_name = argv[0]; | |
346 | + | |
347 | + if (strcmp(program_name,"strip") == 0) { | |
348 | + strip = true; | |
349 | + } | |
350 | + | |
351 | + for (i = 1; i < argc; i++) | |
352 | + { | |
353 | + if (argv[i][0] == '-') { | |
354 | + switch (argv[i][1]) { | |
355 | + case 'v': | |
356 | + verbose = true; | |
357 | + break; | |
358 | + case 'b': | |
359 | + i++; | |
360 | + input_target = output_target = argv[i]; | |
361 | + break; | |
362 | + case 'S': | |
363 | + strip = true; | |
364 | + break; | |
365 | + case 's': | |
366 | + i++; | |
367 | + input_target = argv[i]; | |
368 | + break; | |
369 | + case 'd': | |
370 | + i++; | |
371 | + output_target = argv[i]; | |
372 | + break; | |
373 | + default: | |
374 | + usage(); | |
384 | 375 | } |
385 | - | |
386 | - if (input_filename == (char *) NULL) | |
387 | - usage(); | |
388 | - | |
389 | - if (output_target == (char *) NULL) | |
390 | - output_target = input_target; | |
391 | - | |
392 | - /* If there is no destination file then create a temp and rename | |
393 | - the result into the input */ | |
394 | - | |
395 | - if (output_filename == (char *)NULL) { | |
396 | - char * tmpname = make_tempname(input_filename); | |
397 | - if (copy_file(input_filename, tmpname)) { | |
398 | - output_filename = input_filename; | |
399 | - rename(tmpname, input_filename); | |
400 | - return 0; | |
376 | + } | |
377 | + else { | |
378 | + if (input_filename) { | |
379 | + output_filename = argv[i]; | |
401 | 380 | } |
402 | - } | |
403 | - else if (copy_file(input_filename, output_filename)) | |
404 | - { | |
405 | - return 0; | |
381 | + else { | |
382 | + input_filename = argv[i]; | |
406 | 383 | } |
384 | + } | |
385 | + } | |
386 | + | |
387 | + if (input_filename == (char *) NULL) | |
388 | + usage(); | |
389 | + | |
390 | + if (output_target == (char *) NULL) | |
391 | + output_target = input_target; | |
407 | 392 | |
393 | + /* If there is no destination file then create a temp and rename | |
394 | + the result into the input */ | |
408 | 395 | |
396 | + if (output_filename == (char *)NULL) { | |
397 | + char * tmpname = make_tempname(input_filename); | |
398 | + copy_file(input_filename, tmpname); | |
399 | + output_filename = input_filename; | |
400 | + rename(tmpname, input_filename); | |
401 | + } | |
402 | + else { | |
403 | + copy_file(input_filename, output_filename); | |
404 | + } | |
409 | 405 | return 1; |
410 | 406 | } |