aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2005-06-10 11:04:20 +0000
committerEli Zaretskii2005-06-10 11:04:20 +0000
commit4162f25f3e4ca44c19e4b121ee56ba7463ffac6f (patch)
tree565f3455ced6d948776a2b035106cc1a8e109009 /src
parent257914aaabe89bb14c22b9430a21fbc8b5b05657 (diff)
downloademacs-4162f25f3e4ca44c19e4b121ee56ba7463ffac6f.tar.gz
emacs-4162f25f3e4ca44c19e4b121ee56ba7463ffac6f.zip
(COPY_CHUNK, COPY_PROC_CHUNK): Add a new argument
`verbose'; print diagnostic messages only if it is non-zero. All callers changed to pass a zero value unless DEBUG_DUMP is defined in the environment. (copy_executable_and_dump_data): Print section names with %.8s.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/unexw32.c54
2 files changed, 42 insertions, 20 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 94479694c7a..3f76f1f8eb3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12005-06-10 Eli Zaretskii <eliz@gnu.org>
2
3 * unexw32.c (COPY_CHUNK, COPY_PROC_CHUNK): Add a new argument
4 `verbose'; print diagnostic messages only if it is non-zero. All
5 callers changed to pass a zero value unless DEBUG_DUMP is defined
6 in the environment.
7 (copy_executable_and_dump_data): Print section names with %.8s.
8
12005-06-10 Masatake YAMATO <jet@gyve.org> 92005-06-10 Masatake YAMATO <jet@gyve.org>
2 10
3 * xdisp.c (note_mode_line_or_margin_highlight): Call clear_mouse_face 11 * xdisp.c (note_mode_line_or_margin_highlight): Call clear_mouse_face
diff --git a/src/unexw32.c b/src/unexw32.c
index 1b2dbe74c31..6c565ff7491 100644
--- a/src/unexw32.c
+++ b/src/unexw32.c
@@ -491,27 +491,34 @@ copy_executable_and_dump_data (file_data *p_infile,
491 PIMAGE_SECTION_HEADER dst_section; 491 PIMAGE_SECTION_HEADER dst_section;
492 DWORD offset; 492 DWORD offset;
493 int i; 493 int i;
494 int be_verbose = GetEnvironmentVariable ("DEBUG_DUMP", NULL, 0) > 0;
494 495
495#define COPY_CHUNK(message, src, size) \ 496#define COPY_CHUNK(message, src, size, verbose) \
496 do { \ 497 do { \
497 unsigned char *s = (void *)(src); \ 498 unsigned char *s = (void *)(src); \
498 unsigned long count = (size); \ 499 unsigned long count = (size); \
499 printf ("%s\n", (message)); \ 500 if (verbose) \
500 printf ("\t0x%08x Offset in input file.\n", s - p_infile->file_base); \ 501 { \
501 printf ("\t0x%08x Offset in output file.\n", dst - p_outfile->file_base); \ 502 printf ("%s\n", (message)); \
502 printf ("\t0x%08x Size in bytes.\n", count); \ 503 printf ("\t0x%08x Offset in input file.\n", s - p_infile->file_base); \
504 printf ("\t0x%08x Offset in output file.\n", dst - p_outfile->file_base); \
505 printf ("\t0x%08x Size in bytes.\n", count); \
506 } \
503 memcpy (dst, s, count); \ 507 memcpy (dst, s, count); \
504 dst += count; \ 508 dst += count; \
505 } while (0) 509 } while (0)
506 510
507#define COPY_PROC_CHUNK(message, src, size) \ 511#define COPY_PROC_CHUNK(message, src, size, verbose) \
508 do { \ 512 do { \
509 unsigned char *s = (void *)(src); \ 513 unsigned char *s = (void *)(src); \
510 unsigned long count = (size); \ 514 unsigned long count = (size); \
511 printf ("%s\n", (message)); \ 515 if (verbose) \
512 printf ("\t0x%08x Address in process.\n", s); \ 516 { \
513 printf ("\t0x%08x Offset in output file.\n", dst - p_outfile->file_base); \ 517 printf ("%s\n", (message)); \
514 printf ("\t0x%08x Size in bytes.\n", count); \ 518 printf ("\t0x%08x Address in process.\n", s); \
519 printf ("\t0x%08x Offset in output file.\n", dst - p_outfile->file_base); \
520 printf ("\t0x%08x Size in bytes.\n", count); \
521 } \
515 memcpy (dst, s, count); \ 522 memcpy (dst, s, count); \
516 dst += count; \ 523 dst += count; \
517 } while (0) 524 } while (0)
@@ -542,13 +549,14 @@ copy_executable_and_dump_data (file_data *p_infile,
542 dst = (unsigned char *) p_outfile->file_base; 549 dst = (unsigned char *) p_outfile->file_base;
543 550
544 COPY_CHUNK ("Copying DOS header...", dos_header, 551 COPY_CHUNK ("Copying DOS header...", dos_header,
545 (DWORD) nt_header - (DWORD) dos_header); 552 (DWORD) nt_header - (DWORD) dos_header, be_verbose);
546 dst_nt_header = (PIMAGE_NT_HEADERS) dst; 553 dst_nt_header = (PIMAGE_NT_HEADERS) dst;
547 COPY_CHUNK ("Copying NT header...", nt_header, 554 COPY_CHUNK ("Copying NT header...", nt_header,
548 (DWORD) section - (DWORD) nt_header); 555 (DWORD) section - (DWORD) nt_header, be_verbose);
549 dst_section = (PIMAGE_SECTION_HEADER) dst; 556 dst_section = (PIMAGE_SECTION_HEADER) dst;
550 COPY_CHUNK ("Copying section table...", section, 557 COPY_CHUNK ("Copying section table...", section,
551 nt_header->FileHeader.NumberOfSections * sizeof (*section)); 558 nt_header->FileHeader.NumberOfSections * sizeof (*section),
559 be_verbose);
552 560
553 /* Align the first section's raw data area, and set the header size 561 /* Align the first section's raw data area, and set the header size
554 field accordingly. */ 562 field accordingly. */
@@ -558,7 +566,9 @@ copy_executable_and_dump_data (file_data *p_infile,
558 for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++) 566 for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++)
559 { 567 {
560 char msg[100]; 568 char msg[100];
561 sprintf (msg, "Copying raw data for %s...", section->Name); 569 /* Windows section names are fixed 8-char strings, only
570 zero-terminated if the name is shorter than 8 characters. */
571 sprintf (msg, "Copying raw data for %.8s...", section->Name);
562 572
563 dst_save = dst; 573 dst_save = dst;
564 574
@@ -571,7 +581,7 @@ copy_executable_and_dump_data (file_data *p_infile,
571 /* Can always copy the original raw data. */ 581 /* Can always copy the original raw data. */
572 COPY_CHUNK 582 COPY_CHUNK
573 (msg, OFFSET_TO_PTR (section->PointerToRawData, p_infile), 583 (msg, OFFSET_TO_PTR (section->PointerToRawData, p_infile),
574 section->SizeOfRawData); 584 section->SizeOfRawData, be_verbose);
575 /* Ensure alignment slop is zeroed. */ 585 /* Ensure alignment slop is zeroed. */
576 ROUND_UP_DST_AND_ZERO (dst_nt_header->OptionalHeader.FileAlignment); 586 ROUND_UP_DST_AND_ZERO (dst_nt_header->OptionalHeader.FileAlignment);
577 587
@@ -580,7 +590,8 @@ copy_executable_and_dump_data (file_data *p_infile,
580 { 590 {
581 dst = dst_save 591 dst = dst_save
582 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (data_start), dst_section); 592 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (data_start), dst_section);
583 COPY_PROC_CHUNK ("Dumping initialized data...", data_start, data_size); 593 COPY_PROC_CHUNK ("Dumping initialized data...",
594 data_start, data_size, be_verbose);
584 dst = dst_save + dst_section->SizeOfRawData; 595 dst = dst_save + dst_section->SizeOfRawData;
585 } 596 }
586 if (section == bss_section) 597 if (section == bss_section)
@@ -589,7 +600,8 @@ copy_executable_and_dump_data (file_data *p_infile,
589 data size as necessary. */ 600 data size as necessary. */
590 dst = dst_save 601 dst = dst_save
591 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (bss_start), dst_section); 602 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (bss_start), dst_section);
592 COPY_PROC_CHUNK ("Dumping bss data...", bss_start, bss_size); 603 COPY_PROC_CHUNK ("Dumping bss data...", bss_start,
604 bss_size, be_verbose);
593 ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment); 605 ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment);
594 dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile); 606 dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile);
595 /* Determine new size of raw data area. */ 607 /* Determine new size of raw data area. */
@@ -604,7 +616,8 @@ copy_executable_and_dump_data (file_data *p_infile,
604 section's raw data size as necessary. */ 616 section's raw data size as necessary. */
605 dst = dst_save 617 dst = dst_save
606 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (bss_start_static), dst_section); 618 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (bss_start_static), dst_section);
607 COPY_PROC_CHUNK ("Dumping static bss data...", bss_start_static, bss_size_static); 619 COPY_PROC_CHUNK ("Dumping static bss data...", bss_start_static,
620 bss_size_static, be_verbose);
608 ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment); 621 ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment);
609 dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile); 622 dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile);
610 /* Determine new size of raw data area. */ 623 /* Determine new size of raw data area. */
@@ -622,7 +635,8 @@ copy_executable_and_dump_data (file_data *p_infile,
622 section's size to the appropriate size. */ 635 section's size to the appropriate size. */
623 dst = dst_save 636 dst = dst_save
624 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (heap_start), dst_section); 637 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (heap_start), dst_section);
625 COPY_PROC_CHUNK ("Dumping heap...", heap_start, heap_size); 638 COPY_PROC_CHUNK ("Dumping heap...", heap_start, heap_size,
639 be_verbose);
626 ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment); 640 ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment);
627 dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile); 641 dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile);
628 /* Determine new size of raw data area. */ 642 /* Determine new size of raw data area. */
@@ -657,7 +671,7 @@ copy_executable_and_dump_data (file_data *p_infile,
657 COPY_CHUNK 671 COPY_CHUNK
658 ("Copying remainder of executable...", 672 ("Copying remainder of executable...",
659 OFFSET_TO_PTR (offset, p_infile), 673 OFFSET_TO_PTR (offset, p_infile),
660 p_infile->size - offset); 674 p_infile->size - offset, be_verbose);
661 675
662 /* Final size for new image. */ 676 /* Final size for new image. */
663 p_outfile->size = DST_TO_OFFSET (); 677 p_outfile->size = DST_TO_OFFSET ();