emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/unexw32.c


From: Eli Zaretskii
Subject: [Emacs-diffs] Changes to emacs/src/unexw32.c
Date: Fri, 10 Jun 2005 07:03:07 -0400

Index: emacs/src/unexw32.c
diff -c emacs/src/unexw32.c:1.25 emacs/src/unexw32.c:1.26
*** emacs/src/unexw32.c:1.25    Mon Jun  6 19:28:02 2005
--- emacs/src/unexw32.c Fri Jun 10 11:03:07 2005
***************
*** 491,517 ****
    PIMAGE_SECTION_HEADER dst_section;
    DWORD offset;
    int i;
  
! #define COPY_CHUNK(message, src, size)                                        
        \
    do {                                                                        
        \
      unsigned char *s = (void *)(src);                                         
\
      unsigned long count = (size);                                             
\
!     printf ("%s\n", (message));                                               
        \
!     printf ("\t0x%08x Offset in input file.\n", s - p_infile->file_base);     
\
!     printf ("\t0x%08x Offset in output file.\n", dst - p_outfile->file_base); 
\
!     printf ("\t0x%08x Size in bytes.\n", count);                              
\
      memcpy (dst, s, count);                                                   
\
      dst += count;                                                             
\
    } while (0)
  
! #define COPY_PROC_CHUNK(message, src, size)                                   
\
    do {                                                                        
        \
      unsigned char *s = (void *)(src);                                         
\
      unsigned long count = (size);                                             
\
!     printf ("%s\n", (message));                                               
        \
!     printf ("\t0x%08x Address in process.\n", s);                             
\
!     printf ("\t0x%08x Offset in output file.\n", dst - p_outfile->file_base); 
\
!     printf ("\t0x%08x Size in bytes.\n", count);                              
\
      memcpy (dst, s, count);                                                   
\
      dst += count;                                                             
\
    } while (0)
--- 491,524 ----
    PIMAGE_SECTION_HEADER dst_section;
    DWORD offset;
    int i;
+   int be_verbose = GetEnvironmentVariable ("DEBUG_DUMP", NULL, 0) > 0;
  
! #define COPY_CHUNK(message, src, size, verbose)                               
        \
    do {                                                                        
        \
      unsigned char *s = (void *)(src);                                         
\
      unsigned long count = (size);                                             
\
!     if (verbose)                                                              
\
!       {                                                                       
        \
!       printf ("%s\n", (message));                                             
\
!       printf ("\t0x%08x Offset in input file.\n", s - p_infile->file_base);   
\
!       printf ("\t0x%08x Offset in output file.\n", dst - 
p_outfile->file_base); \
!       printf ("\t0x%08x Size in bytes.\n", count);                            
\
!       }                                                                       
        \
      memcpy (dst, s, count);                                                   
\
      dst += count;                                                             
\
    } while (0)
  
! #define COPY_PROC_CHUNK(message, src, size, verbose)                          
\
    do {                                                                        
        \
      unsigned char *s = (void *)(src);                                         
\
      unsigned long count = (size);                                             
\
!     if (verbose)                                                              
\
!       {                                                                       
        \
!       printf ("%s\n", (message));                                             
\
!       printf ("\t0x%08x Address in process.\n", s);                           
\
!       printf ("\t0x%08x Offset in output file.\n", dst - 
p_outfile->file_base); \
!       printf ("\t0x%08x Size in bytes.\n", count);                            
\
!       }                                                                       
        \
      memcpy (dst, s, count);                                                   
\
      dst += count;                                                             
\
    } while (0)
***************
*** 542,554 ****
    dst = (unsigned char *) p_outfile->file_base;
  
    COPY_CHUNK ("Copying DOS header...", dos_header,
!             (DWORD) nt_header - (DWORD) dos_header);
    dst_nt_header = (PIMAGE_NT_HEADERS) dst;
    COPY_CHUNK ("Copying NT header...", nt_header,
!             (DWORD) section - (DWORD) nt_header);
    dst_section = (PIMAGE_SECTION_HEADER) dst;
    COPY_CHUNK ("Copying section table...", section,
!             nt_header->FileHeader.NumberOfSections * sizeof (*section));
  
    /* Align the first section's raw data area, and set the header size
       field accordingly.  */
--- 549,562 ----
    dst = (unsigned char *) p_outfile->file_base;
  
    COPY_CHUNK ("Copying DOS header...", dos_header,
!             (DWORD) nt_header - (DWORD) dos_header, be_verbose);
    dst_nt_header = (PIMAGE_NT_HEADERS) dst;
    COPY_CHUNK ("Copying NT header...", nt_header,
!             (DWORD) section - (DWORD) nt_header, be_verbose);
    dst_section = (PIMAGE_SECTION_HEADER) dst;
    COPY_CHUNK ("Copying section table...", section,
!             nt_header->FileHeader.NumberOfSections * sizeof (*section),
!             be_verbose);
  
    /* Align the first section's raw data area, and set the header size
       field accordingly.  */
***************
*** 558,564 ****
    for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++)
      {
        char msg[100];
!       sprintf (msg, "Copying raw data for %s...", section->Name);
  
        dst_save = dst;
  
--- 566,574 ----
    for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++)
      {
        char msg[100];
!       /* Windows section names are fixed 8-char strings, only
!        zero-terminated if the name is shorter than 8 characters.  */
!       sprintf (msg, "Copying raw data for %.8s...", section->Name);
  
        dst_save = dst;
  
***************
*** 571,577 ****
        /* Can always copy the original raw data.  */
        COPY_CHUNK
        (msg, OFFSET_TO_PTR (section->PointerToRawData, p_infile),
!        section->SizeOfRawData);
        /* Ensure alignment slop is zeroed.  */
        ROUND_UP_DST_AND_ZERO (dst_nt_header->OptionalHeader.FileAlignment);
  
--- 581,587 ----
        /* Can always copy the original raw data.  */
        COPY_CHUNK
        (msg, OFFSET_TO_PTR (section->PointerToRawData, p_infile),
!        section->SizeOfRawData, be_verbose);
        /* Ensure alignment slop is zeroed.  */
        ROUND_UP_DST_AND_ZERO (dst_nt_header->OptionalHeader.FileAlignment);
  
***************
*** 580,586 ****
        {
          dst = dst_save
            + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (data_start), dst_section);
!         COPY_PROC_CHUNK ("Dumping initialized data...", data_start, 
data_size);
          dst = dst_save + dst_section->SizeOfRawData;
        }
        if (section == bss_section)
--- 590,597 ----
        {
          dst = dst_save
            + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (data_start), dst_section);
!         COPY_PROC_CHUNK ("Dumping initialized data...",
!                          data_start, data_size, be_verbose);
          dst = dst_save + dst_section->SizeOfRawData;
        }
        if (section == bss_section)
***************
*** 589,595 ****
               data size as necessary.  */
          dst = dst_save
            + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (bss_start), dst_section);
!         COPY_PROC_CHUNK ("Dumping bss data...", bss_start, bss_size);
          ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment);
          dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile);
          /* Determine new size of raw data area.  */
--- 600,607 ----
               data size as necessary.  */
          dst = dst_save
            + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (bss_start), dst_section);
!         COPY_PROC_CHUNK ("Dumping bss data...", bss_start,
!                          bss_size, be_verbose);
          ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment);
          dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile);
          /* Determine new size of raw data area.  */
***************
*** 604,610 ****
               section's raw data size as necessary.  */
          dst = dst_save
            + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (bss_start_static), 
dst_section);
!         COPY_PROC_CHUNK ("Dumping static bss data...", bss_start_static, 
bss_size_static);
          ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment);
          dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile);
          /* Determine new size of raw data area.  */
--- 616,623 ----
               section's raw data size as necessary.  */
          dst = dst_save
            + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (bss_start_static), 
dst_section);
!         COPY_PROC_CHUNK ("Dumping static bss data...", bss_start_static,
!                          bss_size_static, be_verbose);
          ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment);
          dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile);
          /* Determine new size of raw data area.  */
***************
*** 622,628 ****
               section's size to the appropriate size.  */
          dst = dst_save
            + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (heap_start), dst_section);
!         COPY_PROC_CHUNK ("Dumping heap...", heap_start, heap_size);
          ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment);
          dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile);
          /* Determine new size of raw data area.  */
--- 635,642 ----
               section's size to the appropriate size.  */
          dst = dst_save
            + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (heap_start), dst_section);
!         COPY_PROC_CHUNK ("Dumping heap...", heap_start, heap_size,
!                          be_verbose);
          ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment);
          dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile);
          /* Determine new size of raw data area.  */
***************
*** 657,663 ****
    COPY_CHUNK
      ("Copying remainder of executable...",
       OFFSET_TO_PTR (offset, p_infile),
!      p_infile->size - offset);
  
    /* Final size for new image.  */
    p_outfile->size = DST_TO_OFFSET ();
--- 671,677 ----
    COPY_CHUNK
      ("Copying remainder of executable...",
       OFFSET_TO_PTR (offset, p_infile),
!      p_infile->size - offset, be_verbose);
  
    /* Final size for new image.  */
    p_outfile->size = DST_TO_OFFSET ();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]