| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: elf2ecoff.c,v 1.23 2009/04/23 14:49:32 tsutsui Exp $ */ | | 1 | /* $NetBSD: elf2ecoff.c,v 1.24 2009/12/14 00:43:05 matt Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1997 Jonathan Stone | | 4 | * Copyright (c) 1997 Jonathan Stone |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * Copyright (c) 1995 | | 6 | * Copyright (c) 1995 |
7 | * Ted Lemon (hereinafter referred to as the author) | | 7 | * Ted Lemon (hereinafter referred to as the author) |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -390,36 +390,36 @@ usage: | | | @@ -390,36 +390,36 @@ usage: |
390 | | | 390 | |
391 | /* Make the output file... */ | | 391 | /* Make the output file... */ |
392 | if ((outfile = open(argv[2], O_WRONLY | O_CREAT, 0777)) < 0) { | | 392 | if ((outfile = open(argv[2], O_WRONLY | O_CREAT, 0777)) < 0) { |
393 | fprintf(stderr, "Unable to create %s: %s\n", argv[2], strerror(errno)); | | 393 | fprintf(stderr, "Unable to create %s: %s\n", argv[2], strerror(errno)); |
394 | exit(1); | | 394 | exit(1); |
395 | } | | 395 | } |
396 | /* Truncate file... */ | | 396 | /* Truncate file... */ |
397 | if (ftruncate(outfile, 0)) { | | 397 | if (ftruncate(outfile, 0)) { |
398 | warn("ftruncate %s", argv[2]); | | 398 | warn("ftruncate %s", argv[2]); |
399 | } | | 399 | } |
400 | /* Write the headers... */ | | 400 | /* Write the headers... */ |
401 | safewrite(outfile, &ep.f, sizeof(ep.f), "ep.f: write: %s\n"); | | 401 | safewrite(outfile, &ep.f, sizeof(ep.f), "ep.f: write: %s\n"); |
402 | if (debug) | | 402 | if (debug) |
403 | fprintf(stderr, "wrote %d byte file header.\n", sizeof(ep.f)); | | 403 | fprintf(stderr, "wrote %zu byte file header.\n", sizeof(ep.f)); |
404 | | | 404 | |
405 | safewrite(outfile, &ep.a, sizeof(ep.a), "ep.a: write: %s\n"); | | 405 | safewrite(outfile, &ep.a, sizeof(ep.a), "ep.a: write: %s\n"); |
406 | if (debug) | | 406 | if (debug) |
407 | fprintf(stderr, "wrote %d byte a.out header.\n", sizeof(ep.a)); | | 407 | fprintf(stderr, "wrote %zu byte a.out header.\n", sizeof(ep.a)); |
408 | | | 408 | |
409 | safewrite(outfile, &esecs, sizeof(esecs[0]) * nsecs, | | 409 | safewrite(outfile, &esecs, sizeof(esecs[0]) * nsecs, |
410 | "esecs: write: %s\n"); | | 410 | "esecs: write: %s\n"); |
411 | if (debug) | | 411 | if (debug) |
412 | fprintf(stderr, "wrote %d bytes of section headers.\n", | | 412 | fprintf(stderr, "wrote %zu bytes of section headers.\n", |
413 | sizeof(esecs[0]) * nsecs); | | 413 | sizeof(esecs[0]) * nsecs); |
414 | | | 414 | |
415 | | | 415 | |
416 | pad = ((sizeof ep.f + sizeof ep.a + sizeof esecs) & 15); | | 416 | pad = ((sizeof ep.f + sizeof ep.a + sizeof esecs) & 15); |
417 | if (pad) { | | 417 | if (pad) { |
418 | pad = 16 - pad; | | 418 | pad = 16 - pad; |
419 | pad16(outfile, pad, "ipad: write: %s\n"); | | 419 | pad16(outfile, pad, "ipad: write: %s\n"); |
420 | if (debug) | | 420 | if (debug) |
421 | fprintf(stderr, "wrote %d byte pad.\n", pad); | | 421 | fprintf(stderr, "wrote %d byte pad.\n", pad); |
422 | } | | 422 | } |
423 | /* Copy the loadable sections. Zero-fill any gaps less than 64k; | | 423 | /* Copy the loadable sections. Zero-fill any gaps less than 64k; |
424 | * complain about any zero-filling, and die if we're asked to | | 424 | * complain about any zero-filling, and die if we're asked to |
425 | * zero-fill more than 64k. */ | | 425 | * zero-fill more than 64k. */ |
| @@ -651,27 +651,27 @@ write_ecoff_symhdr(out, ep, symhdrp, nes | | | @@ -651,27 +651,27 @@ write_ecoff_symhdr(out, ep, symhdrp, nes |
651 | nesyms, (u_long) ep->f.f_symptr); | | 651 | nesyms, (u_long) ep->f.f_symptr); |
652 | | | 652 | |
653 | ep->f.f_nsyms = sizeof(struct ecoff_symhdr); | | 653 | ep->f.f_nsyms = sizeof(struct ecoff_symhdr); |
654 | | | 654 | |
655 | memset(symhdrp, 0, sizeof(*symhdrp)); | | 655 | memset(symhdrp, 0, sizeof(*symhdrp)); |
656 | symhdrp->esymMax = nesyms; | | 656 | symhdrp->esymMax = nesyms; |
657 | symhdrp->magic = 0x7009;/* XXX */ | | 657 | symhdrp->magic = 0x7009;/* XXX */ |
658 | symhdrp->cbExtOffset = extsymoff; | | 658 | symhdrp->cbExtOffset = extsymoff; |
659 | symhdrp->cbSsExtOffset = extstroff; | | 659 | symhdrp->cbSsExtOffset = extstroff; |
660 | | | 660 | |
661 | symhdrp->issExtMax = strsize; | | 661 | symhdrp->issExtMax = strsize; |
662 | if (debug) | | 662 | if (debug) |
663 | fprintf(stderr, | | 663 | fprintf(stderr, |
664 | "ECOFF symhdr: symhdr %x, strsize %lx, symsize %lx\n", | | 664 | "ECOFF symhdr: symhdr %zx, strsize %lx, symsize %lx\n", |
665 | sizeof(*symhdrp), strsize, | | 665 | sizeof(*symhdrp), strsize, |
666 | (nesyms * sizeof(struct ecoff_extsym))); | | 666 | (nesyms * sizeof(struct ecoff_extsym))); |
667 | | | 667 | |
668 | if (needswap) { | | 668 | if (needswap) { |
669 | bswap32_region(&symhdrp->ilineMax, | | 669 | bswap32_region(&symhdrp->ilineMax, |
670 | sizeof(*symhdrp) - sizeof(symhdrp->magic) - | | 670 | sizeof(*symhdrp) - sizeof(symhdrp->magic) - |
671 | sizeof(symhdrp->ilineMax)); | | 671 | sizeof(symhdrp->ilineMax)); |
672 | symhdrp->magic = bswap16(symhdrp->magic); | | 672 | symhdrp->magic = bswap16(symhdrp->magic); |
673 | symhdrp->ilineMax = bswap16(symhdrp->ilineMax); | | 673 | symhdrp->ilineMax = bswap16(symhdrp->ilineMax); |
674 | } | | 674 | } |
675 | | | 675 | |
676 | safewrite(out, symhdrp, sizeof(*symhdrp), | | 676 | safewrite(out, symhdrp, sizeof(*symhdrp), |
677 | "writing symbol header: %s\n"); | | 677 | "writing symbol header: %s\n"); |